You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sims-hq/packages/domain/src/documents.ts

73 lines
1.7 KiB
TypeScript

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
}