@endora-commerce/mod-invoices 0.107.0 → 0.109.0
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/dist/admin/pages/InvoiceDetail.d.ts.map +1 -1
- package/dist/admin/pages/InvoiceDetail.js +3 -1
- package/dist/admin/pages/InvoiceDetail.js.map +1 -1
- package/dist/admin/templates/invoice-puck-config.d.ts.map +1 -1
- package/dist/admin/templates/invoice-puck-config.js +14 -2
- package/dist/admin/templates/invoice-puck-config.js.map +1 -1
- package/dist/backend/document/block-descriptions.d.ts.map +1 -1
- package/dist/backend/document/block-descriptions.js +2 -0
- package/dist/backend/document/block-descriptions.js.map +1 -1
- package/dist/backend/document/invoice-document-type.d.ts +6 -1
- package/dist/backend/document/invoice-document-type.d.ts.map +1 -1
- package/dist/backend/document/invoice-document-type.js +25 -1
- package/dist/backend/document/invoice-document-type.js.map +1 -1
- package/dist/backend/entities/invoice.entity.d.ts +13 -0
- package/dist/backend/entities/invoice.entity.d.ts.map +1 -1
- package/dist/backend/entities/invoice.entity.js +10 -0
- package/dist/backend/entities/invoice.entity.js.map +1 -1
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +53 -8
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/invoices-prose.d.ts +63 -0
- package/dist/backend/invoices-prose.d.ts.map +1 -0
- package/dist/backend/invoices-prose.js +78 -0
- package/dist/backend/invoices-prose.js.map +1 -0
- package/dist/backend/pdf-components/sample.d.ts.map +1 -1
- package/dist/backend/pdf-components/sample.js +1 -0
- package/dist/backend/pdf-components/sample.js.map +1 -1
- package/dist/backend/pdf-components/sections.d.ts +29 -7
- package/dist/backend/pdf-components/sections.d.ts.map +1 -1
- package/dist/backend/pdf-components/sections.js +78 -38
- package/dist/backend/pdf-components/sections.js.map +1 -1
- package/dist/backend/pdf-components/tree-mapper.d.ts +3 -0
- package/dist/backend/pdf-components/tree-mapper.d.ts.map +1 -1
- package/dist/backend/pdf-components/tree-mapper.js +5 -5
- package/dist/backend/pdf-components/tree-mapper.js.map +1 -1
- package/dist/backend/plugin.d.ts +15 -1
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +3 -2
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/seeds/generic-invoice-template.d.ts.map +1 -1
- package/dist/backend/seeds/generic-invoice-template.js +5 -0
- package/dist/backend/seeds/generic-invoice-template.js.map +1 -1
- package/dist/backend/services/auto-issue-reactor.d.ts.map +1 -1
- package/dist/backend/services/auto-issue-reactor.js +11 -0
- package/dist/backend/services/auto-issue-reactor.js.map +1 -1
- package/dist/backend/services/corrective-invoice.d.ts +90 -0
- package/dist/backend/services/corrective-invoice.d.ts.map +1 -1
- package/dist/backend/services/corrective-invoice.js +275 -63
- package/dist/backend/services/corrective-invoice.js.map +1 -1
- package/dist/backend/services/cross-module-context.d.ts +7 -0
- package/dist/backend/services/cross-module-context.d.ts.map +1 -1
- package/dist/backend/services/cross-module-context.js +19 -0
- package/dist/backend/services/cross-module-context.js.map +1 -1
- package/dist/backend/services/invoice-email-dispatch.d.ts +7 -0
- package/dist/backend/services/invoice-email-dispatch.d.ts.map +1 -1
- package/dist/backend/services/invoice-email-dispatch.js +10 -3
- package/dist/backend/services/invoice-email-dispatch.js.map +1 -1
- package/dist/backend/services/invoice-line-builder.d.ts +63 -13
- package/dist/backend/services/invoice-line-builder.d.ts.map +1 -1
- package/dist/backend/services/invoice-line-builder.js +79 -28
- package/dist/backend/services/invoice-line-builder.js.map +1 -1
- package/dist/backend/services/invoice-paid.d.ts +56 -0
- package/dist/backend/services/invoice-paid.d.ts.map +1 -0
- package/dist/backend/services/invoice-paid.js +74 -0
- package/dist/backend/services/invoice-paid.js.map +1 -0
- package/dist/backend/services/invoice-service.d.ts +43 -2
- package/dist/backend/services/invoice-service.d.ts.map +1 -1
- package/dist/backend/services/invoice-service.js +115 -56
- package/dist/backend/services/invoice-service.js.map +1 -1
- package/dist/manifest.d.ts +3 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +34 -6
- package/dist/manifest.js.map +1 -1
- package/dist/migrations/20261024T145631_invoices_vat_summary.d.ts +18 -0
- package/dist/migrations/20261024T145631_invoices_vat_summary.d.ts.map +1 -0
- package/dist/migrations/20261024T145631_invoices_vat_summary.js +22 -0
- package/dist/migrations/20261024T145631_invoices_vat_summary.js.map +1 -0
- package/dist/migrations/index.d.ts +2 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +3 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/invoices.md +45 -0
- package/i18n/en.json +38 -1
- package/i18n/pl.json +38 -1
- package/package.json +14 -14
package/dist/backend/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { moneySum } from '@endora-commerce/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* A payment attempt whose amount was captured: paid, or paid and since
|
|
4
|
+
* refunded in part or in full (a refund is the return's to record, not the
|
|
5
|
+
* invoice's).
|
|
6
|
+
*/
|
|
7
|
+
const CAPTURED = new Set(['paid', 'partially_refunded', 'refunded']);
|
|
8
|
+
import { effectiveState, lazyPort } from '@endora-commerce/platform/kernel';
|
|
2
9
|
import { z } from 'zod';
|
|
3
10
|
import { invoicesModule } from './plugin.js';
|
|
4
11
|
import { CorrectiveInvoiceProvider } from './services/corrective-invoice.js';
|
|
@@ -10,7 +17,7 @@ import { InvoiceCopyHostService } from './services/invoice-copy-host.service.js'
|
|
|
10
17
|
import { InvoiceReadService, createInvoicePdfPort } from './services/invoice-read-port.js';
|
|
11
18
|
import { NumberingConfigurationService } from './services/numbering-configuration.js';
|
|
12
19
|
import { createNumberingPatternValidator } from './services/numbering-write-validator.js';
|
|
13
|
-
import { createAssetImageLoader, createChannelLanguageResolver, createRecipientEmailResolver, } from './services/cross-module-context.js';
|
|
20
|
+
import { createAssetImageLoader, createChannelLanguageResolver, createChannelUrlFactsResolver, createRecipientEmailResolver, } from './services/cross-module-context.js';
|
|
14
21
|
import { INVOICE_ISSUED_DEFAULT } from './email-templates/invoice-issued.default.js';
|
|
15
22
|
import { InvoiceExternalAttachment } from './entities/invoice-external-attachment.entity.js';
|
|
16
23
|
import { InvoiceLine } from './entities/invoice-line.entity.js';
|
|
@@ -19,6 +26,9 @@ import { createInvoiceDocumentType } from './document/invoice-document-type.js';
|
|
|
19
26
|
import { GRANT_DONE_SETTING, grantDocumentTemplatesAccess } from './document/document-templates-grant.js';
|
|
20
27
|
import { Invoice } from './entities/invoice.entity.js';
|
|
21
28
|
export function registerModule(ctx) {
|
|
29
|
+
// This module's bundle, for the invoice labels and line names it writes in
|
|
30
|
+
// the invoice's language (issue #95). Resolved per call, so the gate stays live.
|
|
31
|
+
const translate = (key, language, params) => lazyPort(ctx, 'adminI18nService').translate('invoices', key, language, params);
|
|
22
32
|
ctx.di.register({
|
|
23
33
|
/**
|
|
24
34
|
* Feature 078, D-95.3 / D-95.4 — the boot-time numbering configuration.
|
|
@@ -74,6 +84,7 @@ export function registerModule(ctx) {
|
|
|
74
84
|
// `orders` an operator had switched off. `orders` is already a
|
|
75
85
|
// binding dependency of this manifest and the edge stays fail-closed.
|
|
76
86
|
orderReadPort: lazyPort(ctx, 'orderReadPort'),
|
|
87
|
+
translate,
|
|
77
88
|
assetReadPort: lazyPort(ctx, 'assetReadPort'),
|
|
78
89
|
assetsLibrary: lazyPort(ctx, 'assetsLibraryPort'),
|
|
79
90
|
// Feature 134, T061 — this module's own registry, not a connector's
|
|
@@ -101,10 +112,37 @@ export function registerModule(ctx) {
|
|
|
101
112
|
getTransactionalEmailSender: () => cradle().transactionalEmailSenderAccessor(),
|
|
102
113
|
resolveRecipientEmail: createRecipientEmailResolver(lazyPort(ctx, 'customerAccountReadPort')),
|
|
103
114
|
resolveLanguage: createChannelLanguageResolver(emFactory),
|
|
115
|
+
channelUrlFactsFor: createChannelUrlFactsResolver(emFactory),
|
|
104
116
|
loadAssetImage: createAssetImageLoader(lazyPort(ctx, 'assetReadPort')),
|
|
105
117
|
// `specs/152-compare-pdf-template/` — every invoice PDF is produced
|
|
106
118
|
// by `document_templates`, which this manifest binds (owner answer N2).
|
|
107
119
|
documents: lazyPort(ctx, 'documentRenderPort'),
|
|
120
|
+
// Issue #417 — what was captured for an order, from `payments` when
|
|
121
|
+
// it is present (a `degrades-without` dependency of this manifest).
|
|
122
|
+
capturedPayments: {
|
|
123
|
+
capturedFor: async (orderId) => {
|
|
124
|
+
if (!effectiveState.isPresent('payments'))
|
|
125
|
+
return null;
|
|
126
|
+
const captured = (await lazyPort(ctx, 'paymentReadPort').listByOrderId(orderId)).filter((p) => CAPTURED.has(p.status));
|
|
127
|
+
if (captured.length === 0)
|
|
128
|
+
return null;
|
|
129
|
+
// Each captured attempt once, and what was refunded from it (review of PR #423).
|
|
130
|
+
return {
|
|
131
|
+
captured: moneySum(captured.map((p) => p.amount)),
|
|
132
|
+
refunded: moneySum(captured.map((p) => p.refundedAmount)),
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
// Issue #428 — what a settled return refunded outside `payments` (a
|
|
137
|
+
// manual transfer, a credit-limit top-up), from `returns` when it is
|
|
138
|
+
// present (a `degrades-without` dependency of this manifest).
|
|
139
|
+
returnRefunds: {
|
|
140
|
+
refundsFor: async (orderId) => {
|
|
141
|
+
if (!effectiveState.isPresent('returns'))
|
|
142
|
+
return [];
|
|
143
|
+
return lazyPort(ctx, 'returnRefundReadPort').listForOrder(orderId);
|
|
144
|
+
},
|
|
145
|
+
},
|
|
108
146
|
ledgerRouting: {
|
|
109
147
|
numberingModeFor: async (salesChannelId) => {
|
|
110
148
|
if (!effectiveState.isPresent('invoice_ledger'))
|
|
@@ -285,6 +323,7 @@ export function registerModule(ctx) {
|
|
|
285
323
|
lazyPort(ctx, 'documentTypeRegistry').register(createInvoiceDocumentType({
|
|
286
324
|
contributed: invoicePdfBlockRegistry,
|
|
287
325
|
loadAssetImage: invoices.handle.loadAssetImage,
|
|
326
|
+
translate,
|
|
288
327
|
}));
|
|
289
328
|
});
|
|
290
329
|
/**
|
|
@@ -294,23 +333,29 @@ export function registerModule(ctx) {
|
|
|
294
333
|
* (D-68): with invoicing off nothing is written, and the grant runs the first
|
|
295
334
|
* boot invoicing is present again. Once it has run, a hidden setting says so
|
|
296
335
|
* and it never runs again.
|
|
336
|
+
*
|
|
337
|
+
* It opens no scope of its own. The platform runs every boot hook inside the
|
|
338
|
+
* system scope it enters for that module (`boot: invoices`, entry point
|
|
339
|
+
* `boot`), so the hook already crosses organisations and that access is
|
|
340
|
+
* already recorded. `enterSystemScope` is for starting a detached execution
|
|
341
|
+
* — a worker, a timer — and calling it here recorded a second widening on
|
|
342
|
+
* every boot, labelled `worker` although nothing but the boot ran it.
|
|
297
343
|
*/
|
|
298
344
|
ctx.onBoot(async () => {
|
|
299
345
|
if (!effectiveState.isPresent('invoices'))
|
|
300
346
|
return;
|
|
301
347
|
const settings = lazyPort(ctx, 'settingsReadPort');
|
|
302
348
|
const settingsAdmin = lazyPort(ctx, 'settingsAdminService');
|
|
303
|
-
|
|
349
|
+
const outcome = await grantDocumentTemplatesAccess({
|
|
304
350
|
roles: lazyPort(ctx, 'adminRolePort'),
|
|
305
351
|
isDone: () => settings.get(GRANT_DONE_SETTING, null, z.boolean()),
|
|
306
352
|
markDone: async () => {
|
|
307
353
|
await settingsAdmin.setValueForAllChannels(GRANT_DONE_SETTING, true, null, { actorAdminUserId: null });
|
|
308
354
|
},
|
|
309
|
-
})
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}));
|
|
355
|
+
});
|
|
356
|
+
if (outcome.status === 'granted' && outcome.roleCodes.length > 0) {
|
|
357
|
+
ctx.log.info({ roleCodes: outcome.roleCodes }, '[invoices] granted document template access to roles');
|
|
358
|
+
}
|
|
314
359
|
});
|
|
315
360
|
}
|
|
316
361
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;;;GAIG;AACH,MAAM,QAAQ,GAAsC,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAAC;AAExG,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAyD,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAA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IAAI,EAAE;gBACnB,MAAM,aAAa,CAAC,sBAAsB,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;YACzG,CAAC;SACF,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,sDAAsD,CAAC,CAAC;QACzG,CAAC;IACH,CAAC,CAAC,CAAC;AAEL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW;IACX,oBAAoB;IACpB,yBAAyB;IACzB,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { SupportedLanguage } from '@endora-commerce/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* The prose this module's backend composes for a reader whose language it
|
|
4
|
+
* knows: the labels of a rendered invoice PDF, which carries its own
|
|
5
|
+
* `language`, and the names of the lines an invoice itemises beside the
|
|
6
|
+
* products, which are written in the invoice's language when it is issued
|
|
7
|
+
* (`specs/conventions/module-i18n.md`, the case where the backend can resolve
|
|
8
|
+
* the reader's language).
|
|
9
|
+
*
|
|
10
|
+
* The sentences live in this module's bundle; this table keeps their English
|
|
11
|
+
* beside the code as the last tier, for when the bundle cannot answer.
|
|
12
|
+
* `invoices-prose.test.ts` holds it equal to `i18n/en.json`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INVOICES_PROSE_EN: {
|
|
15
|
+
readonly 'pdf.title.invoice': "Invoice";
|
|
16
|
+
readonly 'pdf.title.proforma': "Proforma invoice";
|
|
17
|
+
readonly 'pdf.title.correction': "Corrective invoice";
|
|
18
|
+
readonly 'pdf.title.wz': "Goods dispatch note";
|
|
19
|
+
readonly 'pdf.title.numbered': "{title} No. {number}";
|
|
20
|
+
readonly 'pdf.label.ksefNumber': "KSeF number";
|
|
21
|
+
readonly 'pdf.label.issuedAt': "Issue date";
|
|
22
|
+
readonly 'pdf.label.saleDate': "Sale date";
|
|
23
|
+
readonly 'pdf.label.paymentDue': "Payment due";
|
|
24
|
+
readonly 'pdf.label.paymentMethod': "Payment method";
|
|
25
|
+
readonly 'pdf.label.seller': "Seller";
|
|
26
|
+
readonly 'pdf.label.buyer': "Buyer";
|
|
27
|
+
readonly 'pdf.label.taxId': "Tax ID";
|
|
28
|
+
readonly 'pdf.column.ordinal': "No.";
|
|
29
|
+
readonly 'pdf.column.name': "Name";
|
|
30
|
+
readonly 'pdf.column.unit': "Unit";
|
|
31
|
+
readonly 'pdf.column.quantity': "Qty";
|
|
32
|
+
readonly 'pdf.column.unitNet': "Net price";
|
|
33
|
+
readonly 'pdf.column.taxRate': "Rate";
|
|
34
|
+
readonly 'pdf.column.net': "Net value";
|
|
35
|
+
readonly 'pdf.column.gross': "Gross value";
|
|
36
|
+
readonly 'pdf.vat.rate': "VAT rate";
|
|
37
|
+
readonly 'pdf.vat.amount': "VAT amount";
|
|
38
|
+
readonly 'pdf.label.total': "Total";
|
|
39
|
+
readonly 'pdf.label.paid': "Paid";
|
|
40
|
+
readonly 'pdf.label.amountDue': "Amount due";
|
|
41
|
+
readonly 'pdf.label.overpayment': "Overpayment";
|
|
42
|
+
readonly 'pdf.label.inWords': "In words";
|
|
43
|
+
readonly 'pdf.footer.default': "Thank you for your business.\n{{var seller.legalName}} · Tax ID {{var seller.taxId}}";
|
|
44
|
+
readonly 'lines.item': "Item";
|
|
45
|
+
readonly 'lines.unit.piece': "pcs";
|
|
46
|
+
readonly 'lines.unit.service': "svc";
|
|
47
|
+
readonly 'lines.delivery': "Delivery";
|
|
48
|
+
readonly 'lines.paymentSurcharge': "Payment method surcharge";
|
|
49
|
+
readonly 'lines.discount': "Discount";
|
|
50
|
+
};
|
|
51
|
+
export type InvoicesProseKey = keyof typeof INVOICES_PROSE_EN;
|
|
52
|
+
export type ProseParams = Record<string, string | number>;
|
|
53
|
+
/**
|
|
54
|
+
* `_i18n`'s `adminI18nService.translate`, bound to this module's bundle. It
|
|
55
|
+
* answers `invoices.<key>` for a key no bundle carries.
|
|
56
|
+
*/
|
|
57
|
+
export type InvoicesTranslate = (key: string, language: SupportedLanguage, params?: ProseParams) => Promise<string>;
|
|
58
|
+
/** One sentence of this module's prose in `language`, English when the bundle cannot answer. */
|
|
59
|
+
export declare function invoicesProse(translate: InvoicesTranslate | undefined, key: InvoicesProseKey, language: SupportedLanguage, params?: ProseParams): Promise<string>;
|
|
60
|
+
/** Every key at once, for a renderer that draws synchronously. */
|
|
61
|
+
export declare function invoicesProseTable<K extends InvoicesProseKey>(translate: InvoicesTranslate | undefined, keys: readonly K[], language: SupportedLanguage): Promise<Record<K, string>>;
|
|
62
|
+
export declare function fillPlaceholders(template: string, params?: ProseParams): string;
|
|
63
|
+
//# sourceMappingURL=invoices-prose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoices-prose.d.ts","sourceRoot":"","sources":["../../src/backend/invoices-prose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCpB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,iBAAiB,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,gGAAgG;AAChG,wBAAsB,aAAa,CACjC,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,kEAAkE;AAClE,wBAAsB,kBAAkB,CAAC,CAAC,SAAS,gBAAgB,EACjE,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAM5B;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAK/E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The prose this module's backend composes for a reader whose language it
|
|
3
|
+
* knows: the labels of a rendered invoice PDF, which carries its own
|
|
4
|
+
* `language`, and the names of the lines an invoice itemises beside the
|
|
5
|
+
* products, which are written in the invoice's language when it is issued
|
|
6
|
+
* (`specs/conventions/module-i18n.md`, the case where the backend can resolve
|
|
7
|
+
* the reader's language).
|
|
8
|
+
*
|
|
9
|
+
* The sentences live in this module's bundle; this table keeps their English
|
|
10
|
+
* beside the code as the last tier, for when the bundle cannot answer.
|
|
11
|
+
* `invoices-prose.test.ts` holds it equal to `i18n/en.json`.
|
|
12
|
+
*/
|
|
13
|
+
export const INVOICES_PROSE_EN = {
|
|
14
|
+
'pdf.title.invoice': 'Invoice',
|
|
15
|
+
'pdf.title.proforma': 'Proforma invoice',
|
|
16
|
+
'pdf.title.correction': 'Corrective invoice',
|
|
17
|
+
'pdf.title.wz': 'Goods dispatch note',
|
|
18
|
+
'pdf.title.numbered': '{title} No. {number}',
|
|
19
|
+
'pdf.label.ksefNumber': 'KSeF number',
|
|
20
|
+
'pdf.label.issuedAt': 'Issue date',
|
|
21
|
+
'pdf.label.saleDate': 'Sale date',
|
|
22
|
+
'pdf.label.paymentDue': 'Payment due',
|
|
23
|
+
'pdf.label.paymentMethod': 'Payment method',
|
|
24
|
+
'pdf.label.seller': 'Seller',
|
|
25
|
+
'pdf.label.buyer': 'Buyer',
|
|
26
|
+
'pdf.label.taxId': 'Tax ID',
|
|
27
|
+
'pdf.column.ordinal': 'No.',
|
|
28
|
+
'pdf.column.name': 'Name',
|
|
29
|
+
'pdf.column.unit': 'Unit',
|
|
30
|
+
'pdf.column.quantity': 'Qty',
|
|
31
|
+
'pdf.column.unitNet': 'Net price',
|
|
32
|
+
'pdf.column.taxRate': 'Rate',
|
|
33
|
+
'pdf.column.net': 'Net value',
|
|
34
|
+
'pdf.column.gross': 'Gross value',
|
|
35
|
+
'pdf.vat.rate': 'VAT rate',
|
|
36
|
+
'pdf.vat.amount': 'VAT amount',
|
|
37
|
+
'pdf.label.total': 'Total',
|
|
38
|
+
'pdf.label.paid': 'Paid',
|
|
39
|
+
'pdf.label.amountDue': 'Amount due',
|
|
40
|
+
'pdf.label.overpayment': 'Overpayment',
|
|
41
|
+
'pdf.label.inWords': 'In words',
|
|
42
|
+
'pdf.footer.default': 'Thank you for your business.\n{{var seller.legalName}} · Tax ID {{var seller.taxId}}',
|
|
43
|
+
'lines.item': 'Item',
|
|
44
|
+
'lines.unit.piece': 'pcs',
|
|
45
|
+
'lines.unit.service': 'svc',
|
|
46
|
+
'lines.delivery': 'Delivery',
|
|
47
|
+
'lines.paymentSurcharge': 'Payment method surcharge',
|
|
48
|
+
'lines.discount': 'Discount',
|
|
49
|
+
};
|
|
50
|
+
/** One sentence of this module's prose in `language`, English when the bundle cannot answer. */
|
|
51
|
+
export async function invoicesProse(translate, key, language, params) {
|
|
52
|
+
if (translate) {
|
|
53
|
+
try {
|
|
54
|
+
const text = await translate(key, language, params);
|
|
55
|
+
if (text !== `invoices.${key}`)
|
|
56
|
+
return text;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// The English tier below is the answer to an unreachable bundle.
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return fillPlaceholders(INVOICES_PROSE_EN[key], params);
|
|
63
|
+
}
|
|
64
|
+
/** Every key at once, for a renderer that draws synchronously. */
|
|
65
|
+
export async function invoicesProseTable(translate, keys, language) {
|
|
66
|
+
// One at a time: every lookup is a read of `_i18n`'s bundle table, and a
|
|
67
|
+
// table of them at once would take that many pool connections together.
|
|
68
|
+
const table = {};
|
|
69
|
+
for (const key of keys)
|
|
70
|
+
table[key] = await invoicesProse(translate, key, language);
|
|
71
|
+
return table;
|
|
72
|
+
}
|
|
73
|
+
export function fillPlaceholders(template, params) {
|
|
74
|
+
if (!params)
|
|
75
|
+
return template;
|
|
76
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => params[name] != null ? String(params[name]) : match);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=invoices-prose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoices-prose.js","sourceRoot":"","sources":["../../src/backend/invoices-prose.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,mBAAmB,EAAE,SAAS;IAC9B,oBAAoB,EAAE,kBAAkB;IACxC,sBAAsB,EAAE,oBAAoB;IAC5C,cAAc,EAAE,qBAAqB;IACrC,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,aAAa;IACrC,oBAAoB,EAAE,YAAY;IAClC,oBAAoB,EAAE,WAAW;IACjC,sBAAsB,EAAE,aAAa;IACrC,yBAAyB,EAAE,gBAAgB;IAC3C,kBAAkB,EAAE,QAAQ;IAC5B,iBAAiB,EAAE,OAAO;IAC1B,iBAAiB,EAAE,QAAQ;IAC3B,oBAAoB,EAAE,KAAK;IAC3B,iBAAiB,EAAE,MAAM;IACzB,iBAAiB,EAAE,MAAM;IACzB,qBAAqB,EAAE,KA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,EAAE,QAAQ,CAAC,CAAC;IACnF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,MAAoB;IACrE,IAAI,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC7B,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE,CAC5D,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../../../src/backend/pdf-components/sample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"sample.d.ts","sourceRoot":"","sources":["../../../src/backend/pdf-components/sample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,aAAa,CAyEnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../../src/backend/pdf-components/sample.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,EAAE,EAAE,sCAAsC;QAC1C,OAAO,EAAE,sCAAsC;QAC/C,eAAe,EAAE,eAAe;QAChC,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,0BAA0B;QACpC,QAAQ,EAAE,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AK,EAAE;YACL,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,YAAY;YACnB,YAAY,EAAE,qBAAqB;YACnC,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"sample.js","sourceRoot":"","sources":["../../../src/backend/pdf-components/sample.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,EAAE,EAAE,sCAAsC;QAC1C,OAAO,EAAE,sCAAsC;QAC/C,eAAe,EAAE,eAAe;QAChC,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,0BAA0B;QACpC,QAAQ,EAAE,YAAY;QACtB,cAAc,EAAE,YAAY;QAC5B,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,GAAG;QACb,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,CAAC;QACd,KAAK,EAAE,IAAI;QACX,iBAAiB,EAAE,IAAI;QACvB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,IAAI;QAChB,mBAAmB,EAAE,IAAI;QACzB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE;YACL;gBACE,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE,6BAA6B;gBACnC,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,CAAC;gBACX,YAAY,EAAE,GAAG;gBACjB,OAAO,EAAE,GAAG;gBACZ,QAAQ,EAAE,GAAG;gBACb,UAAU,EAAE,GAAG;aAChB;YACD;gBACE,OAAO,EAAE,CAAC;gBACV,IAAI,EAAE,oCAAoC;gBAC1C,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAE,EAAE;gBACZ,YAAY,EAAE,GAAG;gBACjB,OAAO,EAAE,GAAG;gBACZ,QAAQ,EAAE,IAAI;gBACd,UAAU,EAAE,IAAI;aACjB;SACF;QACD,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAChF,MAAM,EAAE;YACN,SAAS,EAAE,oBAAoB;YAC/B,YAAY,EAAE,4BAA4B;YAC1C,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE,IAAI;YACb,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,cAAc;YACxB,WAAW,EAAE,gCAAgC;YAC7C,KAAK,EAAE,WAAW;YAClB,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;SACV;QACD,KAAK,EAAE;YACL,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,YAAY;YACnB,YAAY,EAAE,qBAAqB;YACnC,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Content } from 'pdfmake/interfaces.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type InvoiceDetail } from '@endora-commerce/contracts';
|
|
3
3
|
import { type AmountToWordsLocale } from '../services/amount-to-words.js';
|
|
4
4
|
/**
|
|
5
5
|
* Invoice PDF section builders (feature 047, US6). Each maps a slice of the
|
|
@@ -7,8 +7,23 @@ import { type AmountToWordsLocale } from '../services/amount-to-words.js';
|
|
|
7
7
|
* built-in generic layout and the WYSIWYG template tree mapper.
|
|
8
8
|
*/
|
|
9
9
|
export declare function money(n: number): string;
|
|
10
|
+
/**
|
|
11
|
+
* A unit price — the unit net price column: its significant places, up to
|
|
12
|
+
* four, at least two (owner ruling of 2026-10-25; `unitPriceFractionDigits`).
|
|
13
|
+
* Line values and totals are {@link money}, two places.
|
|
14
|
+
*/
|
|
15
|
+
export declare function unitMoney(n: number): string;
|
|
10
16
|
export declare function pct(rate: number): string;
|
|
11
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Every label the PDF draws that a template prop does not supply, keyed by its
|
|
19
|
+
* key in this module's bundle. The renderer resolves them in the document's
|
|
20
|
+
* `language` before drawing (`document/invoice-document-type.ts`); a section
|
|
21
|
+
* built without them draws English.
|
|
22
|
+
*/
|
|
23
|
+
export declare const INVOICE_PDF_LABEL_KEYS: ("pdf.title.invoice" | "pdf.title.proforma" | "pdf.title.correction" | "pdf.title.wz" | "pdf.title.numbered" | "pdf.label.ksefNumber" | "pdf.label.issuedAt" | "pdf.label.saleDate" | "pdf.label.paymentDue" | "pdf.label.paymentMethod" | "pdf.label.seller" | "pdf.label.buyer" | "pdf.label.taxId" | "pdf.column.ordinal" | "pdf.column.name" | "pdf.column.unit" | "pdf.column.quantity" | "pdf.column.unitNet" | "pdf.column.taxRate" | "pdf.column.net" | "pdf.column.gross" | "pdf.vat.rate" | "pdf.vat.amount" | "pdf.label.total" | "pdf.label.paid" | "pdf.label.amountDue" | "pdf.label.overpayment" | "pdf.label.inWords" | "pdf.footer.default")[];
|
|
24
|
+
export type InvoicePdfLabelKey = (typeof INVOICE_PDF_LABEL_KEYS)[number];
|
|
25
|
+
export type InvoicePdfLabels = Readonly<Record<InvoicePdfLabelKey, string>>;
|
|
26
|
+
export declare const INVOICE_PDF_LABELS_EN: InvoicePdfLabels;
|
|
12
27
|
type Props = Record<string, unknown>;
|
|
13
28
|
/** Interpolate `{{var invoice.x}}` / `{{var order.x}}` style tokens. */
|
|
14
29
|
export declare function interpolate(text: string, inv: InvoiceDetail): string;
|
|
@@ -19,14 +34,21 @@ export interface HeaderSectionOptions {
|
|
|
19
34
|
* header's own row stands down (`specs/134-paid-module-extraction/` T137).
|
|
20
35
|
*/
|
|
21
36
|
readonly suppressKsefNumber?: boolean;
|
|
37
|
+
/** The labels in the document's language. Absent, English. */
|
|
38
|
+
readonly labels?: InvoicePdfLabels;
|
|
22
39
|
}
|
|
23
40
|
export declare function headerSection(inv: InvoiceDetail, props?: Props, options?: HeaderSectionOptions): Content;
|
|
24
|
-
export declare function partiesSection(inv: InvoiceDetail, props?: Props): Content;
|
|
25
|
-
export declare function lineItemsSection(inv: InvoiceDetail, props?: Props): Content;
|
|
26
|
-
export declare function vatSummarySection(inv: InvoiceDetail, props?: Props): Content;
|
|
27
|
-
|
|
41
|
+
export declare function partiesSection(inv: InvoiceDetail, props?: Props, labels?: InvoicePdfLabels): Content;
|
|
42
|
+
export declare function lineItemsSection(inv: InvoiceDetail, props?: Props, labels?: InvoicePdfLabels): Content;
|
|
43
|
+
export declare function vatSummarySection(inv: InvoiceDetail, props?: Props, labels?: InvoicePdfLabels): Content;
|
|
44
|
+
/**
|
|
45
|
+
* `locale` is the language the amount in words is written in; `labels` the
|
|
46
|
+
* language of the labels, the document's. The overpayment row (issue #428) is
|
|
47
|
+
* labelled from `labels` unless a template's `labelOverpayment` replaces it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function totalsSection(inv: InvoiceDetail, locale: AmountToWordsLocale, props?: Props, labels?: InvoicePdfLabels): Content;
|
|
28
50
|
export declare function notesSection(props: Props, inv: InvoiceDetail): Content;
|
|
29
|
-
export declare function footerSection(props: Props, inv: InvoiceDetail): Content;
|
|
51
|
+
export declare function footerSection(props: Props, inv: InvoiceDetail, labels?: InvoicePdfLabels): Content;
|
|
30
52
|
export declare function spacerSection(props?: Props): Content;
|
|
31
53
|
export declare function dividerSection(props?: Props): Content;
|
|
32
54
|
export declare function logoSection(props?: Props): Content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../../src/backend/pdf-components/sections.ts"],"names":[],"mappings":"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