@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,106 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
export interface AccountantShareScope {
|
|
3
|
+
from: string | null;
|
|
4
|
+
to: string | null;
|
|
5
|
+
baseCurrency: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface AccountantShareRecord extends AccountantShareScope {
|
|
8
|
+
id: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
expiresAt: string;
|
|
11
|
+
lastAccessedAt: string | null;
|
|
12
|
+
accessCount: number;
|
|
13
|
+
}
|
|
14
|
+
export interface AccountantInvoiceAttachment {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
mimeType: string | null;
|
|
18
|
+
fileSize: number | null;
|
|
19
|
+
hasFile: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type AccountantInvoiceKind = "client" | "supplier";
|
|
22
|
+
export interface AccountantInvoiceRecord {
|
|
23
|
+
id: string;
|
|
24
|
+
kind: AccountantInvoiceKind;
|
|
25
|
+
invoiceNumber: string;
|
|
26
|
+
status: string;
|
|
27
|
+
currency: string;
|
|
28
|
+
totalCents: number;
|
|
29
|
+
paidCents: number;
|
|
30
|
+
balanceDueCents: number;
|
|
31
|
+
issueDate: string;
|
|
32
|
+
dueDate: string | null;
|
|
33
|
+
attachments: AccountantInvoiceAttachment[];
|
|
34
|
+
}
|
|
35
|
+
export type AccountantShareResolution = {
|
|
36
|
+
status: "ready";
|
|
37
|
+
grantId: string;
|
|
38
|
+
scope: AccountantShareScope;
|
|
39
|
+
} | {
|
|
40
|
+
status: "not_found";
|
|
41
|
+
} | {
|
|
42
|
+
status: "gone";
|
|
43
|
+
};
|
|
44
|
+
export declare const accountantSharesService: {
|
|
45
|
+
create(db: PostgresJsDatabase, input: {
|
|
46
|
+
from?: string | null;
|
|
47
|
+
to?: string | null;
|
|
48
|
+
baseCurrency?: string | null;
|
|
49
|
+
ttlDays?: number | null;
|
|
50
|
+
}, ctx: {
|
|
51
|
+
publicBaseUrl: string;
|
|
52
|
+
userId?: string | null;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
from: string | null;
|
|
55
|
+
to: string | null;
|
|
56
|
+
baseCurrency: string | null;
|
|
57
|
+
id: string;
|
|
58
|
+
url: string;
|
|
59
|
+
expiresAt: string | null;
|
|
60
|
+
}>;
|
|
61
|
+
list(db: PostgresJsDatabase): Promise<AccountantShareRecord[]>;
|
|
62
|
+
revoke(db: PostgresJsDatabase, id: string, userId?: string | null): Promise<{
|
|
63
|
+
id: string;
|
|
64
|
+
createdAt: Date;
|
|
65
|
+
metadata: unknown;
|
|
66
|
+
expiresAt: Date;
|
|
67
|
+
filename: string | null;
|
|
68
|
+
contentType: string;
|
|
69
|
+
storageKey: string;
|
|
70
|
+
tokenHash: string;
|
|
71
|
+
storageProvider: string | null;
|
|
72
|
+
sourceModule: string | null;
|
|
73
|
+
sourceEntity: string | null;
|
|
74
|
+
sourceId: string | null;
|
|
75
|
+
createdBy: string | null;
|
|
76
|
+
createdByType: string | null;
|
|
77
|
+
accessCount: number;
|
|
78
|
+
lastAccessedAt: Date | null;
|
|
79
|
+
lastAccessedIp: string | null;
|
|
80
|
+
lastAccessedUserAgent: string | null;
|
|
81
|
+
revokedAt: Date | null;
|
|
82
|
+
revokedBy: string | null;
|
|
83
|
+
} | null>;
|
|
84
|
+
resolve(db: PostgresJsDatabase, token: string): Promise<AccountantShareResolution>;
|
|
85
|
+
recordAccess(db: PostgresJsDatabase, grantId: string, ctx: {
|
|
86
|
+
ip?: string | null;
|
|
87
|
+
userAgent?: string | null;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/** Customer (AR) + supplier (AP) invoices in the scope window, with attachments. */
|
|
90
|
+
getInvoicesWithAttachments(db: PostgresJsDatabase, scope: AccountantShareScope): Promise<AccountantInvoiceRecord[]>;
|
|
91
|
+
/** Resolve a single attachment for download, enforcing it sits within scope. */
|
|
92
|
+
getAttachmentForDownload(db: PostgresJsDatabase, scope: AccountantShareScope, kind: AccountantInvoiceKind, invoiceId: string, attachmentId: string): Promise<{
|
|
93
|
+
storageKey: string;
|
|
94
|
+
name: string;
|
|
95
|
+
mimeType: string | null;
|
|
96
|
+
} | null>;
|
|
97
|
+
/** Every in-scope invoice attachment that has a stored file, for bulk ZIP. */
|
|
98
|
+
listAttachmentsForZip(db: PostgresJsDatabase, scope: AccountantShareScope): Promise<Array<{
|
|
99
|
+
kind: AccountantInvoiceKind;
|
|
100
|
+
invoiceNumber: string;
|
|
101
|
+
name: string;
|
|
102
|
+
storageKey: string;
|
|
103
|
+
}>>;
|
|
104
|
+
};
|
|
105
|
+
export declare function buildAccountantInvoicesCsv(rows: AccountantInvoiceRecord[]): string;
|
|
106
|
+
//# sourceMappingURL=service-accountant-shares.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-accountant-shares.d.ts","sourceRoot":"","sources":["../src/service-accountant-shares.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAuBjE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,UAAU,CAAA;AAEzD,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,qBAAqB,CAAA;IAC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M,GAAG,IAAI,CAAA;KAAE;IAUxD,oFAAoF;mCAE9E,kBAAkB,SACf,oBAAoB,GAC1B,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAgIrC,gFAAgF;iCAE1E,kBAAkB,SACf,oBAAoB,QACrB,qBAAqB,aAChB,MAAM,gBACH,MAAM,GACnB,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAkDhF,8EAA8E;8BAExE,kBAAkB,SACf,oBAAoB,GAC1B,OAAO,CACR,KAAK,CAAC;QAAE,IAAI,EAAE,qBAAqB,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAChG;CAmDF,CAAA;AASD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,EAAE,GAAG,MAAM,CA4BlF"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { infraPublicDocumentDeliveryGrantsTable } from "@voyant-travel/db/schema/infra";
|
|
2
|
+
import { createDrizzlePublicDocumentDeliveryGrantStore, createPublicDocumentDeliveryGrant, resolvePublicDocumentDeliveryGrant, revokePublicDocumentDeliveryGrant, } from "@voyant-travel/hono";
|
|
3
|
+
import { and, desc, eq, gte, inArray, isNotNull, isNull, lte, ne } from "drizzle-orm";
|
|
4
|
+
import { invoiceAttachments, invoices, supplierInvoiceAttachments, supplierInvoices, } from "./schema.js";
|
|
5
|
+
/**
|
|
6
|
+
* Accountant shares — a revocable, TTL'd, audited public link that opens a
|
|
7
|
+
* read-only finance portal scoped to a date range (RFC §13.2). Built on the
|
|
8
|
+
* generic `public_document_delivery_grants` token store: we mint a grant tagged
|
|
9
|
+
* `finance/accountant-share` whose `metadata` carries the period scope. The
|
|
10
|
+
* portal validates the token, reads the scope, and serves profitability +
|
|
11
|
+
* invoices for that window. No login; the token is the credential.
|
|
12
|
+
*/
|
|
13
|
+
const SOURCE_MODULE = "finance";
|
|
14
|
+
const SOURCE_ENTITY = "accountant-share";
|
|
15
|
+
const SHARE_SENTINEL_STORAGE_KEY = "accountant-share";
|
|
16
|
+
const DEFAULT_TTL_DAYS = 30;
|
|
17
|
+
function scopeFromMetadata(metadata) {
|
|
18
|
+
const m = (metadata ?? {});
|
|
19
|
+
return {
|
|
20
|
+
from: typeof m.from === "string" ? m.from : null,
|
|
21
|
+
to: typeof m.to === "string" ? m.to : null,
|
|
22
|
+
baseCurrency: typeof m.baseCurrency === "string" ? m.baseCurrency : null,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function toIso(value) {
|
|
26
|
+
if (value == null)
|
|
27
|
+
return null;
|
|
28
|
+
return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
|
|
29
|
+
}
|
|
30
|
+
export const accountantSharesService = {
|
|
31
|
+
async create(db, input, ctx) {
|
|
32
|
+
const store = createDrizzlePublicDocumentDeliveryGrantStore(db);
|
|
33
|
+
const scope = {
|
|
34
|
+
from: input.from?.trim() || null,
|
|
35
|
+
to: input.to?.trim() || null,
|
|
36
|
+
baseCurrency: input.baseCurrency?.trim().toUpperCase() || null,
|
|
37
|
+
};
|
|
38
|
+
const ttlDays = input.ttlDays && input.ttlDays > 0 ? input.ttlDays : DEFAULT_TTL_DAYS;
|
|
39
|
+
const envelope = await createPublicDocumentDeliveryGrant(store, {
|
|
40
|
+
storageKey: SHARE_SENTINEL_STORAGE_KEY,
|
|
41
|
+
publicBaseUrl: ctx.publicBaseUrl,
|
|
42
|
+
publicPath: "/accountant",
|
|
43
|
+
ttlSeconds: ttlDays * 24 * 60 * 60,
|
|
44
|
+
contentType: "application/json",
|
|
45
|
+
source: { module: SOURCE_MODULE, entity: SOURCE_ENTITY, id: null },
|
|
46
|
+
metadata: scope,
|
|
47
|
+
createdBy: ctx.userId ?? null,
|
|
48
|
+
createdByType: "staff",
|
|
49
|
+
});
|
|
50
|
+
return { id: envelope.grantId, url: envelope.url, expiresAt: envelope.expiresAt, ...scope };
|
|
51
|
+
},
|
|
52
|
+
async list(db) {
|
|
53
|
+
const rows = await db
|
|
54
|
+
.select()
|
|
55
|
+
.from(infraPublicDocumentDeliveryGrantsTable)
|
|
56
|
+
.where(and(eq(infraPublicDocumentDeliveryGrantsTable.sourceEntity, SOURCE_ENTITY), isNull(infraPublicDocumentDeliveryGrantsTable.revokedAt)))
|
|
57
|
+
.orderBy(desc(infraPublicDocumentDeliveryGrantsTable.createdAt));
|
|
58
|
+
return rows.map((row) => ({
|
|
59
|
+
id: row.id,
|
|
60
|
+
...scopeFromMetadata(row.metadata),
|
|
61
|
+
createdAt: toIso(row.createdAt) ?? "",
|
|
62
|
+
expiresAt: toIso(row.expiresAt) ?? "",
|
|
63
|
+
lastAccessedAt: toIso(row.lastAccessedAt),
|
|
64
|
+
accessCount: row.accessCount,
|
|
65
|
+
}));
|
|
66
|
+
},
|
|
67
|
+
async revoke(db, id, userId) {
|
|
68
|
+
const store = createDrizzlePublicDocumentDeliveryGrantStore(db);
|
|
69
|
+
return revokePublicDocumentDeliveryGrant(store, { id, revokedBy: userId ?? null });
|
|
70
|
+
},
|
|
71
|
+
async resolve(db, token) {
|
|
72
|
+
const store = createDrizzlePublicDocumentDeliveryGrantStore(db);
|
|
73
|
+
const resolution = await resolvePublicDocumentDeliveryGrant(store, token);
|
|
74
|
+
if (resolution.status === "not_found")
|
|
75
|
+
return { status: "not_found" };
|
|
76
|
+
if (resolution.status !== "ready")
|
|
77
|
+
return { status: "gone" };
|
|
78
|
+
if (resolution.grant.sourceEntity !== SOURCE_ENTITY)
|
|
79
|
+
return { status: "not_found" };
|
|
80
|
+
return {
|
|
81
|
+
status: "ready",
|
|
82
|
+
grantId: resolution.grant.id,
|
|
83
|
+
scope: scopeFromMetadata(resolution.grant.metadata),
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
async recordAccess(db, grantId, ctx) {
|
|
87
|
+
const store = createDrizzlePublicDocumentDeliveryGrantStore(db);
|
|
88
|
+
await store.recordAccess(grantId, {
|
|
89
|
+
accessedAt: new Date(),
|
|
90
|
+
ip: ctx.ip ?? null,
|
|
91
|
+
userAgent: ctx.userAgent ?? null,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
/** Customer (AR) + supplier (AP) invoices in the scope window, with attachments. */
|
|
95
|
+
async getInvoicesWithAttachments(db, scope) {
|
|
96
|
+
const clientConditions = [ne(invoices.status, "void"), ne(invoices.invoiceType, "proforma")];
|
|
97
|
+
if (scope.from)
|
|
98
|
+
clientConditions.push(gte(invoices.issueDate, scope.from));
|
|
99
|
+
if (scope.to)
|
|
100
|
+
clientConditions.push(lte(invoices.issueDate, scope.to));
|
|
101
|
+
const supplierConditions = [
|
|
102
|
+
ne(supplierInvoices.status, "void"),
|
|
103
|
+
isNull(supplierInvoices.deletedAt),
|
|
104
|
+
];
|
|
105
|
+
if (scope.from)
|
|
106
|
+
supplierConditions.push(gte(supplierInvoices.issueDate, scope.from));
|
|
107
|
+
if (scope.to)
|
|
108
|
+
supplierConditions.push(lte(supplierInvoices.issueDate, scope.to));
|
|
109
|
+
const [clientRows, supplierRows] = await Promise.all([
|
|
110
|
+
db
|
|
111
|
+
.select({
|
|
112
|
+
id: invoices.id,
|
|
113
|
+
invoiceNumber: invoices.invoiceNumber,
|
|
114
|
+
status: invoices.status,
|
|
115
|
+
currency: invoices.currency,
|
|
116
|
+
totalCents: invoices.totalCents,
|
|
117
|
+
paidCents: invoices.paidCents,
|
|
118
|
+
balanceDueCents: invoices.balanceDueCents,
|
|
119
|
+
issueDate: invoices.issueDate,
|
|
120
|
+
dueDate: invoices.dueDate,
|
|
121
|
+
})
|
|
122
|
+
.from(invoices)
|
|
123
|
+
.where(and(...clientConditions)),
|
|
124
|
+
db
|
|
125
|
+
.select({
|
|
126
|
+
id: supplierInvoices.id,
|
|
127
|
+
invoiceNumber: supplierInvoices.supplierInvoiceNo,
|
|
128
|
+
status: supplierInvoices.status,
|
|
129
|
+
currency: supplierInvoices.currency,
|
|
130
|
+
totalCents: supplierInvoices.totalCents,
|
|
131
|
+
paidCents: supplierInvoices.paidCents,
|
|
132
|
+
balanceDueCents: supplierInvoices.balanceDueCents,
|
|
133
|
+
issueDate: supplierInvoices.issueDate,
|
|
134
|
+
dueDate: supplierInvoices.dueDate,
|
|
135
|
+
})
|
|
136
|
+
.from(supplierInvoices)
|
|
137
|
+
.where(and(...supplierConditions)),
|
|
138
|
+
]);
|
|
139
|
+
const [clientAttachments, supplierAttachments] = await Promise.all([
|
|
140
|
+
clientRows.length
|
|
141
|
+
? db
|
|
142
|
+
.select({
|
|
143
|
+
id: invoiceAttachments.id,
|
|
144
|
+
parentId: invoiceAttachments.invoiceId,
|
|
145
|
+
name: invoiceAttachments.name,
|
|
146
|
+
mimeType: invoiceAttachments.mimeType,
|
|
147
|
+
fileSize: invoiceAttachments.fileSize,
|
|
148
|
+
storageKey: invoiceAttachments.storageKey,
|
|
149
|
+
})
|
|
150
|
+
.from(invoiceAttachments)
|
|
151
|
+
.where(inArray(invoiceAttachments.invoiceId, clientRows.map((row) => row.id)))
|
|
152
|
+
: Promise.resolve([]),
|
|
153
|
+
supplierRows.length
|
|
154
|
+
? db
|
|
155
|
+
.select({
|
|
156
|
+
id: supplierInvoiceAttachments.id,
|
|
157
|
+
parentId: supplierInvoiceAttachments.supplierInvoiceId,
|
|
158
|
+
name: supplierInvoiceAttachments.name,
|
|
159
|
+
mimeType: supplierInvoiceAttachments.mimeType,
|
|
160
|
+
fileSize: supplierInvoiceAttachments.fileSize,
|
|
161
|
+
storageKey: supplierInvoiceAttachments.storageKey,
|
|
162
|
+
})
|
|
163
|
+
.from(supplierInvoiceAttachments)
|
|
164
|
+
.where(inArray(supplierInvoiceAttachments.supplierInvoiceId, supplierRows.map((row) => row.id)))
|
|
165
|
+
: Promise.resolve([]),
|
|
166
|
+
]);
|
|
167
|
+
const groupAttachments = (rows) => {
|
|
168
|
+
const map = new Map();
|
|
169
|
+
for (const att of rows) {
|
|
170
|
+
const list = map.get(att.parentId) ?? [];
|
|
171
|
+
list.push({
|
|
172
|
+
id: att.id,
|
|
173
|
+
name: att.name,
|
|
174
|
+
mimeType: att.mimeType,
|
|
175
|
+
fileSize: att.fileSize,
|
|
176
|
+
hasFile: Boolean(att.storageKey),
|
|
177
|
+
});
|
|
178
|
+
map.set(att.parentId, list);
|
|
179
|
+
}
|
|
180
|
+
return map;
|
|
181
|
+
};
|
|
182
|
+
const clientByInvoice = groupAttachments(clientAttachments);
|
|
183
|
+
const supplierByInvoice = groupAttachments(supplierAttachments);
|
|
184
|
+
const records = [
|
|
185
|
+
...clientRows.map((row) => ({
|
|
186
|
+
...row,
|
|
187
|
+
kind: "client",
|
|
188
|
+
attachments: clientByInvoice.get(row.id) ?? [],
|
|
189
|
+
})),
|
|
190
|
+
...supplierRows.map((row) => ({
|
|
191
|
+
...row,
|
|
192
|
+
kind: "supplier",
|
|
193
|
+
attachments: supplierByInvoice.get(row.id) ?? [],
|
|
194
|
+
})),
|
|
195
|
+
];
|
|
196
|
+
records.sort((a, b) => b.issueDate.localeCompare(a.issueDate) || a.invoiceNumber.localeCompare(b.invoiceNumber));
|
|
197
|
+
return records;
|
|
198
|
+
},
|
|
199
|
+
/** Resolve a single attachment for download, enforcing it sits within scope. */
|
|
200
|
+
async getAttachmentForDownload(db, scope, kind, invoiceId, attachmentId) {
|
|
201
|
+
if (kind === "supplier") {
|
|
202
|
+
const conditions = [
|
|
203
|
+
eq(supplierInvoiceAttachments.id, attachmentId),
|
|
204
|
+
eq(supplierInvoiceAttachments.supplierInvoiceId, invoiceId),
|
|
205
|
+
ne(supplierInvoices.status, "void"),
|
|
206
|
+
isNull(supplierInvoices.deletedAt),
|
|
207
|
+
];
|
|
208
|
+
if (scope.from)
|
|
209
|
+
conditions.push(gte(supplierInvoices.issueDate, scope.from));
|
|
210
|
+
if (scope.to)
|
|
211
|
+
conditions.push(lte(supplierInvoices.issueDate, scope.to));
|
|
212
|
+
const [row] = await db
|
|
213
|
+
.select({
|
|
214
|
+
storageKey: supplierInvoiceAttachments.storageKey,
|
|
215
|
+
name: supplierInvoiceAttachments.name,
|
|
216
|
+
mimeType: supplierInvoiceAttachments.mimeType,
|
|
217
|
+
})
|
|
218
|
+
.from(supplierInvoiceAttachments)
|
|
219
|
+
.innerJoin(supplierInvoices, eq(supplierInvoiceAttachments.supplierInvoiceId, supplierInvoices.id))
|
|
220
|
+
.where(and(...conditions))
|
|
221
|
+
.limit(1);
|
|
222
|
+
if (!row?.storageKey)
|
|
223
|
+
return null;
|
|
224
|
+
return { storageKey: row.storageKey, name: row.name, mimeType: row.mimeType };
|
|
225
|
+
}
|
|
226
|
+
const conditions = [
|
|
227
|
+
eq(invoiceAttachments.id, attachmentId),
|
|
228
|
+
eq(invoiceAttachments.invoiceId, invoiceId),
|
|
229
|
+
ne(invoices.status, "void"),
|
|
230
|
+
];
|
|
231
|
+
if (scope.from)
|
|
232
|
+
conditions.push(gte(invoices.issueDate, scope.from));
|
|
233
|
+
if (scope.to)
|
|
234
|
+
conditions.push(lte(invoices.issueDate, scope.to));
|
|
235
|
+
const [row] = await db
|
|
236
|
+
.select({
|
|
237
|
+
storageKey: invoiceAttachments.storageKey,
|
|
238
|
+
name: invoiceAttachments.name,
|
|
239
|
+
mimeType: invoiceAttachments.mimeType,
|
|
240
|
+
})
|
|
241
|
+
.from(invoiceAttachments)
|
|
242
|
+
.innerJoin(invoices, eq(invoiceAttachments.invoiceId, invoices.id))
|
|
243
|
+
.where(and(...conditions))
|
|
244
|
+
.limit(1);
|
|
245
|
+
if (!row?.storageKey)
|
|
246
|
+
return null;
|
|
247
|
+
return { storageKey: row.storageKey, name: row.name, mimeType: row.mimeType };
|
|
248
|
+
},
|
|
249
|
+
/** Every in-scope invoice attachment that has a stored file, for bulk ZIP. */
|
|
250
|
+
async listAttachmentsForZip(db, scope) {
|
|
251
|
+
const clientConditions = [ne(invoices.status, "void"), ne(invoices.invoiceType, "proforma")];
|
|
252
|
+
if (scope.from)
|
|
253
|
+
clientConditions.push(gte(invoices.issueDate, scope.from));
|
|
254
|
+
if (scope.to)
|
|
255
|
+
clientConditions.push(lte(invoices.issueDate, scope.to));
|
|
256
|
+
const supplierConditions = [
|
|
257
|
+
ne(supplierInvoices.status, "void"),
|
|
258
|
+
isNull(supplierInvoices.deletedAt),
|
|
259
|
+
];
|
|
260
|
+
if (scope.from)
|
|
261
|
+
supplierConditions.push(gte(supplierInvoices.issueDate, scope.from));
|
|
262
|
+
if (scope.to)
|
|
263
|
+
supplierConditions.push(lte(supplierInvoices.issueDate, scope.to));
|
|
264
|
+
const [clientRows, supplierRows] = await Promise.all([
|
|
265
|
+
db
|
|
266
|
+
.select({
|
|
267
|
+
invoiceNumber: invoices.invoiceNumber,
|
|
268
|
+
name: invoiceAttachments.name,
|
|
269
|
+
storageKey: invoiceAttachments.storageKey,
|
|
270
|
+
})
|
|
271
|
+
.from(invoiceAttachments)
|
|
272
|
+
.innerJoin(invoices, eq(invoiceAttachments.invoiceId, invoices.id))
|
|
273
|
+
.where(and(...clientConditions, isNotNull(invoiceAttachments.storageKey))),
|
|
274
|
+
db
|
|
275
|
+
.select({
|
|
276
|
+
invoiceNumber: supplierInvoices.supplierInvoiceNo,
|
|
277
|
+
name: supplierInvoiceAttachments.name,
|
|
278
|
+
storageKey: supplierInvoiceAttachments.storageKey,
|
|
279
|
+
})
|
|
280
|
+
.from(supplierInvoiceAttachments)
|
|
281
|
+
.innerJoin(supplierInvoices, eq(supplierInvoiceAttachments.supplierInvoiceId, supplierInvoices.id))
|
|
282
|
+
.where(and(...supplierConditions, isNotNull(supplierInvoiceAttachments.storageKey))),
|
|
283
|
+
]);
|
|
284
|
+
return [
|
|
285
|
+
...clientRows.map((r) => ({
|
|
286
|
+
kind: "client",
|
|
287
|
+
invoiceNumber: r.invoiceNumber,
|
|
288
|
+
name: r.name,
|
|
289
|
+
storageKey: r.storageKey,
|
|
290
|
+
})),
|
|
291
|
+
...supplierRows.map((r) => ({
|
|
292
|
+
kind: "supplier",
|
|
293
|
+
invoiceNumber: r.invoiceNumber,
|
|
294
|
+
name: r.name,
|
|
295
|
+
storageKey: r.storageKey,
|
|
296
|
+
})),
|
|
297
|
+
];
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
// ---------- invoices CSV (accountant export) ----------
|
|
301
|
+
const invCsvField = (value) => {
|
|
302
|
+
const str = value == null ? "" : String(value);
|
|
303
|
+
return /[",\n\r]/.test(str) ? `"${str.replace(/"/g, '""')}"` : str;
|
|
304
|
+
};
|
|
305
|
+
export function buildAccountantInvoicesCsv(rows) {
|
|
306
|
+
const header = [
|
|
307
|
+
"type",
|
|
308
|
+
"invoice_number",
|
|
309
|
+
"status",
|
|
310
|
+
"currency",
|
|
311
|
+
"total",
|
|
312
|
+
"paid",
|
|
313
|
+
"balance_due",
|
|
314
|
+
"issue_date",
|
|
315
|
+
"due_date",
|
|
316
|
+
];
|
|
317
|
+
const body = rows.map((r) => [
|
|
318
|
+
r.kind,
|
|
319
|
+
r.invoiceNumber,
|
|
320
|
+
r.status,
|
|
321
|
+
r.currency,
|
|
322
|
+
(r.totalCents / 100).toFixed(2),
|
|
323
|
+
(r.paidCents / 100).toFixed(2),
|
|
324
|
+
(r.balanceDueCents / 100).toFixed(2),
|
|
325
|
+
r.issueDate,
|
|
326
|
+
r.dueDate ?? "",
|
|
327
|
+
]
|
|
328
|
+
.map(invCsvField)
|
|
329
|
+
.join(","));
|
|
330
|
+
return `${[header.join(","), ...body].join("\r\n")}\r\n`;
|
|
331
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type ActionLedgerRequestContextValues, type BuildActionLedgerMutationInput } from "@voyant-travel/action-ledger";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { creditNoteLineItems, creditNotes, invoiceLineItems, invoices, payments } from "./schema.js";
|
|
4
|
+
import type { updateCreditNoteSchema, updateInvoiceLineItemSchema, updateInvoiceSchema, updatePaymentSchema } from "./validation.js";
|
|
5
|
+
type UpdateInvoiceInput = z.infer<typeof updateInvoiceSchema>;
|
|
6
|
+
type UpdateInvoiceLineItemInput = z.infer<typeof updateInvoiceLineItemSchema>;
|
|
7
|
+
type UpdateCreditNoteInput = z.infer<typeof updateCreditNoteSchema>;
|
|
8
|
+
type UpdatePaymentInput = z.infer<typeof updatePaymentSchema>;
|
|
9
|
+
type InvoiceRecord = typeof invoices.$inferSelect;
|
|
10
|
+
type PaymentRecord = typeof payments.$inferSelect;
|
|
11
|
+
type CreditNoteRecord = typeof creditNotes.$inferSelect;
|
|
12
|
+
type InvoiceLineItemRecord = typeof invoiceLineItems.$inferSelect;
|
|
13
|
+
type CreditNoteLineItemRecord = typeof creditNoteLineItems.$inferSelect;
|
|
14
|
+
type RecordPaymentLedgerInput = {
|
|
15
|
+
invoice: InvoiceRecord;
|
|
16
|
+
payment: PaymentRecord;
|
|
17
|
+
};
|
|
18
|
+
type RecordPaymentCommandInput = Pick<PaymentRecord, "amountCents" | "currency" | "baseCurrency" | "baseAmountCents" | "fxRateSetId" | "paymentMethod" | "paymentInstrumentId" | "paymentAuthorizationId" | "paymentCaptureId" | "status" | "referenceNumber" | "paymentDate">;
|
|
19
|
+
type PaymentUpdateLedgerInput = {
|
|
20
|
+
invoice: InvoiceRecord;
|
|
21
|
+
payment: PaymentRecord;
|
|
22
|
+
changes: UpdatePaymentInput;
|
|
23
|
+
};
|
|
24
|
+
type PaymentDeleteLedgerInput = {
|
|
25
|
+
invoice: InvoiceRecord;
|
|
26
|
+
payment: PaymentRecord;
|
|
27
|
+
};
|
|
28
|
+
type InvoiceIssuedLedgerInput = {
|
|
29
|
+
invoice: InvoiceRecord;
|
|
30
|
+
};
|
|
31
|
+
type InvoiceUpdateLedgerInput = {
|
|
32
|
+
invoice: InvoiceRecord;
|
|
33
|
+
changes: UpdateInvoiceInput;
|
|
34
|
+
};
|
|
35
|
+
type InvoiceDeleteLedgerInput = {
|
|
36
|
+
invoice: InvoiceRecord;
|
|
37
|
+
};
|
|
38
|
+
type InvoiceLineItemMutationLedgerInput = {
|
|
39
|
+
invoice: InvoiceRecord;
|
|
40
|
+
lineItem: InvoiceLineItemRecord;
|
|
41
|
+
changes?: UpdateInvoiceLineItemInput;
|
|
42
|
+
};
|
|
43
|
+
type CreateCreditNoteLedgerInput = {
|
|
44
|
+
invoice: InvoiceRecord;
|
|
45
|
+
creditNote: CreditNoteRecord;
|
|
46
|
+
};
|
|
47
|
+
type CreditNoteUpdateLedgerInput = {
|
|
48
|
+
invoice: InvoiceRecord;
|
|
49
|
+
creditNote: CreditNoteRecord;
|
|
50
|
+
changes: UpdateCreditNoteInput;
|
|
51
|
+
};
|
|
52
|
+
type CreditNoteLineItemCreateLedgerInput = {
|
|
53
|
+
invoice: InvoiceRecord;
|
|
54
|
+
creditNote: CreditNoteRecord;
|
|
55
|
+
lineItem: CreditNoteLineItemRecord;
|
|
56
|
+
};
|
|
57
|
+
export declare function buildRecordPaymentActionLedgerInput(context: ActionLedgerRequestContextValues, input: RecordPaymentLedgerInput, options?: {
|
|
58
|
+
authorizationSource?: string | null;
|
|
59
|
+
idempotencyKey?: string | null;
|
|
60
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
61
|
+
export declare function buildRecordPaymentIdempotency(invoice: InvoiceRecord, payment: RecordPaymentCommandInput, options?: {
|
|
62
|
+
requestedKey?: string | null;
|
|
63
|
+
targetType?: string;
|
|
64
|
+
targetId?: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
scope: string;
|
|
67
|
+
key: string;
|
|
68
|
+
fingerprint: string;
|
|
69
|
+
}>;
|
|
70
|
+
export declare function buildPaymentUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: PaymentUpdateLedgerInput, options?: {
|
|
71
|
+
authorizationSource?: string | null;
|
|
72
|
+
}): BuildActionLedgerMutationInput;
|
|
73
|
+
export declare function buildPaymentDeleteActionLedgerInput(context: ActionLedgerRequestContextValues, input: PaymentDeleteLedgerInput, options?: {
|
|
74
|
+
authorizationSource?: string | null;
|
|
75
|
+
}): BuildActionLedgerMutationInput;
|
|
76
|
+
export declare function buildInvoiceIssuedActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceIssuedLedgerInput, options?: {
|
|
77
|
+
authorizationSource?: string | null;
|
|
78
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
79
|
+
export declare function buildInvoiceUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceUpdateLedgerInput, options?: {
|
|
80
|
+
authorizationSource?: string | null;
|
|
81
|
+
}): BuildActionLedgerMutationInput;
|
|
82
|
+
export declare function buildInvoiceDeleteActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceDeleteLedgerInput, options?: {
|
|
83
|
+
authorizationSource?: string | null;
|
|
84
|
+
}): BuildActionLedgerMutationInput;
|
|
85
|
+
export declare function buildInvoiceLineItemCreateActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceLineItemMutationLedgerInput, options?: {
|
|
86
|
+
authorizationSource?: string | null;
|
|
87
|
+
}): BuildActionLedgerMutationInput;
|
|
88
|
+
export declare function buildInvoiceLineItemUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceLineItemMutationLedgerInput, options?: {
|
|
89
|
+
authorizationSource?: string | null;
|
|
90
|
+
}): BuildActionLedgerMutationInput;
|
|
91
|
+
export declare function buildInvoiceLineItemDeleteActionLedgerInput(context: ActionLedgerRequestContextValues, input: InvoiceLineItemMutationLedgerInput, options?: {
|
|
92
|
+
authorizationSource?: string | null;
|
|
93
|
+
}): BuildActionLedgerMutationInput;
|
|
94
|
+
export declare function buildCreditNoteCreationActionLedgerInput(context: ActionLedgerRequestContextValues, input: CreateCreditNoteLedgerInput, options?: {
|
|
95
|
+
authorizationSource?: string | null;
|
|
96
|
+
}): Promise<BuildActionLedgerMutationInput>;
|
|
97
|
+
export declare function buildCreditNoteUpdateActionLedgerInput(context: ActionLedgerRequestContextValues, input: CreditNoteUpdateLedgerInput, options?: {
|
|
98
|
+
authorizationSource?: string | null;
|
|
99
|
+
}): BuildActionLedgerMutationInput;
|
|
100
|
+
export declare function buildCreditNoteLineItemCreateActionLedgerInput(context: ActionLedgerRequestContextValues, input: CreditNoteLineItemCreateLedgerInput, options?: {
|
|
101
|
+
authorizationSource?: string | null;
|
|
102
|
+
}): BuildActionLedgerMutationInput;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=service-action-ledger-accounting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-action-ledger-accounting.d.ts","sourceRoot":"","sources":["../src/service-action-ledger-accounting.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EAEpC,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACT,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AAExB,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC7D,KAAK,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC7E,KAAK,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AACnE,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE7D,KAAK,aAAa,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AACjD,KAAK,aAAa,GAAG,OAAO,QAAQ,CAAC,YAAY,CAAA;AACjD,KAAK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