import type { Paise } from './money' import type { IsoDate } from './business-day' /** * Documents are immutable events (02-ARCHITECTURE §3 rule 2). A committed bill * is never edited; corrections are new documents referencing the original. */ export type DocType = 'SALE' | 'SALE_RETURN' | 'PURCHASE' | 'PURCHASE_RETURN' | 'STOCK_ADJUST' export interface BillLine { itemId: string name: string hsn: string qty: number unitCode: string unitPricePaise: Paise mrpPaise?: Paise grossPaise: Paise discountPaise: Paise taxablePaise: Paise taxRateBp: number cgstPaise: Paise sgstPaise: Paise igstPaise: Paise cessPaise: Paise lineTotalPaise: Paise batchId?: string } export type PaymentMode = 'CASH' | 'UPI' | 'CARD' | 'KHATA' export interface Payment { mode: PaymentMode amountPaise: Paise reference?: string } export interface BillTotals { grossPaise: Paise discountPaise: Paise taxablePaise: Paise cgstPaise: Paise sgstPaise: Paise igstPaise: Paise cessPaise: Paise roundOffPaise: Paise payablePaise: Paise savingsVsMrpPaise: Paise } export interface BillDoc { id: string // uuidv7, client-generated tenantId: string storeId: string counterId: string docType: DocType docNo: string /** Working date from Day Begin — never the machine clock. */ businessDate: IsoDate cashierId: string shiftId: string customerId?: string refDocId?: string // returns/corrections point at the original lines: BillLine[] payments: Payment[] totals: BillTotals /** Wall clock is display metadata only; ordering uses (lamport, deviceId). */ createdAtWallClock: string lamport: number deviceId: string deviceSeq: number }