@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
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, the acceptance of support, warranty, indemnity, or
|
|
168
|
+
other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PixelMakers Studio SRL
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @voyant-travel/finance
|
|
2
|
+
|
|
3
|
+
Finance module for Voyant. Invoices, payments, credit notes, supplier payments, and finance notes.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voyant-travel/finance
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { financeModule } from "@voyant-travel/finance"
|
|
15
|
+
import { createApp } from "@voyant-travel/hono"
|
|
16
|
+
|
|
17
|
+
const app = createApp({
|
|
18
|
+
modules: [financeModule],
|
|
19
|
+
// ...
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Entities
|
|
24
|
+
|
|
25
|
+
- **Invoices** + **Invoice lines** (`inv`, `inli`)
|
|
26
|
+
- **Payments** (`pay`)
|
|
27
|
+
- **Credit notes** + **Credit note lines** (`crn`, `cnli`)
|
|
28
|
+
- **Supplier payments** (`spay`)
|
|
29
|
+
- **Finance notes** (`fnot`)
|
|
30
|
+
- **Invoice number series** (`invs`)
|
|
31
|
+
- **Invoice templates** (`invt`)
|
|
32
|
+
- **Invoice renditions** (`invr`)
|
|
33
|
+
- **Tax regimes** (`txrg`)
|
|
34
|
+
- **Invoice external refs** (`iner`)
|
|
35
|
+
|
|
36
|
+
## Invoice Rendition Events
|
|
37
|
+
|
|
38
|
+
Use `financeService.bindInvoiceRendition(db, invoiceId, artifact, { eventBus })`
|
|
39
|
+
when a rendered invoice artifact has already been stored and should be bound to
|
|
40
|
+
the invoice as the ready rendition. The helper creates the `invoice_renditions`
|
|
41
|
+
row with `status: "ready"` inside a transaction, optionally marks previous
|
|
42
|
+
renditions of the same format as `stale` when `replaceExisting` is true, and
|
|
43
|
+
then emits `invoice.rendered` after the transaction commits.
|
|
44
|
+
|
|
45
|
+
`invoice.rendered` is an internal service event. Subscribers receive metadata
|
|
46
|
+
only:
|
|
47
|
+
|
|
48
|
+
- `invoiceId`
|
|
49
|
+
- `invoiceStatus`
|
|
50
|
+
- `invoiceType`
|
|
51
|
+
- `renditionId`
|
|
52
|
+
- `format`
|
|
53
|
+
- `storageKey`
|
|
54
|
+
- `contentType`
|
|
55
|
+
- `byteSize`
|
|
56
|
+
- `contentHash`
|
|
57
|
+
|
|
58
|
+
The event does not include rendered document bodies or signed download URLs.
|
|
59
|
+
Subscriber failures do not roll back the rendition write; use a durable job or
|
|
60
|
+
workflow when a downstream reaction needs retries.
|
|
61
|
+
|
|
62
|
+
## Customer-Safe Document Lookup
|
|
63
|
+
|
|
64
|
+
Public finance routes include booking-scoped document lookup for customer
|
|
65
|
+
portal and checkout surfaces:
|
|
66
|
+
|
|
67
|
+
- `GET /v1/public/finance/bookings/:bookingId/documents`
|
|
68
|
+
- `GET /v1/public/finance/bookings/:bookingId/documents/by-reference?reference=...`
|
|
69
|
+
- `GET /v1/public/finance/documents/by-reference?reference=...`
|
|
70
|
+
|
|
71
|
+
Booking-scoped routes require a checkout capability for the requested booking.
|
|
72
|
+
The by-reference variant resolves invoice numbers and payment reference numbers
|
|
73
|
+
only inside that booking, so a valid capability for one booking cannot retrieve
|
|
74
|
+
documents from another booking.
|
|
75
|
+
|
|
76
|
+
## Checkout Collection
|
|
77
|
+
|
|
78
|
+
Finance owns the checkout collection runtime under the `./checkout`,
|
|
79
|
+
`./checkout-routes`, and `./checkout-validation` subpaths. Provider startup is
|
|
80
|
+
injected through payment starters, bank-transfer details are resolved through
|
|
81
|
+
host wiring, and notification delivery stays behind a dispatcher instead of a
|
|
82
|
+
direct package dependency.
|
|
83
|
+
|
|
84
|
+
Mounted Finance routes include:
|
|
85
|
+
|
|
86
|
+
- `POST /v1/public/finance/bookings/:bookingId/collection-plan`
|
|
87
|
+
- `POST /v1/public/finance/bookings/:bookingId/initiate-collection`
|
|
88
|
+
- `POST /v1/public/finance/collections/bootstrap`
|
|
89
|
+
- `GET /v1/admin/finance/bookings/:bookingId/reminder-runs`
|
|
90
|
+
|
|
91
|
+
## Booking Tax Preview
|
|
92
|
+
|
|
93
|
+
Booking creation UIs can show the same tax line that booking finalization will
|
|
94
|
+
persist by mounting the booking-tax extension:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { createBookingTaxHonoExtension } from "@voyant-travel/finance/booking-tax"
|
|
98
|
+
|
|
99
|
+
createApp({
|
|
100
|
+
extensions: [
|
|
101
|
+
createBookingTaxHonoExtension({
|
|
102
|
+
resolveBookingTaxSettings: async (db) => {
|
|
103
|
+
const settings = await getTaxSettings(db)
|
|
104
|
+
return {
|
|
105
|
+
taxPriceMode: settings?.taxPriceMode ?? "inclusive",
|
|
106
|
+
taxPolicyProfileId: settings?.taxPolicyProfileId ?? null,
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
111
|
+
})
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The settings callback is the storage seam. A template can read a singleton
|
|
115
|
+
settings table, KV, environment configuration, or any other deployment-owned
|
|
116
|
+
store, while `@voyant-travel/finance` owns the tax policy rule walker, tax-regime
|
|
117
|
+
lookup, product tax-class fallback, and inclusive/exclusive math.
|
|
118
|
+
|
|
119
|
+
Templates that already mount custom routes can call `mountBookingTaxRoutes(...)`
|
|
120
|
+
from the same entrypoint instead of using the Hono extension.
|
|
121
|
+
|
|
122
|
+
Mounting this route registers:
|
|
123
|
+
|
|
124
|
+
- `GET /v1/admin/bookings/tax-settings`
|
|
125
|
+
- `PATCH /v1/admin/bookings/tax-settings` when `updateBookingTaxSettings` is supplied
|
|
126
|
+
- `POST /v1/admin/bookings/tax-preview`
|
|
127
|
+
|
|
128
|
+
The preview endpoint is consumed by `@voyant-travel/bookings-react` tax-preview
|
|
129
|
+
hooks. Consumers that use the booking-create dialog without mounting the route
|
|
130
|
+
will silently lose tax rows in the dialog summary because the client treats a
|
|
131
|
+
missing preview as "no tax to show".
|
|
132
|
+
|
|
133
|
+
Server-side booking-finalize code can use the same helpers directly:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import {
|
|
137
|
+
computeBookingItemTaxLine,
|
|
138
|
+
loadProductTaxFacts,
|
|
139
|
+
resolveBookingSellTaxRate,
|
|
140
|
+
} from "@voyant-travel/finance/booking-tax"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Invoice FX Settings
|
|
144
|
+
|
|
145
|
+
Invoice issuing can enrich `invoice.issued` events with operator accounting
|
|
146
|
+
currency, FX rate, FX commission, and effective provider rate. Configure the
|
|
147
|
+
finance module with `invoiceFxSettings` or `resolveInvoiceFxSettings`, plus an
|
|
148
|
+
exchange-rate resolver:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import {
|
|
152
|
+
createFinanceHonoModule,
|
|
153
|
+
createVoyantDataFxExchangeRateResolver,
|
|
154
|
+
} from "@voyant-travel/finance"
|
|
155
|
+
|
|
156
|
+
createFinanceHonoModule({
|
|
157
|
+
invoiceFxSettings: {
|
|
158
|
+
baseCurrency: "RON",
|
|
159
|
+
fxCommissionBps: 200,
|
|
160
|
+
fxCommissionInvoiceMention: "2% comision curs risc valutar",
|
|
161
|
+
},
|
|
162
|
+
resolveInvoiceExchangeRate: createVoyantDataFxExchangeRateResolver({
|
|
163
|
+
apiKey: process.env.VOYANT_DATA_API_KEY!,
|
|
164
|
+
}),
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The default data resolver uses `@voyant-travel/data-sdk` to call the Voyant Data FX
|
|
169
|
+
pair route `/data/fx/v1/fx/pair/{invoiceCurrency}/{baseCurrency}`. SDK
|
|
170
|
+
responses can add provenance metadata such as `source`, `quotedAt`, and
|
|
171
|
+
`validUntil`; invoice-issued events expose those as `fxRateSource`,
|
|
172
|
+
`fxRateQuotedAt`, and `fxRateValidUntil`. If the invoice currency matches the
|
|
173
|
+
operator base currency, no FX fields are emitted.
|
|
174
|
+
|
|
175
|
+
The same resolver also backs `GET /v1/finance/invoice-fx-rate`, which lets
|
|
176
|
+
operator UI surfaces auto-fill cross-currency payment rates without exposing
|
|
177
|
+
the Voyant Cloud API key to the browser.
|
|
178
|
+
|
|
179
|
+
## Exports
|
|
180
|
+
|
|
181
|
+
| Entry | Description |
|
|
182
|
+
| --- | --- |
|
|
183
|
+
| `.` | Module export |
|
|
184
|
+
| `./invoice-fx` | Invoice FX settings, route helpers, and data FX resolver |
|
|
185
|
+
| `./schema` | Drizzle tables |
|
|
186
|
+
| `./validation` | Zod schemas |
|
|
187
|
+
| `./booking-tax` | Booking sell-side tax policy helpers and route mounting |
|
|
188
|
+
| `./routes` | Hono routes |
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
Apache-2.0
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AnyDrizzleDb } from "@voyant-travel/db";
|
|
2
|
+
import { type SQL } from "drizzle-orm";
|
|
3
|
+
export type FinanceActionLedgerDriftCheck = "invoice" | "payment" | "payment_session";
|
|
4
|
+
export interface CheckFinanceActionLedgerDriftInput {
|
|
5
|
+
createdAtFrom?: Date | string | null;
|
|
6
|
+
sampleLimit?: number | null;
|
|
7
|
+
}
|
|
8
|
+
export interface FinanceActionLedgerDriftRow {
|
|
9
|
+
check: FinanceActionLedgerDriftCheck;
|
|
10
|
+
missingCount: number;
|
|
11
|
+
sampleIds: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface CheckFinanceActionLedgerDriftResult {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
rows: FinanceActionLedgerDriftRow[];
|
|
16
|
+
}
|
|
17
|
+
interface FinanceActionLedgerDriftQueryRow extends Record<string, unknown> {
|
|
18
|
+
check: FinanceActionLedgerDriftCheck;
|
|
19
|
+
missing_count: number | string;
|
|
20
|
+
sample_ids: string[] | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function buildFinanceActionLedgerDriftQueries(input?: CheckFinanceActionLedgerDriftInput): Record<FinanceActionLedgerDriftCheck, SQL<FinanceActionLedgerDriftQueryRow>>;
|
|
23
|
+
export declare function checkFinanceActionLedgerDrift(db: AnyDrizzleDb, input?: CheckFinanceActionLedgerDriftInput): Promise<CheckFinanceActionLedgerDriftResult>;
|
|
24
|
+
declare function normalizeRow(row: FinanceActionLedgerDriftQueryRow): FinanceActionLedgerDriftRow;
|
|
25
|
+
export declare const __test__: {
|
|
26
|
+
normalizeRow: typeof normalizeRow;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=action-ledger-drift.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-ledger-drift.d.ts","sourceRoot":"","sources":["../src/action-ledger-drift.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,KAAK,GAAG,EAAwB,MAAM,aAAa,CAAA;AAmB5D,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,iBAAiB,CAAA;AAErF,MAAM,WAAW,kCAAkC;IACjD,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IACpC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,6BAA6B,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,mCAAmC;IAClD,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,2BAA2B,EAAE,CAAA;CACpC;AAED,UAAU,gCAAiC,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxE,KAAK,EAAE,6BAA6B,CAAA;IACpC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAC9B,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAC5B;AAED,wBAAgB,oCAAoC,CAClD,KAAK,GAAE,kCAAuC,GAC7C,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,gCAAgC,CAAC,CAAC,CA0G9E;AAED,wBAAsB,6BAA6B,CACjD,EAAE,EAAE,YAAY,EAChB,KAAK,GAAE,kCAAuC,GAC7C,OAAO,CAAC,mCAAmC,CAAC,CAe9C;AA0BD,iBAAS,YAAY,CAAC,GAAG,EAAE,gCAAgC,GAAG,2BAA2B,CAMxF;AAED,eAAO,MAAM,QAAQ;;CAEpB,CAAA"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { actionLedgerEntries } from "@voyant-travel/action-ledger/schema";
|
|
2
|
+
import { sql } from "drizzle-orm";
|
|
3
|
+
import { invoices, paymentSessions, payments } from "./schema.js";
|
|
4
|
+
const DEFAULT_SAMPLE_LIMIT = 20;
|
|
5
|
+
const MAX_SAMPLE_LIMIT = 100;
|
|
6
|
+
const INVOICE_ISSUE_ACTION_NAME = "finance.invoice.issue_from_booking";
|
|
7
|
+
const PAYMENT_RECORD_ACTION_NAME = "finance.payment.record";
|
|
8
|
+
const PAYMENT_SESSION_ACTION_NAMES = [
|
|
9
|
+
"finance.payment_session.create",
|
|
10
|
+
"finance.payment_session.complete",
|
|
11
|
+
"finance.payment_session.update",
|
|
12
|
+
"finance.payment_session.requires_redirect",
|
|
13
|
+
"finance.payment_session.fail",
|
|
14
|
+
"finance.payment_session.cancel",
|
|
15
|
+
"finance.payment_session.expire",
|
|
16
|
+
];
|
|
17
|
+
export function buildFinanceActionLedgerDriftQueries(input = {}) {
|
|
18
|
+
const sampleLimit = normalizeSampleLimit(input.sampleLimit);
|
|
19
|
+
return {
|
|
20
|
+
invoice: sql `
|
|
21
|
+
SELECT
|
|
22
|
+
'invoice' AS check,
|
|
23
|
+
count(*)::int AS missing_count,
|
|
24
|
+
coalesce(
|
|
25
|
+
array_agg(candidate_id ORDER BY created_at DESC, candidate_id DESC)
|
|
26
|
+
FILTER (WHERE sample_ordinal <= ${sampleLimit}),
|
|
27
|
+
ARRAY[]::text[]
|
|
28
|
+
) AS sample_ids
|
|
29
|
+
FROM (
|
|
30
|
+
SELECT
|
|
31
|
+
${invoices.id} AS candidate_id,
|
|
32
|
+
${invoices.createdAt} AS created_at,
|
|
33
|
+
row_number() OVER (ORDER BY ${invoices.createdAt} DESC, ${invoices.id} DESC) AS sample_ordinal
|
|
34
|
+
FROM ${invoices}
|
|
35
|
+
WHERE ${invoices.status} <> ${"draft"}
|
|
36
|
+
${buildCreatedAtCondition(invoices.createdAt, input.createdAtFrom)}
|
|
37
|
+
AND NOT EXISTS (
|
|
38
|
+
SELECT 1
|
|
39
|
+
FROM ${actionLedgerEntries}
|
|
40
|
+
WHERE ${actionLedgerEntries.actionName} = ${INVOICE_ISSUE_ACTION_NAME}
|
|
41
|
+
AND ${actionLedgerEntries.targetType} = ${"booking"}
|
|
42
|
+
AND ${actionLedgerEntries.targetId} = ${invoices.bookingId}
|
|
43
|
+
)
|
|
44
|
+
) missing
|
|
45
|
+
`,
|
|
46
|
+
payment: sql `
|
|
47
|
+
SELECT
|
|
48
|
+
'payment' AS check,
|
|
49
|
+
count(*)::int AS missing_count,
|
|
50
|
+
coalesce(
|
|
51
|
+
array_agg(candidate_id ORDER BY created_at DESC, candidate_id DESC)
|
|
52
|
+
FILTER (WHERE sample_ordinal <= ${sampleLimit}),
|
|
53
|
+
ARRAY[]::text[]
|
|
54
|
+
) AS sample_ids
|
|
55
|
+
FROM (
|
|
56
|
+
SELECT
|
|
57
|
+
${payments.id} AS candidate_id,
|
|
58
|
+
${payments.createdAt} AS created_at,
|
|
59
|
+
row_number() OVER (ORDER BY ${payments.createdAt} DESC, ${payments.id} DESC) AS sample_ordinal
|
|
60
|
+
FROM ${payments}
|
|
61
|
+
INNER JOIN ${invoices} ON ${invoices.id} = ${payments.invoiceId}
|
|
62
|
+
WHERE 1 = 1
|
|
63
|
+
${buildCreatedAtCondition(payments.createdAt, input.createdAtFrom)}
|
|
64
|
+
AND NOT EXISTS (
|
|
65
|
+
SELECT 1
|
|
66
|
+
FROM ${actionLedgerEntries}
|
|
67
|
+
WHERE ${actionLedgerEntries.actionName} = ${PAYMENT_RECORD_ACTION_NAME}
|
|
68
|
+
AND ${actionLedgerEntries.targetType} = ${"booking"}
|
|
69
|
+
AND ${actionLedgerEntries.targetId} = ${invoices.bookingId}
|
|
70
|
+
)
|
|
71
|
+
) missing
|
|
72
|
+
`,
|
|
73
|
+
payment_session: sql `
|
|
74
|
+
SELECT
|
|
75
|
+
'payment_session' AS check,
|
|
76
|
+
count(*)::int AS missing_count,
|
|
77
|
+
coalesce(
|
|
78
|
+
array_agg(candidate_id ORDER BY created_at DESC, candidate_id DESC)
|
|
79
|
+
FILTER (WHERE sample_ordinal <= ${sampleLimit}),
|
|
80
|
+
ARRAY[]::text[]
|
|
81
|
+
) AS sample_ids
|
|
82
|
+
FROM (
|
|
83
|
+
SELECT
|
|
84
|
+
${paymentSessions.id} AS candidate_id,
|
|
85
|
+
${paymentSessions.createdAt} AS created_at,
|
|
86
|
+
row_number() OVER (
|
|
87
|
+
ORDER BY ${paymentSessions.createdAt} DESC, ${paymentSessions.id} DESC
|
|
88
|
+
) AS sample_ordinal
|
|
89
|
+
FROM ${paymentSessions}
|
|
90
|
+
WHERE 1 = 1
|
|
91
|
+
${buildCreatedAtCondition(paymentSessions.createdAt, input.createdAtFrom)}
|
|
92
|
+
AND NOT EXISTS (
|
|
93
|
+
SELECT 1
|
|
94
|
+
FROM ${actionLedgerEntries}
|
|
95
|
+
WHERE ${actionLedgerEntries.actionName} IN (${sql.join(
|
|
96
|
+
// agent-quality: raw-sql reviewed -- owner: finance; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
|
|
97
|
+
PAYMENT_SESSION_ACTION_NAMES.map((actionName) => sql `${actionName}`), sql `, `)})
|
|
98
|
+
AND ${actionLedgerEntries.targetType} = CASE
|
|
99
|
+
WHEN ${paymentSessions.bookingId} IS NOT NULL THEN ${"booking"}
|
|
100
|
+
WHEN ${paymentSessions.invoiceId} IS NOT NULL THEN ${"invoice"}
|
|
101
|
+
WHEN ${paymentSessions.orderId} IS NOT NULL THEN ${"order"}
|
|
102
|
+
WHEN ${paymentSessions.targetId} IS NOT NULL
|
|
103
|
+
AND ${paymentSessions.targetType} <> ${"other"}
|
|
104
|
+
THEN ${paymentSessions.targetType}
|
|
105
|
+
ELSE ${"payment_session"}
|
|
106
|
+
END
|
|
107
|
+
AND ${actionLedgerEntries.targetId} = CASE
|
|
108
|
+
WHEN ${paymentSessions.bookingId} IS NOT NULL THEN ${paymentSessions.bookingId}
|
|
109
|
+
WHEN ${paymentSessions.invoiceId} IS NOT NULL THEN ${paymentSessions.invoiceId}
|
|
110
|
+
WHEN ${paymentSessions.orderId} IS NOT NULL THEN ${paymentSessions.orderId}
|
|
111
|
+
WHEN ${paymentSessions.targetId} IS NOT NULL
|
|
112
|
+
AND ${paymentSessions.targetType} <> ${"other"}
|
|
113
|
+
THEN ${paymentSessions.targetId}
|
|
114
|
+
ELSE ${paymentSessions.id}
|
|
115
|
+
END
|
|
116
|
+
)
|
|
117
|
+
) missing
|
|
118
|
+
`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export async function checkFinanceActionLedgerDrift(db, input = {}) {
|
|
122
|
+
const queries = buildFinanceActionLedgerDriftQueries(input);
|
|
123
|
+
const results = await Promise.all([
|
|
124
|
+
db.execute(queries.invoice),
|
|
125
|
+
db.execute(queries.payment),
|
|
126
|
+
db.execute(queries.payment_session),
|
|
127
|
+
]);
|
|
128
|
+
const rows = results
|
|
129
|
+
.flatMap((result) => extractRows(result))
|
|
130
|
+
.map((row) => normalizeRow(row));
|
|
131
|
+
return {
|
|
132
|
+
ok: rows.every((row) => row.missingCount === 0),
|
|
133
|
+
rows,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function normalizeSampleLimit(limit) {
|
|
137
|
+
if (!limit)
|
|
138
|
+
return DEFAULT_SAMPLE_LIMIT;
|
|
139
|
+
return Math.min(Math.max(Math.trunc(limit), 1), MAX_SAMPLE_LIMIT);
|
|
140
|
+
}
|
|
141
|
+
function buildCreatedAtCondition(column, value) {
|
|
142
|
+
if (!value)
|
|
143
|
+
return sql ``;
|
|
144
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
145
|
+
if (Number.isNaN(date.getTime())) {
|
|
146
|
+
throw new Error("createdAtFrom must be a valid date");
|
|
147
|
+
}
|
|
148
|
+
// agent-quality: raw-sql reviewed -- owner: finance; dynamic SQL interpolation uses Drizzle parameter binding or vetted SQL identifiers.
|
|
149
|
+
return sql `AND ${column} >= ${date}`;
|
|
150
|
+
}
|
|
151
|
+
function extractRows(result) {
|
|
152
|
+
if (Array.isArray(result))
|
|
153
|
+
return result;
|
|
154
|
+
const maybeRows = result.rows;
|
|
155
|
+
return Array.isArray(maybeRows) ? maybeRows : [];
|
|
156
|
+
}
|
|
157
|
+
function normalizeRow(row) {
|
|
158
|
+
return {
|
|
159
|
+
check: row.check,
|
|
160
|
+
missingCount: Number(row.missing_count),
|
|
161
|
+
sampleIds: row.sample_ids ?? [],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export const __test__ = {
|
|
165
|
+
normalizeRow,
|
|
166
|
+
};
|