UNPKG

@eristack/qups

Version:

Quantity / unit price / subtotal (QUPS) with 2-of-3 sources of truth, plus modifiers and tax — business line pricing on @eristack/money

41 lines • 1.89 kB
import type { PricingLineRecord, PricingLineStore } from "../core/stores/types.js"; import type { QupsLineSideTables } from "./tables.js"; import type { DrizzleDialect, DrizzleLikeDb } from "./types.js"; /** * App-owned detail table that includes `qupsLineColumns(...)`. * Must expose at least `id` plus the injected QUPS columns. * Parent document id is whatever you map via `ownerKeyColumn` (e.g. `invoiceId`). */ export type AnyInjectableLineTable = any; export interface CreateDrizzlePricingLineStoreOptions { dialect: DrizzleDialect; db: DrizzleLikeDb; /** Your detail table (invoice_lines, order_lines, …) with qups columns mixed in. */ table: AnyInjectableLineTable; /** * JS property on the table/row that holds the parent document id. * @default "ownerKey" */ ownerKeyColumn?: string; /** * JS property for the line primary key. * @default "id" */ idColumn?: string; /** Optional side tables keyed by your line id. */ modifiers?: QupsLineSideTables["modifiers"]; fieldValues?: QupsLineSideTables["fieldValues"]; } /** Pricing columns only — never touches itemId / other app domain columns. */ export declare function qupsPatchFromRecord(record: PricingLineRecord, table: object): Record<string, unknown>; export declare function pricingFieldsFromRow(row: Record<string, unknown>, options?: { idColumn?: string; ownerKeyColumn?: string; }): Omit<PricingLineRecord, "modifiers" | "fieldValues">; /** * Drizzle store against an **app-owned** detail table with injected QUPS columns. * Updates only pricing columns so `itemId` and other domain fields stay intact. * On insert, merges `record.rowExtras` (e.g. `{ itemId: "…" }`). */ export declare function createDrizzlePricingLineStore(options: CreateDrizzlePricingLineStoreOptions): PricingLineStore; //# sourceMappingURL=line-store.d.ts.map