@voyant-travel/finance 0.119.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/LICENSE +201 -0
- package/README.md +192 -0
- package/dist/action-ledger-drift.d.ts +29 -0
- package/dist/action-ledger-drift.d.ts.map +1 -0
- package/dist/action-ledger-drift.js +166 -0
- package/dist/booking-tax.d.ts +124 -0
- package/dist/booking-tax.d.ts.map +1 -0
- package/dist/booking-tax.js +264 -0
- package/dist/checkout-routes.d.ts +1154 -0
- package/dist/checkout-routes.d.ts.map +1 -0
- package/dist/checkout-routes.js +116 -0
- package/dist/checkout-service-plan.d.ts +137 -0
- package/dist/checkout-service-plan.d.ts.map +1 -0
- package/dist/checkout-service-plan.js +119 -0
- package/dist/checkout-service.d.ts +9 -0
- package/dist/checkout-service.d.ts.map +1 -0
- package/dist/checkout-service.js +324 -0
- package/dist/checkout-validation.d.ts +1682 -0
- package/dist/checkout-validation.d.ts.map +1 -0
- package/dist/checkout-validation.js +228 -0
- package/dist/document-download.d.ts +3 -0
- package/dist/document-download.d.ts.map +1 -0
- package/dist/document-download.js +1 -0
- package/dist/fx-money.d.ts +17 -0
- package/dist/fx-money.d.ts.map +1 -0
- package/dist/fx-money.js +194 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/invoice-fx.d.ts +134 -0
- package/dist/invoice-fx.d.ts.map +1 -0
- package/dist/invoice-fx.js +240 -0
- package/dist/invoice-number-errors.d.ts +2 -0
- package/dist/invoice-number-errors.d.ts.map +1 -0
- package/dist/invoice-number-errors.js +58 -0
- package/dist/markets-ref.d.ts +149 -0
- package/dist/markets-ref.d.ts.map +1 -0
- package/dist/markets-ref.js +17 -0
- package/dist/payment-link.d.ts +23 -0
- package/dist/payment-link.d.ts.map +1 -0
- package/dist/payment-link.js +30 -0
- package/dist/payment-policy.d.ts +113 -0
- package/dist/payment-policy.d.ts.map +1 -0
- package/dist/payment-policy.js +193 -0
- package/dist/route-runtime.d.ts +22 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/route-runtime.js +18 -0
- package/dist/routes-action-ledger.d.ts +181 -0
- package/dist/routes-action-ledger.d.ts.map +1 -0
- package/dist/routes-action-ledger.js +142 -0
- package/dist/routes-booking-billing.d.ts +852 -0
- package/dist/routes-booking-billing.d.ts.map +1 -0
- package/dist/routes-booking-billing.js +223 -0
- package/dist/routes-booking-create.d.ts +3 -0
- package/dist/routes-booking-create.d.ts.map +1 -0
- package/dist/routes-booking-create.js +194 -0
- package/dist/routes-booking-reads.d.ts +46 -0
- package/dist/routes-booking-reads.d.ts.map +1 -0
- package/dist/routes-booking-reads.js +20 -0
- package/dist/routes-documents.d.ts +195 -0
- package/dist/routes-documents.d.ts.map +1 -0
- package/dist/routes-documents.js +93 -0
- package/dist/routes-invoice-core.d.ts +794 -0
- package/dist/routes-invoice-core.d.ts.map +1 -0
- package/dist/routes-invoice-core.js +238 -0
- package/dist/routes-invoice-documents.d.ts +401 -0
- package/dist/routes-invoice-documents.d.ts.map +1 -0
- package/dist/routes-invoice-documents.js +91 -0
- package/dist/routes-invoice-issue.d.ts +384 -0
- package/dist/routes-invoice-issue.d.ts.map +1 -0
- package/dist/routes-invoice-issue.js +208 -0
- package/dist/routes-payment-processing.d.ts +1193 -0
- package/dist/routes-payment-processing.d.ts.map +1 -0
- package/dist/routes-payment-processing.js +238 -0
- package/dist/routes-payments.d.ts +309 -0
- package/dist/routes-payments.d.ts.map +1 -0
- package/dist/routes-payments.js +94 -0
- package/dist/routes-public.d.ts +1948 -0
- package/dist/routes-public.d.ts.map +1 -0
- package/dist/routes-public.js +275 -0
- package/dist/routes-reference-data.d.ts +977 -0
- package/dist/routes-reference-data.d.ts.map +1 -0
- package/dist/routes-reference-data.js +191 -0
- package/dist/routes-reports.d.ts +344 -0
- package/dist/routes-reports.d.ts.map +1 -0
- package/dist/routes-reports.js +93 -0
- package/dist/routes-runtime.d.ts +71 -0
- package/dist/routes-runtime.d.ts.map +1 -0
- package/dist/routes-runtime.js +59 -0
- package/dist/routes-settlement.d.ts +67 -0
- package/dist/routes-settlement.d.ts.map +1 -0
- package/dist/routes-settlement.js +23 -0
- package/dist/routes-shared.d.ts +35 -0
- package/dist/routes-shared.d.ts.map +1 -0
- package/dist/routes-shared.js +10 -0
- package/dist/routes-supplier-invoices.d.ts +778 -0
- package/dist/routes-supplier-invoices.d.ts.map +1 -0
- package/dist/routes-supplier-invoices.js +159 -0
- package/dist/routes-vouchers.d.ts +228 -0
- package/dist/routes-vouchers.d.ts.map +1 -0
- package/dist/routes-vouchers.js +54 -0
- package/dist/routes.d.ts +5577 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +44 -0
- package/dist/schema/booking-billing.d.ts +1006 -0
- package/dist/schema/booking-billing.d.ts.map +1 -0
- package/dist/schema/booking-billing.js +106 -0
- package/dist/schema/enums.d.ts +48 -0
- package/dist/schema/enums.d.ts.map +1 -0
- package/dist/schema/enums.js +237 -0
- package/dist/schema/invoice-documents.d.ts +1245 -0
- package/dist/schema/invoice-documents.d.ts.map +1 -0
- package/dist/schema/invoice-documents.js +140 -0
- package/dist/schema/payment-instruments.d.ts +418 -0
- package/dist/schema/payment-instruments.d.ts.map +1 -0
- package/dist/schema/payment-instruments.js +45 -0
- package/dist/schema/payment-processing.d.ts +563 -0
- package/dist/schema/payment-processing.d.ts.map +1 -0
- package/dist/schema/payment-processing.js +65 -0
- package/dist/schema/payment-sessions.d.ts +728 -0
- package/dist/schema/payment-sessions.d.ts.map +1 -0
- package/dist/schema/payment-sessions.js +79 -0
- package/dist/schema/receivables.d.ts +1474 -0
- package/dist/schema/receivables.d.ts.map +1 -0
- package/dist/schema/receivables.js +179 -0
- package/dist/schema/relations.d.ts +82 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/relations.js +144 -0
- package/dist/schema/supplier-invoices.d.ts +1619 -0
- package/dist/schema/supplier-invoices.d.ts.map +1 -0
- package/dist/schema/supplier-invoices.js +228 -0
- package/dist/schema/tax.d.ts +712 -0
- package/dist/schema/tax.d.ts.map +1 -0
- package/dist/schema/tax.js +98 -0
- package/dist/schema/vouchers.d.ts +444 -0
- package/dist/schema/vouchers.d.ts.map +1 -0
- package/dist/schema/vouchers.js +64 -0
- package/dist/schema.d.ts +12 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +11 -0
- package/dist/service-accountant-shares.d.ts +106 -0
- package/dist/service-accountant-shares.d.ts.map +1 -0
- package/dist/service-accountant-shares.js +331 -0
- package/dist/service-action-ledger-accounting.d.ts +104 -0
- package/dist/service-action-ledger-accounting.d.ts.map +1 -0
- package/dist/service-action-ledger-accounting.js +386 -0
- package/dist/service-action-ledger-booking-payments.d.ts +48 -0
- package/dist/service-action-ledger-booking-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-booking-payments.js +178 -0
- package/dist/service-action-ledger-bookings.d.ts +44 -0
- package/dist/service-action-ledger-bookings.d.ts.map +1 -0
- package/dist/service-action-ledger-bookings.js +81 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts +48 -0
- package/dist/service-action-ledger-payment-authorizations.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-authorizations.js +209 -0
- package/dist/service-action-ledger-payment-sessions.d.ts +83 -0
- package/dist/service-action-ledger-payment-sessions.d.ts.map +1 -0
- package/dist/service-action-ledger-payment-sessions.js +294 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts +27 -0
- package/dist/service-action-ledger-supplier-invoices.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-invoices.js +111 -0
- package/dist/service-action-ledger-supplier-payments.d.ts +21 -0
- package/dist/service-action-ledger-supplier-payments.d.ts.map +1 -0
- package/dist/service-action-ledger-supplier-payments.js +97 -0
- package/dist/service-action-ledger.d.ts +7 -0
- package/dist/service-action-ledger.d.ts.map +1 -0
- package/dist/service-action-ledger.js +6 -0
- package/dist/service-aggregates.d.ts +96 -0
- package/dist/service-aggregates.d.ts.map +1 -0
- package/dist/service-aggregates.js +294 -0
- package/dist/service-booking-billing.d.ts +2322 -0
- package/dist/service-booking-billing.d.ts.map +1 -0
- package/dist/service-booking-billing.js +8 -0
- package/dist/service-booking-create.d.ts +410 -0
- package/dist/service-booking-create.d.ts.map +1 -0
- package/dist/service-booking-create.js +1256 -0
- package/dist/service-booking-guarantees.d.ts +725 -0
- package/dist/service-booking-guarantees.d.ts.map +1 -0
- package/dist/service-booking-guarantees.js +153 -0
- package/dist/service-booking-item-billing.d.ts +1062 -0
- package/dist/service-booking-item-billing.d.ts.map +1 -0
- package/dist/service-booking-item-billing.js +77 -0
- package/dist/service-booking-payment-schedules.d.ts +557 -0
- package/dist/service-booking-payment-schedules.d.ts.map +1 -0
- package/dist/service-booking-payment-schedules.js +372 -0
- package/dist/service-bookings-dual-create.d.ts +308 -0
- package/dist/service-bookings-dual-create.d.ts.map +1 -0
- package/dist/service-bookings-dual-create.js +131 -0
- package/dist/service-boundary-sql.d.ts +6 -0
- package/dist/service-boundary-sql.d.ts.map +1 -0
- package/dist/service-boundary-sql.js +15 -0
- package/dist/service-cost-categories.d.ts +26 -0
- package/dist/service-cost-categories.d.ts.map +1 -0
- package/dist/service-cost-categories.js +76 -0
- package/dist/service-documents.d.ts +80 -0
- package/dist/service-documents.d.ts.map +1 -0
- package/dist/service-documents.js +228 -0
- package/dist/service-invoice-artifacts.d.ts +246 -0
- package/dist/service-invoice-artifacts.d.ts.map +1 -0
- package/dist/service-invoice-artifacts.js +277 -0
- package/dist/service-invoice-core.d.ts +405 -0
- package/dist/service-invoice-core.d.ts.map +1 -0
- package/dist/service-invoice-core.js +290 -0
- package/dist/service-invoice-credit-notes.d.ts +973 -0
- package/dist/service-invoice-credit-notes.d.ts.map +1 -0
- package/dist/service-invoice-credit-notes.js +142 -0
- package/dist/service-invoice-from-booking.d.ts +41 -0
- package/dist/service-invoice-from-booking.d.ts.map +1 -0
- package/dist/service-invoice-from-booking.js +267 -0
- package/dist/service-invoice-line-items.d.ts +432 -0
- package/dist/service-invoice-line-items.d.ts.map +1 -0
- package/dist/service-invoice-line-items.js +102 -0
- package/dist/service-invoice-numbering.d.ts +227 -0
- package/dist/service-invoice-numbering.d.ts.map +1 -0
- package/dist/service-invoice-numbering.js +260 -0
- package/dist/service-invoice-payments.d.ts +673 -0
- package/dist/service-invoice-payments.d.ts.map +1 -0
- package/dist/service-invoice-payments.js +398 -0
- package/dist/service-invoices.d.ts +2501 -0
- package/dist/service-invoices.d.ts.map +1 -0
- package/dist/service-invoices.js +12 -0
- package/dist/service-issue.d.ts +207 -0
- package/dist/service-issue.d.ts.map +1 -0
- package/dist/service-issue.js +431 -0
- package/dist/service-payment-authorizations.d.ts +164 -0
- package/dist/service-payment-authorizations.d.ts.map +1 -0
- package/dist/service-payment-authorizations.js +227 -0
- package/dist/service-payment-instruments.d.ts +116 -0
- package/dist/service-payment-instruments.d.ts.map +1 -0
- package/dist/service-payment-instruments.js +99 -0
- package/dist/service-payment-processing.d.ts +676 -0
- package/dist/service-payment-processing.d.ts.map +1 -0
- package/dist/service-payment-processing.js +10 -0
- package/dist/service-payment-session-completion.d.ts +48 -0
- package/dist/service-payment-session-completion.d.ts.map +1 -0
- package/dist/service-payment-session-completion.js +238 -0
- package/dist/service-payment-sessions.d.ts +361 -0
- package/dist/service-payment-sessions.d.ts.map +1 -0
- package/dist/service-payment-sessions.js +280 -0
- package/dist/service-profitability.d.ts +114 -0
- package/dist/service-profitability.d.ts.map +1 -0
- package/dist/service-profitability.js +794 -0
- package/dist/service-public.d.ts +553 -0
- package/dist/service-public.d.ts.map +1 -0
- package/dist/service-public.js +583 -0
- package/dist/service-reference-data.d.ts +272 -0
- package/dist/service-reference-data.d.ts.map +1 -0
- package/dist/service-reference-data.js +280 -0
- package/dist/service-rendition-wait.d.ts +38 -0
- package/dist/service-rendition-wait.d.ts.map +1 -0
- package/dist/service-rendition-wait.js +67 -0
- package/dist/service-reports.d.ts +37 -0
- package/dist/service-reports.d.ts.map +1 -0
- package/dist/service-reports.js +62 -0
- package/dist/service-settlement.d.ts +46 -0
- package/dist/service-settlement.d.ts.map +1 -0
- package/dist/service-settlement.js +185 -0
- package/dist/service-shared.d.ts +541 -0
- package/dist/service-shared.d.ts.map +1 -0
- package/dist/service-shared.js +764 -0
- package/dist/service-supplier-invoices.d.ts +871 -0
- package/dist/service-supplier-invoices.d.ts.map +1 -0
- package/dist/service-supplier-invoices.js +744 -0
- package/dist/service-supplier-payments.d.ts +69 -0
- package/dist/service-supplier-payments.d.ts.map +1 -0
- package/dist/service-supplier-payments.js +136 -0
- package/dist/service-vouchers-migration.d.ts +44 -0
- package/dist/service-vouchers-migration.d.ts.map +1 -0
- package/dist/service-vouchers-migration.js +148 -0
- package/dist/service-vouchers.d.ts +157 -0
- package/dist/service-vouchers.d.ts.map +1 -0
- package/dist/service-vouchers.js +191 -0
- package/dist/service.d.ts +6490 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +29 -0
- package/dist/validation-billing.d.ts +2 -0
- package/dist/validation-billing.d.ts.map +1 -0
- package/dist/validation-billing.js +1 -0
- package/dist/validation-payments.d.ts +2 -0
- package/dist/validation-payments.d.ts.map +1 -0
- package/dist/validation-payments.js +1 -0
- package/dist/validation-public.d.ts +2 -0
- package/dist/validation-public.d.ts.map +1 -0
- package/dist/validation-public.js +1 -0
- package/dist/validation-shared.d.ts +2 -0
- package/dist/validation-shared.d.ts.map +1 -0
- package/dist/validation-shared.js +1 -0
- package/dist/validation-vouchers.d.ts +2 -0
- package/dist/validation-vouchers.d.ts.map +1 -0
- package/dist/validation-vouchers.js +1 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
// agent-quality: file-size exception -- owner: finance; existing service module stays co-located until a dedicated split preserves behavior and tests.
|
|
2
|
+
import { buildIdempotencyFingerprint, } from "@voyant-travel/action-ledger";
|
|
3
|
+
export async function buildRecordPaymentActionLedgerInput(context, input, options = {}) {
|
|
4
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
5
|
+
const idempotency = await buildRecordPaymentIdempotency(input.invoice, input.payment, {
|
|
6
|
+
requestedKey: options.idempotencyKey,
|
|
7
|
+
targetType: target.type,
|
|
8
|
+
targetId: target.id,
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
context,
|
|
12
|
+
actionName: "finance.payment.record",
|
|
13
|
+
actionVersion: "v1",
|
|
14
|
+
actionKind: "create",
|
|
15
|
+
status: "succeeded",
|
|
16
|
+
evaluatedRisk: "high",
|
|
17
|
+
targetType: target.type,
|
|
18
|
+
targetId: target.id,
|
|
19
|
+
routeOrToolName: "finance.payment.record",
|
|
20
|
+
authorizationSource: options.authorizationSource ?? "finance.payment.route",
|
|
21
|
+
idempotencyScope: idempotency.scope,
|
|
22
|
+
idempotencyKey: idempotency.key,
|
|
23
|
+
idempotencyFingerprint: idempotency.fingerprint,
|
|
24
|
+
mutationDetail: {
|
|
25
|
+
commandInputRef: `invoice:${input.invoice.id}:payment`,
|
|
26
|
+
commandResultRef: `payment:${input.payment.id}`,
|
|
27
|
+
summary: `Payment ${input.payment.id} recorded for invoice ${input.invoice.id}`,
|
|
28
|
+
reversalKind: "none",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function buildRecordPaymentIdempotency(invoice, payment, options = {}) {
|
|
33
|
+
const target = getInvoiceLedgerTarget(invoice);
|
|
34
|
+
const targetType = options.targetType ?? target.type;
|
|
35
|
+
const targetId = options.targetId ?? target.id;
|
|
36
|
+
const naturalCommandInput = {
|
|
37
|
+
invoiceId: invoice.id,
|
|
38
|
+
amountCents: payment.amountCents,
|
|
39
|
+
currency: payment.currency,
|
|
40
|
+
baseCurrency: payment.baseCurrency ?? null,
|
|
41
|
+
baseAmountCents: payment.baseAmountCents ?? null,
|
|
42
|
+
fxRateSetId: payment.fxRateSetId ?? null,
|
|
43
|
+
paymentMethod: payment.paymentMethod,
|
|
44
|
+
paymentInstrumentId: normalizeLedgerIdempotencyString(payment.paymentInstrumentId),
|
|
45
|
+
paymentAuthorizationId: normalizeLedgerIdempotencyString(payment.paymentAuthorizationId),
|
|
46
|
+
paymentCaptureId: normalizeLedgerIdempotencyString(payment.paymentCaptureId),
|
|
47
|
+
status: payment.status,
|
|
48
|
+
referenceNumber: normalizeLedgerIdempotencyString(payment.referenceNumber),
|
|
49
|
+
paymentDate: payment.paymentDate,
|
|
50
|
+
};
|
|
51
|
+
const requestedKey = normalizeLedgerIdempotencyString(options.requestedKey);
|
|
52
|
+
const naturalKey = normalizeLedgerIdempotencyString(payment.referenceNumber) ??
|
|
53
|
+
normalizeLedgerIdempotencyString(payment.paymentCaptureId) ??
|
|
54
|
+
normalizeLedgerIdempotencyString(payment.paymentAuthorizationId) ??
|
|
55
|
+
(await buildIdempotencyFingerprint({
|
|
56
|
+
actionName: "finance.payment.record",
|
|
57
|
+
actionVersion: "v1",
|
|
58
|
+
targetType,
|
|
59
|
+
targetId,
|
|
60
|
+
commandInput: naturalCommandInput,
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
scope: `finance.invoice:${invoice.id}:payment`,
|
|
64
|
+
key: requestedKey ?? naturalKey,
|
|
65
|
+
fingerprint: await buildIdempotencyFingerprint({
|
|
66
|
+
actionName: "finance.payment.record",
|
|
67
|
+
actionVersion: "v1",
|
|
68
|
+
targetType,
|
|
69
|
+
targetId,
|
|
70
|
+
commandInput: naturalCommandInput,
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function normalizeLedgerIdempotencyString(value) {
|
|
75
|
+
const trimmed = value?.trim();
|
|
76
|
+
return trimmed ? trimmed : null;
|
|
77
|
+
}
|
|
78
|
+
export function buildPaymentUpdateActionLedgerInput(context, input, options = {}) {
|
|
79
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
80
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
81
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
82
|
+
return {
|
|
83
|
+
context,
|
|
84
|
+
actionName: "finance.payment.update",
|
|
85
|
+
actionVersion: "v1",
|
|
86
|
+
actionKind: "update",
|
|
87
|
+
status: "succeeded",
|
|
88
|
+
evaluatedRisk: "high",
|
|
89
|
+
targetType: target.type,
|
|
90
|
+
targetId: target.id,
|
|
91
|
+
routeOrToolName: "finance.payment.update",
|
|
92
|
+
authorizationSource: options.authorizationSource ?? "finance.payment.route",
|
|
93
|
+
idempotencyScope: null,
|
|
94
|
+
idempotencyKey: null,
|
|
95
|
+
idempotencyFingerprint: null,
|
|
96
|
+
mutationDetail: {
|
|
97
|
+
commandInputRef: `payment:${input.payment.id}:update`,
|
|
98
|
+
commandResultRef: `payment:${input.payment.id}`,
|
|
99
|
+
summary: `Payment ${input.payment.id} updated (${changeSummary})`,
|
|
100
|
+
reversalKind: "none",
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function buildPaymentDeleteActionLedgerInput(context, input, options = {}) {
|
|
105
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
106
|
+
return {
|
|
107
|
+
context,
|
|
108
|
+
actionName: "finance.payment.delete",
|
|
109
|
+
actionVersion: "v1",
|
|
110
|
+
actionKind: "delete",
|
|
111
|
+
status: "succeeded",
|
|
112
|
+
evaluatedRisk: "high",
|
|
113
|
+
targetType: target.type,
|
|
114
|
+
targetId: target.id,
|
|
115
|
+
routeOrToolName: "finance.payment.delete",
|
|
116
|
+
authorizationSource: options.authorizationSource ?? "finance.payment.route",
|
|
117
|
+
idempotencyScope: null,
|
|
118
|
+
idempotencyKey: null,
|
|
119
|
+
idempotencyFingerprint: null,
|
|
120
|
+
mutationDetail: {
|
|
121
|
+
commandInputRef: `payment:${input.payment.id}:delete`,
|
|
122
|
+
commandResultRef: null,
|
|
123
|
+
summary: `Payment ${input.payment.id} deleted from invoice ${input.invoice.invoiceNumber}`,
|
|
124
|
+
reversalKind: "none",
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function getInvoiceLedgerTarget(invoice) {
|
|
129
|
+
if (invoice.bookingId)
|
|
130
|
+
return { type: "booking", id: invoice.bookingId };
|
|
131
|
+
return { type: "invoice", id: invoice.id };
|
|
132
|
+
}
|
|
133
|
+
export async function buildInvoiceIssuedActionLedgerInput(context, input, options = {}) {
|
|
134
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
135
|
+
const invoiceTypeLabel = input.invoice.invoiceType === "proforma" ? "Proforma" : "Invoice";
|
|
136
|
+
return {
|
|
137
|
+
context,
|
|
138
|
+
actionName: "finance.invoice.issue_from_booking",
|
|
139
|
+
actionVersion: "v1",
|
|
140
|
+
actionKind: "create",
|
|
141
|
+
status: "succeeded",
|
|
142
|
+
evaluatedRisk: "high",
|
|
143
|
+
targetType: target.type,
|
|
144
|
+
targetId: target.id,
|
|
145
|
+
routeOrToolName: "finance.invoice.issue_from_booking",
|
|
146
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice.from_booking.route",
|
|
147
|
+
idempotencyScope: `finance.booking:${input.invoice.bookingId}:invoice_issue`,
|
|
148
|
+
idempotencyKey: input.invoice.invoiceNumber,
|
|
149
|
+
idempotencyFingerprint: await buildIdempotencyFingerprint({
|
|
150
|
+
actionName: "finance.invoice.issue_from_booking",
|
|
151
|
+
actionVersion: "v1",
|
|
152
|
+
targetType: target.type,
|
|
153
|
+
targetId: target.id,
|
|
154
|
+
commandInput: {
|
|
155
|
+
invoiceId: input.invoice.id,
|
|
156
|
+
invoiceNumber: input.invoice.invoiceNumber,
|
|
157
|
+
invoiceType: input.invoice.invoiceType,
|
|
158
|
+
bookingId: input.invoice.bookingId,
|
|
159
|
+
totalCents: input.invoice.totalCents,
|
|
160
|
+
currency: input.invoice.currency,
|
|
161
|
+
status: input.invoice.status,
|
|
162
|
+
issueDate: input.invoice.issueDate,
|
|
163
|
+
dueDate: input.invoice.dueDate,
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
mutationDetail: {
|
|
167
|
+
commandInputRef: `booking:${input.invoice.bookingId}:invoice_issue`,
|
|
168
|
+
commandResultRef: `invoice:${input.invoice.id}`,
|
|
169
|
+
summary: `${invoiceTypeLabel} ${input.invoice.invoiceNumber} issued for booking ${input.invoice.bookingId}`,
|
|
170
|
+
reversalKind: "none",
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function buildInvoiceUpdateActionLedgerInput(context, input, options = {}) {
|
|
175
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
176
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
177
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
178
|
+
return {
|
|
179
|
+
context,
|
|
180
|
+
actionName: "finance.invoice.update",
|
|
181
|
+
actionVersion: "v1",
|
|
182
|
+
actionKind: "update",
|
|
183
|
+
status: "succeeded",
|
|
184
|
+
evaluatedRisk: "high",
|
|
185
|
+
targetType: target.type,
|
|
186
|
+
targetId: target.id,
|
|
187
|
+
routeOrToolName: "finance.invoice.update",
|
|
188
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice.route",
|
|
189
|
+
idempotencyScope: null,
|
|
190
|
+
idempotencyKey: null,
|
|
191
|
+
idempotencyFingerprint: null,
|
|
192
|
+
mutationDetail: {
|
|
193
|
+
commandInputRef: `invoice:${input.invoice.id}:update`,
|
|
194
|
+
commandResultRef: `invoice:${input.invoice.id}`,
|
|
195
|
+
summary: `Invoice ${input.invoice.invoiceNumber} updated (${changeSummary})`,
|
|
196
|
+
reversalKind: "none",
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export function buildInvoiceDeleteActionLedgerInput(context, input, options = {}) {
|
|
201
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
202
|
+
return {
|
|
203
|
+
context,
|
|
204
|
+
actionName: "finance.invoice.delete",
|
|
205
|
+
actionVersion: "v1",
|
|
206
|
+
actionKind: "delete",
|
|
207
|
+
status: "succeeded",
|
|
208
|
+
evaluatedRisk: "high",
|
|
209
|
+
targetType: target.type,
|
|
210
|
+
targetId: target.id,
|
|
211
|
+
routeOrToolName: "finance.invoice.delete",
|
|
212
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice.route",
|
|
213
|
+
idempotencyScope: null,
|
|
214
|
+
idempotencyKey: null,
|
|
215
|
+
idempotencyFingerprint: null,
|
|
216
|
+
mutationDetail: {
|
|
217
|
+
commandInputRef: `invoice:${input.invoice.id}:delete`,
|
|
218
|
+
commandResultRef: null,
|
|
219
|
+
summary: `Draft invoice ${input.invoice.invoiceNumber} deleted`,
|
|
220
|
+
reversalKind: "none",
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function buildInvoiceLineItemCreateActionLedgerInput(context, input, options = {}) {
|
|
225
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
226
|
+
return {
|
|
227
|
+
context,
|
|
228
|
+
actionName: "finance.invoice_line_item.create",
|
|
229
|
+
actionVersion: "v1",
|
|
230
|
+
actionKind: "create",
|
|
231
|
+
status: "succeeded",
|
|
232
|
+
evaluatedRisk: "high",
|
|
233
|
+
targetType: target.type,
|
|
234
|
+
targetId: target.id,
|
|
235
|
+
routeOrToolName: "finance.invoice_line_item.create",
|
|
236
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice_line_item.route",
|
|
237
|
+
idempotencyScope: null,
|
|
238
|
+
idempotencyKey: null,
|
|
239
|
+
idempotencyFingerprint: null,
|
|
240
|
+
mutationDetail: {
|
|
241
|
+
commandInputRef: `invoice:${input.invoice.id}:line_item`,
|
|
242
|
+
commandResultRef: `invoice_line_item:${input.lineItem.id}`,
|
|
243
|
+
summary: `Line item ${input.lineItem.id} added to invoice ${input.invoice.invoiceNumber}`,
|
|
244
|
+
reversalKind: "none",
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
export function buildInvoiceLineItemUpdateActionLedgerInput(context, input, options = {}) {
|
|
249
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
250
|
+
const changedFields = Object.keys(input.changes ?? {}).sort();
|
|
251
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
252
|
+
return {
|
|
253
|
+
context,
|
|
254
|
+
actionName: "finance.invoice_line_item.update",
|
|
255
|
+
actionVersion: "v1",
|
|
256
|
+
actionKind: "update",
|
|
257
|
+
status: "succeeded",
|
|
258
|
+
evaluatedRisk: "high",
|
|
259
|
+
targetType: target.type,
|
|
260
|
+
targetId: target.id,
|
|
261
|
+
routeOrToolName: "finance.invoice_line_item.update",
|
|
262
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice_line_item.route",
|
|
263
|
+
idempotencyScope: null,
|
|
264
|
+
idempotencyKey: null,
|
|
265
|
+
idempotencyFingerprint: null,
|
|
266
|
+
mutationDetail: {
|
|
267
|
+
commandInputRef: `invoice_line_item:${input.lineItem.id}:update`,
|
|
268
|
+
commandResultRef: `invoice_line_item:${input.lineItem.id}`,
|
|
269
|
+
summary: `Line item ${input.lineItem.id} updated (${changeSummary})`,
|
|
270
|
+
reversalKind: "none",
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export function buildInvoiceLineItemDeleteActionLedgerInput(context, input, options = {}) {
|
|
275
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
276
|
+
return {
|
|
277
|
+
context,
|
|
278
|
+
actionName: "finance.invoice_line_item.delete",
|
|
279
|
+
actionVersion: "v1",
|
|
280
|
+
actionKind: "delete",
|
|
281
|
+
status: "succeeded",
|
|
282
|
+
evaluatedRisk: "high",
|
|
283
|
+
targetType: target.type,
|
|
284
|
+
targetId: target.id,
|
|
285
|
+
routeOrToolName: "finance.invoice_line_item.delete",
|
|
286
|
+
authorizationSource: options.authorizationSource ?? "finance.invoice_line_item.route",
|
|
287
|
+
idempotencyScope: null,
|
|
288
|
+
idempotencyKey: null,
|
|
289
|
+
idempotencyFingerprint: null,
|
|
290
|
+
mutationDetail: {
|
|
291
|
+
commandInputRef: `invoice_line_item:${input.lineItem.id}:delete`,
|
|
292
|
+
commandResultRef: null,
|
|
293
|
+
summary: `Line item ${input.lineItem.id} deleted from invoice ${input.invoice.invoiceNumber}`,
|
|
294
|
+
reversalKind: "none",
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
export async function buildCreditNoteCreationActionLedgerInput(context, input, options = {}) {
|
|
299
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
300
|
+
const idempotencyKey = input.creditNote.creditNoteNumber;
|
|
301
|
+
return {
|
|
302
|
+
context,
|
|
303
|
+
actionName: "finance.credit_note.create",
|
|
304
|
+
actionVersion: "v1",
|
|
305
|
+
actionKind: "create",
|
|
306
|
+
status: "succeeded",
|
|
307
|
+
evaluatedRisk: "high",
|
|
308
|
+
targetType: target.type,
|
|
309
|
+
targetId: target.id,
|
|
310
|
+
routeOrToolName: "finance.credit_note.create",
|
|
311
|
+
authorizationSource: options.authorizationSource ?? "finance.credit_note.route",
|
|
312
|
+
idempotencyScope: `finance.invoice:${input.invoice.id}:credit_note`,
|
|
313
|
+
idempotencyKey,
|
|
314
|
+
idempotencyFingerprint: await buildIdempotencyFingerprint({
|
|
315
|
+
actionName: "finance.credit_note.create",
|
|
316
|
+
actionVersion: "v1",
|
|
317
|
+
targetType: target.type,
|
|
318
|
+
targetId: target.id,
|
|
319
|
+
commandInput: {
|
|
320
|
+
invoiceId: input.invoice.id,
|
|
321
|
+
creditNoteId: input.creditNote.id,
|
|
322
|
+
creditNoteNumber: input.creditNote.creditNoteNumber,
|
|
323
|
+
amountCents: input.creditNote.amountCents,
|
|
324
|
+
currency: input.creditNote.currency,
|
|
325
|
+
status: input.creditNote.status,
|
|
326
|
+
reason: input.creditNote.reason,
|
|
327
|
+
},
|
|
328
|
+
}),
|
|
329
|
+
mutationDetail: {
|
|
330
|
+
commandInputRef: `invoice:${input.invoice.id}:credit_note`,
|
|
331
|
+
commandResultRef: `credit_note:${input.creditNote.id}`,
|
|
332
|
+
summary: `Credit note ${input.creditNote.creditNoteNumber} created for invoice ${input.invoice.id}`,
|
|
333
|
+
reversalKind: "none",
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
export function buildCreditNoteUpdateActionLedgerInput(context, input, options = {}) {
|
|
338
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
339
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
340
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
341
|
+
return {
|
|
342
|
+
context,
|
|
343
|
+
actionName: "finance.credit_note.update",
|
|
344
|
+
actionVersion: "v1",
|
|
345
|
+
actionKind: "update",
|
|
346
|
+
status: "succeeded",
|
|
347
|
+
evaluatedRisk: "high",
|
|
348
|
+
targetType: target.type,
|
|
349
|
+
targetId: target.id,
|
|
350
|
+
routeOrToolName: "finance.credit_note.update",
|
|
351
|
+
authorizationSource: options.authorizationSource ?? "finance.credit_note.route",
|
|
352
|
+
idempotencyScope: null,
|
|
353
|
+
idempotencyKey: null,
|
|
354
|
+
idempotencyFingerprint: null,
|
|
355
|
+
mutationDetail: {
|
|
356
|
+
commandInputRef: `credit_note:${input.creditNote.id}:update`,
|
|
357
|
+
commandResultRef: `credit_note:${input.creditNote.id}`,
|
|
358
|
+
summary: `Credit note ${input.creditNote.creditNoteNumber} updated (${changeSummary})`,
|
|
359
|
+
reversalKind: "none",
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
export function buildCreditNoteLineItemCreateActionLedgerInput(context, input, options = {}) {
|
|
364
|
+
const target = getInvoiceLedgerTarget(input.invoice);
|
|
365
|
+
return {
|
|
366
|
+
context,
|
|
367
|
+
actionName: "finance.credit_note_line_item.create",
|
|
368
|
+
actionVersion: "v1",
|
|
369
|
+
actionKind: "create",
|
|
370
|
+
status: "succeeded",
|
|
371
|
+
evaluatedRisk: "high",
|
|
372
|
+
targetType: target.type,
|
|
373
|
+
targetId: target.id,
|
|
374
|
+
routeOrToolName: "finance.credit_note_line_item.create",
|
|
375
|
+
authorizationSource: options.authorizationSource ?? "finance.credit_note_line_item.route",
|
|
376
|
+
idempotencyScope: null,
|
|
377
|
+
idempotencyKey: null,
|
|
378
|
+
idempotencyFingerprint: null,
|
|
379
|
+
mutationDetail: {
|
|
380
|
+
commandInputRef: `credit_note:${input.creditNote.id}:line_item`,
|
|
381
|
+
commandResultRef: `credit_note_line_item:${input.lineItem.id}`,
|
|
382
|
+
summary: `Line item ${input.lineItem.id} added to credit note ${input.creditNote.creditNoteNumber}`,
|
|
383
|
+
reversalKind: "none",
|
|
384
|
+
},
|
|
385
|
+
};
|
|
386
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ActionLedgerRequestContextValues, type BuildActionLedgerMutationInput } from "@voyant-travel/action-ledger";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { bookingGuarantees, bookingPaymentSchedules } from "./schema.js";
|
|
4
|
+
import type { updateBookingGuaranteeSchema, updateBookingPaymentScheduleSchema } from "./validation.js";
|
|
5
|
+
type UpdateBookingPaymentScheduleInput = z.infer<typeof updateBookingPaymentScheduleSchema>;
|
|
6
|
+
type UpdateBookingGuaranteeInput = z.infer<typeof updateBookingGuaranteeSchema>;
|
|
7
|
+
type BookingPaymentScheduleRecord = typeof bookingPaymentSchedules.$inferSelect;
|
|
8
|
+
type BookingGuaranteeRecord = typeof bookingGuarantees.$inferSelect;
|
|
9
|
+
type BookingPaymentScheduleCreateLedgerInput = {
|
|
10
|
+
schedule: BookingPaymentScheduleRecord;
|
|
11
|
+
};
|
|
12
|
+
type BookingPaymentScheduleUpdateLedgerInput = {
|
|
13
|
+
schedule: BookingPaymentScheduleRecord;
|
|
14
|
+
changes: UpdateBookingPaymentScheduleInput;
|
|
15
|
+
};
|
|
16
|
+
type BookingPaymentScheduleDeleteLedgerInput = {
|
|
17
|
+
schedule: BookingPaymentScheduleRecord;
|
|
18
|
+
};
|
|
19
|
+
type BookingGuaranteeCreateLedgerInput = {
|
|
20
|
+
guarantee: BookingGuaranteeRecord;
|
|
21
|
+
};
|
|
22
|
+
type BookingGuaranteeUpdateLedgerInput = {
|
|
23
|
+
guarantee: BookingGuaranteeRecord;
|
|
24
|
+
changes: UpdateBookingGuaranteeInput;
|
|
25
|
+
};
|
|
26
|
+
type BookingGuaranteeDeleteLedgerInput = {
|
|
27
|
+
guarantee: BookingGuaranteeRecord;
|
|
28
|
+
};
|
|
29
|
+
export declare function buildBookingPaymentScheduleCreateActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingPaymentScheduleCreateLedgerInput, options?: {
|
|
30
|
+
authorizationSource?: string | null;
|
|
31
|
+
}): BuildActionLedgerMutationInput;
|
|
32
|
+
export declare function buildBookingPaymentScheduleUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingPaymentScheduleUpdateLedgerInput, options?: {
|
|
33
|
+
authorizationSource?: string | null;
|
|
34
|
+
}): BuildActionLedgerMutationInput;
|
|
35
|
+
export declare function buildBookingPaymentScheduleDeleteActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingPaymentScheduleDeleteLedgerInput, options?: {
|
|
36
|
+
authorizationSource?: string | null;
|
|
37
|
+
}): BuildActionLedgerMutationInput;
|
|
38
|
+
export declare function buildBookingGuaranteeCreateActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingGuaranteeCreateLedgerInput, options?: {
|
|
39
|
+
authorizationSource?: string | null;
|
|
40
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
41
|
+
export declare function buildBookingGuaranteeUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingGuaranteeUpdateLedgerInput, options?: {
|
|
42
|
+
authorizationSource?: string | null;
|
|
43
|
+
}): BuildActionLedgerMutationInput;
|
|
44
|
+
export declare function buildBookingGuaranteeDeleteActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingGuaranteeDeleteLedgerInput, options?: {
|
|
45
|
+
authorizationSource?: string | null;
|
|
46
|
+
}): BuildActionLedgerMutationInput;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=service-action-ledger-booking-payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-action-ledger-booking-payments.d.ts","sourceRoot":"","sources":["../src/service-action-ledger-booking-payments.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EAEpC,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EACV,4BAA4B,EAC5B,kCAAkC,EACnC,MAAM,iBAAiB,CAAA;AAExB,KAAK,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAC3F,KAAK,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAE/E,KAAK,4BAA4B,GAAG,OAAO,uBAAuB,CAAC,YAAY,CAAA;AAC/E,KAAK,sBAAsB,GAAG,OAAO,iBAAiB,CAAC,YAAY,CAAA;AAEnE,KAAK,uCAAuC,GAAG;IAC7C,QAAQ,EAAE,4BAA4B,CAAA;CACvC,CAAA;AACD,KAAK,uCAAuC,GAAG;IAC7C,QAAQ,EAAE,4BAA4B,CAAA;IACtC,OAAO,EAAE,iCAAiC,CAAA;CAC3C,CAAA;AACD,KAAK,uCAAuC,GAAG;IAC7C,QAAQ,EAAE,4BAA4B,CAAA;CACvC,CAAA;AACD,KAAK,iCAAiC,GAAG;IACvC,SAAS,EAAE,sBAAsB,CAAA;CAClC,CAAA;AACD,KAAK,iCAAiC,GAAG;IACvC,SAAS,EAAE,sBAAsB,CAAA;IACjC,OAAO,EAAE,2BAA2B,CAAA;CACrC,CAAA;AACD,KAAK,iCAAiC,GAAG;IACvC,SAAS,EAAE,sBAAsB,CAAA;CAClC,CAAA;AAED,wBAAgB,kDAAkD,CAChE,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,uCAAuC,EAC9C,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CAwBhC;AAED,wBAAgB,kDAAkD,CAChE,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,uCAAuC,EAC9C,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CA0BhC;AAED,wBAAgB,kDAAkD,CAChE,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,uCAAuC,EAC9C,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CAwBhC;AAMD,wBAAsB,4CAA4C,CAChE,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,iCAAiC,EACxC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,OAAO,CAAC,8BAA8B,CAAC,CA+CzC;AAED,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,iCAAiC,EACxC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CA0BhC;AAED,wBAAgB,4CAA4C,CAC1D,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,iCAAiC,EACxC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,8BAA8B,CAwBhC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { buildIdempotencyFingerprint, } from "@voyant-travel/action-ledger";
|
|
2
|
+
export function buildBookingPaymentScheduleCreateActionLedgerInput(context, input, options = {}) {
|
|
3
|
+
const target = getBookingPaymentScheduleLedgerTarget(input.schedule);
|
|
4
|
+
return {
|
|
5
|
+
context,
|
|
6
|
+
actionName: "finance.booking_payment_schedule.create",
|
|
7
|
+
actionVersion: "v1",
|
|
8
|
+
actionKind: "create",
|
|
9
|
+
status: "succeeded",
|
|
10
|
+
evaluatedRisk: "high",
|
|
11
|
+
targetType: target.type,
|
|
12
|
+
targetId: target.id,
|
|
13
|
+
routeOrToolName: "finance.booking_payment_schedule.create",
|
|
14
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_payment_schedule.route",
|
|
15
|
+
idempotencyScope: null,
|
|
16
|
+
idempotencyKey: null,
|
|
17
|
+
idempotencyFingerprint: null,
|
|
18
|
+
mutationDetail: {
|
|
19
|
+
commandInputRef: `booking:${input.schedule.bookingId}:payment_schedule`,
|
|
20
|
+
commandResultRef: `booking_payment_schedule:${input.schedule.id}`,
|
|
21
|
+
summary: `Payment schedule ${input.schedule.id} created for booking ${input.schedule.bookingId}`,
|
|
22
|
+
reversalKind: "none",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function buildBookingPaymentScheduleUpdateActionLedgerInput(context, input, options = {}) {
|
|
27
|
+
const target = getBookingPaymentScheduleLedgerTarget(input.schedule);
|
|
28
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
29
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
30
|
+
return {
|
|
31
|
+
context,
|
|
32
|
+
actionName: "finance.booking_payment_schedule.update",
|
|
33
|
+
actionVersion: "v1",
|
|
34
|
+
actionKind: "update",
|
|
35
|
+
status: "succeeded",
|
|
36
|
+
evaluatedRisk: "high",
|
|
37
|
+
targetType: target.type,
|
|
38
|
+
targetId: target.id,
|
|
39
|
+
routeOrToolName: "finance.booking_payment_schedule.update",
|
|
40
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_payment_schedule.route",
|
|
41
|
+
idempotencyScope: null,
|
|
42
|
+
idempotencyKey: null,
|
|
43
|
+
idempotencyFingerprint: null,
|
|
44
|
+
mutationDetail: {
|
|
45
|
+
commandInputRef: `booking_payment_schedule:${input.schedule.id}:update`,
|
|
46
|
+
commandResultRef: `booking_payment_schedule:${input.schedule.id}`,
|
|
47
|
+
summary: `Payment schedule ${input.schedule.id} updated (${changeSummary})`,
|
|
48
|
+
reversalKind: "none",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function buildBookingPaymentScheduleDeleteActionLedgerInput(context, input, options = {}) {
|
|
53
|
+
const target = getBookingPaymentScheduleLedgerTarget(input.schedule);
|
|
54
|
+
return {
|
|
55
|
+
context,
|
|
56
|
+
actionName: "finance.booking_payment_schedule.delete",
|
|
57
|
+
actionVersion: "v1",
|
|
58
|
+
actionKind: "delete",
|
|
59
|
+
status: "succeeded",
|
|
60
|
+
evaluatedRisk: "high",
|
|
61
|
+
targetType: target.type,
|
|
62
|
+
targetId: target.id,
|
|
63
|
+
routeOrToolName: "finance.booking_payment_schedule.delete",
|
|
64
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_payment_schedule.route",
|
|
65
|
+
idempotencyScope: null,
|
|
66
|
+
idempotencyKey: null,
|
|
67
|
+
idempotencyFingerprint: null,
|
|
68
|
+
mutationDetail: {
|
|
69
|
+
commandInputRef: `booking_payment_schedule:${input.schedule.id}:delete`,
|
|
70
|
+
commandResultRef: null,
|
|
71
|
+
summary: `Payment schedule ${input.schedule.id} deleted`,
|
|
72
|
+
reversalKind: "none",
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function getBookingPaymentScheduleLedgerTarget(schedule) {
|
|
77
|
+
return { type: "booking", id: schedule.bookingId };
|
|
78
|
+
}
|
|
79
|
+
export async function buildBookingGuaranteeCreateActionLedgerInput(context, input, options = {}) {
|
|
80
|
+
const target = getBookingGuaranteeLedgerTarget(input.guarantee);
|
|
81
|
+
const idempotencyKey = input.guarantee.referenceNumber;
|
|
82
|
+
return {
|
|
83
|
+
context,
|
|
84
|
+
actionName: "finance.booking_guarantee.create",
|
|
85
|
+
actionVersion: "v1",
|
|
86
|
+
actionKind: "create",
|
|
87
|
+
status: "succeeded",
|
|
88
|
+
evaluatedRisk: "high",
|
|
89
|
+
targetType: target.type,
|
|
90
|
+
targetId: target.id,
|
|
91
|
+
routeOrToolName: "finance.booking_guarantee.create",
|
|
92
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_guarantee.route",
|
|
93
|
+
idempotencyScope: idempotencyKey
|
|
94
|
+
? `finance.booking:${input.guarantee.bookingId}:guarantee`
|
|
95
|
+
: null,
|
|
96
|
+
idempotencyKey,
|
|
97
|
+
idempotencyFingerprint: idempotencyKey
|
|
98
|
+
? await buildIdempotencyFingerprint({
|
|
99
|
+
actionName: "finance.booking_guarantee.create",
|
|
100
|
+
actionVersion: "v1",
|
|
101
|
+
targetType: target.type,
|
|
102
|
+
targetId: target.id,
|
|
103
|
+
commandInput: {
|
|
104
|
+
bookingGuaranteeId: input.guarantee.id,
|
|
105
|
+
bookingId: input.guarantee.bookingId,
|
|
106
|
+
bookingPaymentScheduleId: input.guarantee.bookingPaymentScheduleId,
|
|
107
|
+
guaranteeType: input.guarantee.guaranteeType,
|
|
108
|
+
status: input.guarantee.status,
|
|
109
|
+
paymentInstrumentId: input.guarantee.paymentInstrumentId,
|
|
110
|
+
paymentAuthorizationId: input.guarantee.paymentAuthorizationId,
|
|
111
|
+
currency: input.guarantee.currency,
|
|
112
|
+
amountCents: input.guarantee.amountCents,
|
|
113
|
+
provider: input.guarantee.provider,
|
|
114
|
+
referenceNumber: input.guarantee.referenceNumber,
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
: null,
|
|
118
|
+
mutationDetail: {
|
|
119
|
+
commandInputRef: `booking:${input.guarantee.bookingId}:guarantee`,
|
|
120
|
+
commandResultRef: `booking_guarantee:${input.guarantee.id}`,
|
|
121
|
+
summary: `Booking guarantee ${input.guarantee.id} created for booking ${input.guarantee.bookingId}`,
|
|
122
|
+
reversalKind: "none",
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export function buildBookingGuaranteeUpdateActionLedgerInput(context, input, options = {}) {
|
|
127
|
+
const target = getBookingGuaranteeLedgerTarget(input.guarantee);
|
|
128
|
+
const changedFields = Object.keys(input.changes).sort();
|
|
129
|
+
const changeSummary = changedFields.length > 0 ? changedFields.join(", ") : "no fields";
|
|
130
|
+
return {
|
|
131
|
+
context,
|
|
132
|
+
actionName: "finance.booking_guarantee.update",
|
|
133
|
+
actionVersion: "v1",
|
|
134
|
+
actionKind: "update",
|
|
135
|
+
status: "succeeded",
|
|
136
|
+
evaluatedRisk: "high",
|
|
137
|
+
targetType: target.type,
|
|
138
|
+
targetId: target.id,
|
|
139
|
+
routeOrToolName: "finance.booking_guarantee.update",
|
|
140
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_guarantee.route",
|
|
141
|
+
idempotencyScope: null,
|
|
142
|
+
idempotencyKey: null,
|
|
143
|
+
idempotencyFingerprint: null,
|
|
144
|
+
mutationDetail: {
|
|
145
|
+
commandInputRef: `booking_guarantee:${input.guarantee.id}:update`,
|
|
146
|
+
commandResultRef: `booking_guarantee:${input.guarantee.id}`,
|
|
147
|
+
summary: `Booking guarantee ${input.guarantee.id} updated (${changeSummary})`,
|
|
148
|
+
reversalKind: "none",
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export function buildBookingGuaranteeDeleteActionLedgerInput(context, input, options = {}) {
|
|
153
|
+
const target = getBookingGuaranteeLedgerTarget(input.guarantee);
|
|
154
|
+
return {
|
|
155
|
+
context,
|
|
156
|
+
actionName: "finance.booking_guarantee.delete",
|
|
157
|
+
actionVersion: "v1",
|
|
158
|
+
actionKind: "delete",
|
|
159
|
+
status: "succeeded",
|
|
160
|
+
evaluatedRisk: "high",
|
|
161
|
+
targetType: target.type,
|
|
162
|
+
targetId: target.id,
|
|
163
|
+
routeOrToolName: "finance.booking_guarantee.delete",
|
|
164
|
+
authorizationSource: options.authorizationSource ?? "finance.booking_guarantee.route",
|
|
165
|
+
idempotencyScope: null,
|
|
166
|
+
idempotencyKey: null,
|
|
167
|
+
idempotencyFingerprint: null,
|
|
168
|
+
mutationDetail: {
|
|
169
|
+
commandInputRef: `booking_guarantee:${input.guarantee.id}:delete`,
|
|
170
|
+
commandResultRef: null,
|
|
171
|
+
summary: `Booking guarantee ${input.guarantee.id} deleted`,
|
|
172
|
+
reversalKind: "none",
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function getBookingGuaranteeLedgerTarget(guarantee) {
|
|
177
|
+
return { type: "booking", id: guarantee.bookingId };
|
|
178
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ActionLedgerRequestContextValues, type BuildActionLedgerMutationInput } from "@voyant-travel/action-ledger";
|
|
2
|
+
import type { Booking } from "@voyant-travel/bookings/schema";
|
|
3
|
+
type BookingCreateLedgerCommand = {
|
|
4
|
+
productId: string;
|
|
5
|
+
optionId?: string | null;
|
|
6
|
+
slotId?: string | null;
|
|
7
|
+
bookingNumber: string;
|
|
8
|
+
personId?: string | null;
|
|
9
|
+
organizationId?: string | null;
|
|
10
|
+
pax?: number | null;
|
|
11
|
+
itemLineCount?: number;
|
|
12
|
+
extraLineCount?: number;
|
|
13
|
+
travelerCount?: number;
|
|
14
|
+
paymentScheduleCount?: number;
|
|
15
|
+
voucherRedemptionRequested?: boolean;
|
|
16
|
+
groupMembershipAction?: "join" | "create" | null;
|
|
17
|
+
initialStatus?: string | null;
|
|
18
|
+
documentGeneration?: {
|
|
19
|
+
contractDocument: boolean;
|
|
20
|
+
invoiceDocument: boolean;
|
|
21
|
+
invoiceType: "invoice" | "proforma";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type BookingCreateSucceededLedgerInput = {
|
|
25
|
+
booking: Booking;
|
|
26
|
+
command: BookingCreateLedgerCommand;
|
|
27
|
+
};
|
|
28
|
+
type BookingCreateRejectedLedgerInput = {
|
|
29
|
+
existingBooking: {
|
|
30
|
+
id: string;
|
|
31
|
+
bookingNumber: string;
|
|
32
|
+
status: string;
|
|
33
|
+
};
|
|
34
|
+
command: BookingCreateLedgerCommand;
|
|
35
|
+
reason: "duplicate_booking";
|
|
36
|
+
};
|
|
37
|
+
export declare function buildBookingCreateSucceededActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingCreateSucceededLedgerInput, options?: {
|
|
38
|
+
authorizationSource?: string | null;
|
|
39
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
40
|
+
export declare function buildBookingCreateRejectedActionLedgerInput(context: ActionLedgerRequestContextValues, input: BookingCreateRejectedLedgerInput, options?: {
|
|
41
|
+
authorizationSource?: string | null;
|
|
42
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=service-action-ledger-bookings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-action-ledger-bookings.d.ts","sourceRoot":"","sources":["../src/service-action-ledger-bookings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EAEpC,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAE7D,KAAK,0BAA0B,GAAG;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,qBAAqB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAA;IAChD,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,kBAAkB,CAAC,EAAE;QACnB,gBAAgB,EAAE,OAAO,CAAA;QACzB,eAAe,EAAE,OAAO,CAAA;QACxB,WAAW,EAAE,SAAS,GAAG,UAAU,CAAA;KACpC,CAAA;CACF,CAAA;AAED,KAAK,iCAAiC,GAAG;IACvC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,0BAA0B,CAAA;CACpC,CAAA;AAED,KAAK,gCAAgC,GAAG;IACtC,eAAe,EAAE;QACf,EAAE,EAAE,MAAM,CAAA;QACV,aAAa,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,OAAO,EAAE,0BAA0B,CAAA;IACnC,MAAM,EAAE,mBAAmB,CAAA;CAC5B,CAAA;AAED,wBAAsB,4CAA4C,CAChE,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,iCAAiC,EACxC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,OAAO,CAAC,8BAA8B,CAAC,CA4BzC;AAED,wBAAsB,2CAA2C,CAC/D,OAAO,EAAE,gCAAgC,EACzC,KAAK,EAAE,gCAAgC,EACvC,OAAO,GAAE;IACP,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,GACL,OAAO,CAAC,8BAA8B,CAAC,CA+BzC"}
|