@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,164 @@
|
|
|
1
|
+
import type { CreatePaymentAuthorizationInput, CreatePaymentCaptureInput, FinanceServiceRuntime, PaymentAuthorizationListQuery, PaymentCaptureListQuery, PostgresJsDatabase, UpdatePaymentAuthorizationInput, UpdatePaymentCaptureInput } from "./service-shared.js";
|
|
2
|
+
export declare const financePaymentAuthorizationService: {
|
|
3
|
+
listPaymentAuthorizations(db: PostgresJsDatabase, query: PaymentAuthorizationListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
bookingId: string | null;
|
|
7
|
+
orderId: string | null;
|
|
8
|
+
invoiceId: string | null;
|
|
9
|
+
bookingGuaranteeId: string | null;
|
|
10
|
+
paymentInstrumentId: string | null;
|
|
11
|
+
status: "failed" | "pending" | "expired" | "authorized" | "partially_captured" | "captured" | "voided";
|
|
12
|
+
captureMode: "manual" | "automatic";
|
|
13
|
+
currency: string;
|
|
14
|
+
amountCents: number;
|
|
15
|
+
provider: string | null;
|
|
16
|
+
externalAuthorizationId: string | null;
|
|
17
|
+
approvalCode: string | null;
|
|
18
|
+
authorizedAt: Date | null;
|
|
19
|
+
expiresAt: Date | null;
|
|
20
|
+
voidedAt: Date | null;
|
|
21
|
+
notes: string | null;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
}[];
|
|
25
|
+
total: number;
|
|
26
|
+
limit: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
}>;
|
|
29
|
+
getPaymentAuthorizationById(db: PostgresJsDatabase, id: string): Promise<{
|
|
30
|
+
id: string;
|
|
31
|
+
bookingId: string | null;
|
|
32
|
+
orderId: string | null;
|
|
33
|
+
invoiceId: string | null;
|
|
34
|
+
bookingGuaranteeId: string | null;
|
|
35
|
+
paymentInstrumentId: string | null;
|
|
36
|
+
status: "failed" | "pending" | "expired" | "authorized" | "partially_captured" | "captured" | "voided";
|
|
37
|
+
captureMode: "manual" | "automatic";
|
|
38
|
+
currency: string;
|
|
39
|
+
amountCents: number;
|
|
40
|
+
provider: string | null;
|
|
41
|
+
externalAuthorizationId: string | null;
|
|
42
|
+
approvalCode: string | null;
|
|
43
|
+
authorizedAt: Date | null;
|
|
44
|
+
expiresAt: Date | null;
|
|
45
|
+
voidedAt: Date | null;
|
|
46
|
+
notes: string | null;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
updatedAt: Date;
|
|
49
|
+
} | null>;
|
|
50
|
+
createPaymentAuthorization(db: PostgresJsDatabase, data: CreatePaymentAuthorizationInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
51
|
+
currency: string;
|
|
52
|
+
id: string;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
status: "failed" | "pending" | "expired" | "authorized" | "partially_captured" | "captured" | "voided";
|
|
56
|
+
bookingId: string | null;
|
|
57
|
+
provider: string | null;
|
|
58
|
+
invoiceId: string | null;
|
|
59
|
+
amountCents: number;
|
|
60
|
+
notes: string | null;
|
|
61
|
+
bookingGuaranteeId: string | null;
|
|
62
|
+
expiresAt: Date | null;
|
|
63
|
+
voidedAt: Date | null;
|
|
64
|
+
orderId: string | null;
|
|
65
|
+
paymentInstrumentId: string | null;
|
|
66
|
+
captureMode: "manual" | "automatic";
|
|
67
|
+
externalAuthorizationId: string | null;
|
|
68
|
+
approvalCode: string | null;
|
|
69
|
+
authorizedAt: Date | null;
|
|
70
|
+
} | null>;
|
|
71
|
+
updatePaymentAuthorization(db: PostgresJsDatabase, id: string, data: UpdatePaymentAuthorizationInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
72
|
+
id: string;
|
|
73
|
+
bookingId: string | null;
|
|
74
|
+
orderId: string | null;
|
|
75
|
+
invoiceId: string | null;
|
|
76
|
+
bookingGuaranteeId: string | null;
|
|
77
|
+
paymentInstrumentId: string | null;
|
|
78
|
+
status: "failed" | "pending" | "expired" | "authorized" | "partially_captured" | "captured" | "voided";
|
|
79
|
+
captureMode: "manual" | "automatic";
|
|
80
|
+
currency: string;
|
|
81
|
+
amountCents: number;
|
|
82
|
+
provider: string | null;
|
|
83
|
+
externalAuthorizationId: string | null;
|
|
84
|
+
approvalCode: string | null;
|
|
85
|
+
authorizedAt: Date | null;
|
|
86
|
+
expiresAt: Date | null;
|
|
87
|
+
voidedAt: Date | null;
|
|
88
|
+
notes: string | null;
|
|
89
|
+
createdAt: Date;
|
|
90
|
+
updatedAt: Date;
|
|
91
|
+
} | null>;
|
|
92
|
+
deletePaymentAuthorization(db: PostgresJsDatabase, id: string, runtime?: FinanceServiceRuntime): Promise<{
|
|
93
|
+
id: string;
|
|
94
|
+
} | null>;
|
|
95
|
+
listPaymentCaptures(db: PostgresJsDatabase, query: PaymentCaptureListQuery): Promise<{
|
|
96
|
+
data: {
|
|
97
|
+
id: string;
|
|
98
|
+
paymentAuthorizationId: string | null;
|
|
99
|
+
invoiceId: string | null;
|
|
100
|
+
status: "failed" | "pending" | "voided" | "completed" | "refunded";
|
|
101
|
+
currency: string;
|
|
102
|
+
amountCents: number;
|
|
103
|
+
provider: string | null;
|
|
104
|
+
externalCaptureId: string | null;
|
|
105
|
+
capturedAt: Date | null;
|
|
106
|
+
settledAt: Date | null;
|
|
107
|
+
notes: string | null;
|
|
108
|
+
createdAt: Date;
|
|
109
|
+
updatedAt: Date;
|
|
110
|
+
}[];
|
|
111
|
+
total: number;
|
|
112
|
+
limit: number;
|
|
113
|
+
offset: number;
|
|
114
|
+
}>;
|
|
115
|
+
getPaymentCaptureById(db: PostgresJsDatabase, id: string): Promise<{
|
|
116
|
+
id: string;
|
|
117
|
+
paymentAuthorizationId: string | null;
|
|
118
|
+
invoiceId: string | null;
|
|
119
|
+
status: "failed" | "pending" | "voided" | "completed" | "refunded";
|
|
120
|
+
currency: string;
|
|
121
|
+
amountCents: number;
|
|
122
|
+
provider: string | null;
|
|
123
|
+
externalCaptureId: string | null;
|
|
124
|
+
capturedAt: Date | null;
|
|
125
|
+
settledAt: Date | null;
|
|
126
|
+
notes: string | null;
|
|
127
|
+
createdAt: Date;
|
|
128
|
+
updatedAt: Date;
|
|
129
|
+
} | null>;
|
|
130
|
+
createPaymentCapture(db: PostgresJsDatabase, data: CreatePaymentCaptureInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
131
|
+
currency: string;
|
|
132
|
+
id: string;
|
|
133
|
+
createdAt: Date;
|
|
134
|
+
updatedAt: Date;
|
|
135
|
+
status: "failed" | "pending" | "voided" | "completed" | "refunded";
|
|
136
|
+
provider: string | null;
|
|
137
|
+
invoiceId: string | null;
|
|
138
|
+
amountCents: number;
|
|
139
|
+
notes: string | null;
|
|
140
|
+
paymentAuthorizationId: string | null;
|
|
141
|
+
externalCaptureId: string | null;
|
|
142
|
+
capturedAt: Date | null;
|
|
143
|
+
settledAt: Date | null;
|
|
144
|
+
} | null>;
|
|
145
|
+
updatePaymentCapture(db: PostgresJsDatabase, id: string, data: UpdatePaymentCaptureInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
146
|
+
id: string;
|
|
147
|
+
paymentAuthorizationId: string | null;
|
|
148
|
+
invoiceId: string | null;
|
|
149
|
+
status: "failed" | "pending" | "voided" | "completed" | "refunded";
|
|
150
|
+
currency: string;
|
|
151
|
+
amountCents: number;
|
|
152
|
+
provider: string | null;
|
|
153
|
+
externalCaptureId: string | null;
|
|
154
|
+
capturedAt: Date | null;
|
|
155
|
+
settledAt: Date | null;
|
|
156
|
+
notes: string | null;
|
|
157
|
+
createdAt: Date;
|
|
158
|
+
updatedAt: Date;
|
|
159
|
+
} | null>;
|
|
160
|
+
deletePaymentCapture(db: PostgresJsDatabase, id: string, runtime?: FinanceServiceRuntime): Promise<{
|
|
161
|
+
id: string;
|
|
162
|
+
} | null>;
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=service-payment-authorizations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-payment-authorizations.d.ts","sourceRoot":"","sources":["../src/service-payment-authorizations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,qBAAqB,EACrB,6BAA6B,EAC7B,uBAAuB,EACvB,kBAAkB,EAClB,+BAA+B,EAC/B,yBAAyB,EAC1B,MAAM,qBAAqB,CAAA;AA8C5B,eAAO,MAAM,kCAAkC;kCACT,kBAAkB,SAAS,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;oCAyBtD,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;mCAU9D,kBAAkB,QAChB,+BAA+B,YAC5B,qBAAqB;;;;;;;;;;;;;;;;;;;;;mCAkD1B,kBAAkB,MAClB,MAAM,QACJ,+BAA+B,YAC5B,qBAAqB;;;;;;;;;;;;;;;;;;;;;mCAuD1B,kBAAkB,MAClB,MAAM,YACD,qBAAqB;;;4BAoCF,kBAAkB,SAAS,uBAAuB;;;;;;;;;;;;;;;;;;;;8BAqBhD,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;6BAMxD,kBAAkB,QAChB,yBAAyB,YACtB,qBAAqB;;;;;;;;;;;;;;;6BAuC1B,kBAAkB,MAClB,MAAM,QACJ,yBAAyB,YACtB,qBAAqB;;;;;;;;;;;;;;;6BAyC1B,kBAAkB,MAClB,MAAM,YACD,qBAAqB;;;CAmCjC,CAAA"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { and, appendActionLedgerMutation, buildPaymentAuthorizationCreateActionLedgerInput, buildPaymentAuthorizationDeleteActionLedgerInput, buildPaymentAuthorizationUpdateActionLedgerInput, buildPaymentCaptureCreateActionLedgerInput, buildPaymentCaptureDeleteActionLedgerInput, buildPaymentCaptureUpdateActionLedgerInput, desc, eq, paginate, paymentAuthorizations, paymentCaptures, sql, toTimestamp, } from "./service-shared.js";
|
|
2
|
+
function derivePaymentAuthorizationTargetColumns(data) {
|
|
3
|
+
const explicitTarget = "target" in data ? data.target : undefined;
|
|
4
|
+
if (!explicitTarget)
|
|
5
|
+
return {};
|
|
6
|
+
switch (explicitTarget.type) {
|
|
7
|
+
case "booking":
|
|
8
|
+
return { bookingId: explicitTarget.bookingId };
|
|
9
|
+
case "invoice":
|
|
10
|
+
return { invoiceId: explicitTarget.invoiceId };
|
|
11
|
+
case "booking_guarantee":
|
|
12
|
+
return { bookingGuaranteeId: explicitTarget.bookingGuaranteeId };
|
|
13
|
+
case "legacy_order":
|
|
14
|
+
return { orderId: explicitTarget.legacyOrderId };
|
|
15
|
+
default:
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const financePaymentAuthorizationService = {
|
|
20
|
+
async listPaymentAuthorizations(db, query) {
|
|
21
|
+
const conditions = [];
|
|
22
|
+
if (query.bookingId)
|
|
23
|
+
conditions.push(eq(paymentAuthorizations.bookingId, query.bookingId));
|
|
24
|
+
if (query.legacyOrderId)
|
|
25
|
+
conditions.push(eq(paymentAuthorizations.orderId, query.legacyOrderId));
|
|
26
|
+
if (query.invoiceId)
|
|
27
|
+
conditions.push(eq(paymentAuthorizations.invoiceId, query.invoiceId));
|
|
28
|
+
if (query.bookingGuaranteeId)
|
|
29
|
+
conditions.push(eq(paymentAuthorizations.bookingGuaranteeId, query.bookingGuaranteeId));
|
|
30
|
+
if (query.paymentInstrumentId)
|
|
31
|
+
conditions.push(eq(paymentAuthorizations.paymentInstrumentId, query.paymentInstrumentId));
|
|
32
|
+
if (query.status)
|
|
33
|
+
conditions.push(eq(paymentAuthorizations.status, query.status));
|
|
34
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
35
|
+
return paginate(db
|
|
36
|
+
.select()
|
|
37
|
+
.from(paymentAuthorizations)
|
|
38
|
+
.where(where)
|
|
39
|
+
.limit(query.limit)
|
|
40
|
+
.offset(query.offset)
|
|
41
|
+
.orderBy(desc(paymentAuthorizations.createdAt)), db.select({ total: sql `count(*)::int` }).from(paymentAuthorizations).where(where), query.limit, query.offset);
|
|
42
|
+
},
|
|
43
|
+
async getPaymentAuthorizationById(db, id) {
|
|
44
|
+
const [row] = await db
|
|
45
|
+
.select()
|
|
46
|
+
.from(paymentAuthorizations)
|
|
47
|
+
.where(eq(paymentAuthorizations.id, id))
|
|
48
|
+
.limit(1);
|
|
49
|
+
return row ?? null;
|
|
50
|
+
},
|
|
51
|
+
async createPaymentAuthorization(db, data, runtime = {}) {
|
|
52
|
+
const targetColumns = derivePaymentAuthorizationTargetColumns(data);
|
|
53
|
+
const { legacyOrderId, target: _explicitTarget, provenance: _provenance, ...authorizationData } = data;
|
|
54
|
+
const resolvedLegacyOrderId = legacyOrderId ?? null;
|
|
55
|
+
const createAuthorization = (writer) => writer
|
|
56
|
+
.insert(paymentAuthorizations)
|
|
57
|
+
.values({
|
|
58
|
+
...authorizationData,
|
|
59
|
+
...targetColumns,
|
|
60
|
+
orderId: targetColumns.orderId ?? resolvedLegacyOrderId,
|
|
61
|
+
authorizedAt: toTimestamp(data.authorizedAt),
|
|
62
|
+
expiresAt: toTimestamp(data.expiresAt),
|
|
63
|
+
voidedAt: toTimestamp(data.voidedAt),
|
|
64
|
+
})
|
|
65
|
+
.returning();
|
|
66
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
67
|
+
if (actionLedgerContext) {
|
|
68
|
+
const [row] = await db.transaction(async (tx) => {
|
|
69
|
+
const created = await createAuthorization(tx);
|
|
70
|
+
if (created[0]) {
|
|
71
|
+
await appendActionLedgerMutation(tx, await buildPaymentAuthorizationCreateActionLedgerInput(actionLedgerContext, { authorization: created[0] }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
72
|
+
}
|
|
73
|
+
return created;
|
|
74
|
+
});
|
|
75
|
+
return row ?? null;
|
|
76
|
+
}
|
|
77
|
+
const [row] = await createAuthorization(db);
|
|
78
|
+
return row ?? null;
|
|
79
|
+
},
|
|
80
|
+
async updatePaymentAuthorization(db, id, data, runtime = {}) {
|
|
81
|
+
const targetColumns = derivePaymentAuthorizationTargetColumns(data);
|
|
82
|
+
const { legacyOrderId, target: _explicitTarget, provenance: _provenance, ...authorizationData } = data;
|
|
83
|
+
const resolvedLegacyOrderId = legacyOrderId;
|
|
84
|
+
const updateAuthorization = (writer) => writer
|
|
85
|
+
.update(paymentAuthorizations)
|
|
86
|
+
.set({
|
|
87
|
+
...authorizationData,
|
|
88
|
+
...targetColumns,
|
|
89
|
+
orderId: targetColumns.orderId ??
|
|
90
|
+
(resolvedLegacyOrderId === undefined ? undefined : (resolvedLegacyOrderId ?? null)),
|
|
91
|
+
authorizedAt: data.authorizedAt === undefined ? undefined : toTimestamp(data.authorizedAt),
|
|
92
|
+
expiresAt: data.expiresAt === undefined ? undefined : toTimestamp(data.expiresAt),
|
|
93
|
+
voidedAt: data.voidedAt === undefined ? undefined : toTimestamp(data.voidedAt),
|
|
94
|
+
updatedAt: new Date(),
|
|
95
|
+
})
|
|
96
|
+
.where(eq(paymentAuthorizations.id, id))
|
|
97
|
+
.returning();
|
|
98
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
99
|
+
if (actionLedgerContext) {
|
|
100
|
+
const [row] = await db.transaction(async (tx) => {
|
|
101
|
+
const updated = await updateAuthorization(tx);
|
|
102
|
+
if (updated[0]) {
|
|
103
|
+
await appendActionLedgerMutation(tx, buildPaymentAuthorizationUpdateActionLedgerInput(actionLedgerContext, { authorization: updated[0], changes: data }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
104
|
+
}
|
|
105
|
+
return updated;
|
|
106
|
+
});
|
|
107
|
+
return row ?? null;
|
|
108
|
+
}
|
|
109
|
+
const [row] = await updateAuthorization(db);
|
|
110
|
+
return row ?? null;
|
|
111
|
+
},
|
|
112
|
+
async deletePaymentAuthorization(db, id, runtime = {}) {
|
|
113
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
114
|
+
if (actionLedgerContext) {
|
|
115
|
+
return db.transaction(async (tx) => {
|
|
116
|
+
const [existing] = await tx
|
|
117
|
+
.select()
|
|
118
|
+
.from(paymentAuthorizations)
|
|
119
|
+
.where(eq(paymentAuthorizations.id, id))
|
|
120
|
+
.limit(1);
|
|
121
|
+
if (!existing) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
await tx.delete(paymentAuthorizations).where(eq(paymentAuthorizations.id, id));
|
|
125
|
+
await appendActionLedgerMutation(tx, buildPaymentAuthorizationDeleteActionLedgerInput(actionLedgerContext, { authorization: existing }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
126
|
+
return { id: existing.id };
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const [row] = await db
|
|
130
|
+
.delete(paymentAuthorizations)
|
|
131
|
+
.where(eq(paymentAuthorizations.id, id))
|
|
132
|
+
.returning({ id: paymentAuthorizations.id });
|
|
133
|
+
return row ?? null;
|
|
134
|
+
},
|
|
135
|
+
async listPaymentCaptures(db, query) {
|
|
136
|
+
const conditions = [];
|
|
137
|
+
if (query.paymentAuthorizationId)
|
|
138
|
+
conditions.push(eq(paymentCaptures.paymentAuthorizationId, query.paymentAuthorizationId));
|
|
139
|
+
if (query.invoiceId)
|
|
140
|
+
conditions.push(eq(paymentCaptures.invoiceId, query.invoiceId));
|
|
141
|
+
if (query.status)
|
|
142
|
+
conditions.push(eq(paymentCaptures.status, query.status));
|
|
143
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
144
|
+
return paginate(db
|
|
145
|
+
.select()
|
|
146
|
+
.from(paymentCaptures)
|
|
147
|
+
.where(where)
|
|
148
|
+
.limit(query.limit)
|
|
149
|
+
.offset(query.offset)
|
|
150
|
+
.orderBy(desc(paymentCaptures.createdAt)), db.select({ total: sql `count(*)::int` }).from(paymentCaptures).where(where), query.limit, query.offset);
|
|
151
|
+
},
|
|
152
|
+
async getPaymentCaptureById(db, id) {
|
|
153
|
+
const [row] = await db.select().from(paymentCaptures).where(eq(paymentCaptures.id, id)).limit(1);
|
|
154
|
+
return row ?? null;
|
|
155
|
+
},
|
|
156
|
+
async createPaymentCapture(db, data, runtime = {}) {
|
|
157
|
+
const createCapture = (writer) => writer
|
|
158
|
+
.insert(paymentCaptures)
|
|
159
|
+
.values({
|
|
160
|
+
...data,
|
|
161
|
+
capturedAt: toTimestamp(data.capturedAt),
|
|
162
|
+
settledAt: toTimestamp(data.settledAt),
|
|
163
|
+
})
|
|
164
|
+
.returning();
|
|
165
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
166
|
+
if (actionLedgerContext) {
|
|
167
|
+
const [row] = await db.transaction(async (tx) => {
|
|
168
|
+
const created = await createCapture(tx);
|
|
169
|
+
if (created[0]) {
|
|
170
|
+
await appendActionLedgerMutation(tx, await buildPaymentCaptureCreateActionLedgerInput(actionLedgerContext, { capture: created[0] }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
171
|
+
}
|
|
172
|
+
return created;
|
|
173
|
+
});
|
|
174
|
+
return row ?? null;
|
|
175
|
+
}
|
|
176
|
+
const [row] = await createCapture(db);
|
|
177
|
+
return row ?? null;
|
|
178
|
+
},
|
|
179
|
+
async updatePaymentCapture(db, id, data, runtime = {}) {
|
|
180
|
+
const updateCapture = (writer) => writer
|
|
181
|
+
.update(paymentCaptures)
|
|
182
|
+
.set({
|
|
183
|
+
...data,
|
|
184
|
+
capturedAt: data.capturedAt === undefined ? undefined : toTimestamp(data.capturedAt),
|
|
185
|
+
settledAt: data.settledAt === undefined ? undefined : toTimestamp(data.settledAt),
|
|
186
|
+
updatedAt: new Date(),
|
|
187
|
+
})
|
|
188
|
+
.where(eq(paymentCaptures.id, id))
|
|
189
|
+
.returning();
|
|
190
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
191
|
+
if (actionLedgerContext) {
|
|
192
|
+
const [row] = await db.transaction(async (tx) => {
|
|
193
|
+
const updated = await updateCapture(tx);
|
|
194
|
+
if (updated[0]) {
|
|
195
|
+
await appendActionLedgerMutation(tx, buildPaymentCaptureUpdateActionLedgerInput(actionLedgerContext, { capture: updated[0], changes: data }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
196
|
+
}
|
|
197
|
+
return updated;
|
|
198
|
+
});
|
|
199
|
+
return row ?? null;
|
|
200
|
+
}
|
|
201
|
+
const [row] = await updateCapture(db);
|
|
202
|
+
return row ?? null;
|
|
203
|
+
},
|
|
204
|
+
async deletePaymentCapture(db, id, runtime = {}) {
|
|
205
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
206
|
+
if (actionLedgerContext) {
|
|
207
|
+
return db.transaction(async (tx) => {
|
|
208
|
+
const [existing] = await tx
|
|
209
|
+
.select()
|
|
210
|
+
.from(paymentCaptures)
|
|
211
|
+
.where(eq(paymentCaptures.id, id))
|
|
212
|
+
.limit(1);
|
|
213
|
+
if (!existing) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
await tx.delete(paymentCaptures).where(eq(paymentCaptures.id, id));
|
|
217
|
+
await appendActionLedgerMutation(tx, buildPaymentCaptureDeleteActionLedgerInput(actionLedgerContext, { capture: existing }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
218
|
+
return { id: existing.id };
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const [row] = await db
|
|
222
|
+
.delete(paymentCaptures)
|
|
223
|
+
.where(eq(paymentCaptures.id, id))
|
|
224
|
+
.returning({ id: paymentCaptures.id });
|
|
225
|
+
return row ?? null;
|
|
226
|
+
},
|
|
227
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { CreatePaymentInstrumentInput, FinanceServiceRuntime, PaymentInstrumentListQuery, PostgresJsDatabase, UpdatePaymentInstrumentInput } from "./service-shared.js";
|
|
2
|
+
export declare const financePaymentInstrumentService: {
|
|
3
|
+
listPaymentInstruments(db: PostgresJsDatabase, query: PaymentInstrumentListQuery): Promise<{
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
ownerType: "other" | "channel" | "client" | "supplier" | "agency" | "internal";
|
|
7
|
+
personId: string | null;
|
|
8
|
+
organizationId: string | null;
|
|
9
|
+
supplierId: string | null;
|
|
10
|
+
channelId: string | null;
|
|
11
|
+
instrumentType: "other" | "credit_card" | "voucher" | "debit_card" | "cash" | "wallet" | "direct_bill" | "bank_account";
|
|
12
|
+
status: "active" | "expired" | "inactive" | "revoked" | "failed_verification";
|
|
13
|
+
label: string;
|
|
14
|
+
provider: string | null;
|
|
15
|
+
brand: string | null;
|
|
16
|
+
last4: string | null;
|
|
17
|
+
holderName: string | null;
|
|
18
|
+
expiryMonth: number | null;
|
|
19
|
+
expiryYear: number | null;
|
|
20
|
+
externalToken: string | null;
|
|
21
|
+
externalCustomerId: string | null;
|
|
22
|
+
billingEmail: string | null;
|
|
23
|
+
billingAddress: string | null;
|
|
24
|
+
directBillReference: string | null;
|
|
25
|
+
notes: string | null;
|
|
26
|
+
metadata: unknown;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
}[];
|
|
30
|
+
total: number;
|
|
31
|
+
limit: number;
|
|
32
|
+
offset: number;
|
|
33
|
+
}>;
|
|
34
|
+
getPaymentInstrumentById(db: PostgresJsDatabase, id: string): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
ownerType: "other" | "channel" | "client" | "supplier" | "agency" | "internal";
|
|
37
|
+
personId: string | null;
|
|
38
|
+
organizationId: string | null;
|
|
39
|
+
supplierId: string | null;
|
|
40
|
+
channelId: string | null;
|
|
41
|
+
instrumentType: "other" | "credit_card" | "voucher" | "debit_card" | "cash" | "wallet" | "direct_bill" | "bank_account";
|
|
42
|
+
status: "active" | "expired" | "inactive" | "revoked" | "failed_verification";
|
|
43
|
+
label: string;
|
|
44
|
+
provider: string | null;
|
|
45
|
+
brand: string | null;
|
|
46
|
+
last4: string | null;
|
|
47
|
+
holderName: string | null;
|
|
48
|
+
expiryMonth: number | null;
|
|
49
|
+
expiryYear: number | null;
|
|
50
|
+
externalToken: string | null;
|
|
51
|
+
externalCustomerId: string | null;
|
|
52
|
+
billingEmail: string | null;
|
|
53
|
+
billingAddress: string | null;
|
|
54
|
+
directBillReference: string | null;
|
|
55
|
+
notes: string | null;
|
|
56
|
+
metadata: unknown;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
updatedAt: Date;
|
|
59
|
+
} | null>;
|
|
60
|
+
createPaymentInstrument(db: PostgresJsDatabase, data: CreatePaymentInstrumentInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
61
|
+
id: string;
|
|
62
|
+
brand: string | null;
|
|
63
|
+
createdAt: Date;
|
|
64
|
+
updatedAt: Date;
|
|
65
|
+
metadata: unknown;
|
|
66
|
+
label: string;
|
|
67
|
+
status: "active" | "expired" | "inactive" | "revoked" | "failed_verification";
|
|
68
|
+
provider: string | null;
|
|
69
|
+
notes: string | null;
|
|
70
|
+
personId: string | null;
|
|
71
|
+
organizationId: string | null;
|
|
72
|
+
ownerType: "other" | "channel" | "client" | "supplier" | "agency" | "internal";
|
|
73
|
+
supplierId: string | null;
|
|
74
|
+
channelId: string | null;
|
|
75
|
+
instrumentType: "other" | "credit_card" | "voucher" | "debit_card" | "cash" | "wallet" | "direct_bill" | "bank_account";
|
|
76
|
+
last4: string | null;
|
|
77
|
+
holderName: string | null;
|
|
78
|
+
expiryMonth: number | null;
|
|
79
|
+
expiryYear: number | null;
|
|
80
|
+
externalToken: string | null;
|
|
81
|
+
externalCustomerId: string | null;
|
|
82
|
+
billingEmail: string | null;
|
|
83
|
+
billingAddress: string | null;
|
|
84
|
+
directBillReference: string | null;
|
|
85
|
+
} | null>;
|
|
86
|
+
updatePaymentInstrument(db: PostgresJsDatabase, id: string, data: UpdatePaymentInstrumentInput, runtime?: FinanceServiceRuntime): Promise<{
|
|
87
|
+
id: string;
|
|
88
|
+
ownerType: "other" | "channel" | "client" | "supplier" | "agency" | "internal";
|
|
89
|
+
personId: string | null;
|
|
90
|
+
organizationId: string | null;
|
|
91
|
+
supplierId: string | null;
|
|
92
|
+
channelId: string | null;
|
|
93
|
+
instrumentType: "other" | "credit_card" | "voucher" | "debit_card" | "cash" | "wallet" | "direct_bill" | "bank_account";
|
|
94
|
+
status: "active" | "expired" | "inactive" | "revoked" | "failed_verification";
|
|
95
|
+
label: string;
|
|
96
|
+
provider: string | null;
|
|
97
|
+
brand: string | null;
|
|
98
|
+
last4: string | null;
|
|
99
|
+
holderName: string | null;
|
|
100
|
+
expiryMonth: number | null;
|
|
101
|
+
expiryYear: number | null;
|
|
102
|
+
externalToken: string | null;
|
|
103
|
+
externalCustomerId: string | null;
|
|
104
|
+
billingEmail: string | null;
|
|
105
|
+
billingAddress: string | null;
|
|
106
|
+
directBillReference: string | null;
|
|
107
|
+
notes: string | null;
|
|
108
|
+
metadata: unknown;
|
|
109
|
+
createdAt: Date;
|
|
110
|
+
updatedAt: Date;
|
|
111
|
+
} | null>;
|
|
112
|
+
deletePaymentInstrument(db: PostgresJsDatabase, id: string, runtime?: FinanceServiceRuntime): Promise<{
|
|
113
|
+
id: string;
|
|
114
|
+
} | null>;
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=service-payment-instruments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-payment-instruments.d.ts","sourceRoot":"","sources":["../src/service-payment-instruments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,qBAAqB,CAAA;AAgB5B,eAAO,MAAM,+BAA+B;+BACT,kBAAkB,SAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAgCnD,kBAAkB,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;gCAU3D,kBAAkB,QAChB,4BAA4B,YACzB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;gCAgC1B,kBAAkB,MAClB,MAAM,QACJ,4BAA4B,YACzB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;gCAoC1B,kBAAkB,MAClB,MAAM,YACD,qBAAqB;;;CAmCjC,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { and, appendActionLedgerMutation, buildPaymentInstrumentCreateActionLedgerInput, buildPaymentInstrumentDeleteActionLedgerInput, buildPaymentInstrumentUpdateActionLedgerInput, desc, eq, ilike, or, paginate, paymentInstruments, sql, } from "./service-shared.js";
|
|
2
|
+
export const financePaymentInstrumentService = {
|
|
3
|
+
async listPaymentInstruments(db, query) {
|
|
4
|
+
const conditions = [];
|
|
5
|
+
if (query.ownerType)
|
|
6
|
+
conditions.push(eq(paymentInstruments.ownerType, query.ownerType));
|
|
7
|
+
if (query.personId)
|
|
8
|
+
conditions.push(eq(paymentInstruments.personId, query.personId));
|
|
9
|
+
if (query.organizationId)
|
|
10
|
+
conditions.push(eq(paymentInstruments.organizationId, query.organizationId));
|
|
11
|
+
if (query.supplierId)
|
|
12
|
+
conditions.push(eq(paymentInstruments.supplierId, query.supplierId));
|
|
13
|
+
if (query.channelId)
|
|
14
|
+
conditions.push(eq(paymentInstruments.channelId, query.channelId));
|
|
15
|
+
if (query.status)
|
|
16
|
+
conditions.push(eq(paymentInstruments.status, query.status));
|
|
17
|
+
if (query.instrumentType)
|
|
18
|
+
conditions.push(eq(paymentInstruments.instrumentType, query.instrumentType));
|
|
19
|
+
if (query.search) {
|
|
20
|
+
const term = `%${query.search}%`;
|
|
21
|
+
conditions.push(or(ilike(paymentInstruments.label, term), ilike(paymentInstruments.provider, term)));
|
|
22
|
+
}
|
|
23
|
+
const where = conditions.length ? and(...conditions) : undefined;
|
|
24
|
+
return paginate(db
|
|
25
|
+
.select()
|
|
26
|
+
.from(paymentInstruments)
|
|
27
|
+
.where(where)
|
|
28
|
+
.limit(query.limit)
|
|
29
|
+
.offset(query.offset)
|
|
30
|
+
.orderBy(desc(paymentInstruments.updatedAt)), db.select({ total: sql `count(*)::int` }).from(paymentInstruments).where(where), query.limit, query.offset);
|
|
31
|
+
},
|
|
32
|
+
async getPaymentInstrumentById(db, id) {
|
|
33
|
+
const [row] = await db
|
|
34
|
+
.select()
|
|
35
|
+
.from(paymentInstruments)
|
|
36
|
+
.where(eq(paymentInstruments.id, id))
|
|
37
|
+
.limit(1);
|
|
38
|
+
return row ?? null;
|
|
39
|
+
},
|
|
40
|
+
async createPaymentInstrument(db, data, runtime = {}) {
|
|
41
|
+
const createInstrument = (writer) => writer.insert(paymentInstruments).values(data).returning();
|
|
42
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
43
|
+
if (actionLedgerContext) {
|
|
44
|
+
const [row] = await db.transaction(async (tx) => {
|
|
45
|
+
const created = await createInstrument(tx);
|
|
46
|
+
if (created[0]) {
|
|
47
|
+
await appendActionLedgerMutation(tx, buildPaymentInstrumentCreateActionLedgerInput(actionLedgerContext, { instrument: created[0] }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
48
|
+
}
|
|
49
|
+
return created;
|
|
50
|
+
});
|
|
51
|
+
return row ?? null;
|
|
52
|
+
}
|
|
53
|
+
const [row] = await createInstrument(db);
|
|
54
|
+
return row ?? null;
|
|
55
|
+
},
|
|
56
|
+
async updatePaymentInstrument(db, id, data, runtime = {}) {
|
|
57
|
+
const updateInstrument = (writer) => writer
|
|
58
|
+
.update(paymentInstruments)
|
|
59
|
+
.set({ ...data, updatedAt: new Date() })
|
|
60
|
+
.where(eq(paymentInstruments.id, id))
|
|
61
|
+
.returning();
|
|
62
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
63
|
+
if (actionLedgerContext) {
|
|
64
|
+
const [row] = await db.transaction(async (tx) => {
|
|
65
|
+
const updated = await updateInstrument(tx);
|
|
66
|
+
if (updated[0]) {
|
|
67
|
+
await appendActionLedgerMutation(tx, buildPaymentInstrumentUpdateActionLedgerInput(actionLedgerContext, { instrument: updated[0], changes: data }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
68
|
+
}
|
|
69
|
+
return updated;
|
|
70
|
+
});
|
|
71
|
+
return row ?? null;
|
|
72
|
+
}
|
|
73
|
+
const [row] = await updateInstrument(db);
|
|
74
|
+
return row ?? null;
|
|
75
|
+
},
|
|
76
|
+
async deletePaymentInstrument(db, id, runtime = {}) {
|
|
77
|
+
const actionLedgerContext = runtime.actionLedgerContext;
|
|
78
|
+
if (actionLedgerContext) {
|
|
79
|
+
return db.transaction(async (tx) => {
|
|
80
|
+
const [existing] = await tx
|
|
81
|
+
.select()
|
|
82
|
+
.from(paymentInstruments)
|
|
83
|
+
.where(eq(paymentInstruments.id, id))
|
|
84
|
+
.limit(1);
|
|
85
|
+
if (!existing) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
await tx.delete(paymentInstruments).where(eq(paymentInstruments.id, id));
|
|
89
|
+
await appendActionLedgerMutation(tx, buildPaymentInstrumentDeleteActionLedgerInput(actionLedgerContext, { instrument: existing }, { authorizationSource: runtime.actionLedgerAuthorizationSource }));
|
|
90
|
+
return { id: existing.id };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const [row] = await db
|
|
94
|
+
.delete(paymentInstruments)
|
|
95
|
+
.where(eq(paymentInstruments.id, id))
|
|
96
|
+
.returning({ id: paymentInstruments.id });
|
|
97
|
+
return row ?? null;
|
|
98
|
+
},
|
|
99
|
+
};
|