@happyvertical/smrt-commerce 0.57.9 → 0.57.11
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 +1 -0
- package/README.md +61 -0
- package/agents/connected-payments.md +135 -0
- package/agents/contract-billing-schedules.md +6 -0
- package/agents/money-upgrade.md +5 -0
- package/dist/chunks/{ContractLineItemCollection-DQZqRiZi.js → ContractLineItemCollection-DkBeBR7a.js} +4 -4
- package/dist/chunks/{ContractLineItemCollection-DQZqRiZi.js.map → ContractLineItemCollection-DkBeBR7a.js.map} +1 -1
- package/dist/chunks/{DocumentTaxCollection-Dg942m_Z.js → DocumentTaxCollection-D85ut-Fo.js} +14 -10
- package/dist/chunks/{DocumentTaxCollection-Dg942m_Z.js.map → DocumentTaxCollection-D85ut-Fo.js.map} +1 -1
- package/dist/chunks/{InvoiceCollection-XPcPyibo.js → InvoiceCollection-Datg_eZM.js} +9 -9
- package/dist/chunks/{InvoiceCollection-XPcPyibo.js.map → InvoiceCollection-Datg_eZM.js.map} +1 -1
- package/dist/chunks/{TaxCodeCollection-CbTBWO8z.js → TaxCodeCollection-CIC1skxr.js} +2 -2
- package/dist/chunks/{TaxCodeCollection-CbTBWO8z.js.map → TaxCodeCollection-CIC1skxr.js.map} +1 -1
- package/dist/chunks/{TaxComponentCollection-VZ_cGr2n.js → TaxComponentCollection-BHBV-_1J.js} +3 -3
- package/dist/chunks/{TaxComponentCollection-VZ_cGr2n.js.map → TaxComponentCollection-BHBV-_1J.js.map} +1 -1
- package/dist/chunks/{allocation-integrity-Kr8uceRx.js → allocation-integrity-B2SyO1mu.js} +6 -6
- package/dist/chunks/{allocation-integrity-Kr8uceRx.js.map → allocation-integrity-B2SyO1mu.js.map} +1 -1
- package/dist/chunks/{contract-money-DGNqQwf0.js → contract-money-C61kGBkU.js} +7 -6
- package/dist/chunks/contract-money-C61kGBkU.js.map +1 -0
- package/dist/chunks/{invoice-posting-DVSkfSUm.js → invoice-posting-uLfdyLIi.js} +3 -3
- package/dist/chunks/{invoice-posting-DVSkfSUm.js.map → invoice-posting-uLfdyLIi.js.map} +1 -1
- package/dist/chunks/{retention-accounting-Ct5Df6xx.js → retention-accounting-DGuXzt9g.js} +149 -11
- package/dist/chunks/retention-accounting-DGuXzt9g.js.map +1 -0
- package/dist/chunks/{tenant-money-barrier-CG78Xxja.js → tenant-money-barrier-DXnJWxiZ.js} +3 -3
- package/dist/chunks/{tenant-money-barrier-CG78Xxja.js.map → tenant-money-barrier-DXnJWxiZ.js.map} +1 -1
- package/dist/chunks/types-Bbm0Xflc.js.map +1 -1
- package/dist/collections/TenantPaymentAccountCollection.d.ts +28 -0
- package/dist/collections/TenantPaymentAccountCollection.d.ts.map +1 -0
- package/dist/collections/index.d.ts +1 -0
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/connected-payments-internal.d.ts +5 -0
- package/dist/connected-payments-internal.d.ts.map +1 -0
- package/dist/connected-payments.d.ts +361 -0
- package/dist/connected-payments.d.ts.map +1 -0
- package/dist/contract-money.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1241 -160
- package/dist/index.js.map +1 -1
- package/dist/invoices.js +1 -1
- package/dist/manifest.json +1404 -129
- package/dist/models/Contract.d.ts +5 -1
- package/dist/models/Contract.d.ts.map +1 -1
- package/dist/models/Payment.d.ts +33 -0
- package/dist/models/Payment.d.ts.map +1 -1
- package/dist/models/PaymentIntent.d.ts +35 -0
- package/dist/models/PaymentIntent.d.ts.map +1 -1
- package/dist/models/TenantPaymentAccount.d.ts +121 -0
- package/dist/models/TenantPaymentAccount.d.ts.map +1 -0
- package/dist/models/TenantPaymentWebhookEvent.d.ts +50 -0
- package/dist/models/TenantPaymentWebhookEvent.d.ts.map +1 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/recipes.d.ts +15 -0
- package/dist/recipes.d.ts.map +1 -1
- package/dist/smrt-knowledge.json +622 -27
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/upgrade/money-v2.d.ts +2 -0
- package/dist/upgrade/money-v2.d.ts.map +1 -1
- package/package.json +16 -16
- package/dist/chunks/contract-money-DGNqQwf0.js.map +0 -1
- package/dist/chunks/retention-accounting-Ct5Df6xx.js.map +0 -1
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { Y as InvoiceLineItemCollection, t as DocumentTaxCollection, x as lockAndReloadInvoice } from "./DocumentTaxCollection-
|
|
2
|
+
import { Y as InvoiceLineItemCollection, t as DocumentTaxCollection, x as lockAndReloadInvoice } from "./DocumentTaxCollection-D85ut-Fo.js";
|
|
3
3
|
import { d as PaymentStatus, s as InvoiceStatus, u as PaymentMethod } from "./types-Bbm0Xflc.js";
|
|
4
4
|
import { o as minorToMajorUnits } from "./units-8ElbjVZK.js";
|
|
5
5
|
import { i as withOrdinaryAccountingAuthority, n as withRetentionAccountingAuthority, r as hasOrdinaryAccountingAuthority, t as hasRetentionAccountingAuthority } from "./retention-accounting-internal-DNxLLVvK.js";
|
|
6
|
-
import { i as claimAllocationParent, n as allocationTotal, r as assertAllocationParent, t as allocationOwner } from "./allocation-integrity-
|
|
6
|
+
import { i as claimAllocationParent, n as allocationTotal, r as assertAllocationParent, t as allocationOwner } from "./allocation-integrity-B2SyO1mu.js";
|
|
7
7
|
import { n as customerFundsState, t as assertCustomerFundsWrite } from "./customer-funds-internal-BQzoJXK5.js";
|
|
8
8
|
import { MoneyValidationError, assertIntegerMinorUnits, calculateMoneyDocument } from "../money.js";
|
|
9
9
|
import { t as HistoricalCustomerFundsAllocationCollection } from "./HistoricalCustomerFundsCollections-B5x8gTW3.js";
|
|
10
10
|
import { n as calculateAvailableRefund } from "./credit-allocation-yspz0Lab.js";
|
|
11
11
|
import { _ as withDocumentMoneyTransaction, m as isMoneyTransaction, p as DOCUMENT_MONEY_WRITE } from "./detect-DAE-_NAk.js";
|
|
12
|
-
import { c as validateRetentionEvidence, o as calculateInvoicePayable, s as parseInvoiceRetention, t as InvoiceCollection } from "./InvoiceCollection-
|
|
13
|
-
import { t as lockTenantMoneyRuntime } from "./tenant-money-barrier-
|
|
12
|
+
import { c as validateRetentionEvidence, o as calculateInvoicePayable, s as parseInvoiceRetention, t as InvoiceCollection } from "./InvoiceCollection-Datg_eZM.js";
|
|
13
|
+
import { t as lockTenantMoneyRuntime } from "./tenant-money-barrier-DXnJWxiZ.js";
|
|
14
14
|
import { SmrtCollection, SmrtObject, crossPackageRef, field, foreignKey, isPostgresDatabase, smrt } from "@happyvertical/smrt-core";
|
|
15
15
|
import { TenantScoped, getTenantId, queryGlobal, queryWithGlobals, tenantId } from "@happyvertical/smrt-tenancy";
|
|
16
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
16
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
17
18
|
import { prepareQuickBooksCreditMemoRequest, prepareQuickBooksInvoiceRequest, prepareQuickBooksReceivableRequest, requireCreditMemoOperations } from "@happyvertical/accounting";
|
|
19
|
+
//#region src/connected-payments-internal.ts
|
|
20
|
+
var authority = new AsyncLocalStorage();
|
|
21
|
+
function withConnectedPaymentAuthority(tenantId, operation) {
|
|
22
|
+
return authority.run({ tenantId: tenantId.toLowerCase() }, operation);
|
|
23
|
+
}
|
|
24
|
+
function hasConnectedPaymentAuthority(tenantId) {
|
|
25
|
+
const current = authority.getStore();
|
|
26
|
+
return !!current && typeof tenantId === "string" && current.tenantId === tenantId.toLowerCase();
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
18
29
|
//#region src/models/Payment.ts
|
|
19
30
|
var __defProp$1 = Object.defineProperty;
|
|
20
31
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
@@ -139,6 +150,37 @@ var Payment = class extends SmrtObject {
|
|
|
139
150
|
* negative) when accepting payment in a volatile native currency (#2401).
|
|
140
151
|
*/
|
|
141
152
|
usdAtConfirmation = 0;
|
|
153
|
+
/**
|
|
154
|
+
* Connected provider account (for example a Stripe `acct_...`) a direct
|
|
155
|
+
* charge was made on, so the funds landed with the tenant rather than the
|
|
156
|
+
* platform (#3831). Empty for platform-account and non-Connect payments.
|
|
157
|
+
* Server-managed: written only by the connected-payments commands.
|
|
158
|
+
*/
|
|
159
|
+
connectedAccountId = "";
|
|
160
|
+
/**
|
|
161
|
+
* Platform application fee the provider withheld from this direct charge,
|
|
162
|
+
* in integer minor units of {@link currency} (#3831). Settled at source, so
|
|
163
|
+
* {@link recordPayment} books it as a fee expense, never as a payable.
|
|
164
|
+
* Server-managed.
|
|
165
|
+
*/
|
|
166
|
+
applicationFeeCents = 0;
|
|
167
|
+
/**
|
|
168
|
+
* For a `refund` of a connected charge, the `Payment` it refunds (#3831).
|
|
169
|
+
* Server-managed.
|
|
170
|
+
*/
|
|
171
|
+
refundOfPaymentId = "";
|
|
172
|
+
/**
|
|
173
|
+
* For a `refund` of a connected charge, the provider's refund state:
|
|
174
|
+
* `requested` (recorded before the provider is asked), `pending` until the
|
|
175
|
+
* provider confirms it, then `succeeded` (journaled) or `failed` (#3831).
|
|
176
|
+
* Server-managed.
|
|
177
|
+
*/
|
|
178
|
+
connectedRefundState = "";
|
|
179
|
+
/**
|
|
180
|
+
* For a `refund` of a connected charge, whether the platform's application
|
|
181
|
+
* fee was refunded with it (#3831). Server-managed and frozen.
|
|
182
|
+
*/
|
|
183
|
+
applicationFeeRefunded = false;
|
|
142
184
|
constructor(options = {}) {
|
|
143
185
|
super(options);
|
|
144
186
|
if (options.kind !== void 0) this.kind = options.kind;
|
|
@@ -164,6 +206,11 @@ var Payment = class extends SmrtObject {
|
|
|
164
206
|
if (options.nativeCurrency !== void 0) this.nativeCurrency = options.nativeCurrency;
|
|
165
207
|
if (options.usdAtQuote !== void 0) this.usdAtQuote = options.usdAtQuote;
|
|
166
208
|
if (options.usdAtConfirmation !== void 0) this.usdAtConfirmation = options.usdAtConfirmation;
|
|
209
|
+
if (options.connectedAccountId !== void 0) this.connectedAccountId = options.connectedAccountId;
|
|
210
|
+
if (options.applicationFeeCents !== void 0) this.applicationFeeCents = options.applicationFeeCents;
|
|
211
|
+
if (options.refundOfPaymentId !== void 0) this.refundOfPaymentId = options.refundOfPaymentId;
|
|
212
|
+
if (options.connectedRefundState !== void 0) this.connectedRefundState = options.connectedRefundState;
|
|
213
|
+
if (options.applicationFeeRefunded !== void 0) this.applicationFeeRefunded = options.applicationFeeRefunded;
|
|
167
214
|
}
|
|
168
215
|
/**
|
|
169
216
|
* Capture the persisted status the row was loaded with, so the save-time
|
|
@@ -209,14 +256,19 @@ var Payment = class extends SmrtObject {
|
|
|
209
256
|
["amount", this.amount],
|
|
210
257
|
["nativeAmount", this.nativeAmount],
|
|
211
258
|
["usdAtQuote", this.usdAtQuote],
|
|
212
|
-
["usdAtConfirmation", this.usdAtConfirmation]
|
|
259
|
+
["usdAtConfirmation", this.usdAtConfirmation],
|
|
260
|
+
["applicationFeeCents", this.applicationFeeCents]
|
|
213
261
|
]);
|
|
262
|
+
if (this.applicationFeeCents < 0 || this.applicationFeeCents > this.amount) throw new Error("Payment applicationFeeCents must be between 0 and the payment amount");
|
|
263
|
+
if (this.applicationFeeCents > 0 && !this.connectedAccountId) throw new Error("Payment applicationFeeCents requires a connectedAccountId");
|
|
214
264
|
const priorRow = await this.loadPersistedRow();
|
|
215
265
|
if (this.customerFundsJson || priorRow?.customer_funds_json) assertCustomerFundsWrite(this);
|
|
216
266
|
const ordinaryBinding = this.ordinaryAccountingBindingJson || String(priorRow?.ordinary_accounting_binding_json ?? "");
|
|
217
267
|
if (ordinaryBinding && !hasOrdinaryAccountingAuthority(this.tenantId, JSON.parse(ordinaryBinding).invoiceId)) throw new Error("Provider-recorded refund is immutable; use an explicit reversal workflow");
|
|
218
268
|
const retainedBinding = this.retentionAccountingBindingJson || String(priorRow?.retention_accounting_binding_json ?? "");
|
|
219
269
|
if (retainedBinding && !hasRetentionAccountingAuthority(this.tenantId, JSON.parse(retainedBinding).invoiceId)) throw new Error("Provider-recorded refund is immutable; use an explicit reversal workflow");
|
|
270
|
+
if ((this.connectedAccountId || String(priorRow?.connected_account_id ?? "")) && !hasConnectedPaymentAuthority(this.tenantId)) throw new Error("Connected payments and refunds are written only by the connected-payments commands");
|
|
271
|
+
if (priorRow && String(priorRow.connected_account_id ?? "")) this.assertConnectedIdentityUnchanged(priorRow);
|
|
220
272
|
const prior = priorRow && priorRow.status != null ? priorRow.status : loadedPaymentStatus.get(this);
|
|
221
273
|
this.assertStatusTransition(prior);
|
|
222
274
|
if (this.status === PaymentStatus.COMPLETED && prior !== PaymentStatus.COMPLETED && !settlementInProgress.has(this)) throw new Error(`Payment ${this.id || "<new>"}: cannot set status to COMPLETED via raw assignment \u2014 a Payment is only completed through recordPayment(), which posts a balanced settlement journal. Use recordPayment() instead of setting status directly.`);
|
|
@@ -236,8 +288,65 @@ var Payment = class extends SmrtObject {
|
|
|
236
288
|
const persisted = await this.loadPersistedRow();
|
|
237
289
|
if (this.retentionAccountingBindingJson || persisted?.retention_accounting_binding_json || this.ordinaryAccountingBindingJson || persisted?.ordinary_accounting_binding_json) throw new Error("Provider-recorded refund history cannot be deleted");
|
|
238
290
|
if (this.customerFundsJson || persisted?.customer_funds_json) throw new Error("Customer funds cash history cannot be deleted");
|
|
291
|
+
if (this.connectedAccountId || persisted?.connected_account_id) throw new Error("Connected payment and refund history cannot be deleted");
|
|
239
292
|
return super.delete(options);
|
|
240
293
|
}
|
|
294
|
+
/** See the connected-row guard in {@link save}. */
|
|
295
|
+
assertConnectedIdentityUnchanged(priorRow) {
|
|
296
|
+
const frozen = [
|
|
297
|
+
[
|
|
298
|
+
"kind",
|
|
299
|
+
String(priorRow.kind ?? "payment"),
|
|
300
|
+
this.kind
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
"amount",
|
|
304
|
+
Number(priorRow.amount ?? 0),
|
|
305
|
+
Number(this.amount ?? 0)
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
"currency",
|
|
309
|
+
String(priorRow.currency ?? ""),
|
|
310
|
+
this.currency
|
|
311
|
+
],
|
|
312
|
+
[
|
|
313
|
+
"backendId",
|
|
314
|
+
String(priorRow.backend_id ?? ""),
|
|
315
|
+
this.backendId
|
|
316
|
+
],
|
|
317
|
+
[
|
|
318
|
+
"backendTxRef",
|
|
319
|
+
!priorRow.backend_tx_ref && priorRow.connected_refund_state === "requested" && this.connectedRefundState !== "requested" ? this.backendTxRef : String(priorRow.backend_tx_ref ?? ""),
|
|
320
|
+
this.backendTxRef
|
|
321
|
+
],
|
|
322
|
+
[
|
|
323
|
+
"transactionId",
|
|
324
|
+
String(priorRow.transaction_id ?? ""),
|
|
325
|
+
this.transactionId
|
|
326
|
+
],
|
|
327
|
+
[
|
|
328
|
+
"connectedAccountId",
|
|
329
|
+
String(priorRow.connected_account_id ?? ""),
|
|
330
|
+
this.connectedAccountId
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
"applicationFeeCents",
|
|
334
|
+
Number(priorRow.application_fee_cents ?? 0),
|
|
335
|
+
Number(this.applicationFeeCents ?? 0)
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
"refundOfPaymentId",
|
|
339
|
+
String(priorRow.refund_of_payment_id ?? ""),
|
|
340
|
+
this.refundOfPaymentId
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
"applicationFeeRefunded",
|
|
344
|
+
Boolean(priorRow.application_fee_refunded),
|
|
345
|
+
Boolean(this.applicationFeeRefunded)
|
|
346
|
+
]
|
|
347
|
+
];
|
|
348
|
+
for (const [field2, prior, next] of frozen) if (prior !== next) throw new Error(`Payment ${this.id}: '${field2}' of a connected payment or refund cannot change`);
|
|
349
|
+
}
|
|
241
350
|
/**
|
|
242
351
|
* Reject an illegal status flip. Compares the about-to-be-written status
|
|
243
352
|
* against the status the row was loaded with. No-op transitions (status
|
|
@@ -332,6 +441,26 @@ var Payment = class extends SmrtObject {
|
|
|
332
441
|
"usdAtConfirmation",
|
|
333
442
|
Number(priorRow.usd_at_confirmation ?? 0),
|
|
334
443
|
Number(this.usdAtConfirmation ?? 0)
|
|
444
|
+
],
|
|
445
|
+
[
|
|
446
|
+
"connectedAccountId",
|
|
447
|
+
String(priorRow.connected_account_id ?? ""),
|
|
448
|
+
String(this.connectedAccountId ?? "")
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
"applicationFeeCents",
|
|
452
|
+
Number(priorRow.application_fee_cents ?? 0),
|
|
453
|
+
Number(this.applicationFeeCents ?? 0)
|
|
454
|
+
],
|
|
455
|
+
[
|
|
456
|
+
"refundOfPaymentId",
|
|
457
|
+
String(priorRow.refund_of_payment_id ?? ""),
|
|
458
|
+
String(this.refundOfPaymentId ?? "")
|
|
459
|
+
],
|
|
460
|
+
[
|
|
461
|
+
"connectedRefundState",
|
|
462
|
+
String(priorRow.connected_refund_state ?? ""),
|
|
463
|
+
String(this.connectedRefundState ?? "")
|
|
335
464
|
]
|
|
336
465
|
];
|
|
337
466
|
for (const [field2, prior, next] of frozen) if (prior !== next) throw new Error(`Payment ${this.id}: '${field2}' is frozen once the payment is COMPLETED (was '${prior}', got '${next}'). A settled payment's monetary fields cannot be mutated \u2014 issue a refund instead.`);
|
|
@@ -439,6 +568,8 @@ var Payment = class extends SmrtObject {
|
|
|
439
568
|
async postPaymentInTransaction(options) {
|
|
440
569
|
if (this.status === PaymentStatus.COMPLETED) throw new Error("Payment already recorded");
|
|
441
570
|
if (this.amount <= 0) throw new Error("Payment amount must be positive");
|
|
571
|
+
const applicationFee = this.kind === "payment" ? this.applicationFeeCents : 0;
|
|
572
|
+
if (applicationFee > 0 && !options.applicationFeeAccountId) throw new Error("Payment carries an application fee; recordPayment requires applicationFeeAccountId");
|
|
442
573
|
const funds = customerFundsState(this.customerFundsJson);
|
|
443
574
|
const explicitDate = options.effectiveOn;
|
|
444
575
|
if (explicitDate !== void 0 && (typeof explicitDate !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(explicitDate) || !Number.isFinite(Date.parse(explicitDate)) || new Date(explicitDate).toISOString().slice(0, 10) !== explicitDate)) throw new Error("Settlement effectiveOn must be a calendar date");
|
|
@@ -461,10 +592,17 @@ var Payment = class extends SmrtObject {
|
|
|
461
592
|
await journal.addEntry({
|
|
462
593
|
accountId: options.cashAccountId,
|
|
463
594
|
currency: this.currency,
|
|
464
|
-
debit: this.kind === "payment" ? this.amount : 0,
|
|
595
|
+
debit: this.kind === "payment" ? this.amount - applicationFee : 0,
|
|
465
596
|
credit: this.kind === "refund" ? this.amount : 0,
|
|
466
597
|
memo: `${this.kind === "refund" ? "Refund" : "Payment"} ${this.reference || this.id}`
|
|
467
598
|
});
|
|
599
|
+
if (applicationFee > 0) await journal.addEntry({
|
|
600
|
+
accountId: options.applicationFeeAccountId,
|
|
601
|
+
currency: this.currency,
|
|
602
|
+
debit: applicationFee,
|
|
603
|
+
credit: 0,
|
|
604
|
+
memo: `Application fee ${this.reference || this.id}`
|
|
605
|
+
});
|
|
468
606
|
await journal.addEntry({
|
|
469
607
|
accountId: creditAccountId,
|
|
470
608
|
currency: this.currency,
|
|
@@ -813,7 +951,7 @@ var PaymentAllocation = class extends SmrtObject {
|
|
|
813
951
|
if (!this.paymentId || !this.invoiceId) throw new Error("PaymentAllocation requires payment and invoice");
|
|
814
952
|
return this.withTransaction(async () => {
|
|
815
953
|
const { PaymentCollection } = await Promise.resolve().then(() => PaymentCollection_exports);
|
|
816
|
-
const { InvoiceCollection } = await import("./InvoiceCollection-
|
|
954
|
+
const { InvoiceCollection } = await import("./InvoiceCollection-Datg_eZM.js").then((n) => n.n);
|
|
817
955
|
const { PaymentAllocationCollection } = await Promise.resolve().then(() => PaymentAllocationCollection_exports);
|
|
818
956
|
const payments = await PaymentCollection.create({ db: this.db });
|
|
819
957
|
const invoices = await InvoiceCollection.create({ db: this.db });
|
|
@@ -920,7 +1058,7 @@ var PaymentAllocationCollection = class PaymentAllocationCollection extends Smrt
|
|
|
920
1058
|
async allocatePayment(input) {
|
|
921
1059
|
if (!input.allocations.length || new Set(input.allocations.map((item) => item.id)).size !== input.allocations.length) throw new Error("Allocation batch requires distinct stable allocation ids");
|
|
922
1060
|
const { PaymentCollection } = await Promise.resolve().then(() => PaymentCollection_exports);
|
|
923
|
-
const { InvoiceCollection } = await import("./InvoiceCollection-
|
|
1061
|
+
const { InvoiceCollection } = await import("./InvoiceCollection-Datg_eZM.js").then((n) => n.n);
|
|
924
1062
|
const { InvoiceStatus } = await import("./types-Bbm0Xflc.js").then((n) => n.m);
|
|
925
1063
|
const payment = await (await PaymentCollection.create({ db: this.db })).get({ id: input.paymentId }, { cache: false });
|
|
926
1064
|
if (!payment) throw new Error("Payment does not exist");
|
|
@@ -963,7 +1101,7 @@ var PaymentAllocationCollection = class PaymentAllocationCollection extends Smrt
|
|
|
963
1101
|
const allocation = await this.get({ id }, { cache: false });
|
|
964
1102
|
if (!allocation) return;
|
|
965
1103
|
const { PaymentCollection } = await Promise.resolve().then(() => PaymentCollection_exports);
|
|
966
|
-
const { InvoiceCollection } = await import("./InvoiceCollection-
|
|
1104
|
+
const { InvoiceCollection } = await import("./InvoiceCollection-Datg_eZM.js").then((n) => n.n);
|
|
967
1105
|
const payment = await (await PaymentCollection.create({ db: this.db })).get({ id: allocation.paymentId }, { cache: false });
|
|
968
1106
|
if (!payment) throw new Error("Allocation payment does not exist");
|
|
969
1107
|
await payment.withTransaction(async () => {
|
|
@@ -2733,6 +2871,6 @@ async function reconcileRetainedCreditAccounting(input) {
|
|
|
2733
2871
|
}));
|
|
2734
2872
|
}
|
|
2735
2873
|
//#endregion
|
|
2736
|
-
export { PaymentAllocationCollection_exports as A, invoice_accounting_sync_exports as C, syncFrozenInvoiceToAccounting as D, reconcileFrozenInvoiceAccountingSync as E, Payment as F, historicalCreditRefundCommittedTotal as M, PaymentCollection as N, toFrozenInvoiceAccountingInput as O, PaymentCollection_exports as P, calculateInvoiceMinorLine as S, readFrozenAccountingSyncState as T, reconcileOrdinaryCreditAccounting as _, reconcileRetainedBaseInvoice as a, syncOrdinaryRefundToAccounting as b, syncRetainedCreditToAccounting as c, toRetainedCreditAccountingInput as d, toRetainedInvoiceAccountingInput as f, reconcileOrdinaryBaseInvoice as g, reconcileOrdinaryAccountingStep as h, reconcileRetainedAccountingStep as i, PaymentAllocation as j, PaymentAllocationCollection as k, syncRetainedInvoiceToAccounting as l, readOrdinaryInvoiceAccountingState as m, loadRetainedInvoiceAccountingSnapshot as n, reconcileRetainedCreditAccounting as o, loadOrdinaryCreditAccountingSnapshot as p, readRetainedInvoiceAccountingState as r, releaseRetainedInvoiceToAccounting as s, loadRetainedCreditAccountingSnapshot as t, syncRetainedRefundToAccounting as u, syncOrdinaryCreditToAccounting as v, loadFrozenInvoiceAccountingSnapshot as w, toOrdinaryCreditAccountingInput as x, syncOrdinaryInvoiceToAccounting as y };
|
|
2874
|
+
export { PaymentAllocationCollection_exports as A, invoice_accounting_sync_exports as C, syncFrozenInvoiceToAccounting as D, reconcileFrozenInvoiceAccountingSync as E, Payment as F, hasConnectedPaymentAuthority as I, withConnectedPaymentAuthority as L, historicalCreditRefundCommittedTotal as M, PaymentCollection as N, toFrozenInvoiceAccountingInput as O, PaymentCollection_exports as P, calculateInvoiceMinorLine as S, readFrozenAccountingSyncState as T, reconcileOrdinaryCreditAccounting as _, reconcileRetainedBaseInvoice as a, syncOrdinaryRefundToAccounting as b, syncRetainedCreditToAccounting as c, toRetainedCreditAccountingInput as d, toRetainedInvoiceAccountingInput as f, reconcileOrdinaryBaseInvoice as g, reconcileOrdinaryAccountingStep as h, reconcileRetainedAccountingStep as i, PaymentAllocation as j, PaymentAllocationCollection as k, syncRetainedInvoiceToAccounting as l, readOrdinaryInvoiceAccountingState as m, loadRetainedInvoiceAccountingSnapshot as n, reconcileRetainedCreditAccounting as o, loadOrdinaryCreditAccountingSnapshot as p, readRetainedInvoiceAccountingState as r, releaseRetainedInvoiceToAccounting as s, loadRetainedCreditAccountingSnapshot as t, syncRetainedRefundToAccounting as u, syncOrdinaryCreditToAccounting as v, loadFrozenInvoiceAccountingSnapshot as w, toOrdinaryCreditAccountingInput as x, syncOrdinaryInvoiceToAccounting as y };
|
|
2737
2875
|
|
|
2738
|
-
//# sourceMappingURL=retention-accounting-
|
|
2876
|
+
//# sourceMappingURL=retention-accounting-DGuXzt9g.js.map
|