/**
 * Invoice resource types — invoices-core + invoice-approval-workflow deltas.
 * camelCase keys match the established /api/invoices JSON contract.
 */
import type { InvoiceStatus } from './enums'

export interface InvoiceLine {
  id: string
  invoiceId: string
  tenantId: string
  description: string
  quantity: string
  unitPrice: string
  discountPct: string
  lineTotal: string
  taxable: boolean
  position: number
  expenseId: string | null
  createdAt: string
}

export interface Invoice {
  id: string
  tenantId: string
  customerId: string | null
  projectId: string | null
  invoiceNumber: string | null
  proformaNumber: string | null
  status: InvoiceStatus
  currency: string
  issueDate: string | null
  taxIssueDate: string | null
  dueDate: string | null
  vatRate: string | null
  subtotal: string
  vatAmount: string
  total: string
  amountPaid: string
  notes: string | null
  source: string
  sentAt: string | null
  approvedAt: string | null
  approvedBy: string | null
  approvalNote: string | null
  rejectionReason: string | null
  rejectionNotifyCustomer: boolean
  taxIssuedAt: string | null
  paidAt: string | null
  externalId: string | null
  externalProvider: string | null
  voidReason: string | null
  voidedAt: string | null
  voidedBy: string | null
  parentInvoiceId: string | null
  htmlSnapshotUrl: string | null
  createdBy: string
  createdAt: string
  updatedAt: string
  customerName: string | null
}

export interface InvoiceWithLines extends Invoice {
  lines: InvoiceLine[]
}

export interface InvoiceVatComputation {
  net: string
  vat: string
  gross: string
  vatRate: string
}

export interface InvoiceVatInput {
  amount: string
  vatRate: string | null
}
