export type InvoiceStatus =
  | "New"
  | "AI processed"
  | "Needs review"
  | "Auto-ready"
  | "Approved"
  | "Rejected"
  | "Synced"
  | "Sync failed";

export type BankStatus = "Unmatched" | "Suggested" | "Matched" | "Partial" | "Ignored";

export type QueryStatus = "Requested" | "Delivered" | "Approved";

export interface Client {
  id: string;
  name: string;
  kvk: string;
  snelstart: boolean;
  lastUpload: string;
}

export interface LineItem {
  id: string;
  description: string;
  qty: number;
  unitPrice: number;
  vatRate: number;
}

export interface Suggestion {
  ledger: string;
  vatCode: string;
  category: string;
  relation: string;
  reasoning: string;
  editedBy?: undefined | string;
}

export interface Invoice {
  id: string;
  file: string;
  clientId: string;
  supplier: string;
  number: string;
  invoiceDate: string;
  dueDate: string;
  vatAmount: number;
  total: number;
  currency: string;
  paymentRef: string;
  uploadedAt: string;
  confidence: number;
  status: InvoiceStatus;
  lines: LineItem[];
  suggestion: Suggestion;
  duplicateOf?: undefined | string;
  syncError?: undefined | string;
}

export interface BankTx {
  id: string;
  date: string;
  description: string;
  clientId: string;
  amount: number;
  suggestedInvoiceId?: undefined | string;
  confidence?: undefined | number;
  status: BankStatus;
  note?: undefined | string;
}

export interface ClientQuery {
  id: string;
  clientId: string;
  invoiceId?: undefined | string;
  question: string;
  createdAt: string;
  status: QueryStatus;
  answer?: undefined | string;
  answeredAt?: undefined | string;
  proof?: undefined | string;
}

export type ActivityType =
  | "upload"
  | "ai"
  | "approve"
  | "reject"
  | "sync"
  | "sync-failed"
  | "query"
  | "answer"
  | "edit"
  | "match";

export interface ActivityEvent {
  id: string;
  type: ActivityType;
  text: string;
  actor: string;
  at: number;
  clientId?: undefined | string;
  invoiceId?: undefined | string;
}

export interface Settings {
  threshold: number;
  autoSync: boolean;
  globalRule: string;
  clientRules: Record<string, string>;
}
