@endora-commerce/mod-invoices 0.0.0-stage → 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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/dist/admin/components/InvoiceSectionTabs.d.ts +22 -0
  4. package/dist/admin/components/InvoiceSectionTabs.d.ts.map +1 -0
  5. package/dist/admin/components/InvoiceSectionTabs.js +34 -0
  6. package/dist/admin/components/InvoiceSectionTabs.js.map +1 -0
  7. package/dist/admin/index.d.ts +34 -0
  8. package/dist/admin/index.d.ts.map +1 -0
  9. package/dist/admin/index.js +69 -0
  10. package/dist/admin/index.js.map +1 -0
  11. package/dist/admin/pages/InvoiceDetail.d.ts +10 -0
  12. package/dist/admin/pages/InvoiceDetail.d.ts.map +1 -0
  13. package/dist/admin/pages/InvoiceDetail.js +111 -0
  14. package/dist/admin/pages/InvoiceDetail.js.map +1 -0
  15. package/dist/admin/pages/InvoiceTemplateEditor.d.ts +11 -0
  16. package/dist/admin/pages/InvoiceTemplateEditor.d.ts.map +1 -0
  17. package/dist/admin/pages/InvoiceTemplateEditor.js +188 -0
  18. package/dist/admin/pages/InvoiceTemplateEditor.js.map +1 -0
  19. package/dist/admin/pages/InvoiceTemplatesPage.d.ts +10 -0
  20. package/dist/admin/pages/InvoiceTemplatesPage.d.ts.map +1 -0
  21. package/dist/admin/pages/InvoiceTemplatesPage.js +60 -0
  22. package/dist/admin/pages/InvoiceTemplatesPage.js.map +1 -0
  23. package/dist/admin/pages/InvoicesList.d.ts +9 -0
  24. package/dist/admin/pages/InvoicesList.d.ts.map +1 -0
  25. package/dist/admin/pages/InvoicesList.js +116 -0
  26. package/dist/admin/pages/InvoicesList.js.map +1 -0
  27. package/dist/admin/templates/described-blocks.d.ts +67 -0
  28. package/dist/admin/templates/described-blocks.d.ts.map +1 -0
  29. package/dist/admin/templates/described-blocks.js +83 -0
  30. package/dist/admin/templates/described-blocks.js.map +1 -0
  31. package/dist/admin/templates/invoice-builder-plugin.d.ts +4 -0
  32. package/dist/admin/templates/invoice-builder-plugin.d.ts.map +1 -0
  33. package/dist/admin/templates/invoice-builder-plugin.js +12 -0
  34. package/dist/admin/templates/invoice-builder-plugin.js.map +1 -0
  35. package/dist/admin/templates/invoice-puck-config.d.ts +37 -0
  36. package/dist/admin/templates/invoice-puck-config.d.ts.map +1 -0
  37. package/dist/admin/templates/invoice-puck-config.js +733 -0
  38. package/dist/admin/templates/invoice-puck-config.js.map +1 -0
  39. package/dist/backend/email-templates/invoice-issued.default.d.ts +10 -0
  40. package/dist/backend/email-templates/invoice-issued.default.d.ts.map +1 -0
  41. package/dist/backend/email-templates/invoice-issued.default.js +45 -0
  42. package/dist/backend/email-templates/invoice-issued.default.js.map +1 -0
  43. package/dist/backend/entities/invoice-external-attachment.entity.d.ts +20 -0
  44. package/dist/backend/entities/invoice-external-attachment.entity.d.ts.map +1 -0
  45. package/dist/backend/entities/invoice-external-attachment.entity.js +77 -0
  46. package/dist/backend/entities/invoice-external-attachment.entity.js.map +1 -0
  47. package/dist/backend/entities/invoice-line.entity.d.ts +20 -0
  48. package/dist/backend/entities/invoice-line.entity.d.ts.map +1 -0
  49. package/dist/backend/entities/invoice-line.entity.js +82 -0
  50. package/dist/backend/entities/invoice-line.entity.js.map +1 -0
  51. package/dist/backend/entities/invoice-number-counter.entity.d.ts +18 -0
  52. package/dist/backend/entities/invoice-number-counter.entity.d.ts.map +1 -0
  53. package/dist/backend/entities/invoice-number-counter.entity.js +63 -0
  54. package/dist/backend/entities/invoice-number-counter.entity.js.map +1 -0
  55. package/dist/backend/entities/invoice-template.entity.d.ts +22 -0
  56. package/dist/backend/entities/invoice-template.entity.d.ts.map +1 -0
  57. package/dist/backend/entities/invoice-template.entity.js +84 -0
  58. package/dist/backend/entities/invoice-template.entity.js.map +1 -0
  59. package/dist/backend/entities/invoice.entity.d.ts +64 -0
  60. package/dist/backend/entities/invoice.entity.d.ts.map +1 -0
  61. package/dist/backend/entities/invoice.entity.js +202 -0
  62. package/dist/backend/entities/invoice.entity.js.map +1 -0
  63. package/dist/backend/index.d.ts +111 -0
  64. package/dist/backend/index.d.ts.map +1 -0
  65. package/dist/backend/index.js +291 -0
  66. package/dist/backend/index.js.map +1 -0
  67. package/dist/backend/pdf-components/descriptor.d.ts +29 -0
  68. package/dist/backend/pdf-components/descriptor.d.ts.map +1 -0
  69. package/dist/backend/pdf-components/descriptor.js +227 -0
  70. package/dist/backend/pdf-components/descriptor.js.map +1 -0
  71. package/dist/backend/pdf-components/embed-logo-images.d.ts +35 -0
  72. package/dist/backend/pdf-components/embed-logo-images.d.ts.map +1 -0
  73. package/dist/backend/pdf-components/embed-logo-images.js +101 -0
  74. package/dist/backend/pdf-components/embed-logo-images.js.map +1 -0
  75. package/dist/backend/pdf-components/sample.d.ts +4 -0
  76. package/dist/backend/pdf-components/sample.d.ts.map +1 -0
  77. package/dist/backend/pdf-components/sample.js +75 -0
  78. package/dist/backend/pdf-components/sample.js.map +1 -0
  79. package/dist/backend/pdf-components/sections.d.ts +34 -0
  80. package/dist/backend/pdf-components/sections.d.ts.map +1 -0
  81. package/dist/backend/pdf-components/sections.js +445 -0
  82. package/dist/backend/pdf-components/sections.js.map +1 -0
  83. package/dist/backend/pdf-components/tree-mapper.d.ts +37 -0
  84. package/dist/backend/pdf-components/tree-mapper.d.ts.map +1 -0
  85. package/dist/backend/pdf-components/tree-mapper.js +76 -0
  86. package/dist/backend/pdf-components/tree-mapper.js.map +1 -0
  87. package/dist/backend/plugin.d.ts +124 -0
  88. package/dist/backend/plugin.d.ts.map +1 -0
  89. package/dist/backend/plugin.js +87 -0
  90. package/dist/backend/plugin.js.map +1 -0
  91. package/dist/backend/routes.admin.d.ts +41 -0
  92. package/dist/backend/routes.admin.d.ts.map +1 -0
  93. package/dist/backend/routes.admin.js +219 -0
  94. package/dist/backend/routes.admin.js.map +1 -0
  95. package/dist/backend/routes.customer.d.ts +33 -0
  96. package/dist/backend/routes.customer.d.ts.map +1 -0
  97. package/dist/backend/routes.customer.js +124 -0
  98. package/dist/backend/routes.customer.js.map +1 -0
  99. package/dist/backend/seeds/generic-invoice-template.d.ts +18 -0
  100. package/dist/backend/seeds/generic-invoice-template.d.ts.map +1 -0
  101. package/dist/backend/seeds/generic-invoice-template.js +174 -0
  102. package/dist/backend/seeds/generic-invoice-template.js.map +1 -0
  103. package/dist/backend/services/amount-to-words.d.ts +20 -0
  104. package/dist/backend/services/amount-to-words.d.ts.map +1 -0
  105. package/dist/backend/services/amount-to-words.js +232 -0
  106. package/dist/backend/services/amount-to-words.js.map +1 -0
  107. package/dist/backend/services/auto-issue-reactor.d.ts +53 -0
  108. package/dist/backend/services/auto-issue-reactor.d.ts.map +1 -0
  109. package/dist/backend/services/auto-issue-reactor.js +122 -0
  110. package/dist/backend/services/auto-issue-reactor.js.map +1 -0
  111. package/dist/backend/services/corrective-invoice.d.ts +38 -0
  112. package/dist/backend/services/corrective-invoice.d.ts.map +1 -0
  113. package/dist/backend/services/corrective-invoice.js +257 -0
  114. package/dist/backend/services/corrective-invoice.js.map +1 -0
  115. package/dist/backend/services/cross-module-context.d.ts +82 -0
  116. package/dist/backend/services/cross-module-context.d.ts.map +1 -0
  117. package/dist/backend/services/cross-module-context.js +93 -0
  118. package/dist/backend/services/cross-module-context.js.map +1 -0
  119. package/dist/backend/services/duplicate-number-refusal.d.ts +33 -0
  120. package/dist/backend/services/duplicate-number-refusal.d.ts.map +1 -0
  121. package/dist/backend/services/duplicate-number-refusal.js +92 -0
  122. package/dist/backend/services/duplicate-number-refusal.js.map +1 -0
  123. package/dist/backend/services/erp-sale-document-write-port.d.ts +37 -0
  124. package/dist/backend/services/erp-sale-document-write-port.d.ts.map +1 -0
  125. package/dist/backend/services/erp-sale-document-write-port.js +192 -0
  126. package/dist/backend/services/erp-sale-document-write-port.js.map +1 -0
  127. package/dist/backend/services/invoice-attachment-fetch-registry.d.ts +75 -0
  128. package/dist/backend/services/invoice-attachment-fetch-registry.d.ts.map +1 -0
  129. package/dist/backend/services/invoice-attachment-fetch-registry.js +81 -0
  130. package/dist/backend/services/invoice-attachment-fetch-registry.js.map +1 -0
  131. package/dist/backend/services/invoice-copy-host.service.d.ts +9 -0
  132. package/dist/backend/services/invoice-copy-host.service.d.ts.map +1 -0
  133. package/dist/backend/services/invoice-copy-host.service.js +52 -0
  134. package/dist/backend/services/invoice-copy-host.service.js.map +1 -0
  135. package/dist/backend/services/invoice-email-dispatch.d.ts +89 -0
  136. package/dist/backend/services/invoice-email-dispatch.d.ts.map +1 -0
  137. package/dist/backend/services/invoice-email-dispatch.js +138 -0
  138. package/dist/backend/services/invoice-email-dispatch.js.map +1 -0
  139. package/dist/backend/services/invoice-line-builder.d.ts +29 -0
  140. package/dist/backend/services/invoice-line-builder.d.ts.map +1 -0
  141. package/dist/backend/services/invoice-line-builder.js +46 -0
  142. package/dist/backend/services/invoice-line-builder.js.map +1 -0
  143. package/dist/backend/services/invoice-number-collisions.d.ts +17 -0
  144. package/dist/backend/services/invoice-number-collisions.d.ts.map +1 -0
  145. package/dist/backend/services/invoice-number-collisions.js +154 -0
  146. package/dist/backend/services/invoice-number-collisions.js.map +1 -0
  147. package/dist/backend/services/invoice-number-generator.d.ts +96 -0
  148. package/dist/backend/services/invoice-number-generator.d.ts.map +1 -0
  149. package/dist/backend/services/invoice-number-generator.js +157 -0
  150. package/dist/backend/services/invoice-number-generator.js.map +1 -0
  151. package/dist/backend/services/invoice-pdf-block-registry.d.ts +65 -0
  152. package/dist/backend/services/invoice-pdf-block-registry.d.ts.map +1 -0
  153. package/dist/backend/services/invoice-pdf-block-registry.js +94 -0
  154. package/dist/backend/services/invoice-pdf-block-registry.js.map +1 -0
  155. package/dist/backend/services/invoice-pdf-renderer.d.ts +57 -0
  156. package/dist/backend/services/invoice-pdf-renderer.d.ts.map +1 -0
  157. package/dist/backend/services/invoice-pdf-renderer.js +158 -0
  158. package/dist/backend/services/invoice-pdf-renderer.js.map +1 -0
  159. package/dist/backend/services/invoice-pdf.d.ts +24 -0
  160. package/dist/backend/services/invoice-pdf.d.ts.map +1 -0
  161. package/dist/backend/services/invoice-pdf.js +52 -0
  162. package/dist/backend/services/invoice-pdf.js.map +1 -0
  163. package/dist/backend/services/invoice-placement-apply-port.d.ts +29 -0
  164. package/dist/backend/services/invoice-placement-apply-port.d.ts.map +1 -0
  165. package/dist/backend/services/invoice-placement-apply-port.js +40 -0
  166. package/dist/backend/services/invoice-placement-apply-port.js.map +1 -0
  167. package/dist/backend/services/invoice-read-port.d.ts +44 -0
  168. package/dist/backend/services/invoice-read-port.d.ts.map +1 -0
  169. package/dist/backend/services/invoice-read-port.js +95 -0
  170. package/dist/backend/services/invoice-read-port.js.map +1 -0
  171. package/dist/backend/services/invoice-service.d.ts +94 -0
  172. package/dist/backend/services/invoice-service.d.ts.map +1 -0
  173. package/dist/backend/services/invoice-service.js +374 -0
  174. package/dist/backend/services/invoice-service.js.map +1 -0
  175. package/dist/backend/services/invoice-template-service.d.ts +43 -0
  176. package/dist/backend/services/invoice-template-service.d.ts.map +1 -0
  177. package/dist/backend/services/invoice-template-service.js +147 -0
  178. package/dist/backend/services/invoice-template-service.js.map +1 -0
  179. package/dist/backend/services/numbering-configuration.d.ts +76 -0
  180. package/dist/backend/services/numbering-configuration.d.ts.map +1 -0
  181. package/dist/backend/services/numbering-configuration.js +176 -0
  182. package/dist/backend/services/numbering-configuration.js.map +1 -0
  183. package/dist/backend/services/numbering-write-validator.d.ts +22 -0
  184. package/dist/backend/services/numbering-write-validator.d.ts.map +1 -0
  185. package/dist/backend/services/numbering-write-validator.js +82 -0
  186. package/dist/backend/services/numbering-write-validator.js.map +1 -0
  187. package/dist/backend/services/seller-settings.d.ts +24 -0
  188. package/dist/backend/services/seller-settings.d.ts.map +1 -0
  189. package/dist/backend/services/seller-settings.js +38 -0
  190. package/dist/backend/services/seller-settings.js.map +1 -0
  191. package/dist/backend/services/vendor-number-hold.d.ts +10 -0
  192. package/dist/backend/services/vendor-number-hold.d.ts.map +1 -0
  193. package/dist/backend/services/vendor-number-hold.js +14 -0
  194. package/dist/backend/services/vendor-number-hold.js.map +1 -0
  195. package/dist/manifest.d.ts +203 -0
  196. package/dist/manifest.d.ts.map +1 -0
  197. package/dist/manifest.js +390 -0
  198. package/dist/manifest.js.map +1 -0
  199. package/dist/migrations/20260629T125121_invoices_module.d.ts +17 -0
  200. package/dist/migrations/20260629T125121_invoices_module.d.ts.map +1 -0
  201. package/dist/migrations/20260629T125121_invoices_module.js +117 -0
  202. package/dist/migrations/20260629T125121_invoices_module.js.map +1 -0
  203. package/dist/migrations/20260801T111000_invoices_generic_template_reseed.d.ts +6 -0
  204. package/dist/migrations/20260801T111000_invoices_generic_template_reseed.d.ts.map +1 -0
  205. package/dist/migrations/20260801T111000_invoices_generic_template_reseed.js +25 -0
  206. package/dist/migrations/20260801T111000_invoices_generic_template_reseed.js.map +1 -0
  207. package/dist/migrations/20260817T201110_invoices_correction_idempotency_key.d.ts +20 -0
  208. package/dist/migrations/20260817T201110_invoices_correction_idempotency_key.d.ts.map +1 -0
  209. package/dist/migrations/20260817T201110_invoices_correction_idempotency_key.js +33 -0
  210. package/dist/migrations/20260817T201110_invoices_correction_idempotency_key.js.map +1 -0
  211. package/dist/migrations/20260903T101756_invoices_namespace_block_names.d.ts +6 -0
  212. package/dist/migrations/20260903T101756_invoices_namespace_block_names.d.ts.map +1 -0
  213. package/dist/migrations/20260903T101756_invoices_namespace_block_names.js +56 -0
  214. package/dist/migrations/20260903T101756_invoices_namespace_block_names.js.map +1 -0
  215. package/dist/migrations/20260914T133603_invoices_erp_imported_sale_documents.d.ts +12 -0
  216. package/dist/migrations/20260914T133603_invoices_erp_imported_sale_documents.d.ts.map +1 -0
  217. package/dist/migrations/20260914T133603_invoices_erp_imported_sale_documents.js +87 -0
  218. package/dist/migrations/20260914T133603_invoices_erp_imported_sale_documents.js.map +1 -0
  219. package/dist/migrations/20260926T230239_invoices_import_identity.d.ts +33 -0
  220. package/dist/migrations/20260926T230239_invoices_import_identity.d.ts.map +1 -0
  221. package/dist/migrations/20260926T230239_invoices_import_identity.js +83 -0
  222. package/dist/migrations/20260926T230239_invoices_import_identity.js.map +1 -0
  223. package/dist/migrations/index.d.ts +32 -0
  224. package/dist/migrations/index.d.ts.map +1 -0
  225. package/dist/migrations/index.js +39 -0
  226. package/dist/migrations/index.js.map +1 -0
  227. package/dist/ports/index.d.ts +93 -0
  228. package/dist/ports/index.d.ts.map +1 -0
  229. package/dist/ports/index.js +2 -0
  230. package/dist/ports/index.js.map +1 -0
  231. package/docs/invoices.md +113 -0
  232. package/i18n/en.json +45 -0
  233. package/i18n/pl.json +45 -0
  234. package/package.json +119 -3
  235. package/tailwind.css +14 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.entity.d.ts","sourceRoot":"","sources":["../../../src/backend/entities/invoice.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAgC,MAAM,iBAAiB,CAAC;AAE7F,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGvG;;;;;GAKG;AACH,qBAEa,OAAO;IAClB,CAAC,aAAa,CAAC,CAAC,EACZ,IAAI,GACJ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,UAAU,GACV,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,WAAW,GACX,mBAAmB,GACnB,0BAA0B,GAC1B,YAAY,GACZ,gBAAgB,GAChB,eAAe,GACf,qBAAqB,GACrB,iBAAiB,GACjB,UAAU,GACV,QAAQ,GACR,gBAAgB,GAChB,qBAAqB,GACrB,SAAS,CAAC;IAGd,EAAE,EAAE,MAAM,CAAgB;IAI1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAIxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAI/B,MAAM,EAAE,UAAU,GAAG,YAAY,CAAc;IAG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ate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { Entity, Index, OptionalProps, PrimaryKey, Property, Unique } from '@mikro-orm/core';
11
+ import { randomUUID } from 'crypto';
12
+ import { TransitivelyScoped } from '@endora-commerce/platform/tenancy';
13
+ /**
14
+ * Invoice — a document issued against an order (feature 047). Immutable once
15
+ * `status = 'ready'`; content changes only via a `correction` invoice. The
16
+ * legacy `total` column is retained as an alias of `grossTotal` for back-compat
17
+ * with the original commerce-init schema.
18
+ */
19
+ let Invoice = class Invoice {
20
+ [OptionalProps];
21
+ id = randomUUID();
22
+ orderId;
23
+ organizationId;
24
+ origin = 'platform';
25
+ externalDocumentRef;
26
+ salesChannelId;
27
+ kind;
28
+ number;
29
+ issuedAt = new Date();
30
+ saleDate;
31
+ paymentDueDate;
32
+ paymentMethod;
33
+ currency;
34
+ netTotal;
35
+ taxTotal;
36
+ total;
37
+ paidTotal = '0';
38
+ originalInvoiceId;
39
+ /**
40
+ * The caller's key for a correction, unique among the rows that carry one
41
+ * (D-91). A return settlement passes its return case id, so a retried
42
+ * settlement is answered with the document the first attempt issued instead
43
+ * of a second one. Null on every invoice issued without a key — every
44
+ * `proforma`, every `invoice`, and every correction issued by hand.
45
+ */
46
+ correctionIdempotencyKey;
47
+ templateId;
48
+ sellerSnapshot;
49
+ buyerSnapshot;
50
+ /**
51
+ * The invoice's number in KSeF and when KSeF processed it — **this module's
52
+ * columns, and staying here** (`specs/134-paid-module-extraction/` T067).
53
+ *
54
+ * KSeF is Poland's statutory e-invoicing clearing system, not a vendor.
55
+ * Whether and when an invoice reached it is a fact about the invoice, written
56
+ * by whichever module delivered it: the `ksef` module submitting directly
57
+ * (`recordKsefAssignment`), or an accounting vendor behind `invoice_ledger`
58
+ * submitting on the operator's behalf (`invoiceKsefAssignmentPort`). An
59
+ * operator's own finance system reads the same fields through the invoice API.
60
+ *
61
+ * The `ksef` prefix names the clearing system, not the module of that name,
62
+ * so these are not coupling to it and do not leave with it. Do not move,
63
+ * rename or drop them to "finish" that module's extraction;
64
+ * `packages/contracts/src/statutory-ksef-state.test.ts` is the guard.
65
+ */
66
+ ksefReferenceNumber;
67
+ ksefProcessedAt;
68
+ issuedBy;
69
+ pdfAssetId;
70
+ status = 'pending';
71
+ createdAt = new Date();
72
+ updatedAt = new Date();
73
+ };
74
+ __decorate([
75
+ PrimaryKey({ type: 'uuid' }),
76
+ __metadata("design:type", String)
77
+ ], Invoice.prototype, "id", void 0);
78
+ __decorate([
79
+ Property({ type: 'uuid', nullable: true }),
80
+ Index(),
81
+ __metadata("design:type", Object)
82
+ ], Invoice.prototype, "orderId", void 0);
83
+ __decorate([
84
+ Property({ type: 'uuid', nullable: true }),
85
+ Index(),
86
+ __metadata("design:type", Object)
87
+ ], Invoice.prototype, "organizationId", void 0);
88
+ __decorate([
89
+ Property({ type: 'string', length: 16 }),
90
+ Index(),
91
+ __metadata("design:type", String)
92
+ ], Invoice.prototype, "origin", void 0);
93
+ __decorate([
94
+ Property({ type: 'json', nullable: true }),
95
+ __metadata("design:type", Object)
96
+ ], Invoice.prototype, "externalDocumentRef", void 0);
97
+ __decorate([
98
+ Property({ type: 'uuid', nullable: true }),
99
+ Index(),
100
+ __metadata("design:type", Object)
101
+ ], Invoice.prototype, "salesChannelId", void 0);
102
+ __decorate([
103
+ Property({ type: 'string', length: 16 }),
104
+ Index(),
105
+ __metadata("design:type", String)
106
+ ], Invoice.prototype, "kind", void 0);
107
+ __decorate([
108
+ Property({ type: 'string', length: 64 }),
109
+ Unique(),
110
+ __metadata("design:type", String)
111
+ ], Invoice.prototype, "number", void 0);
112
+ __decorate([
113
+ Property({ type: 'datetime' }),
114
+ __metadata("design:type", Date)
115
+ ], Invoice.prototype, "issuedAt", void 0);
116
+ __decorate([
117
+ Property({ type: 'date', nullable: true }),
118
+ __metadata("design:type", Object)
119
+ ], Invoice.prototype, "saleDate", void 0);
120
+ __decorate([
121
+ Property({ type: 'date', nullable: true }),
122
+ __metadata("design:type", Object)
123
+ ], Invoice.prototype, "paymentDueDate", void 0);
124
+ __decorate([
125
+ Property({ type: 'string', length: 64, nullable: true }),
126
+ __metadata("design:type", Object)
127
+ ], Invoice.prototype, "paymentMethod", void 0);
128
+ __decorate([
129
+ Property({ type: 'string', length: 3 }),
130
+ __metadata("design:type", String)
131
+ ], Invoice.prototype, "currency", void 0);
132
+ __decorate([
133
+ Property({ type: 'decimal', precision: 14, scale: 2, nullable: true }),
134
+ __metadata("design:type", Object)
135
+ ], Invoice.prototype, "netTotal", void 0);
136
+ __decorate([
137
+ Property({ type: 'decimal', precision: 14, scale: 2, nullable: true }),
138
+ __metadata("design:type", Object)
139
+ ], Invoice.prototype, "taxTotal", void 0);
140
+ __decorate([
141
+ Property({ type: 'decimal', precision: 14, scale: 2 }),
142
+ __metadata("design:type", String)
143
+ ], Invoice.prototype, "total", void 0);
144
+ __decorate([
145
+ Property({ type: 'decimal', precision: 14, scale: 2 }),
146
+ __metadata("design:type", String)
147
+ ], Invoice.prototype, "paidTotal", void 0);
148
+ __decorate([
149
+ Property({ type: 'uuid', nullable: true }),
150
+ __metadata("design:type", Object)
151
+ ], Invoice.prototype, "originalInvoiceId", void 0);
152
+ __decorate([
153
+ Property({ type: 'string', length: 64, nullable: true }),
154
+ __metadata("design:type", Object)
155
+ ], Invoice.prototype, "correctionIdempotencyKey", void 0);
156
+ __decorate([
157
+ Property({ type: 'uuid', nullable: true }),
158
+ __metadata("design:type", Object)
159
+ ], Invoice.prototype, "templateId", void 0);
160
+ __decorate([
161
+ Property({ type: 'json', nullable: true }),
162
+ __metadata("design:type", Object)
163
+ ], Invoice.prototype, "sellerSnapshot", void 0);
164
+ __decorate([
165
+ Property({ type: 'json', nullable: true }),
166
+ __metadata("design:type", Object)
167
+ ], Invoice.prototype, "buyerSnapshot", void 0);
168
+ __decorate([
169
+ Property({ type: 'string', length: 128, nullable: true }),
170
+ __metadata("design:type", Object)
171
+ ], Invoice.prototype, "ksefReferenceNumber", void 0);
172
+ __decorate([
173
+ Property({ type: 'datetime', nullable: true }),
174
+ __metadata("design:type", Object)
175
+ ], Invoice.prototype, "ksefProcessedAt", void 0);
176
+ __decorate([
177
+ Property({ type: 'string', length: 128, nullable: true }),
178
+ __metadata("design:type", Object)
179
+ ], Invoice.prototype, "issuedBy", void 0);
180
+ __decorate([
181
+ Property({ type: 'uuid', nullable: true }),
182
+ __metadata("design:type", Object)
183
+ ], Invoice.prototype, "pdfAssetId", void 0);
184
+ __decorate([
185
+ Property({ type: 'string', length: 16 }),
186
+ Index(),
187
+ __metadata("design:type", String)
188
+ ], Invoice.prototype, "status", void 0);
189
+ __decorate([
190
+ Property({ type: 'datetime', onCreate: () => new Date() }),
191
+ __metadata("design:type", Date)
192
+ ], Invoice.prototype, "createdAt", void 0);
193
+ __decorate([
194
+ Property({ type: 'datetime', onUpdate: () => new Date() }),
195
+ __metadata("design:type", Date)
196
+ ], Invoice.prototype, "updatedAt", void 0);
197
+ Invoice = __decorate([
198
+ TransitivelyScoped('Order', 'orderId'),
199
+ Entity({ tableName: 'invoices' })
200
+ ], Invoice);
201
+ export { Invoice };
202
+ //# sourceMappingURL=invoice.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.entity.js","sourceRoot":"","sources":["../../../src/backend/entities/invoice.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aA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,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACjC;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAChB;AAI3B;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACxC,KAAK,EAAE;;uCAC8C;AAGtD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAChD,IAAI;0CAAc;AAG7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAChD,IAAI;0CAAc;AA7IlB,OAAO;IAFnB,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC;IACtC,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;GACrB,OAAO,CA8InB"}
@@ -0,0 +1,111 @@
1
+ import type { EntityManager } from '@mikro-orm/postgresql';
2
+ import type { AuditPort } from '@endora-commerce/platform/kernel';
3
+ import type { EventBus } from '@endora-commerce/platform/events';
4
+ import type { TransactionalEmailSender } from '@endora-commerce/contracts';
5
+ import type { ModuleContext } from '@endora-commerce/platform/kernel';
6
+ import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
7
+ import type { FastifyRequest } from 'fastify';
8
+ import { type InvoicesModuleOptions, type InvoicesModuleHandle } from './plugin.js';
9
+ import { InvoicePdfBlockRegistry } from './services/invoice-pdf-block-registry.js';
10
+ import { InvoiceAttachmentFetchRegistry } from './services/invoice-attachment-fetch-registry.js';
11
+ import { NumberingConfigurationService } from './services/numbering-configuration.js';
12
+ import { InvoiceExternalAttachment } from './entities/invoice-external-attachment.entity.js';
13
+ import { InvoiceLine } from './entities/invoice-line.entity.js';
14
+ import { InvoiceNumberCounter } from './entities/invoice-number-counter.entity.js';
15
+ import { InvoiceTemplate } from './entities/invoice-template.entity.js';
16
+ import { Invoice } from './entities/invoice.entity.js';
17
+ /**
18
+ * `invoices` — a document module with a late-bound verifier (feature 072,
19
+ * wave 2, T113).
20
+ *
21
+ * **`InvoicesBridge` is gone** (`specs/110-instance-repository/` T118c). Six
22
+ * options used to be one contributed object — naming the acting admin,
23
+ * resolving the calling customer, finding the transactional e-mail sender and a
24
+ * recipient address, picking a channel's language, and loading logo bytes from
25
+ * `assets_library` — written as closures in `backend/src/composition.ts` and
26
+ * again in `backend/test/helpers/test-server.ts`. Re-derived member by member,
27
+ * none was a composition's answer to give:
28
+ *
29
+ * - the acting admin and the calling customer are the platform's own
30
+ * `adminContextResolver` and `customerContextResolver`, read from the
31
+ * cradle, which is what every other module that takes a request actor does;
32
+ * - the transactional sender is `transactional_emails`' published
33
+ * `transactionalEmailSenderAccessor`, an accessor because that module
34
+ * announces its sender later than this one composes;
35
+ * - the recipient address is `customer_accounts`' published record, the
36
+ * channel's language a read of the platform's own entity, and the logo bytes
37
+ * `assets_library`' `assetReadPort` — all three in
38
+ * `services/cross-module-context.ts`, so the mappings are testable with
39
+ * nothing composed.
40
+ *
41
+ * Five of the six were **optional** options, and the harness omitted one of
42
+ * them entirely (D-223). They are required now: an option no composition may
43
+ * decline to supply is not an option, and typing one as omittable leaves a
44
+ * branch no test can drive.
45
+ *
46
+ * **Blocks another module renders are a contribution registry, not an
47
+ * option.** `invoicePdfBlockRegistry` is this module's own; a module that
48
+ * declares an invoice template block registers its renderer, its description
49
+ * and the per-render data it needs from its own composition root, and a
50
+ * deployment without that module simply has no such section on the PDF. It
51
+ * replaced the `ksefVerificationResolver` contribution point a root had to
52
+ * fill (`specs/134-paid-module-extraction/` T063, T126): only this repository's
53
+ * reference root filled it, so an instance composed through the platform
54
+ * rendered no KSeF verification block with `ksef` installed and on, and this
55
+ * module's cradle carried a name belonging to a module that may be absent.
56
+ * Same distinction `pwa`'s auto-trigger resolvers drew — absence removes a
57
+ * feature, it does not weaken a check.
58
+ *
59
+ * `audit` and `auditLog` are two different sinks and both stop being optional:
60
+ * the first records issuance and correction (FR-035), the second is the
61
+ * co-transactional sink for template writes. An invoice is a legal document, so
62
+ * "issued but unrecorded" is the wrong failure to leave reachable by omission.
63
+ */
64
+ export interface InvoicesCradle {
65
+ readonly emFactory: () => EntityManager;
66
+ readonly eventBus: EventBus;
67
+ readonly auditLogService: AuditPort;
68
+ readonly requireAdmin: RequireAdminFactory;
69
+ readonly requireCustomer: (req: FastifyRequest, reply: unknown) => Promise<void>;
70
+ readonly settingsReadPort: InvoicesModuleOptions['settingsService'];
71
+ /** Platform-owned name — how this composition names the acting admin. */
72
+ readonly adminContextResolver: (req: FastifyRequest) => {
73
+ adminUserId: string;
74
+ };
75
+ /** Platform-owned name — how this composition names the calling customer. */
76
+ readonly customerContextResolver: (req: FastifyRequest) => {
77
+ customerAccountId: string;
78
+ organizationId: string;
79
+ };
80
+ /**
81
+ * `transactional_emails`' late-bound sender, read per send. It answers
82
+ * `undefined` until that module announces it, which is later than this module
83
+ * composes — the reason it is an accessor rather than the sender itself.
84
+ */
85
+ readonly transactionalEmailSenderAccessor: () => TransactionalEmailSender | undefined;
86
+ /** The blocks other modules render onto the PDF (T063/T126). */
87
+ readonly invoicePdfBlockRegistry: InvoicePdfBlockRegistry;
88
+ readonly invoiceAttachmentFetchRegistry: InvoiceAttachmentFetchRegistry;
89
+ readonly invoices: {
90
+ handle: InvoicesModuleHandle;
91
+ plugin: unknown;
92
+ };
93
+ readonly invoiceService: InvoicesModuleHandle['invoiceService'];
94
+ readonly invoiceNumberGenerator: InvoicesModuleHandle['numberGenerator'];
95
+ readonly invoicePdfRenderer: InvoicesModuleHandle['pdfRenderer'];
96
+ readonly invoicesNumberingConfiguration: NumberingConfigurationService;
97
+ }
98
+ export declare function registerModule(ctx: ModuleContext): void;
99
+ /**
100
+ * The module's persisted entity classes, on the `./backend` subpath, as one
101
+ * array and **no named class export** (D-168).
102
+ *
103
+ * This is the shape the platform reads when the package is *installed*: the
104
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
105
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
106
+ * which is the third source of `check:module-boundary`'s `table→owner` map and
107
+ * the package pass of `check-entity-tenant-classification`. A missing array is
108
+ * answered with `[]` — zero entities registered, no error anywhere.
109
+ */
110
+ export declare const entities: (typeof Invoice | typeof InvoiceLine | typeof InvoiceNumberCounter | typeof InvoiceTemplate | typeof InvoiceExternalAttachment)[];
111
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAiBV,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAKjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAQtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kDAAkD,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,oBAAoB,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;IAChE,QAAQ,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACzE,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACjE,QAAQ,CAAC,8BAA8B,EAAE,6BAA6B,CAAC;CACxE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAmVvD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,mIAMpB,CAAC"}
@@ -0,0 +1,291 @@
1
+ import { effectiveState, lazyPort } from '@endora-commerce/platform/kernel';
2
+ import { invoicesModule } from './plugin.js';
3
+ import { CorrectiveInvoiceProvider } from './services/corrective-invoice.js';
4
+ import { ErpSaleDocumentWritePortService } from './services/erp-sale-document-write-port.js';
5
+ import { InvoicePdfBlockRegistry } from './services/invoice-pdf-block-registry.js';
6
+ import { InvoiceAttachmentFetchRegistry } from './services/invoice-attachment-fetch-registry.js';
7
+ import { InvoicePlacementApplyService } from './services/invoice-placement-apply-port.js';
8
+ import { InvoiceCopyHostService } from './services/invoice-copy-host.service.js';
9
+ import { InvoiceReadService, createInvoicePdfPort } from './services/invoice-read-port.js';
10
+ import { NumberingConfigurationService } from './services/numbering-configuration.js';
11
+ import { createNumberingPatternValidator } from './services/numbering-write-validator.js';
12
+ import { createAssetImageLoader, createChannelLanguageResolver, createRecipientEmailResolver, } from './services/cross-module-context.js';
13
+ import { INVOICE_ISSUED_DEFAULT } from './email-templates/invoice-issued.default.js';
14
+ import { InvoiceExternalAttachment } from './entities/invoice-external-attachment.entity.js';
15
+ import { InvoiceLine } from './entities/invoice-line.entity.js';
16
+ import { InvoiceNumberCounter } from './entities/invoice-number-counter.entity.js';
17
+ import { InvoiceTemplate } from './entities/invoice-template.entity.js';
18
+ import { Invoice } from './entities/invoice.entity.js';
19
+ export function registerModule(ctx) {
20
+ ctx.di.register({
21
+ /**
22
+ * Feature 078, D-95.3 / D-95.4 — the boot-time numbering configuration.
23
+ *
24
+ * The `settingsAdminService` port is resolved here, inside the factory,
25
+ * rather than from the boot hook: `settings` is non-deactivatable, so the
26
+ * gate has no state in which it says no, but keeping the resolution at the
27
+ * point of use is the rule the rest of the tree follows.
28
+ */
29
+ invoicesNumberingConfiguration: ctx
30
+ .asFunction(({ emFactory }) => {
31
+ const settingsAdmin = lazyPort(ctx, 'settingsAdminService');
32
+ return new NumberingConfigurationService(emFactory, () => settingsAdmin, ctx.log);
33
+ })
34
+ .singleton(),
35
+ /**
36
+ * `specs/134-paid-module-extraction/` T063 / T126 — the contributed PDF
37
+ * block seam, a **contribution registry** and a plain `di.register` on
38
+ * purpose. A contributor pushes its block from `ctx.onBoot`, which runs
39
+ * whatever this module's effective state is, so a `providePort` gate here
40
+ * would stop the backend from starting for an operator who switched
41
+ * invoicing off. Presence is answered per render and per descriptor read,
42
+ * keyed on the contributor recorded with each block; the policy is stated
43
+ * at the class.
44
+ */
45
+ invoicePdfBlockRegistry: ctx
46
+ .asFunction(() => new InvoicePdfBlockRegistry((moduleId) => effectiveState.isPresent(moduleId)))
47
+ .singleton(),
48
+ /**
49
+ * Feature 134, T061 (`research.md` D12) — the ERP attachment fetch seam, a
50
+ * **contribution registry** and a plain `di.register` on purpose. A
51
+ * connector pushes its provider from `ctx.onBoot`, which runs whatever this
52
+ * module's effective state is, so a `providePort` gate here would stop the
53
+ * backend from starting for an operator who switched invoicing off. The
54
+ * presence question is answered per download, keyed on the contributor
55
+ * recorded with each provider; the policy is stated at the class.
56
+ */
57
+ invoiceAttachmentFetchRegistry: ctx
58
+ .asFunction(({ emFactory }) => {
59
+ const context = new ErpSaleDocumentWritePortService(emFactory);
60
+ return new InvoiceAttachmentFetchRegistry((input) => context.resolveAttachmentContext(input), (moduleId) => effectiveState.isPresent(moduleId));
61
+ })
62
+ .singleton(),
63
+ invoices: ctx
64
+ .asFunction(({ emFactory, eventBus, auditLogService, invoicePdfBlockRegistry }) => {
65
+ const cradle = () => ctx.cradle();
66
+ const result = invoicesModule({
67
+ emFactory,
68
+ // Feature 075, Phase C — `orders`' published read model, resolved per
69
+ // call. The five reads it replaces were `em.findOne(Order, …)` /
70
+ // `em.find(OrderItem, …)` in this module's own services and routes:
71
+ // deactivation drops no tables, so they kept answering out of an
72
+ // `orders` an operator had switched off. `orders` is already a
73
+ // binding dependency of this manifest and the edge stays fail-closed.
74
+ orderReadPort: lazyPort(ctx, 'orderReadPort'),
75
+ assetReadPort: lazyPort(ctx, 'assetReadPort'),
76
+ assetsLibrary: lazyPort(ctx, 'assetsLibraryPort'),
77
+ // Feature 134, T061 — this module's own registry, not a connector's
78
+ // port: it dispatches on the document's source system and answers
79
+ // `null` for a provider that is absent, off or unknown.
80
+ saleDocumentAttachments: cradle().invoiceAttachmentFetchRegistry,
81
+ eventBus,
82
+ audit: auditLogService,
83
+ auditLog: auditLogService,
84
+ settingsService: lazyPort(ctx, 'settingsReadPort'),
85
+ requireAdmin: (permission) => async (req, reply) => ctx.cradle().requireAdmin(permission)(req, reply),
86
+ requireCustomer: (req, reply) => ctx.cradle().requireCustomer(req, reply),
87
+ // T118c — the platform's own actor resolvers, read per request. Both
88
+ // were `invoicesBridge` members spelling the identical closure in two
89
+ // roots: `resolveAdminUserId` was `adminContextResolver(req).adminUserId`
90
+ // in `composition.ts` verbatim, and `resolveCustomerContext` was
91
+ // `customerContextResolver(req)` minus the impersonator field this
92
+ // module does not read. That is the shape `mfa` found in two of its
93
+ // six members and `pwa` in one of its eight.
94
+ resolveAdminUserId: (req) => cradle().adminContextResolver(req).adminUserId,
95
+ resolveCustomerContext: (req) => cradle().customerContextResolver(req),
96
+ // Read per send: `transactional_emails` announces its sender after
97
+ // this module composes, so the accessor is the value and the sender
98
+ // is whatever it answers at the moment the e-mail goes out.
99
+ getTransactionalEmailSender: () => cradle().transactionalEmailSenderAccessor(),
100
+ resolveRecipientEmail: createRecipientEmailResolver(lazyPort(ctx, 'customerAccountReadPort')),
101
+ resolveLanguage: createChannelLanguageResolver(emFactory),
102
+ loadAssetImage: createAssetImageLoader(lazyPort(ctx, 'assetReadPort')),
103
+ pdfBlocks: invoicePdfBlockRegistry,
104
+ ledgerRouting: {
105
+ numberingModeFor: async (salesChannelId) => {
106
+ if (!effectiveState.isPresent('invoice_ledger'))
107
+ return 'endora';
108
+ return lazyPort(ctx, 'invoiceLedgerRoutingPort').numberingModeFor(salesChannelId);
109
+ },
110
+ activeVendorModuleId: async () => {
111
+ if (!effectiveState.isPresent('invoice_ledger'))
112
+ return null;
113
+ return lazyPort(ctx, 'invoiceLedgerRoutingPort').activeVendorModuleId();
114
+ },
115
+ },
116
+ });
117
+ return result;
118
+ })
119
+ .singleton(),
120
+ });
121
+ ctx.di.providePort('invoiceService', ctx.asFunction(({ invoices }) => invoices.handle.invoiceService).singleton());
122
+ ctx.di.providePort('invoiceNumberingHostPort', ctx.asFunction(({ invoices }) => invoices.handle.invoiceService).singleton());
123
+ ctx.di.providePort('invoicePaidHostPort', ctx.asFunction(({ invoices }) => invoices.handle.invoiceService).singleton());
124
+ ctx.di.providePort('invoiceKsefAssignmentPort', ctx.asFunction(({ invoices }) => invoices.handle.invoiceService).singleton());
125
+ ctx.di.providePort('invoiceCopyHostPort', ctx
126
+ .asFunction(({ emFactory }) => {
127
+ const orders = lazyPort(ctx, 'orderReadPort');
128
+ return new InvoiceCopyHostService(emFactory, orders);
129
+ })
130
+ .singleton());
131
+ ctx.di.providePort('invoiceNumberGenerator', ctx.asFunction(({ invoices }) => invoices.handle.numberGenerator).singleton());
132
+ // ---------------------------------------------------------------------------
133
+ // Feature 075, Phase P — the published surface.
134
+ //
135
+ // Four inbound sites read the `Invoice` entity — `orders` twice, `ksef`
136
+ // twice. `invoiceReadPort` is that read; `invoicePdfPort` is the document
137
+ // surface `orders` renders from, and it is a port rather than a relocation
138
+ // even though the two builders behind it are pure. See its note: the
139
+ // question a document asks is Constitution XVII's, not FR-013's.
140
+ // ---------------------------------------------------------------------------
141
+ ctx.di.providePort('invoiceReadPort', ctx.asFunction(({ emFactory }) => new InvoiceReadService(emFactory)).singleton());
142
+ ctx.di.providePort('erpSaleDocumentWritePort', ctx
143
+ .asFunction(({ emFactory }) => new ErpSaleDocumentWritePortService(emFactory))
144
+ .singleton());
145
+ ctx.di.providePort('invoicePdfPort', ctx.asFunction(() => createInvoicePdfPort()).singleton());
146
+ /**
147
+ * The proforma order placement opens, on the **caller's** `EntityManager`
148
+ * (feature 080, T048; D-169).
149
+ *
150
+ * `orders` imported this module's `Invoice` class for it until T048 — a
151
+ * co-transactional seam D-78 point 2 ruled permanent, held by
152
+ * `invoices_order_fk` (`on delete restrict`): the row cannot exist before its
153
+ * order does, and the order does not commit until placement returns. The
154
+ * constraint and the transaction are unchanged; what moved is the statement,
155
+ * to the module that owns the table. `InvoicePlacementApplyPort` is declared
156
+ * in this module's `ports/` directory rather than in
157
+ * `@endora-commerce/contracts`, because it takes a MikroORM `EntityManager`
158
+ * and FR-034 keeps that package free of them.
159
+ *
160
+ * It is a **gated** registration like every other name here, which is the
161
+ * half `orders` writing the row itself could never have: an operator who has
162
+ * switched invoicing off now gets no proforma, instead of one written into a
163
+ * switched-off module's table. `orders` declares the edge `degrades-without`
164
+ * and asks presence before the call.
165
+ */
166
+ ctx.di.providePort('invoicePlacementApplyPort', ctx.asFunction(() => new InvoicePlacementApplyService()).singleton());
167
+ ctx.di.providePort('invoicePdfRenderer', ctx.asFunction(({ invoices }) => invoices.handle.pdfRenderer).singleton());
168
+ /**
169
+ * The corrective invoice a return settlement issues (feature 046 / 047 US3),
170
+ * as this module's port instead of a class both roots constructed (T143c).
171
+ *
172
+ * This is the entry the ledger was worth building for: the two roots built it
173
+ * with **different** number generators. Production passed an accessor onto
174
+ * `invoiceNumberGenerator`, the module's one instance; the harness built a
175
+ * second `InvoiceNumberGenerator` over a second pattern resolver, so every
176
+ * corrective number a test drew came out of a counter the module could not
177
+ * see. One instance now, in both compositions, and it stops answering when
178
+ * `invoices` is switched off — which a root's copy never did, correction
179
+ * numbers and all.
180
+ *
181
+ * The generator is still reached through an accessor rather than
182
+ * destructured: it is this module's own gated port, so resolving it while
183
+ * this registration is built asks the gate at composition time, which is what
184
+ * took the backend down for an operator who had switched the module off.
185
+ */
186
+ const numberGenerator = lazyPort(ctx, 'invoiceNumberGenerator');
187
+ ctx.di.providePort('correctiveInvoicePort', ctx
188
+ .asFunction(({ emFactory, eventBus, auditLogService }) => new CorrectiveInvoiceProvider(emFactory, () => numberGenerator, auditLogService, eventBus, {
189
+ numberingModeFor: async (salesChannelId) => {
190
+ if (!effectiveState.isPresent('invoice_ledger'))
191
+ return 'endora';
192
+ return lazyPort(ctx, 'invoiceLedgerRoutingPort').numberingModeFor(salesChannelId);
193
+ },
194
+ activeVendorModuleId: async () => {
195
+ if (!effectiveState.isPresent('invoice_ledger'))
196
+ return null;
197
+ return lazyPort(ctx, 'invoiceLedgerRoutingPort').activeVendorModuleId();
198
+ },
199
+ }))
200
+ .singleton());
201
+ /**
202
+ * FR-002 — auto-issue on an order status change (issue #107).
203
+ *
204
+ * A bare `eventBus.on` here meant the heaviest write in the sweep that found
205
+ * this: a switched-off `invoices` still issued a numbered legal document, took
206
+ * a number out of the sequence and e-mailed the PDF, with no surface an
207
+ * operator could see it on. `ctx.subscribe` gates it on the effective state.
208
+ */
209
+ ctx.subscribe('order.status_changed.v1', async (payload) => {
210
+ await ctx
211
+ .cradle()
212
+ .invoices.handle.autoIssueReactor.onOrderStatusChanged(payload);
213
+ });
214
+ ctx.routes(async (app) => {
215
+ const plugin = ctx.cradle().invoices.plugin;
216
+ await plugin(app);
217
+ });
218
+ /**
219
+ * The default subject and content for the 1 transactional email this
220
+ * module declares in its manifest (T143a).
221
+ *
222
+ * These were fourteen `emailDefaultsRegistry.register(...)` calls in
223
+ * `composition.ts`, each importing a template constant out of the module that
224
+ * owns it — a root reaching into seven modules to hand their own content to
225
+ * an eighth. Each module registers its own now.
226
+ *
227
+ * `ctx.onBoot` rather than a registration: the registry is *read* once, by
228
+ * `transactional_emails`' boot reconciler inside its plugin body. Boot hooks
229
+ * run during composition and plugin bodies only when the Fastify app is
230
+ * built, so this always lands first — by construction, not by ordering luck.
231
+ */
232
+ ctx.onBoot(async () => {
233
+ // Feature 075, Phase C — the registry's published shape. Still a
234
+ // **contribution**, not a call: the classification in the
235
+ // deactivation-consequence ledger is unchanged, and must be — the host
236
+ // filters by contributor at enumeration, so this must not become an edge
237
+ // that fails closed.
238
+ const defaults = lazyPort(ctx, 'emailDefaultsPort');
239
+ defaults.register('invoice_issued', INVOICE_ISSUED_DEFAULT, 'invoices');
240
+ });
241
+ /**
242
+ * Feature 078, D-95.2 — the settings-write validator, a **contribution**.
243
+ *
244
+ * Deliberately its own hook, and deliberately without a presence probe. The
245
+ * host filters by contributor at enumeration (`SettingWriteValidatorRegistry`
246
+ * states the policy at the class), so probing here would make switching
247
+ * `invoices` back on require a restart before its numbering rule applied
248
+ * again. It is kept separate from the numbering-configuration hook below
249
+ * because a hook that both works and contributes is a `mixed-boot-hook`, and
250
+ * its remedy is to split it — never to probe the top of it.
251
+ */
252
+ ctx.onBoot(() => {
253
+ const validators = lazyPort(ctx, 'settingWriteValidatorRegistry');
254
+ validators.register(createNumberingPatternValidator());
255
+ });
256
+ /**
257
+ * Feature 078, D-95.3 / D-95.4 — the grandfather write and the collision
258
+ * report. A **working** hook, and it deliberately does not probe presence.
259
+ *
260
+ * The write is a one-time migration of this module's own configuration.
261
+ * Activation is reversible and a migration is not, so gating it on an
262
+ * operator's activation choice means a deployment that happened to have
263
+ * `invoices` off during the upgrade gets the new `{channel}` default applied
264
+ * to its first channel and its invoice numbers change shape. The entry in
265
+ * `BOOT_HOOKS_WITHOUT_PRESENCE` says the same thing where the ledger is read.
266
+ * The hook writes at most three rows, once, and does nothing on every later
267
+ * boot.
268
+ */
269
+ ctx.onBoot(async () => {
270
+ await ctx.cradle().invoicesNumberingConfiguration.reconcile();
271
+ });
272
+ }
273
+ /**
274
+ * The module's persisted entity classes, on the `./backend` subpath, as one
275
+ * array and **no named class export** (D-168).
276
+ *
277
+ * This is the shape the platform reads when the package is *installed*: the
278
+ * boot-time loader (`src/packages/package-runtime.ts`, `exported['entities']`)
279
+ * and the static declaration reader (`scripts/lib/package-declarations.ts`),
280
+ * which is the third source of `check:module-boundary`'s `table→owner` map and
281
+ * the package pass of `check-entity-tenant-classification`. A missing array is
282
+ * answered with `[]` — zero entities registered, no error anywhere.
283
+ */
284
+ export const entities = [
285
+ InvoiceLine,
286
+ InvoiceNumberCounter,
287
+ InvoiceTemplate,
288
+ InvoiceExternalAttachment,
289
+ Invoice,
290
+ ];
291
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAI5E,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,4BAA4B,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,yBAAyB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