@happyvertical/smrt-commerce 0.57.3 → 0.57.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +20 -0
- package/README.md +130 -0
- package/agents/accounting-snapshot-mapper.md +11 -0
- package/agents/contract-billing-schedules.md +67 -0
- package/agents/contract-money.md +81 -0
- package/agents/customer-funds.md +96 -0
- package/agents/historical-sales.md +150 -0
- package/agents/money-calculator.md +36 -0
- package/agents/money-model.md +6 -3
- package/agents/observed-purchase-prices.md +37 -0
- package/agents/ordinary-accounting.md +72 -0
- package/agents/payment-allocations.md +59 -0
- package/agents/received-sales-contract-money.md +38 -0
- package/dist/accounting-snapshot.d.ts +8 -1
- package/dist/accounting-snapshot.d.ts.map +1 -1
- package/dist/accounting-steps-internal.d.ts +49 -0
- package/dist/accounting-steps-internal.d.ts.map +1 -0
- package/dist/allocation-integrity.d.ts.map +1 -1
- package/dist/chunks/{ContractLineItemCollection-BZcrlrrY.js → ContractLineItemCollection-D5hBzrct.js} +6 -6
- package/dist/chunks/{ContractLineItemCollection-BZcrlrrY.js.map → ContractLineItemCollection-D5hBzrct.js.map} +1 -1
- package/dist/chunks/DocumentTaxCollection-C6cI5U89.js +4395 -0
- package/dist/chunks/DocumentTaxCollection-C6cI5U89.js.map +1 -0
- package/dist/chunks/HistoricalCustomerFundsCollections-B5x8gTW3.js +170 -0
- package/dist/chunks/HistoricalCustomerFundsCollections-B5x8gTW3.js.map +1 -0
- package/dist/chunks/{InvoiceCollection-cinzAqt6.js → InvoiceCollection-BolwughC.js} +133 -18
- package/dist/chunks/InvoiceCollection-BolwughC.js.map +1 -0
- package/dist/chunks/{TaxCodeCollection-DaBOPG9c.js → TaxCodeCollection-CW-tWjkU.js} +3 -4
- package/dist/chunks/TaxCodeCollection-CW-tWjkU.js.map +1 -0
- package/dist/chunks/{TaxComponentCollection-C4zxnyVu.js → TaxComponentCollection-BiJ9aAe8.js} +3 -3
- package/dist/chunks/{TaxComponentCollection-C4zxnyVu.js.map → TaxComponentCollection-BiJ9aAe8.js.map} +1 -1
- package/dist/chunks/{allocation-integrity-WmWyXhtG.js → allocation-integrity-CH-i-hsY.js} +7 -7
- package/dist/chunks/{allocation-integrity-WmWyXhtG.js.map → allocation-integrity-CH-i-hsY.js.map} +1 -1
- package/dist/chunks/{contract-money-EuToOghh.js → contract-money-BMsq4cpL.js} +45 -12
- package/dist/chunks/contract-money-BMsq4cpL.js.map +1 -0
- package/dist/chunks/customer-funds-internal-BQzoJXK5.js +24 -0
- package/dist/chunks/customer-funds-internal-BQzoJXK5.js.map +1 -0
- package/dist/chunks/{detect-CY9ufaFb.js → detect-DAE-_NAk.js} +5 -2
- package/dist/chunks/{detect-CY9ufaFb.js.map → detect-DAE-_NAk.js.map} +1 -1
- package/dist/chunks/historical-commerce-internal-C9ButfuH.js +18 -0
- package/dist/chunks/historical-commerce-internal-C9ButfuH.js.map +1 -0
- package/dist/chunks/{invoice-posting-C2i5dOVZ.js → invoice-posting-IXic4UEP.js} +5 -5
- package/dist/chunks/invoice-posting-IXic4UEP.js.map +1 -0
- package/dist/chunks/retention-accounting-c7kY7gFU.js +2738 -0
- package/dist/chunks/retention-accounting-c7kY7gFU.js.map +1 -0
- package/dist/chunks/retention-accounting-internal-DNxLLVvK.js +30 -0
- package/dist/chunks/retention-accounting-internal-DNxLLVvK.js.map +1 -0
- package/dist/chunks/{tenant-money-barrier-6TlqUeVj.js → tenant-money-barrier-DEVLrpaB.js} +5 -5
- package/dist/chunks/{tenant-money-barrier-6TlqUeVj.js.map → tenant-money-barrier-DEVLrpaB.js.map} +1 -1
- package/dist/chunks/types-Bbm0Xflc.js.map +1 -1
- package/dist/collections/DocumentTaxCollection.d.ts +4 -1
- package/dist/collections/DocumentTaxCollection.d.ts.map +1 -1
- package/dist/collections/HistoricalCustomerFundsCollections.d.ts +10 -0
- package/dist/collections/HistoricalCustomerFundsCollections.d.ts.map +1 -0
- package/dist/collections/HistoricalSalesLineCollection.d.ts +6 -0
- package/dist/collections/HistoricalSalesLineCollection.d.ts.map +1 -0
- package/dist/collections/PaymentAllocationCollection.d.ts +2 -6
- package/dist/collections/PaymentAllocationCollection.d.ts.map +1 -1
- package/dist/collections/PurchasePriceObservationCollection.d.ts +6 -0
- package/dist/collections/PurchasePriceObservationCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/contract-billing-schedule.d.ts +83 -0
- package/dist/contract-billing-schedule.d.ts.map +1 -0
- package/dist/contract-money.d.ts +2 -0
- package/dist/contract-money.d.ts.map +1 -1
- package/dist/customer-funds-internal.d.ts +6 -0
- package/dist/customer-funds-internal.d.ts.map +1 -0
- package/dist/customer-funds.d.ts +108 -0
- package/dist/customer-funds.d.ts.map +1 -0
- package/dist/document-money.d.ts +11 -0
- package/dist/document-money.d.ts.map +1 -1
- package/dist/historical-commerce-internal.d.ts +3 -0
- package/dist/historical-commerce-internal.d.ts.map +1 -0
- package/dist/historical-customer-funds-types.d.ts +113 -0
- package/dist/historical-customer-funds-types.d.ts.map +1 -0
- package/dist/historical-customer-funds.d.ts +23 -0
- package/dist/historical-customer-funds.d.ts.map +1 -0
- package/dist/historical-funds-internal.d.ts +5 -0
- package/dist/historical-funds-internal.d.ts.map +1 -0
- package/dist/historical-sales-money.d.ts +22 -0
- package/dist/historical-sales-money.d.ts.map +1 -0
- package/dist/historical-sales-reports.d.ts +31 -0
- package/dist/historical-sales-reports.d.ts.map +1 -0
- package/dist/historical-sales-types.d.ts +106 -0
- package/dist/historical-sales-types.d.ts.map +1 -0
- package/dist/historical-sales-validation.d.ts +12 -0
- package/dist/historical-sales-validation.d.ts.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1668 -1643
- package/dist/index.js.map +1 -1
- package/dist/invoice-accounting-sync.d.ts +0 -1
- package/dist/invoice-accounting-sync.d.ts.map +1 -1
- package/dist/invoice-mcp.d.ts.map +1 -1
- package/dist/invoice-posting.d.ts.map +1 -1
- package/dist/invoice-retention.d.ts +16 -0
- package/dist/invoice-retention.d.ts.map +1 -0
- package/dist/invoices.d.ts +3 -0
- package/dist/invoices.d.ts.map +1 -1
- package/dist/invoices.js +2 -2
- package/dist/manifest.json +7626 -4446
- package/dist/models/Contract.d.ts +14 -0
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/DocumentTax.d.ts +2 -0
- package/dist/models/DocumentTax.d.ts.map +1 -1
- package/dist/models/HistoricalCustomerFunds.d.ts +36 -0
- package/dist/models/HistoricalCustomerFunds.d.ts.map +1 -0
- package/dist/models/HistoricalCustomerFundsAllocation.d.ts +32 -0
- package/dist/models/HistoricalCustomerFundsAllocation.d.ts.map +1 -0
- package/dist/models/HistoricalSalesLine.d.ts +29 -0
- package/dist/models/HistoricalSalesLine.d.ts.map +1 -0
- package/dist/models/Invoice.d.ts +12 -1
- package/dist/models/Invoice.d.ts.map +1 -1
- package/dist/models/Payment.d.ts +9 -1
- package/dist/models/Payment.d.ts.map +1 -1
- package/dist/models/PaymentAllocation.d.ts +3 -1
- package/dist/models/PaymentAllocation.d.ts.map +1 -1
- package/dist/models/PaymentIntent.d.ts.map +1 -1
- package/dist/models/Payout.d.ts.map +1 -1
- package/dist/models/PurchasePriceObservation.d.ts +15 -0
- package/dist/models/PurchasePriceObservation.d.ts.map +1 -0
- package/dist/models/TaxCode.d.ts +1 -1
- package/dist/models/TaxCode.d.ts.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/money.d.ts +5 -1
- package/dist/money.d.ts.map +1 -1
- package/dist/money.js +62 -15
- package/dist/money.js.map +1 -1
- package/dist/observed-purchase-price-internal.d.ts +3 -0
- package/dist/observed-purchase-price-internal.d.ts.map +1 -0
- package/dist/observed-purchase-price.d.ts +71 -0
- package/dist/observed-purchase-price.d.ts.map +1 -0
- package/dist/ordinary-accounting-internal.d.ts +3 -0
- package/dist/ordinary-accounting-internal.d.ts.map +1 -0
- package/dist/ordinary-accounting.d.ts +104 -0
- package/dist/ordinary-accounting.d.ts.map +1 -0
- package/dist/received-purchase-money.d.ts +87 -0
- package/dist/received-purchase-money.d.ts.map +1 -0
- package/dist/recipes.d.ts +4 -1
- package/dist/recipes.d.ts.map +1 -1
- package/dist/retention-accounting-internal.d.ts +3 -0
- package/dist/retention-accounting-internal.d.ts.map +1 -0
- package/dist/retention-accounting.d.ts +143 -0
- package/dist/retention-accounting.d.ts.map +1 -0
- package/dist/retention-money.d.ts +43 -0
- package/dist/retention-money.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +1872 -113
- package/dist/tax/cookbook.d.ts.map +1 -1
- package/dist/tax-summary.d.ts +1 -0
- package/dist/tax-summary.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +16 -16
- package/dist/chunks/CustomerCollection-BIPH2ZUx.js +0 -99
- package/dist/chunks/CustomerCollection-BIPH2ZUx.js.map +0 -1
- package/dist/chunks/DocumentTaxCollection-DDzlywMW.js +0 -1666
- package/dist/chunks/DocumentTaxCollection-DDzlywMW.js.map +0 -1
- package/dist/chunks/InvoiceCollection-cinzAqt6.js.map +0 -1
- package/dist/chunks/TaxCodeCollection-DaBOPG9c.js.map +0 -1
- package/dist/chunks/VendorCollection-D6ZcUYy8.js +0 -100
- package/dist/chunks/VendorCollection-D6ZcUYy8.js.map +0 -1
- package/dist/chunks/calculations-C9daQLsh.js +0 -82
- package/dist/chunks/calculations-C9daQLsh.js.map +0 -1
- package/dist/chunks/contract-money-EuToOghh.js.map +0 -1
- package/dist/chunks/document-money-DV5t4vlK.js +0 -1186
- package/dist/chunks/document-money-DV5t4vlK.js.map +0 -1
- package/dist/chunks/invoice-posting-C2i5dOVZ.js.map +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type AccountingProvider, type CreditMemoInput, type QuickBooksReceivableMapping } from '@happyvertical/accounting';
|
|
2
|
+
import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
|
|
3
|
+
import { type AccountingStep } from './accounting-steps-internal.js';
|
|
4
|
+
import { type FrozenInvoiceAccountingInput, type QuickBooksFrozenInvoiceMapping, type ReconcileFrozenInvoiceAccountingInput } from './invoice-accounting-sync.js';
|
|
5
|
+
import type { Invoice } from './models/Invoice.js';
|
|
6
|
+
import { type InvoiceRetentionEvidence } from './retention-money.js';
|
|
7
|
+
import { type AccountingInvoiceInput } from './types/index.js';
|
|
8
|
+
type Provider = Pick<AccountingProvider, 'type' | 'invoices' | 'creditMemos' | 'receivableTransfers'>;
|
|
9
|
+
interface Scope {
|
|
10
|
+
db: DatabaseInterface;
|
|
11
|
+
tenantId: string;
|
|
12
|
+
invoiceId: string;
|
|
13
|
+
provider: Provider;
|
|
14
|
+
}
|
|
15
|
+
interface RefundRecording {
|
|
16
|
+
paymentId: string;
|
|
17
|
+
creditId: string;
|
|
18
|
+
requestId: string;
|
|
19
|
+
evidenceRef: string;
|
|
20
|
+
effectiveOn: string;
|
|
21
|
+
amountMinor: number;
|
|
22
|
+
paymentFingerprint: string;
|
|
23
|
+
committed: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface CreditAdjustment {
|
|
26
|
+
creditId: string;
|
|
27
|
+
moneySnapshotId: string;
|
|
28
|
+
requestId: string;
|
|
29
|
+
evidenceRef: string;
|
|
30
|
+
effectiveOn: string;
|
|
31
|
+
grossMinor: number;
|
|
32
|
+
retainedMinor: number;
|
|
33
|
+
appliedMinor: number;
|
|
34
|
+
mapping: QuickBooksFrozenInvoiceMapping;
|
|
35
|
+
committed: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface Release extends InvoiceRetentionEvidence {
|
|
38
|
+
amountMinor: number;
|
|
39
|
+
effectiveOn: string;
|
|
40
|
+
dueOn: string;
|
|
41
|
+
stepKey: string;
|
|
42
|
+
committed: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface RetainedInvoiceAccountingState {
|
|
45
|
+
version: 1;
|
|
46
|
+
invoiceId: string;
|
|
47
|
+
moneySnapshotId: string;
|
|
48
|
+
requestId: string;
|
|
49
|
+
evidenceRef: string;
|
|
50
|
+
currency: string;
|
|
51
|
+
grossMinor: number;
|
|
52
|
+
retainedMinor: number;
|
|
53
|
+
retentionAgreementHash: string;
|
|
54
|
+
effectiveOn: string;
|
|
55
|
+
mapping: QuickBooksReceivableMapping;
|
|
56
|
+
invoiceMapping: QuickBooksFrozenInvoiceMapping;
|
|
57
|
+
status: 'pending' | 'ready';
|
|
58
|
+
steps: AccountingStep[];
|
|
59
|
+
releases: Release[];
|
|
60
|
+
credits: CreditAdjustment[];
|
|
61
|
+
refunds: RefundRecording[];
|
|
62
|
+
}
|
|
63
|
+
export interface SyncRetainedInvoiceToAccountingInput extends Scope {
|
|
64
|
+
requestId: string;
|
|
65
|
+
evidenceRef: string;
|
|
66
|
+
effectiveOn: string;
|
|
67
|
+
mapping: QuickBooksReceivableMapping;
|
|
68
|
+
invoiceMapping: QuickBooksFrozenInvoiceMapping;
|
|
69
|
+
}
|
|
70
|
+
export interface ReleaseRetainedInvoiceToAccountingInput extends Scope, InvoiceRetentionEvidence {
|
|
71
|
+
amountMinor: number;
|
|
72
|
+
effectiveOn: string;
|
|
73
|
+
dueOn: string;
|
|
74
|
+
expectedUpdatedAt: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function readRetainedInvoiceAccountingState(invoice: Invoice): RetainedInvoiceAccountingState | null;
|
|
77
|
+
/** Read-only review of the exact retained document; generic export stays blocked.
|
|
78
|
+
* The host supplies authorization, and every read stays on the caller's executor.
|
|
79
|
+
*/
|
|
80
|
+
export declare function loadRetainedInvoiceAccountingSnapshot(input: Omit<FrozenInvoiceAccountingInput, 'mapping'>): Promise<import("./invoice-accounting-sync.js").FrozenInvoiceAccountingSnapshot>;
|
|
81
|
+
/** Validate reviewed realm item/tax mapping without creating a provider operation. */
|
|
82
|
+
export declare function toRetainedInvoiceAccountingInput(input: FrozenInvoiceAccountingInput): Promise<AccountingInvoiceInput>;
|
|
83
|
+
type RetainedCreditReviewScope = Omit<FrozenInvoiceAccountingInput, 'mapping'> & {
|
|
84
|
+
creditInvoiceId: string;
|
|
85
|
+
};
|
|
86
|
+
/** Read an issued retained-first credit without permitting generic credit export. */
|
|
87
|
+
export declare function loadRetainedCreditAccountingSnapshot(input: RetainedCreditReviewScope): Promise<import("./invoice-accounting-sync.js").FrozenInvoiceAccountingSnapshot>;
|
|
88
|
+
/** Map a retained-first credit using the existing frozen reader's realm/lineage checks. */
|
|
89
|
+
export declare function toRetainedCreditAccountingInput(input: RetainedCreditReviewScope & {
|
|
90
|
+
mapping: QuickBooksFrozenInvoiceMapping;
|
|
91
|
+
}): Promise<CreditMemoInput>;
|
|
92
|
+
/** Export unchanged gross/tax, then reclassify and apply its exact retained amount. */
|
|
93
|
+
export declare function syncRetainedInvoiceToAccounting(input: SyncRetainedInvoiceToAccountingInput): Promise<RetainedInvoiceAccountingState>;
|
|
94
|
+
/** Release date is provider TxnDate; dueOn remains explicit host collection policy. */
|
|
95
|
+
export declare function releaseRetainedInvoiceToAccounting(input: ReleaseRetainedInvoiceToAccountingInput): Promise<RetainedInvoiceAccountingState>;
|
|
96
|
+
export interface ReconcileRetainedAccountingStepInput extends Scope {
|
|
97
|
+
stepKey: string;
|
|
98
|
+
requestId: string;
|
|
99
|
+
attemptId: string;
|
|
100
|
+
confirmInterruptedOwnerStopped?: true;
|
|
101
|
+
outcome: {
|
|
102
|
+
status: 'found';
|
|
103
|
+
externalId: string;
|
|
104
|
+
} | {
|
|
105
|
+
status: 'absent';
|
|
106
|
+
evidenceRef: string;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** Unknown remote outcomes never reset on a guessed absence or an unobserved owner. */
|
|
110
|
+
export declare function reconcileRetainedAccountingStep(input: ReconcileRetainedAccountingStepInput): Promise<RetainedInvoiceAccountingState>;
|
|
111
|
+
/** Reconcile the existing frozen invoice step using its established owner proof. */
|
|
112
|
+
export declare function reconcileRetainedBaseInvoice(input: ReconcileFrozenInvoiceAccountingInput & {
|
|
113
|
+
provider: Provider;
|
|
114
|
+
}): Promise<import("./invoice-accounting-sync.js").FrozenAccountingSyncResult | import("./invoice-accounting-sync.js").FrozenAccountingReconciliationReady>;
|
|
115
|
+
export interface SyncRetainedCreditToAccountingInput extends Scope {
|
|
116
|
+
creditInvoiceId: string;
|
|
117
|
+
creditMapping: QuickBooksFrozenInvoiceMapping;
|
|
118
|
+
requestId: string;
|
|
119
|
+
evidenceRef: string;
|
|
120
|
+
effectiveOn: string;
|
|
121
|
+
}
|
|
122
|
+
/** Apply retained-first credit to the retained asset, then to the original due balance. */
|
|
123
|
+
export declare function syncRetainedCreditToAccounting(input: SyncRetainedCreditToAccountingInput): Promise<RetainedInvoiceAccountingState>;
|
|
124
|
+
export interface SyncRetainedRefundToAccountingInput extends Scope {
|
|
125
|
+
paymentId: string;
|
|
126
|
+
creditInvoiceId: string;
|
|
127
|
+
requestId: string;
|
|
128
|
+
evidenceRef: string;
|
|
129
|
+
effectiveOn: string;
|
|
130
|
+
}
|
|
131
|
+
/** Record an already settled local refund and consume its existing remote credit. No bank I/O. */
|
|
132
|
+
export declare function syncRetainedRefundToAccounting(input: SyncRetainedRefundToAccountingInput): Promise<RetainedInvoiceAccountingState>;
|
|
133
|
+
export interface ReconcileRetainedCreditAccountingInput extends Scope {
|
|
134
|
+
creditInvoiceId: string;
|
|
135
|
+
requestId: string;
|
|
136
|
+
attemptId: string;
|
|
137
|
+
confirmInterruptedOwnerStopped?: true;
|
|
138
|
+
outcome: ReconcileFrozenInvoiceAccountingInput['outcome'];
|
|
139
|
+
}
|
|
140
|
+
/** Resolve an interrupted credit-memo export before its retained-first applications resume. */
|
|
141
|
+
export declare function reconcileRetainedCreditAccounting(input: ReconcileRetainedCreditAccountingInput): Promise<import("./invoice-accounting-sync.js").FrozenAccountingSyncResult | import("./invoice-accounting-sync.js").FrozenAccountingReconciliationReady>;
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=retention-accounting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention-accounting.d.ts","sourceRoot":"","sources":["../src/retention-accounting.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EAEpB,KAAK,2BAA2B,EAGjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAG7E,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,gCAAgC,CAAC;AAUxC,OAAO,EACL,KAAK,4BAA4B,EAEjC,KAAK,8BAA8B,EACnC,KAAK,qCAAqC,EAI3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAEL,KAAK,wBAAwB,EAG9B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,KAAK,sBAAsB,EAAiB,MAAM,kBAAkB,CAAC;AAE9E,KAAK,QAAQ,GAAG,IAAI,CAClB,kBAAkB,EAClB,MAAM,GAAG,UAAU,GAAG,aAAa,GAAG,qBAAqB,CAC5D,CAAC;AACF,UAAU,KAAK;IACb,EAAE,EAAE,iBAAiB,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AACD,UAAU,eAAe;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;CACpB;AACD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;I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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface InvoiceRetentionEvidence {
|
|
2
|
+
requestId: string;
|
|
3
|
+
policyVersion: string;
|
|
4
|
+
evidenceRef: string;
|
|
5
|
+
actorId: string;
|
|
6
|
+
reason: string;
|
|
7
|
+
/** Explicit business calendar date for original or current evidence; recordedAt stays actual record time. */
|
|
8
|
+
effectiveOn?: string;
|
|
9
|
+
sameDayCreditOrder?: 'credit-before-release' | 'release-before-credit' | null;
|
|
10
|
+
}
|
|
11
|
+
export interface InvoiceRetentionRelease extends InvoiceRetentionEvidence {
|
|
12
|
+
amountMinor: number;
|
|
13
|
+
recordedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface InvoiceRetentionState extends InvoiceRetentionEvidence {
|
|
16
|
+
version: 1;
|
|
17
|
+
currency: string;
|
|
18
|
+
creditPolicy: 'retained-first';
|
|
19
|
+
retainedMinor: number;
|
|
20
|
+
recordedAt: string;
|
|
21
|
+
releases: InvoiceRetentionRelease[];
|
|
22
|
+
}
|
|
23
|
+
export interface InvoicePayableFacts {
|
|
24
|
+
grossMinor: number;
|
|
25
|
+
retainedMinor: number;
|
|
26
|
+
releasedMinor: number;
|
|
27
|
+
creditedRetentionMinor: number;
|
|
28
|
+
retainedRemainingMinor: number;
|
|
29
|
+
allocationCapMinor: number;
|
|
30
|
+
grossBalanceMinor: number;
|
|
31
|
+
currentlyDueMinor: number;
|
|
32
|
+
}
|
|
33
|
+
export declare function assertRetentionMinor(amount: number, label: string): void;
|
|
34
|
+
export declare function validateRetentionEvidence(input: InvoiceRetentionEvidence): void;
|
|
35
|
+
export declare function parseInvoiceRetention(json: string): InvoiceRetentionState | null;
|
|
36
|
+
export declare function calculateInvoicePayable(input: {
|
|
37
|
+
totalAmount: number;
|
|
38
|
+
creditedAmount: number;
|
|
39
|
+
amountPaid: number;
|
|
40
|
+
currency: string;
|
|
41
|
+
retentionStateJson?: string;
|
|
42
|
+
}): InvoicePayableFacts;
|
|
43
|
+
//# sourceMappingURL=retention-money.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retention-money.d.ts","sourceRoot":"","sources":["../src/retention-money.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,6GAA6G;IAC7G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,GAAG,IAAI,CAAC;CAC/E;AACD,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;IACrE,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,gBAAgB,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,uBAAuB,EAAE,CAAC;CACrC;AACD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGxE;AACD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,wBAAwB,GAC9B,IAAI,CAYN;AACD,wBA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