@endora-commerce/contracts 0.100.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/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/actor.d.ts +79 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +41 -0
- package/dist/actor.js.map +1 -0
- package/dist/addresses.d.ts +134 -0
- package/dist/addresses.d.ts.map +1 -0
- package/dist/addresses.js +16 -0
- package/dist/addresses.js.map +1 -0
- package/dist/admin-actions.d.ts +367 -0
- package/dist/admin-actions.d.ts.map +1 -0
- package/dist/admin-actions.js +287 -0
- package/dist/admin-actions.js.map +1 -0
- package/dist/admin-contributions.d.ts +518 -0
- package/dist/admin-contributions.d.ts.map +1 -0
- package/dist/admin-contributions.js +495 -0
- package/dist/admin-contributions.js.map +1 -0
- package/dist/admin-i18n.d.ts +135 -0
- package/dist/admin-i18n.d.ts.map +1 -0
- package/dist/admin-i18n.js +72 -0
- package/dist/admin-i18n.js.map +1 -0
- package/dist/admin-notifications.d.ts +55 -0
- package/dist/admin-notifications.d.ts.map +1 -0
- package/dist/admin-notifications.js +16 -0
- package/dist/admin-notifications.js.map +1 -0
- package/dist/admin-roles.d.ts +125 -0
- package/dist/admin-roles.d.ts.map +1 -0
- package/dist/admin-roles.js +2 -0
- package/dist/admin-roles.js.map +1 -0
- package/dist/admin-users.d.ts +178 -0
- package/dist/admin-users.d.ts.map +1 -0
- package/dist/admin-users.js +14 -0
- package/dist/admin-users.js.map +1 -0
- package/dist/admin.d.ts +243 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +246 -0
- package/dist/admin.js.map +1 -0
- package/dist/analytics.d.ts +123 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/analytics.js +68 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api-keys.d.ts +97 -0
- package/dist/api-keys.d.ts.map +1 -0
- package/dist/api-keys.js +64 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/assets-library.d.ts +684 -0
- package/dist/assets-library.d.ts.map +1 -0
- package/dist/assets-library.js +181 -0
- package/dist/assets-library.js.map +1 -0
- package/dist/audit-logs.d.ts +141 -0
- package/dist/audit-logs.d.ts.map +1 -0
- package/dist/audit-logs.js +31 -0
- package/dist/audit-logs.js.map +1 -0
- package/dist/auth.d.ts +174 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +27 -0
- package/dist/auth.js.map +1 -0
- package/dist/blog.d.ts +669 -0
- package/dist/blog.d.ts.map +1 -0
- package/dist/blog.js +360 -0
- package/dist/blog.js.map +1 -0
- package/dist/capabilities.d.ts +40 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +38 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/carts.d.ts +1367 -0
- package/dist/carts.d.ts.map +1 -0
- package/dist/carts.js +405 -0
- package/dist/carts.js.map +1 -0
- package/dist/catalog.d.ts +2855 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +1543 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cms.d.ts +872 -0
- package/dist/cms.d.ts.map +1 -0
- package/dist/cms.js +468 -0
- package/dist/cms.js.map +1 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +72 -0
- package/dist/common.js.map +1 -0
- package/dist/comparisons.d.ts +487 -0
- package/dist/comparisons.d.ts.map +1 -0
- package/dist/comparisons.js +221 -0
- package/dist/comparisons.js.map +1 -0
- package/dist/credentials.d.ts +292 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +142 -0
- package/dist/credentials.js.map +1 -0
- package/dist/credit-limits.d.ts +111 -0
- package/dist/credit-limits.d.ts.map +1 -0
- package/dist/credit-limits.js +35 -0
- package/dist/credit-limits.js.map +1 -0
- package/dist/currencies.d.ts +127 -0
- package/dist/currencies.d.ts.map +1 -0
- package/dist/currencies.js +20 -0
- package/dist/currencies.js.map +1 -0
- package/dist/custom-fields.d.ts +345 -0
- package/dist/custom-fields.d.ts.map +1 -0
- package/dist/custom-fields.js +185 -0
- package/dist/custom-fields.js.map +1 -0
- package/dist/customer-accounts.d.ts +690 -0
- package/dist/customer-accounts.d.ts.map +1 -0
- package/dist/customer-accounts.js +41 -0
- package/dist/customer-accounts.js.map +1 -0
- package/dist/customers.d.ts +305 -0
- package/dist/customers.d.ts.map +1 -0
- package/dist/customers.js +158 -0
- package/dist/customers.js.map +1 -0
- package/dist/dictionary.d.ts +580 -0
- package/dist/dictionary.d.ts.map +1 -0
- package/dist/dictionary.js +297 -0
- package/dist/dictionary.js.map +1 -0
- package/dist/email-address.d.ts +62 -0
- package/dist/email-address.d.ts.map +1 -0
- package/dist/email-address.js +64 -0
- package/dist/email-address.js.map +1 -0
- package/dist/email.d.ts +175 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +45 -0
- package/dist/email.js.map +1 -0
- package/dist/envelopes.d.ts +15 -0
- package/dist/envelopes.d.ts.map +1 -0
- package/dist/envelopes.js +16 -0
- package/dist/envelopes.js.map +1 -0
- package/dist/environment-inputs.d.ts +306 -0
- package/dist/environment-inputs.d.ts.map +1 -0
- package/dist/environment-inputs.js +277 -0
- package/dist/environment-inputs.js.map +1 -0
- package/dist/erp-connector.d.ts +52 -0
- package/dist/erp-connector.d.ts.map +1 -0
- package/dist/erp-connector.js +34 -0
- package/dist/erp-connector.js.map +1 -0
- package/dist/errors.d.ts +455 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +532 -0
- package/dist/errors.js.map +1 -0
- package/dist/google-analytics.d.ts +181 -0
- package/dist/google-analytics.d.ts.map +1 -0
- package/dist/google-analytics.js +176 -0
- package/dist/google-analytics.js.map +1 -0
- package/dist/google-tag-manager.d.ts +111 -0
- package/dist/google-tag-manager.d.ts.map +1 -0
- package/dist/google-tag-manager.js +129 -0
- package/dist/google-tag-manager.js.map +1 -0
- package/dist/i18n.d.ts +69 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +59 -0
- package/dist/i18n.js.map +1 -0
- package/dist/import-export.d.ts +63 -0
- package/dist/import-export.d.ts.map +1 -0
- package/dist/import-export.js +37 -0
- package/dist/import-export.js.map +1 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +673 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +412 -0
- package/dist/inventory.js.map +1 -0
- package/dist/invoice-ledger.d.ts +366 -0
- package/dist/invoice-ledger.d.ts.map +1 -0
- package/dist/invoice-ledger.js +114 -0
- package/dist/invoice-ledger.js.map +1 -0
- package/dist/invoices.d.ts +845 -0
- package/dist/invoices.d.ts.map +1 -0
- package/dist/invoices.js +314 -0
- package/dist/invoices.js.map +1 -0
- package/dist/kernel.d.ts +49 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +19 -0
- package/dist/kernel.js.map +1 -0
- package/dist/languages.d.ts +122 -0
- package/dist/languages.d.ts.map +1 -0
- package/dist/languages.js +24 -0
- package/dist/languages.js.map +1 -0
- package/dist/linkedin-ads.d.ts +167 -0
- package/dist/linkedin-ads.d.ts.map +1 -0
- package/dist/linkedin-ads.js +156 -0
- package/dist/linkedin-ads.js.map +1 -0
- package/dist/megamenu.d.ts +556 -0
- package/dist/megamenu.d.ts.map +1 -0
- package/dist/megamenu.js +186 -0
- package/dist/megamenu.js.map +1 -0
- package/dist/meta-ads.d.ts +126 -0
- package/dist/meta-ads.d.ts.map +1 -0
- package/dist/meta-ads.js +112 -0
- package/dist/meta-ads.js.map +1 -0
- package/dist/mfa.d.ts +274 -0
- package/dist/mfa.d.ts.map +1 -0
- package/dist/mfa.js +187 -0
- package/dist/mfa.js.map +1 -0
- package/dist/modules.d.ts +1706 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +1390 -0
- package/dist/modules.js.map +1 -0
- package/dist/newsletter.d.ts +611 -0
- package/dist/newsletter.d.ts.map +1 -0
- package/dist/newsletter.js +345 -0
- package/dist/newsletter.js.map +1 -0
- package/dist/orders.d.ts +1175 -0
- package/dist/orders.d.ts.map +1 -0
- package/dist/orders.js +630 -0
- package/dist/orders.js.map +1 -0
- package/dist/organizations.d.ts +938 -0
- package/dist/organizations.d.ts.map +1 -0
- package/dist/organizations.js +418 -0
- package/dist/organizations.js.map +1 -0
- package/dist/pagination.d.ts +21 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +22 -0
- package/dist/pagination.js.map +1 -0
- package/dist/payment-methods.d.ts +472 -0
- package/dist/payment-methods.d.ts.map +1 -0
- package/dist/payment-methods.js +175 -0
- package/dist/payment-methods.js.map +1 -0
- package/dist/payment-return-url.d.ts +53 -0
- package/dist/payment-return-url.d.ts.map +1 -0
- package/dist/payment-return-url.js +35 -0
- package/dist/payment-return-url.js.map +1 -0
- package/dist/payments.d.ts +386 -0
- package/dist/payments.d.ts.map +1 -0
- package/dist/payments.js +84 -0
- package/dist/payments.js.map +1 -0
- package/dist/pim-connector.d.ts +60 -0
- package/dist/pim-connector.d.ts.map +1 -0
- package/dist/pim-connector.js +43 -0
- package/dist/pim-connector.js.map +1 -0
- package/dist/pim-field-path.d.ts +6 -0
- package/dist/pim-field-path.d.ts.map +1 -0
- package/dist/pim-field-path.js +101 -0
- package/dist/pim-field-path.js.map +1 -0
- package/dist/platform-language.d.ts +20 -0
- package/dist/platform-language.d.ts.map +1 -0
- package/dist/platform-language.js +22 -0
- package/dist/platform-language.js.map +1 -0
- package/dist/price-lists.d.ts +685 -0
- package/dist/price-lists.d.ts.map +1 -0
- package/dist/price-lists.js +330 -0
- package/dist/price-lists.js.map +1 -0
- package/dist/product-feeds.d.ts +2837 -0
- package/dist/product-feeds.d.ts.map +1 -0
- package/dist/product-feeds.js +1504 -0
- package/dist/product-feeds.js.map +1 -0
- package/dist/product-scope-overrides.d.ts +134 -0
- package/dist/product-scope-overrides.d.ts.map +1 -0
- package/dist/product-scope-overrides.js +82 -0
- package/dist/product-scope-overrides.js.map +1 -0
- package/dist/product-value-resolver.d.ts +88 -0
- package/dist/product-value-resolver.d.ts.map +1 -0
- package/dist/product-value-resolver.js +128 -0
- package/dist/product-value-resolver.js.map +1 -0
- package/dist/promotions.d.ts +678 -0
- package/dist/promotions.d.ts.map +1 -0
- package/dist/promotions.js +479 -0
- package/dist/promotions.js.map +1 -0
- package/dist/prompt-actions.d.ts +582 -0
- package/dist/prompt-actions.d.ts.map +1 -0
- package/dist/prompt-actions.js +221 -0
- package/dist/prompt-actions.js.map +1 -0
- package/dist/pwa.d.ts +293 -0
- package/dist/pwa.d.ts.map +1 -0
- package/dist/pwa.js +204 -0
- package/dist/pwa.js.map +1 -0
- package/dist/quick-order.d.ts +340 -0
- package/dist/quick-order.d.ts.map +1 -0
- package/dist/quick-order.js +177 -0
- package/dist/quick-order.js.map +1 -0
- package/dist/quote-requests.d.ts +538 -0
- package/dist/quote-requests.d.ts.map +1 -0
- package/dist/quote-requests.js +308 -0
- package/dist/quote-requests.js.map +1 -0
- package/dist/returns.d.ts +774 -0
- package/dist/returns.d.ts.map +1 -0
- package/dist/returns.js +389 -0
- package/dist/returns.js.map +1 -0
- package/dist/sales-channels.d.ts +392 -0
- package/dist/sales-channels.d.ts.map +1 -0
- package/dist/sales-channels.js +285 -0
- package/dist/sales-channels.js.map +1 -0
- package/dist/scope-notice.d.ts +60 -0
- package/dist/scope-notice.d.ts.map +1 -0
- package/dist/scope-notice.js +56 -0
- package/dist/scope-notice.js.map +1 -0
- package/dist/search.d.ts +321 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +160 -0
- package/dist/search.js.map +1 -0
- package/dist/seo.d.ts +113 -0
- package/dist/seo.d.ts.map +1 -0
- package/dist/seo.js +63 -0
- package/dist/seo.js.map +1 -0
- package/dist/settings.d.ts +453 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +337 -0
- package/dist/settings.js.map +1 -0
- package/dist/shipments.d.ts +140 -0
- package/dist/shipments.d.ts.map +1 -0
- package/dist/shipments.js +14 -0
- package/dist/shipments.js.map +1 -0
- package/dist/shipping-methods.d.ts +350 -0
- package/dist/shipping-methods.d.ts.map +1 -0
- package/dist/shipping-methods.js +99 -0
- package/dist/shipping-methods.js.map +1 -0
- package/dist/shopping-lists.d.ts +122 -0
- package/dist/shopping-lists.d.ts.map +1 -0
- package/dist/shopping-lists.js +92 -0
- package/dist/shopping-lists.js.map +1 -0
- package/dist/taxes.d.ts +106 -0
- package/dist/taxes.d.ts.map +1 -0
- package/dist/taxes.js +80 -0
- package/dist/taxes.js.map +1 -0
- package/dist/text-normalization.d.ts +199 -0
- package/dist/text-normalization.d.ts.map +1 -0
- package/dist/text-normalization.js +205 -0
- package/dist/text-normalization.js.map +1 -0
- package/dist/transactional-emails.d.ts +459 -0
- package/dist/transactional-emails.d.ts.map +1 -0
- package/dist/transactional-emails.js +212 -0
- package/dist/transactional-emails.js.map +1 -0
- package/dist/webhooks.d.ts +69 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +53 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,845 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Invoices (FR-080 + feature 047-invoices-module). Produces proforma, VAT
|
|
4
|
+
* invoice, and corrective (credit-note) PDFs against orders. The binary
|
|
5
|
+
* download happens at `GET /orders/:id/invoices/:invoiceId/pdf` (customer) and
|
|
6
|
+
* `GET /admin/invoices/:id/pdf` (admin); this file defines the JSON metadata,
|
|
7
|
+
* the seller/company settings shape, the line/VAT-summary snapshots, and the
|
|
8
|
+
* WYSIWYG template metadata.
|
|
9
|
+
*/
|
|
10
|
+
export declare const invoiceKindSchema: z.ZodEnum<{
|
|
11
|
+
proforma: "proforma";
|
|
12
|
+
invoice: "invoice";
|
|
13
|
+
correction: "correction";
|
|
14
|
+
wz: "wz";
|
|
15
|
+
}>;
|
|
16
|
+
export type InvoiceKind = z.infer<typeof invoiceKindSchema>;
|
|
17
|
+
/** Whether a row was issued by the platform or imported from an ERP connector. */
|
|
18
|
+
export declare const invoiceOriginSchema: z.ZodEnum<{
|
|
19
|
+
platform: "platform";
|
|
20
|
+
erp_import: "erp_import";
|
|
21
|
+
}>;
|
|
22
|
+
export type InvoiceOrigin = z.infer<typeof invoiceOriginSchema>;
|
|
23
|
+
/** Sale-document kind carried inside {@link externalDocumentRefSchema}. */
|
|
24
|
+
export declare const erpSaleDocumentKindSchema: z.ZodEnum<{
|
|
25
|
+
invoice: "invoice";
|
|
26
|
+
wz: "wz";
|
|
27
|
+
}>;
|
|
28
|
+
export type ErpSaleDocumentKind = z.infer<typeof erpSaleDocumentKindSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Stable identity for an ERP-imported sale document (feature 119, FR-087/FR-088).
|
|
31
|
+
*
|
|
32
|
+
* An imported document is identified by the pair `(system, externalId)`: the
|
|
33
|
+
* source system it was imported from, and its id in that system. Ids from two
|
|
34
|
+
* source systems come from unrelated id spaces, so the same `externalId` from
|
|
35
|
+
* another `system` is another document (feature 134, T135; `research.md` D21).
|
|
36
|
+
*
|
|
37
|
+
* `system` is also the key an attachment fetch provider registers under
|
|
38
|
+
* ({@link InvoiceAttachmentFetchRegistryPort}). It is open rather than a literal
|
|
39
|
+
* since feature 134 (T065): a free contract that enumerates its connectors has
|
|
40
|
+
* to be edited for every connector that is added, which is the coupling the
|
|
41
|
+
* seam removes. `externalNumber` is the document number the source system
|
|
42
|
+
* shows, when it has one.
|
|
43
|
+
*/
|
|
44
|
+
export declare const externalDocumentRefSchema: z.ZodObject<{
|
|
45
|
+
system: z.ZodString;
|
|
46
|
+
externalId: z.ZodString;
|
|
47
|
+
externalNumber: z.ZodOptional<z.ZodString>;
|
|
48
|
+
documentKind: z.ZodEnum<{
|
|
49
|
+
invoice: "invoice";
|
|
50
|
+
wz: "wz";
|
|
51
|
+
}>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type ExternalDocumentRef = z.infer<typeof externalDocumentRefSchema>;
|
|
54
|
+
export declare const invoiceStatusSchema: z.ZodEnum<{
|
|
55
|
+
pending: "pending";
|
|
56
|
+
cancelled: "cancelled";
|
|
57
|
+
ready: "ready";
|
|
58
|
+
}>;
|
|
59
|
+
export type InvoiceStatus = z.infer<typeof invoiceStatusSchema>;
|
|
60
|
+
/** Whether the invoice email carries the PDF or a storefront download link. */
|
|
61
|
+
export declare const invoiceDeliveryModeSchema: z.ZodEnum<{
|
|
62
|
+
attachment: "attachment";
|
|
63
|
+
link: "link";
|
|
64
|
+
}>;
|
|
65
|
+
export type InvoiceDeliveryMode = z.infer<typeof invoiceDeliveryModeSchema>;
|
|
66
|
+
/**
|
|
67
|
+
* Seller (own company) data printed on every invoice. Stored as a JSON setting
|
|
68
|
+
* (`invoices.seller.company_data`); the VAT/NIP lives in a separate
|
|
69
|
+
* `invoices.seller.tax_id` setting but is surfaced together here at render time.
|
|
70
|
+
*/
|
|
71
|
+
export declare const sellerCompanyDataSchema: z.ZodObject<{
|
|
72
|
+
legalName: z.ZodString;
|
|
73
|
+
addressLine1: z.ZodString;
|
|
74
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
75
|
+
postalCode: z.ZodString;
|
|
76
|
+
city: z.ZodString;
|
|
77
|
+
country: z.ZodString;
|
|
78
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
79
|
+
bankName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
80
|
+
bankAccount: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
81
|
+
swift: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
82
|
+
email: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
83
|
+
phone: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export type SellerCompanyData = z.infer<typeof sellerCompanyDataSchema>;
|
|
86
|
+
/** Buyer (recipient) snapshot captured at issuance. */
|
|
87
|
+
export declare const invoiceBuyerSchema: z.ZodObject<{
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
90
|
+
addressLine1: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
91
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
92
|
+
postalCode: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
93
|
+
city: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
94
|
+
country: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export type InvoiceBuyer = z.infer<typeof invoiceBuyerSchema>;
|
|
97
|
+
/** One immutable invoice line, snapshotted from the order at issuance. */
|
|
98
|
+
export declare const invoiceLineSchema: z.ZodObject<{
|
|
99
|
+
ordinal: z.ZodNumber;
|
|
100
|
+
name: z.ZodString;
|
|
101
|
+
unit: z.ZodString;
|
|
102
|
+
quantity: z.ZodNumber;
|
|
103
|
+
unitNetPrice: z.ZodNumber;
|
|
104
|
+
taxRate: z.ZodNumber;
|
|
105
|
+
netValue: z.ZodNumber;
|
|
106
|
+
grossValue: z.ZodNumber;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export type InvoiceLine = z.infer<typeof invoiceLineSchema>;
|
|
109
|
+
/** Aggregation per VAT rate; reconciles with the invoice totals. */
|
|
110
|
+
export declare const vatSummaryRowSchema: z.ZodObject<{
|
|
111
|
+
taxRate: z.ZodNumber;
|
|
112
|
+
netTotal: z.ZodNumber;
|
|
113
|
+
vatAmount: z.ZodNumber;
|
|
114
|
+
grossTotal: z.ZodNumber;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
export type VatSummaryRow = z.infer<typeof vatSummaryRowSchema>;
|
|
117
|
+
export declare const invoiceSchema: z.ZodObject<{
|
|
118
|
+
id: z.ZodString;
|
|
119
|
+
orderId: z.ZodNullable<z.ZodString>;
|
|
120
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
121
|
+
kind: z.ZodEnum<{
|
|
122
|
+
proforma: "proforma";
|
|
123
|
+
invoice: "invoice";
|
|
124
|
+
correction: "correction";
|
|
125
|
+
wz: "wz";
|
|
126
|
+
}>;
|
|
127
|
+
number: z.ZodString;
|
|
128
|
+
status: z.ZodEnum<{
|
|
129
|
+
pending: "pending";
|
|
130
|
+
cancelled: "cancelled";
|
|
131
|
+
ready: "ready";
|
|
132
|
+
}>;
|
|
133
|
+
currency: z.ZodString;
|
|
134
|
+
issuedAt: z.ZodString;
|
|
135
|
+
saleDate: z.ZodNullable<z.ZodString>;
|
|
136
|
+
paymentDueDate: z.ZodNullable<z.ZodString>;
|
|
137
|
+
paymentMethod: z.ZodNullable<z.ZodString>;
|
|
138
|
+
netTotal: z.ZodNumber;
|
|
139
|
+
taxTotal: z.ZodNumber;
|
|
140
|
+
grossTotal: z.ZodNumber;
|
|
141
|
+
paidTotal: z.ZodNumber;
|
|
142
|
+
amountDue: z.ZodNumber;
|
|
143
|
+
total: z.ZodNumber;
|
|
144
|
+
originalInvoiceId: z.ZodNullable<z.ZodString>;
|
|
145
|
+
templateId: z.ZodNullable<z.ZodString>;
|
|
146
|
+
pdfAssetId: z.ZodNullable<z.ZodString>;
|
|
147
|
+
ksefReferenceNumber: z.ZodNullable<z.ZodString>;
|
|
148
|
+
ksefProcessedAt: z.ZodNullable<z.ZodString>;
|
|
149
|
+
}, z.core.$strip>;
|
|
150
|
+
export type Invoice = z.infer<typeof invoiceSchema>;
|
|
151
|
+
export declare const invoiceDetailSchema: z.ZodObject<{
|
|
152
|
+
id: z.ZodString;
|
|
153
|
+
orderId: z.ZodNullable<z.ZodString>;
|
|
154
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
155
|
+
kind: z.ZodEnum<{
|
|
156
|
+
proforma: "proforma";
|
|
157
|
+
invoice: "invoice";
|
|
158
|
+
correction: "correction";
|
|
159
|
+
wz: "wz";
|
|
160
|
+
}>;
|
|
161
|
+
number: z.ZodString;
|
|
162
|
+
status: z.ZodEnum<{
|
|
163
|
+
pending: "pending";
|
|
164
|
+
cancelled: "cancelled";
|
|
165
|
+
ready: "ready";
|
|
166
|
+
}>;
|
|
167
|
+
currency: z.ZodString;
|
|
168
|
+
issuedAt: z.ZodString;
|
|
169
|
+
saleDate: z.ZodNullable<z.ZodString>;
|
|
170
|
+
paymentDueDate: z.ZodNullable<z.ZodString>;
|
|
171
|
+
paymentMethod: z.ZodNullable<z.ZodString>;
|
|
172
|
+
netTotal: z.ZodNumber;
|
|
173
|
+
taxTotal: z.ZodNumber;
|
|
174
|
+
grossTotal: z.ZodNumber;
|
|
175
|
+
paidTotal: z.ZodNumber;
|
|
176
|
+
amountDue: z.ZodNumber;
|
|
177
|
+
total: z.ZodNumber;
|
|
178
|
+
originalInvoiceId: z.ZodNullable<z.ZodString>;
|
|
179
|
+
templateId: z.ZodNullable<z.ZodString>;
|
|
180
|
+
pdfAssetId: z.ZodNullable<z.ZodString>;
|
|
181
|
+
ksefReferenceNumber: z.ZodNullable<z.ZodString>;
|
|
182
|
+
ksefProcessedAt: z.ZodNullable<z.ZodString>;
|
|
183
|
+
orderBusinessId: z.ZodNullable<z.ZodString>;
|
|
184
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
185
|
+
ordinal: z.ZodNumber;
|
|
186
|
+
name: z.ZodString;
|
|
187
|
+
unit: z.ZodString;
|
|
188
|
+
quantity: z.ZodNumber;
|
|
189
|
+
unitNetPrice: z.ZodNumber;
|
|
190
|
+
taxRate: z.ZodNumber;
|
|
191
|
+
netValue: z.ZodNumber;
|
|
192
|
+
grossValue: z.ZodNumber;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
vatSummary: z.ZodArray<z.ZodObject<{
|
|
195
|
+
taxRate: z.ZodNumber;
|
|
196
|
+
netTotal: z.ZodNumber;
|
|
197
|
+
vatAmount: z.ZodNumber;
|
|
198
|
+
grossTotal: z.ZodNumber;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
seller: z.ZodObject<{
|
|
201
|
+
legalName: z.ZodString;
|
|
202
|
+
addressLine1: z.ZodString;
|
|
203
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
204
|
+
postalCode: z.ZodString;
|
|
205
|
+
city: z.ZodString;
|
|
206
|
+
country: z.ZodString;
|
|
207
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
208
|
+
bankName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
209
|
+
bankAccount: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
210
|
+
swift: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
211
|
+
email: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
212
|
+
phone: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
213
|
+
}, z.core.$strip>;
|
|
214
|
+
buyer: z.ZodObject<{
|
|
215
|
+
name: z.ZodString;
|
|
216
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
217
|
+
addressLine1: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
218
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
219
|
+
postalCode: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
220
|
+
city: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
221
|
+
country: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
export type InvoiceDetail = z.infer<typeof invoiceDetailSchema>;
|
|
225
|
+
/** WYSIWYG (Puck) invoice PDF template metadata. */
|
|
226
|
+
export declare const invoiceTemplateSchema: z.ZodObject<{
|
|
227
|
+
id: z.ZodString;
|
|
228
|
+
code: z.ZodString;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
231
|
+
languages: z.ZodArray<z.ZodString>;
|
|
232
|
+
active: z.ZodBoolean;
|
|
233
|
+
isSystem: z.ZodBoolean;
|
|
234
|
+
version: z.ZodNumber;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
export type InvoiceTemplate = z.infer<typeof invoiceTemplateSchema>;
|
|
237
|
+
/** Body for issuing an invoice/proforma against an order. */
|
|
238
|
+
export declare const issueInvoiceRequestSchema: z.ZodObject<{
|
|
239
|
+
kind: z.ZodDefault<z.ZodEnum<{
|
|
240
|
+
proforma: "proforma";
|
|
241
|
+
invoice: "invoice";
|
|
242
|
+
}>>;
|
|
243
|
+
saleDate: z.ZodOptional<z.ZodString>;
|
|
244
|
+
paymentDueDate: z.ZodOptional<z.ZodString>;
|
|
245
|
+
}, z.core.$strip>;
|
|
246
|
+
export type IssueInvoiceRequest = z.infer<typeof issueInvoiceRequestSchema>;
|
|
247
|
+
/** Body for (re)sending the invoice email. */
|
|
248
|
+
export declare const sendInvoiceEmailRequestSchema: z.ZodObject<{
|
|
249
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
250
|
+
attachment: "attachment";
|
|
251
|
+
link: "link";
|
|
252
|
+
}>>;
|
|
253
|
+
}, z.core.$strip>;
|
|
254
|
+
export type SendInvoiceEmailRequest = z.infer<typeof sendInvoiceEmailRequestSchema>;
|
|
255
|
+
/**
|
|
256
|
+
* Why the invoice e-mail did not go out (issue #103).
|
|
257
|
+
*
|
|
258
|
+
* The dispatcher has answered these seven since #103; they only ever reached a
|
|
259
|
+
* log. They are part of the API shape now because the operator who clicked
|
|
260
|
+
* "issue" is the one person who can act on them (issue #149).
|
|
261
|
+
*/
|
|
262
|
+
export declare const invoiceEmailNotSentReasonSchema: z.ZodEnum<{
|
|
263
|
+
failed: "failed";
|
|
264
|
+
no_sender: "no_sender";
|
|
265
|
+
invoice_not_found: "invoice_not_found";
|
|
266
|
+
no_recipient: "no_recipient";
|
|
267
|
+
deactivated: "deactivated";
|
|
268
|
+
no_transport: "no_transport";
|
|
269
|
+
no_definition: "no_definition";
|
|
270
|
+
}>;
|
|
271
|
+
export type InvoiceEmailNotSentReason = z.infer<typeof invoiceEmailNotSentReasonSchema>;
|
|
272
|
+
/**
|
|
273
|
+
* `POST /admin/invoices/:id/send-email` — the answer to an explicitly requested
|
|
274
|
+
* re-send. The route has carried it since issue #103; it is written down here
|
|
275
|
+
* because both admin surfaces used to announce "sent" over it (issue #149).
|
|
276
|
+
*/
|
|
277
|
+
export declare const sendInvoiceEmailResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
278
|
+
ok: z.ZodLiteral<true>;
|
|
279
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
280
|
+
ok: z.ZodLiteral<false>;
|
|
281
|
+
reason: z.ZodEnum<{
|
|
282
|
+
failed: "failed";
|
|
283
|
+
no_sender: "no_sender";
|
|
284
|
+
invoice_not_found: "invoice_not_found";
|
|
285
|
+
no_recipient: "no_recipient";
|
|
286
|
+
deactivated: "deactivated";
|
|
287
|
+
no_transport: "no_transport";
|
|
288
|
+
no_definition: "no_definition";
|
|
289
|
+
}>;
|
|
290
|
+
}, z.core.$strip>], "ok">;
|
|
291
|
+
export type SendInvoiceEmailResult = z.infer<typeof sendInvoiceEmailResultSchema>;
|
|
292
|
+
/**
|
|
293
|
+
* What became of the send-on-issue e-mail an issuance triggered (issue #149).
|
|
294
|
+
*
|
|
295
|
+
* Three answers, and the middle one is the point: `not_requested` means the
|
|
296
|
+
* operator switched send-on-issue off for this channel, which is a configured
|
|
297
|
+
* choice and not a delivery that failed. Reading "no e-mail" out of a missing
|
|
298
|
+
* field cannot tell those apart, which is how an issuance whose notification was
|
|
299
|
+
* suppressed came back as a bare 201 saying "issued".
|
|
300
|
+
*
|
|
301
|
+
* A suppressed or failed e-mail never invalidates the issuance (FR-029): the
|
|
302
|
+
* invoice is a legal document that was drawn, numbered and stored, so this
|
|
303
|
+
* rides **alongside** a 201 rather than turning it into an error.
|
|
304
|
+
*/
|
|
305
|
+
export declare const issueInvoiceEmailOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
306
|
+
status: z.ZodLiteral<"sent">;
|
|
307
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
308
|
+
status: z.ZodLiteral<"not_requested">;
|
|
309
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
310
|
+
status: z.ZodLiteral<"not_sent">;
|
|
311
|
+
reason: z.ZodEnum<{
|
|
312
|
+
failed: "failed";
|
|
313
|
+
no_sender: "no_sender";
|
|
314
|
+
invoice_not_found: "invoice_not_found";
|
|
315
|
+
no_recipient: "no_recipient";
|
|
316
|
+
deactivated: "deactivated";
|
|
317
|
+
no_transport: "no_transport";
|
|
318
|
+
no_definition: "no_definition";
|
|
319
|
+
}>;
|
|
320
|
+
}, z.core.$strip>], "status">;
|
|
321
|
+
export type IssueInvoiceEmailOutcome = z.infer<typeof issueInvoiceEmailOutcomeSchema>;
|
|
322
|
+
/**
|
|
323
|
+
* `POST /admin/orders/:orderId/invoices` — the issued document plus what became
|
|
324
|
+
* of its notification. `email` is a sibling of `data`, the way `pagination` is
|
|
325
|
+
* on a collection: it describes the action, not the invoice, and the invoice
|
|
326
|
+
* detail shape stays identical on every surface that reads one.
|
|
327
|
+
*/
|
|
328
|
+
export declare const issueInvoiceResponseSchema: z.ZodObject<{
|
|
329
|
+
data: z.ZodObject<{
|
|
330
|
+
id: z.ZodString;
|
|
331
|
+
orderId: z.ZodNullable<z.ZodString>;
|
|
332
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
333
|
+
kind: z.ZodEnum<{
|
|
334
|
+
proforma: "proforma";
|
|
335
|
+
invoice: "invoice";
|
|
336
|
+
correction: "correction";
|
|
337
|
+
wz: "wz";
|
|
338
|
+
}>;
|
|
339
|
+
number: z.ZodString;
|
|
340
|
+
status: z.ZodEnum<{
|
|
341
|
+
pending: "pending";
|
|
342
|
+
cancelled: "cancelled";
|
|
343
|
+
ready: "ready";
|
|
344
|
+
}>;
|
|
345
|
+
currency: z.ZodString;
|
|
346
|
+
issuedAt: z.ZodString;
|
|
347
|
+
saleDate: z.ZodNullable<z.ZodString>;
|
|
348
|
+
paymentDueDate: z.ZodNullable<z.ZodString>;
|
|
349
|
+
paymentMethod: z.ZodNullable<z.ZodString>;
|
|
350
|
+
netTotal: z.ZodNumber;
|
|
351
|
+
taxTotal: z.ZodNumber;
|
|
352
|
+
grossTotal: z.ZodNumber;
|
|
353
|
+
paidTotal: z.ZodNumber;
|
|
354
|
+
amountDue: z.ZodNumber;
|
|
355
|
+
total: z.ZodNumber;
|
|
356
|
+
originalInvoiceId: z.ZodNullable<z.ZodString>;
|
|
357
|
+
templateId: z.ZodNullable<z.ZodString>;
|
|
358
|
+
pdfAssetId: z.ZodNullable<z.ZodString>;
|
|
359
|
+
ksefReferenceNumber: z.ZodNullable<z.ZodString>;
|
|
360
|
+
ksefProcessedAt: z.ZodNullable<z.ZodString>;
|
|
361
|
+
orderBusinessId: z.ZodNullable<z.ZodString>;
|
|
362
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
363
|
+
ordinal: z.ZodNumber;
|
|
364
|
+
name: z.ZodString;
|
|
365
|
+
unit: z.ZodString;
|
|
366
|
+
quantity: z.ZodNumber;
|
|
367
|
+
unitNetPrice: z.ZodNumber;
|
|
368
|
+
taxRate: z.ZodNumber;
|
|
369
|
+
netValue: z.ZodNumber;
|
|
370
|
+
grossValue: z.ZodNumber;
|
|
371
|
+
}, z.core.$strip>>;
|
|
372
|
+
vatSummary: z.ZodArray<z.ZodObject<{
|
|
373
|
+
taxRate: z.ZodNumber;
|
|
374
|
+
netTotal: z.ZodNumber;
|
|
375
|
+
vatAmount: z.ZodNumber;
|
|
376
|
+
grossTotal: z.ZodNumber;
|
|
377
|
+
}, z.core.$strip>>;
|
|
378
|
+
seller: z.ZodObject<{
|
|
379
|
+
legalName: z.ZodString;
|
|
380
|
+
addressLine1: z.ZodString;
|
|
381
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
382
|
+
postalCode: z.ZodString;
|
|
383
|
+
city: z.ZodString;
|
|
384
|
+
country: z.ZodString;
|
|
385
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
386
|
+
bankName: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
387
|
+
bankAccount: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
388
|
+
swift: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
389
|
+
email: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
390
|
+
phone: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
391
|
+
}, z.core.$strip>;
|
|
392
|
+
buyer: z.ZodObject<{
|
|
393
|
+
name: z.ZodString;
|
|
394
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
395
|
+
addressLine1: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
396
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
397
|
+
postalCode: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
398
|
+
city: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
399
|
+
country: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
400
|
+
}, z.core.$strip>;
|
|
401
|
+
}, z.core.$strip>;
|
|
402
|
+
email: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
403
|
+
status: z.ZodLiteral<"sent">;
|
|
404
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
405
|
+
status: z.ZodLiteral<"not_requested">;
|
|
406
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
407
|
+
status: z.ZodLiteral<"not_sent">;
|
|
408
|
+
reason: z.ZodEnum<{
|
|
409
|
+
failed: "failed";
|
|
410
|
+
no_sender: "no_sender";
|
|
411
|
+
invoice_not_found: "invoice_not_found";
|
|
412
|
+
no_recipient: "no_recipient";
|
|
413
|
+
deactivated: "deactivated";
|
|
414
|
+
no_transport: "no_transport";
|
|
415
|
+
no_definition: "no_definition";
|
|
416
|
+
}>;
|
|
417
|
+
}, z.core.$strip>], "status">;
|
|
418
|
+
}, z.core.$strip>;
|
|
419
|
+
export type IssueInvoiceResponse = z.infer<typeof issueInvoiceResponseSchema>;
|
|
420
|
+
/**
|
|
421
|
+
* An invoice as it crosses a module boundary — a plain shape, never the ORM
|
|
422
|
+
* entity (FR-011). Every money column stays a decimal string: these are VAT
|
|
423
|
+
* documents, and a `number` cannot round-trip one.
|
|
424
|
+
*/
|
|
425
|
+
export interface InvoiceRecord {
|
|
426
|
+
id: string;
|
|
427
|
+
orderId: string | null;
|
|
428
|
+
salesChannelId: string | null;
|
|
429
|
+
kind: InvoiceKind;
|
|
430
|
+
number: string;
|
|
431
|
+
issuedAt: Date;
|
|
432
|
+
/** ISO date (no time) — the tax point, which is not the issue timestamp. */
|
|
433
|
+
saleDate: string | null;
|
|
434
|
+
paymentDueDate: string | null;
|
|
435
|
+
paymentMethod: string | null;
|
|
436
|
+
currency: string;
|
|
437
|
+
netTotal: string | null;
|
|
438
|
+
taxTotal: string | null;
|
|
439
|
+
total: string;
|
|
440
|
+
paidTotal: string;
|
|
441
|
+
/** Set on a `correction`: the document this one credits. */
|
|
442
|
+
originalInvoiceId: string | null;
|
|
443
|
+
templateId: string | null;
|
|
444
|
+
ksefReferenceNumber: string | null;
|
|
445
|
+
ksefProcessedAt: Date | null;
|
|
446
|
+
issuedBy: string | null;
|
|
447
|
+
pdfAssetId: string | null;
|
|
448
|
+
status: InvoiceStatus;
|
|
449
|
+
createdAt: Date;
|
|
450
|
+
updatedAt: Date;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Container name: `invoiceReadPort`. Owner: `invoices`.
|
|
454
|
+
*
|
|
455
|
+
* Four inbound sites read the entity: `orders` listing an order's invoices on
|
|
456
|
+
* the order screen and again at cancellation, and `ksef` resolving the invoice
|
|
457
|
+
* behind a submission — twice, once from its entity file, where the read is a
|
|
458
|
+
* `@TransitivelyScoped` tenancy classification rather than a query and needs
|
|
459
|
+
* its own remedy (R-05).
|
|
460
|
+
*
|
|
461
|
+
* The seller and buyer snapshots are deliberately absent. They are the
|
|
462
|
+
* document's own frozen copy of two other modules' rows; no cross-module
|
|
463
|
+
* caller reads them, and publishing them would invite one to.
|
|
464
|
+
*/
|
|
465
|
+
export interface InvoiceReadPort {
|
|
466
|
+
findById(id: string): Promise<InvoiceRecord | null>;
|
|
467
|
+
findByIds(ids: readonly string[]): Promise<InvoiceRecord[]>;
|
|
468
|
+
/**
|
|
469
|
+
* The document number is the operator's handle on an invoice — `ksef` filters
|
|
470
|
+
* its submission list by it — so the lookup is published rather than left as
|
|
471
|
+
* a second module's query over this one's unique index.
|
|
472
|
+
*/
|
|
473
|
+
findByNumber(number: string): Promise<InvoiceRecord | null>;
|
|
474
|
+
/** An order's invoices, newest first. */
|
|
475
|
+
listForOrder(orderId: string): Promise<InvoiceRecord[]>;
|
|
476
|
+
/** Several orders' invoices at once, for a list screen. */
|
|
477
|
+
listForOrders(orderIds: readonly string[]): Promise<InvoiceRecord[]>;
|
|
478
|
+
}
|
|
479
|
+
/** One line of a bulk PDF — enough to identify the document it renders. */
|
|
480
|
+
export interface InvoicePdfLine {
|
|
481
|
+
invoiceNumber: string;
|
|
482
|
+
total: string;
|
|
483
|
+
currency: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Container name: `invoicePdfPort`. Owner: `invoices`.
|
|
487
|
+
*
|
|
488
|
+
* **A port, although the two builders behind it are pure**, and the exception
|
|
489
|
+
* is worth stating because FR-013's test does not settle it. "Does switching
|
|
490
|
+
* the owner off change the answer?" asks whether the *bytes* would differ, and
|
|
491
|
+
* they would not. The question that decides this one is Constitution XVII's:
|
|
492
|
+
* should the platform produce an invoice document for a business that has
|
|
493
|
+
* switched invoicing off? An order screen offering an invoice PDF is a surface
|
|
494
|
+
* the module owns, and a surface a switched-off module owns must disappear.
|
|
495
|
+
*
|
|
496
|
+
* `hashPassword` is the contrast, and it is the right one: it is
|
|
497
|
+
* platform-generic, reachable from five modules and the dev seed, and nobody
|
|
498
|
+
* would call hashing "an `auth` surface". A VAT document is an `invoices`
|
|
499
|
+
* surface.
|
|
500
|
+
*
|
|
501
|
+
* Returns `Uint8Array` rather than Node's `Buffer` so this package stays free
|
|
502
|
+
* of Node types — it is imported by the admin SPA and the storefront too.
|
|
503
|
+
*/
|
|
504
|
+
export interface InvoicePdfPort {
|
|
505
|
+
renderMinimal(params: {
|
|
506
|
+
invoiceNumber: string;
|
|
507
|
+
total: string;
|
|
508
|
+
currency: string;
|
|
509
|
+
}): Uint8Array;
|
|
510
|
+
renderBulk(invoices: readonly InvoicePdfLine[]): Uint8Array;
|
|
511
|
+
}
|
|
512
|
+
export declare const INVOICE_NUMBERING_HOST_PORT: "invoiceNumberingHostPort";
|
|
513
|
+
export declare const INVOICE_PAID_HOST_PORT: "invoicePaidHostPort";
|
|
514
|
+
export declare const INVOICE_COPY_HOST_PORT: "invoiceCopyHostPort";
|
|
515
|
+
export declare const INVOICE_KSEF_ASSIGNMENT_PORT: "invoiceKsefAssignmentPort";
|
|
516
|
+
/**
|
|
517
|
+
* Container name: `invoiceNumberingHostPort`. Owner: `invoices`.
|
|
518
|
+
* Ledger vendor number wait (mode B) → ready + unique number.
|
|
519
|
+
*/
|
|
520
|
+
export interface InvoiceNumberingHostPort {
|
|
521
|
+
applyVendorAssignedNumber(invoiceId: string, number: string): Promise<void>;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Container name: `invoicePaidHostPort`. Owner: `invoices`.
|
|
525
|
+
* Infakt `invoice_paid` stamps paidTotal only. Never Payments.
|
|
526
|
+
*/
|
|
527
|
+
export interface InvoicePaidHostPort {
|
|
528
|
+
recordPaidFromLedger(invoiceId: string): Promise<void>;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Container name: `invoiceKsefAssignmentPort`. Owner: `invoices`.
|
|
532
|
+
* Native ksef and Infakt delegated KSeF success both call this. Idempotent
|
|
533
|
+
* same number; 409 on a different number.
|
|
534
|
+
*/
|
|
535
|
+
export interface InvoiceKsefAssignmentPort {
|
|
536
|
+
recordKsefAssignment(invoiceId: string, assignment: {
|
|
537
|
+
ksefReferenceNumber: string;
|
|
538
|
+
ksefProcessedAt: Date;
|
|
539
|
+
}): Promise<void>;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Container name: `invoiceCopyHostPort`. Owner: `invoices`.
|
|
543
|
+
* Ledger / Infakt VAT copy: buyer snapshot and lines, never a catalog write.
|
|
544
|
+
*/
|
|
545
|
+
export interface InvoiceCopyRecord {
|
|
546
|
+
invoiceId: string;
|
|
547
|
+
organizationId: string;
|
|
548
|
+
number: string;
|
|
549
|
+
kind: InvoiceKind;
|
|
550
|
+
salesChannelId: string | null;
|
|
551
|
+
currency: string;
|
|
552
|
+
saleDate: string | null;
|
|
553
|
+
paymentDueDate: string | null;
|
|
554
|
+
paymentMethod: string | null;
|
|
555
|
+
/** Set on a `correction`: the VAT document this one credits. */
|
|
556
|
+
originalInvoiceId: string | null;
|
|
557
|
+
buyer: InvoiceBuyer;
|
|
558
|
+
lines: InvoiceLine[];
|
|
559
|
+
}
|
|
560
|
+
export interface InvoiceCopyHostPort {
|
|
561
|
+
getById(invoiceId: string): Promise<InvoiceCopyRecord | null>;
|
|
562
|
+
}
|
|
563
|
+
/** `invoice.issued.v1` payload, emitted when `invoices` issues a VAT invoice or a proforma. */
|
|
564
|
+
export declare const invoiceIssuedEventSchema: z.ZodObject<{
|
|
565
|
+
invoiceId: z.ZodString;
|
|
566
|
+
orderId: z.ZodString;
|
|
567
|
+
kind: z.ZodEnum<{
|
|
568
|
+
proforma: "proforma";
|
|
569
|
+
invoice: "invoice";
|
|
570
|
+
}>;
|
|
571
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
572
|
+
}, z.core.$strip>;
|
|
573
|
+
export type InvoiceIssuedEvent = z.infer<typeof invoiceIssuedEventSchema>;
|
|
574
|
+
/** `invoice.corrected.v1` payload, emitted when `invoices` issues a corrective invoice. */
|
|
575
|
+
export declare const invoiceCorrectedEventSchema: z.ZodObject<{
|
|
576
|
+
invoiceId: z.ZodString;
|
|
577
|
+
originalInvoiceId: z.ZodNullable<z.ZodString>;
|
|
578
|
+
orderId: z.ZodString;
|
|
579
|
+
salesChannelId: z.ZodNullable<z.ZodString>;
|
|
580
|
+
}, z.core.$strip>;
|
|
581
|
+
export type InvoiceCorrectedEvent = z.infer<typeof invoiceCorrectedEventSchema>;
|
|
582
|
+
/** One configurable field of an invoice template block, as the builder descriptor serves it. */
|
|
583
|
+
export interface InvoiceTemplateBlockField {
|
|
584
|
+
type: 'text' | 'textarea' | 'number' | 'select' | 'radio' | 'color';
|
|
585
|
+
label: string;
|
|
586
|
+
options?: Array<{
|
|
587
|
+
label: string;
|
|
588
|
+
value: string | boolean | number;
|
|
589
|
+
}>;
|
|
590
|
+
}
|
|
591
|
+
/** What a contributed block tells the invoice template builder about itself. */
|
|
592
|
+
export interface InvoiceTemplateBlockDescription {
|
|
593
|
+
readonly label: string;
|
|
594
|
+
readonly fields: Readonly<Record<string, InvoiceTemplateBlockField>>;
|
|
595
|
+
}
|
|
596
|
+
/** A block another module renders onto the invoice PDF. */
|
|
597
|
+
export interface InvoicePdfBlockRegistration {
|
|
598
|
+
/** The full block name, `<moduleId>.<LocalName>`, exactly as the contributor's manifest declares it. */
|
|
599
|
+
readonly name: string;
|
|
600
|
+
/** The declaring module. While it is not present the block is neither rendered nor described. */
|
|
601
|
+
readonly moduleId: string;
|
|
602
|
+
/**
|
|
603
|
+
* `true` when this block prints the invoice's KSeF number itself
|
|
604
|
+
* (`specs/134-paid-module-extraction/` T137, `research.md` D22 §3(a)). The
|
|
605
|
+
* number is `invoices`' statutory data and is printed exactly once: while a
|
|
606
|
+
* block with this flag is present **and placed** in the template being
|
|
607
|
+
* rendered (present, for the built-in layout), `invoices`' own header row for
|
|
608
|
+
* the number is suppressed; otherwise the header prints it.
|
|
609
|
+
*/
|
|
610
|
+
readonly printsKsefReferenceNumber?: boolean;
|
|
611
|
+
/** Label and field schema for the builder descriptor. */
|
|
612
|
+
describe(): InvoiceTemplateBlockDescription;
|
|
613
|
+
/**
|
|
614
|
+
* Data the block needs beyond the invoice, read once per render — the KSeF
|
|
615
|
+
* verification link, for instance. A rejection renders the block with
|
|
616
|
+
* `null`: the data is an enrichment and never fails the document.
|
|
617
|
+
*/
|
|
618
|
+
resolve?(invoiceId: string): Promise<unknown>;
|
|
619
|
+
/**
|
|
620
|
+
* One pdfmake content node. `props` are the stored block props (`{}` in the
|
|
621
|
+
* built-in layout), and `resolved` is what {@link resolve} answered, or `null`.
|
|
622
|
+
*/
|
|
623
|
+
render(input: {
|
|
624
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
625
|
+
readonly invoice: InvoiceDetail;
|
|
626
|
+
readonly locale: string;
|
|
627
|
+
readonly resolved: unknown;
|
|
628
|
+
}): unknown;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Container name: `invoicePdfBlockRegistry`. Owner: `invoices`.
|
|
632
|
+
*
|
|
633
|
+
* The registry of contributed PDF blocks. An ungated contribution registry: a
|
|
634
|
+
* contributor pushes from its boot hook, and `invoices` skips the block of a
|
|
635
|
+
* contributor that is not present on every render and descriptor read.
|
|
636
|
+
*/
|
|
637
|
+
export interface InvoicePdfBlockRegistryPort {
|
|
638
|
+
register(registration: InvoicePdfBlockRegistration): void;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* The tokens an invoice numbering pattern may contain. Everything else in a
|
|
642
|
+
* pattern is literal text.
|
|
643
|
+
*
|
|
644
|
+
* `{channel}` renders the sales channel's `code`, uppercased and otherwise
|
|
645
|
+
* verbatim. The code charset is `/^[a-z][a-z0-9_-]*$/`
|
|
646
|
+
* (`salesChannelCreateBodySchema`), so uppercasing is injective and no two
|
|
647
|
+
* channels can produce the same discriminator; the code is also immutable
|
|
648
|
+
* (the update schema accepts it only when it repeats the current value), so a
|
|
649
|
+
* number already rendered through `{channel}` can never be retroactively
|
|
650
|
+
* invalidated by a rename.
|
|
651
|
+
*/
|
|
652
|
+
export declare const INVOICE_NUMBER_TOKENS: readonly ["seq", "seq:N", "channel", "YYYY", "YY", "MM"];
|
|
653
|
+
export type InvoiceNumberToken = (typeof INVOICE_NUMBER_TOKENS)[number];
|
|
654
|
+
/** One channel's numbering series for one document kind. */
|
|
655
|
+
export interface NumberingSeries {
|
|
656
|
+
readonly salesChannelId: string;
|
|
657
|
+
readonly salesChannelCode: string;
|
|
658
|
+
readonly salesChannelName: string;
|
|
659
|
+
/** The *effective* pattern: the stored value, or the default when it is blank. */
|
|
660
|
+
readonly pattern: string;
|
|
661
|
+
}
|
|
662
|
+
/** Two series that can render one and the same document number. */
|
|
663
|
+
export interface NumberPatternCollision {
|
|
664
|
+
readonly a: NumberingSeries;
|
|
665
|
+
readonly b: NumberingSeries;
|
|
666
|
+
/** One string both series can render — the proof, for the log and for tests. */
|
|
667
|
+
readonly example: string;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Why a single pattern cannot number a series on its own. Today there is one
|
|
671
|
+
* reason: a pattern with no sequence token renders one string for a whole
|
|
672
|
+
* year, so it collides with itself on the second document.
|
|
673
|
+
*/
|
|
674
|
+
export type NumberPatternSequenceDefect = 'no_sequence_token';
|
|
675
|
+
export declare const ERP_SALE_DOCUMENT_WRITE_PORT: "erpSaleDocumentWritePort";
|
|
676
|
+
/**
|
|
677
|
+
* Metadata for a source-system attachment registered on import; bytes arrive on
|
|
678
|
+
* first download (FR-086). `externalAttachmentId` is the attachment's id in the
|
|
679
|
+
* source system, unique within its document.
|
|
680
|
+
*/
|
|
681
|
+
export declare const erpSaleDocumentAttachmentInputSchema: z.ZodObject<{
|
|
682
|
+
externalAttachmentId: z.ZodString;
|
|
683
|
+
fileName: z.ZodString;
|
|
684
|
+
contentType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
685
|
+
}, z.core.$strip>;
|
|
686
|
+
export type ErpSaleDocumentAttachmentInput = z.infer<typeof erpSaleDocumentAttachmentInputSchema>;
|
|
687
|
+
export declare const erpSaleDocumentUpsertInputSchema: z.ZodObject<{
|
|
688
|
+
organizationId: z.ZodString;
|
|
689
|
+
orderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
690
|
+
externalDocumentRef: z.ZodObject<{
|
|
691
|
+
system: z.ZodString;
|
|
692
|
+
externalId: z.ZodString;
|
|
693
|
+
externalNumber: z.ZodOptional<z.ZodString>;
|
|
694
|
+
documentKind: z.ZodEnum<{
|
|
695
|
+
invoice: "invoice";
|
|
696
|
+
wz: "wz";
|
|
697
|
+
}>;
|
|
698
|
+
}, z.core.$strip>;
|
|
699
|
+
kind: z.ZodEnum<{
|
|
700
|
+
proforma: "proforma";
|
|
701
|
+
invoice: "invoice";
|
|
702
|
+
correction: "correction";
|
|
703
|
+
wz: "wz";
|
|
704
|
+
}>;
|
|
705
|
+
number: z.ZodString;
|
|
706
|
+
currency: z.ZodString;
|
|
707
|
+
issuedAt: z.ZodString;
|
|
708
|
+
saleDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
709
|
+
paymentDueDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
710
|
+
paymentMethod: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
711
|
+
netTotal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
712
|
+
taxTotal: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
713
|
+
grossTotal: z.ZodString;
|
|
714
|
+
paidTotal: z.ZodOptional<z.ZodString>;
|
|
715
|
+
buyerSnapshot: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
716
|
+
name: z.ZodString;
|
|
717
|
+
taxId: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
718
|
+
addressLine1: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
719
|
+
addressLine2: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
720
|
+
postalCode: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
721
|
+
city: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
722
|
+
country: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
723
|
+
}, z.core.$strip>>>;
|
|
724
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
725
|
+
externalAttachmentId: z.ZodString;
|
|
726
|
+
fileName: z.ZodString;
|
|
727
|
+
contentType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
728
|
+
}, z.core.$strip>>>;
|
|
729
|
+
}, z.core.$strip>;
|
|
730
|
+
export type ErpSaleDocumentUpsertInput = z.infer<typeof erpSaleDocumentUpsertInputSchema>;
|
|
731
|
+
export declare const erpSaleDocumentUpsertResultSchema: z.ZodObject<{
|
|
732
|
+
invoiceId: z.ZodString;
|
|
733
|
+
created: z.ZodBoolean;
|
|
734
|
+
}, z.core.$strip>;
|
|
735
|
+
export type ErpSaleDocumentUpsertResult = z.infer<typeof erpSaleDocumentUpsertResultSchema>;
|
|
736
|
+
export declare const erpSaleDocumentAttachmentListItemSchema: z.ZodObject<{
|
|
737
|
+
id: z.ZodString;
|
|
738
|
+
fileName: z.ZodString;
|
|
739
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
740
|
+
downloadHref: z.ZodString;
|
|
741
|
+
}, z.core.$strip>;
|
|
742
|
+
export type ErpSaleDocumentAttachmentListItem = z.infer<typeof erpSaleDocumentAttachmentListItemSchema>;
|
|
743
|
+
export declare const erpSaleDocumentListItemSchema: z.ZodObject<{
|
|
744
|
+
id: z.ZodString;
|
|
745
|
+
kind: z.ZodEnum<{
|
|
746
|
+
proforma: "proforma";
|
|
747
|
+
invoice: "invoice";
|
|
748
|
+
correction: "correction";
|
|
749
|
+
wz: "wz";
|
|
750
|
+
}>;
|
|
751
|
+
number: z.ZodString;
|
|
752
|
+
documentKind: z.ZodEnum<{
|
|
753
|
+
invoice: "invoice";
|
|
754
|
+
wz: "wz";
|
|
755
|
+
}>;
|
|
756
|
+
issuedAt: z.ZodString;
|
|
757
|
+
currency: z.ZodString;
|
|
758
|
+
total: z.ZodNumber;
|
|
759
|
+
orderId: z.ZodNullable<z.ZodString>;
|
|
760
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
761
|
+
id: z.ZodString;
|
|
762
|
+
fileName: z.ZodString;
|
|
763
|
+
contentType: z.ZodNullable<z.ZodString>;
|
|
764
|
+
downloadHref: z.ZodString;
|
|
765
|
+
}, z.core.$strip>>;
|
|
766
|
+
}, z.core.$strip>;
|
|
767
|
+
export type ErpSaleDocumentListItem = z.infer<typeof erpSaleDocumentListItemSchema>;
|
|
768
|
+
/**
|
|
769
|
+
* Container name: `erpSaleDocumentWritePort`. Owner: `invoices`.
|
|
770
|
+
*
|
|
771
|
+
* An importing connector calls this when it applies a sale document from its
|
|
772
|
+
* source system (FR-087). `invoices` owns persistence and identifies a document
|
|
773
|
+
* by `(externalDocumentRef.system, externalDocumentRef.externalId)`; the
|
|
774
|
+
* connector owns the mapping from its source system and lazy attachment fetch
|
|
775
|
+
* (FR-088). `upsertImportedDocument` validates its input against
|
|
776
|
+
* {@link erpSaleDocumentUpsertInputSchema} and writes nothing when it does not
|
|
777
|
+
* parse.
|
|
778
|
+
*/
|
|
779
|
+
export interface ErpSaleDocumentAttachmentContext {
|
|
780
|
+
/** The imported document's `externalDocumentRef.system`. */
|
|
781
|
+
system: string;
|
|
782
|
+
/** The imported document's `externalDocumentRef.externalId`. */
|
|
783
|
+
externalId: string;
|
|
784
|
+
/** The attachment's id in the source system. */
|
|
785
|
+
externalAttachmentId: string;
|
|
786
|
+
fileName: string;
|
|
787
|
+
contentType: string | null;
|
|
788
|
+
}
|
|
789
|
+
export interface ErpSaleDocumentWritePort {
|
|
790
|
+
upsertImportedDocument(input: ErpSaleDocumentUpsertInput): Promise<ErpSaleDocumentUpsertResult>;
|
|
791
|
+
resolveAttachmentContext(input: {
|
|
792
|
+
invoiceId: string;
|
|
793
|
+
attachmentId: string;
|
|
794
|
+
organizationId: string;
|
|
795
|
+
}): Promise<ErpSaleDocumentAttachmentContext | null>;
|
|
796
|
+
/** Links fetched attachment bytes to an ERP-imported document (feature 119, FR-086). */
|
|
797
|
+
linkAttachmentAsset(input: {
|
|
798
|
+
invoiceId: string;
|
|
799
|
+
attachmentId: string;
|
|
800
|
+
organizationId: string;
|
|
801
|
+
assetId: string;
|
|
802
|
+
contentType?: string | null;
|
|
803
|
+
}): Promise<boolean>;
|
|
804
|
+
}
|
|
805
|
+
export declare const INVOICE_ATTACHMENT_FETCH_REGISTRY: "invoiceAttachmentFetchRegistry";
|
|
806
|
+
/**
|
|
807
|
+
* Fetches and stores the bytes of one attachment of an ERP-imported sale
|
|
808
|
+
* document, on its first download (feature 119, FR-086). Answers the stored
|
|
809
|
+
* asset, or `null` when the attachment cannot be fetched.
|
|
810
|
+
*
|
|
811
|
+
* Implemented by the connector that imported the document. `invoices` calls it
|
|
812
|
+
* only through its own registry, after it has checked that the invoice and the
|
|
813
|
+
* attachment belong to the calling organization.
|
|
814
|
+
*/
|
|
815
|
+
export interface InvoiceAttachmentFetchPort {
|
|
816
|
+
ensureAttachmentBytes(input: {
|
|
817
|
+
invoiceId: string;
|
|
818
|
+
attachmentId: string;
|
|
819
|
+
organizationId: string;
|
|
820
|
+
}): Promise<{
|
|
821
|
+
assetId: string;
|
|
822
|
+
} | null>;
|
|
823
|
+
}
|
|
824
|
+
/** One contributed fetch provider, with the module that contributed it. */
|
|
825
|
+
export interface InvoiceAttachmentFetchRegistration {
|
|
826
|
+
/** The `externalDocumentRef.system` value of the documents this provider serves. */
|
|
827
|
+
readonly system: string;
|
|
828
|
+
/** The contributing module; its effective presence is read on every download. */
|
|
829
|
+
readonly moduleId: string;
|
|
830
|
+
readonly provider: InvoiceAttachmentFetchPort;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Container name: `invoiceAttachmentFetchRegistry`. Owner: `invoices`.
|
|
834
|
+
*
|
|
835
|
+
* A contribution registry: a connector registers its provider from a boot
|
|
836
|
+
* hook, keyed by the source system it imports from. It is an ungated
|
|
837
|
+
* registration, and `invoices` skips a provider whose module is not
|
|
838
|
+
* effectively present, so the customer route answers the attachment as not
|
|
839
|
+
* found rather than reaching a switched-off connector. A second provider for a
|
|
840
|
+
* system that already has one is refused, not ordered.
|
|
841
|
+
*/
|
|
842
|
+
export interface InvoiceAttachmentFetchRegistryPort {
|
|
843
|
+
register(registration: InvoiceAttachmentFetchRegistration): void;
|
|
844
|
+
}
|
|
845
|
+
//# sourceMappingURL=invoices.d.ts.map
|