import { TaxResolver } from "./resolver.mjs"; import { DocumentFiscalPosition, DocumentTaxBreakdown, PriceBasis } from "./document.mjs"; //#region src/sale.d.ts /** The breakdown line id of the delivery charge (the order kernel's `SHIPPING_TAX_LINE_ID` equals it). */ declare const SALE_DELIVERY_LINE_ID = "shipping"; /** A sale that cannot be rated: an unknown class or a document the algorithm refuses. Refused, never priced. */ declare class SaleUnratedError extends Error { readonly code = "SALE_UNRATED"; readonly status = 422; constructor(message: string); } /** A line's class, as the deployment classifies the frozen catalog snapshot. */ interface SaleLineTaxClass { readonly taxClass: string; /** Where the class came from, in the pack's vocabulary (`class`, `deployment_default`, …). */ readonly classBasis: string; /** The product's own basis when it states one; absent ⇒ the deployment basis. */ readonly priceBasis?: PriceBasis; /** Pack extras for this line (`sdRate`, …). */ readonly extra?: Readonly>; } interface SaleFiscalPosition { readonly position: DocumentFiscalPosition; /** A product class → the class this sale is rated under (export → zero-rated, relief → exempt). */ mapTaxClass(taxClass: string): string; } /** * HOST: how this deployment rates a sale. REQUIRED on every placement — a channel that cannot say * how it taxes a sale must not sell. An unregistered seller passes a resolver that rules every class * not taxable with its reason (`createNotRegisteredTaxResolver`), so its sales are zero by decision. */ interface SaleTaxPort { readonly resolver: Pick; /** Do this deployment's shelf prices include tax? */ priceBasis(request: unknown): Promise | PriceBasis; /** The class of one priced line, from the class its catalog snapshot froze (`undefined`: none stated). */ lineClass(line: { kind: string; taxClass: string | undefined; }): SaleLineTaxClass; /** The class the delivery charge is rated under. */ deliveryClass(): SaleLineTaxClass; /** * The fiscal position for this buyer, decided ONCE and stored with the sale: the pack's resolution * with its evidence refusals (an exempt or zero-rated position without its reference is refused * here, before the sale), and the class remap it implies. */ fiscalPosition(customer: TCustomer, request: unknown): Promise | SaleFiscalPosition; /** * Is a loyalty-points redemption a DISCOUNT (it reduces the consideration, VAT Act s.2(59) proviso) * or a TENDER (payment by stored value)? One deployment policy for every channel, stated, never * defaulted. `'tender'` has no placement path yet, so a redemption is refused rather than misstated. */ readonly loyaltyRedemption: 'discount' | 'tender'; } interface RateSaleInput { readonly lines: ReadonlyArray<{ readonly kind: string; readonly quantity: number; readonly unitPriceMinor: number; readonly lineTotalMinor: number; /** May the order discount reach this line? A pass-through deposit says no. */ readonly discountable: boolean; /** The tax class the catalog snapshot froze; `undefined` when it states none. */ readonly taxClass: string | undefined; }>; readonly discountMinor: number; readonly deliveryMinor: number; readonly customer: TCustomer; readonly asOf: Date; readonly request: unknown; } /** Rate a sale. Line ids are the order kernel's (`line_`), so the kernel can bind the result. */ declare function rateSale(port: SaleTaxPort, input: RateSaleInput): Promise; //#endregion export { RateSaleInput, SALE_DELIVERY_LINE_ID, SaleFiscalPosition, SaleLineTaxClass, SaleTaxPort, SaleUnratedError, rateSale };