@stackforge-eu/factur-x 0.1.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 (94) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +287 -0
  3. package/README.md +264 -0
  4. package/dist/index.cjs +1320 -0
  5. package/dist/index.d.cts +1336 -0
  6. package/dist/index.d.ts +1336 -0
  7. package/dist/index.js +1285 -0
  8. package/package.json +81 -0
  9. package/schema/README.md +39 -0
  10. package/schema/basic/FACTUR-X_BASIC.xsd +20 -0
  11. package/schema/basic/FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +86 -0
  12. package/schema/basic/FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +249 -0
  13. package/schema/basic/FACTUR-X_BASIC_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +60 -0
  14. package/schema/basic-wl/FACTUR-X_BASIC-WL.xsd +20 -0
  15. package/schema/basic-wl/FACTUR-X_BASIC-WL_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +86 -0
  16. package/schema/basic-wl/FACTUR-X_BASIC-WL_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +196 -0
  17. package/schema/basic-wl/FACTUR-X_BASIC-WL_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +53 -0
  18. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B.xsd +25 -0
  19. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_EDIFICAS-EU_AccountingAccountType_D11A.xsd +18 -0
  20. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_EDIFICAS-EU_AccountingAmountType_D11A.xsd +17 -0
  21. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_ISO_ISO3AlphaCurrencyCode_2012-08-31.xsd +191 -0
  22. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_ActionCode_D22A.xsd +130 -0
  23. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_AddressType_D22A.xsd +19 -0
  24. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_AdjustmentReasonDescriptionCode_D22A.xsd +116 -0
  25. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_AllowanceChargeIdentificationCode_D22A.xsd +116 -0
  26. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_AllowanceChargeReasonCode_D22A.xsd +116 -0
  27. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_AutomaticDataCaptureMethodCode_D22A.xsd +21 -0
  28. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_CargoOperationalCategoryCode_D22A.xsd +36 -0
  29. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_CargoTypeCode_1996Rev2Final.xsd +20 -0
  30. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_CommodityIdentificationCode_D22A.xsd +12 -0
  31. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_CommunicationMeansTypeCode_D22A.xsd +58 -0
  32. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_ContactFunctionCode_D22A.xsd +114 -0
  33. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DangerousGoodsPackingCode_D22A.xsd +15 -0
  34. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DangerousGoodsRegulationCode_D22A.xsd +35 -0
  35. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DateOnlyFormatCode_D21B.xsd +21 -0
  36. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DeliveryTermsCode_2020.xsd +24 -0
  37. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DeliveryTermsFunctionCode_D22A.xsd +19 -0
  38. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DimensionTypeCode_D22A.xsd +35 -0
  39. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DocumentNameCode_Accounting_D22A.xsd +35 -0
  40. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DocumentNameCode_D22A.xsd +819 -0
  41. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DocumentStatusCode_D22A.xsd +61 -0
  42. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DutyTaxFeeTypeCode_D22A.xsd +67 -0
  43. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_DutyorTaxorFeeCategoryCode_D22A.xsd +33 -0
  44. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_EventTimeReferenceCodePaymentTermsEvent_D22A.xsd +16 -0
  45. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_EventTimeReferenceCode_D22A.xsd +76 -0
  46. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_FreightChargeQuantityUnitBasisCode_D22A.xsd +12 -0
  47. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_FreightChargeTariffCode_D22A.xsd +25 -0
  48. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_GoodsTypeCode_D22A.xsd +12 -0
  49. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_GoodsTypeExtensionCode_D22A.xsd +12 -0
  50. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_LocationFunctionCode_D22A.xsd +326 -0
  51. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_MeasurementUnitCommonCodeLinear_4.xsd +17 -0
  52. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_MeasurementUnitCommonCodeVolume_4.xsd +18 -0
  53. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_MeasurementUnitCommonCodeWeight_4.xsd +15 -0
  54. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_MessageFunctionCode_D22A.xsd +84 -0
  55. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PackageTypeCode_2006.xsd +416 -0
  56. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PackagingMarkingCode_D22A.xsd +63 -0
  57. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PartyRoleCode_ChargePaying_D22A.xsd +32 -0
  58. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PartyRoleCode_D22A.xsd +635 -0
  59. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PaymentGuaranteeMeansCode_D22A.xsd +23 -0
  60. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PaymentMeansChannelCode_D22A.xsd +27 -0
  61. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PaymentMeansCode_D22A.xsd +94 -0
  62. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PaymentTermsTypeCode_D22A.xsd +90 -0
  63. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_PriceTypeCode_D22A.xsd +50 -0
  64. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_ReferenceTypeCode_D22A.xsd +828 -0
  65. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_SealConditionCode_D22A.xsd +16 -0
  66. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_SealingPartyRoleCode_D22A.xsd +18 -0
  67. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_StatusCode_D22A.xsd +527 -0
  68. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_StatusDescriptionCode_AccountingDebitCredit_D22A.xsd +18 -0
  69. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TimeOnlyFormatCode_D21B.xsd +16 -0
  70. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TimePointFormatCode_D21B.xsd +17 -0
  71. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportEquipmentCategoryCode_D22A.xsd +107 -0
  72. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportEquipmentFullnessCode_D22A.xsd +24 -0
  73. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportMeansTypeCode_2007.xsd +145 -0
  74. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportModeCode_2.xsd +21 -0
  75. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportMovementStageCode_D22A.xsd +41 -0
  76. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_codelist_standard_UNECE_TransportPaymentArrangementCode_D22A.xsd +15 -0
  77. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +818 -0
  78. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +6176 -0
  79. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +144 -0
  80. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_identifierlist_standard_ISO_ISOTwo-letterCountryCode_SecondEdition2006.xsd +260 -0
  81. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_identifierlist_standard_UNECE_FreightCostCode_4.xsd +1722 -0
  82. package/schema/cii-d22b/CrossIndustryInvoice_100pD22B_urn_un_unece_uncefact_identifierlist_standard_UNECE_PaymentTermsDescriptionIdentifier_D22A.xsd +18 -0
  83. package/schema/en16931/FACTUR-X_EN16931.xsd +20 -0
  84. package/schema/en16931/FACTUR-X_EN16931_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +94 -0
  85. package/schema/en16931/FACTUR-X_EN16931_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +318 -0
  86. package/schema/en16931/FACTUR-X_EN16931_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +84 -0
  87. package/schema/extended/FACTUR-X_EXTENDED.xsd +20 -0
  88. package/schema/extended/FACTUR-X_EXTENDED_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +142 -0
  89. package/schema/extended/FACTUR-X_EXTENDED_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +475 -0
  90. package/schema/extended/FACTUR-X_EXTENDED_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +101 -0
  91. package/schema/minimum/FACTUR-X_MINIMUM.xsd +20 -0
  92. package/schema/minimum/FACTUR-X_MINIMUM_urn_un_unece_uncefact_data_standard_QualifiedDataType_100.xsd +30 -0
  93. package/schema/minimum/FACTUR-X_MINIMUM_urn_un_unece_uncefact_data_standard_ReusableAggregateBusinessInformationEntity_100.xsd +86 -0
  94. package/schema/minimum/FACTUR-X_MINIMUM_urn_un_unece_uncefact_data_standard_UnqualifiedDataType_100.xsd +38 -0
@@ -0,0 +1,1336 @@
1
+ /**
2
+ * Factur-X Input Object Types
3
+ *
4
+ * These types define the structured input for invoice generation across
5
+ * all supported profiles (MINIMUM → EXTENDED) and flavors (factur-x,
6
+ * zugferd, xrechnung, chrono-pro).
7
+ *
8
+ * Fields are annotated with their EN 16931 Business Term (BT) mapping
9
+ * and the minimum profile level at which they become relevant.
10
+ *
11
+ * @module types/input
12
+ * @see docs/INPUT_OBJECT_SPECIFICATION.md
13
+ * @see https://fnfe-mpe.org/factur-x/
14
+ * @license EUPL-1.2
15
+ */
16
+ /**
17
+ * Invoice type codes per UNTDID 1001 — Document name code (BT-3).
18
+ *
19
+ * The full code list from the Factur-X / EN 16931 specification.
20
+ * Common codes for most implementations:
21
+ *
22
+ * | Code | Meaning | Chorus Pro |
23
+ * |------|-------------------------------|------------|
24
+ * | 380 | Commercial invoice | ✅ |
25
+ * | 381 | Credit note | ✅ |
26
+ * | 384 | Corrected invoice | ✅ |
27
+ * | 386 | Prepayment invoice | ✅ |
28
+ * | 389 | Self-billed invoice | ❌ |
29
+ * | 261 | Self-billed credit note | ❌ |
30
+ * | 751 | Invoice info for accounting | ❌ (DE only)|
31
+ *
32
+ * Code `751` is required in Germany to meet regulatory requirements.
33
+ * Codes `261`, `389`, `471`, `500`, `501`, `527` are **not accepted**
34
+ * by Chorus Pro (France).
35
+ *
36
+ * @see EN 16931 BT-3
37
+ * @see UNTDID 1001
38
+ */
39
+ declare enum DocumentTypeCode {
40
+ /** Request for payment */
41
+ REQUEST_FOR_PAYMENT = "71",
42
+ /** Debit note related to goods or services */
43
+ DEBIT_NOTE_GOODS_SERVICES = "80",
44
+ /** Credit note related to goods or services */
45
+ CREDIT_NOTE_GOODS_SERVICES = "81",
46
+ /** Metered services invoice */
47
+ METERED_SERVICES_INVOICE = "82",
48
+ /** Credit note related to financial adjustments */
49
+ CREDIT_NOTE_FINANCIAL_ADJUSTMENTS = "83",
50
+ /** Debit note related to financial adjustments */
51
+ DEBIT_NOTE_FINANCIAL_ADJUSTMENTS = "84",
52
+ /** Tax notification */
53
+ TAX_NOTIFICATION = "102",
54
+ /** Invoicing data sheet */
55
+ INVOICING_DATA_SHEET = "130",
56
+ /** Direct payment valuation */
57
+ DIRECT_PAYMENT_VALUATION = "202",
58
+ /** Provisional payment valuation */
59
+ PROVISIONAL_PAYMENT_VALUATION = "203",
60
+ /** Payment valuation */
61
+ PAYMENT_VALUATION = "204",
62
+ /** Interim application for payment */
63
+ INTERIM_APPLICATION_FOR_PAYMENT = "211",
64
+ /** Final payment request based on completion of work */
65
+ FINAL_PAYMENT_REQUEST = "218",
66
+ /** Payment request for completed units */
67
+ PAYMENT_REQUEST_COMPLETED_UNITS = "219",
68
+ /** Self-billed credit note (not accepted by Chorus Pro) */
69
+ SELF_BILLED_CREDIT_NOTE = "261",
70
+ /** Consolidated credit note — goods and services */
71
+ CONSOLIDATED_CREDIT_NOTE = "262",
72
+ /** Price variation invoice */
73
+ PRICE_VARIATION_INVOICE = "295",
74
+ /** Credit note for price variation */
75
+ CREDIT_NOTE_PRICE_VARIATION = "296",
76
+ /** Delcredere credit note */
77
+ DELCREDERE_CREDIT_NOTE = "308",
78
+ /** Proforma invoice */
79
+ PROFORMA_INVOICE = "325",
80
+ /** Partial invoice */
81
+ PARTIAL_INVOICE = "326",
82
+ /** Commercial invoice which includes a packing list */
83
+ COMMERCIAL_INVOICE_PACKING_LIST = "331",
84
+ /** Commercial invoice */
85
+ COMMERCIAL_INVOICE = "380",
86
+ /** Credit note */
87
+ CREDIT_NOTE = "381",
88
+ /** Commission note */
89
+ COMMISSION_NOTE = "382",
90
+ /** Debit note */
91
+ DEBIT_NOTE = "383",
92
+ /** Corrected invoice */
93
+ CORRECTED_INVOICE = "384",
94
+ /** Consolidated invoice */
95
+ CONSOLIDATED_INVOICE = "385",
96
+ /** Prepayment invoice */
97
+ PREPAYMENT_INVOICE = "386",
98
+ /** Hire invoice */
99
+ HIRE_INVOICE = "387",
100
+ /** Tax invoice */
101
+ TAX_INVOICE = "388",
102
+ /** Self-billed invoice (not accepted by Chorus Pro) */
103
+ SELF_BILLED_INVOICE = "389",
104
+ /** Delcredere invoice */
105
+ DELCREDERE_INVOICE = "390",
106
+ /** Factored invoice */
107
+ FACTORED_INVOICE = "393",
108
+ /** Lease invoice */
109
+ LEASE_INVOICE = "394",
110
+ /** Consignment invoice */
111
+ CONSIGNMENT_INVOICE = "395",
112
+ /** Factored credit note */
113
+ FACTORED_CREDIT_NOTE = "396",
114
+ /** Optical Character Reading (OCR) payment credit note */
115
+ OCR_PAYMENT_CREDIT_NOTE = "420",
116
+ /** Debit advice */
117
+ DEBIT_ADVICE = "456",
118
+ /** Reversal of debit */
119
+ REVERSAL_OF_DEBIT = "457",
120
+ /** Reversal of credit */
121
+ REVERSAL_OF_CREDIT = "458",
122
+ /** Self-billed corrective invoice (not accepted by Chorus Pro) */
123
+ SELF_BILLED_CORRECTIVE_INVOICE = "471",
124
+ /** Factored corrective invoice */
125
+ FACTORED_CORRECTIVE_INVOICE = "472",
126
+ /** Self-billed factored corrective invoice */
127
+ SELF_BILLED_FACTORED_CORRECTIVE_INVOICE = "473",
128
+ /** Self-billed prepayment invoice (not accepted by Chorus Pro) */
129
+ SELF_BILLED_PREPAYMENT_INVOICE = "500",
130
+ /** Self-billed factored invoice (not accepted by Chorus Pro) */
131
+ SELF_BILLED_FACTORED_INVOICE = "501",
132
+ /** Self-billed factored credit note */
133
+ SELF_BILLED_FACTORED_CREDIT_NOTE = "502",
134
+ /** Prepayment credit note */
135
+ PREPAYMENT_CREDIT_NOTE = "503",
136
+ /** Self-billed debit note (not accepted by Chorus Pro) */
137
+ SELF_BILLED_DEBIT_NOTE = "527",
138
+ /** Forwarder's credit note */
139
+ FORWARDERS_CREDIT_NOTE = "532",
140
+ /** Forwarder's invoice discrepancy report */
141
+ FORWARDERS_INVOICE_DISCREPANCY_REPORT = "553",
142
+ /** Insurer's invoice */
143
+ INSURERS_INVOICE = "575",
144
+ /** Forwarder's invoice */
145
+ FORWARDERS_INVOICE = "623",
146
+ /** Port charges documents */
147
+ PORT_CHARGES_DOCUMENTS = "633",
148
+ /**
149
+ * Invoice information for accounting purposes.
150
+ * Required in Germany for regulatory requirements.
151
+ * **Not accepted** by Chorus Pro.
152
+ */
153
+ INVOICE_INFO_ACCOUNTING = "751",
154
+ /** Freight invoice */
155
+ FREIGHT_INVOICE = "780",
156
+ /** Claim notification */
157
+ CLAIM_NOTIFICATION = "817",
158
+ /** Consular invoice */
159
+ CONSULAR_INVOICE = "870",
160
+ /** Partial construction invoice */
161
+ PARTIAL_CONSTRUCTION_INVOICE = "875",
162
+ /** Partial final construction invoice */
163
+ PARTIAL_FINAL_CONSTRUCTION_INVOICE = "876",
164
+ /** Final construction invoice */
165
+ FINAL_CONSTRUCTION_INVOICE = "877"
166
+ }
167
+ /**
168
+ * Common unit of measure codes per UN/ECE Recommendation 20 (BT-130).
169
+ *
170
+ * Only codes typically found on invoices are active. Less common codes
171
+ * (imperial, scientific, niche packaging) are commented out but can be
172
+ * uncommented if needed. Any valid Rec 20 string is accepted by the
173
+ * `unitCode` field — use this enum for readability and autocompletion.
174
+ *
175
+ * @see EN 16931 BT-130
176
+ * @see https://unece.org/trade/uncefact/cl-recommendations
177
+ */
178
+ declare enum UnitCode {
179
+ /** One (unit / piece) — most common default */
180
+ UNIT = "C62",
181
+ /** Each */
182
+ EACH = "EA",
183
+ /** Piece */
184
+ PIECE = "H87",
185
+ /** Number of articles */
186
+ NUMBER_OF_ARTICLES = "NAR",
187
+ /** Pair */
188
+ PAIR = "PR",
189
+ /** Set */
190
+ SET = "SET",
191
+ /** Dozen */
192
+ DOZEN = "DZN",
193
+ /** Lot */
194
+ LOT = "LOT",
195
+ /** Hundred */
196
+ HUNDRED = "CEN",
197
+ /** Thousand */
198
+ THOUSAND = "MIL",
199
+ /** Minute */
200
+ MINUTE = "MIN",
201
+ /** Hour */
202
+ HOUR = "HUR",
203
+ /** Day */
204
+ DAY = "DAY",
205
+ /** Week */
206
+ WEEK = "WEE",
207
+ /** Month */
208
+ MONTH = "MON",
209
+ /** Year */
210
+ YEAR = "ANN",
211
+ /** Gram */
212
+ GRAM = "GRM",
213
+ /** Kilogram */
214
+ KILOGRAM = "KGM",
215
+ /** Tonne (metric ton, 1000 kg) */
216
+ TONNE = "TNE",
217
+ /** Millimetre */
218
+ MILLIMETRE = "MMT",
219
+ /** Centimetre */
220
+ CENTIMETRE = "CMT",
221
+ /** Metre */
222
+ METRE = "MTR",
223
+ /** Kilometre */
224
+ KILOMETRE = "KMT",
225
+ /** Square metre */
226
+ SQUARE_METRE = "MTK",
227
+ /** Millilitre */
228
+ MILLILITRE = "MLT",
229
+ /** Litre */
230
+ LITRE = "LTR",
231
+ /** Cubic metre */
232
+ CUBIC_METRE = "MTQ",
233
+ /** Kilowatt hour */
234
+ KILOWATT_HOUR = "KWH",
235
+ /** Megawatt hour */
236
+ MEGAWATT_HOUR = "MWH",
237
+ /** Package */
238
+ PACKAGE = "XPK",
239
+ /** Pallet */
240
+ PALLET = "XPX",
241
+ /** Box */
242
+ BOX = "XBX",
243
+ /** Carton */
244
+ CARTON = "XCT",
245
+ /** Byte (8 bits) */
246
+ BYTE = "AD",
247
+ /** Kilobyte (10³ bytes) */
248
+ KILOBYTE = "2P",
249
+ /** Megabyte (10⁶ bytes) */
250
+ MEGABYTE = "4L",
251
+ /** Gigabyte (10⁹ bytes) */
252
+ GIGABYTE = "E34",
253
+ /** Terabyte (10¹² bytes) */
254
+ TERABYTE = "E35",
255
+ /** Petabyte (10¹⁵ bytes) */
256
+ PETABYTE = "E36",
257
+ /** Byte per second */
258
+ BYTE_PER_SECOND = "P93",
259
+ /** Kilobyte per second */
260
+ KILOBYTE_PER_SECOND = "P94",
261
+ /** Lump sum */
262
+ LUMP_SUM = "LS",
263
+ /** Percent */
264
+ PERCENT = "P1",
265
+ /** Sheet */
266
+ SHEET = "ST",
267
+ /** Roll */
268
+ ROLL = "RO"
269
+ }
270
+ /**
271
+ * Note attached to the invoice document.
272
+ *
273
+ * @see EN 16931 BG-1
274
+ * @since BASIC_WL
275
+ */
276
+ interface NoteInput {
277
+ /** Free-text content of the note */
278
+ content: string;
279
+ /**
280
+ * Subject code qualifying the note (e.g. `"AAK"` = discount terms,
281
+ * `"REG"` = regulatory information). Optional.
282
+ */
283
+ subjectCode?: string;
284
+ }
285
+ /**
286
+ * Invoice document metadata.
287
+ *
288
+ * @see EN 16931 BT-1 (id), BT-2 (issueDate), BT-3 (typeCode)
289
+ */
290
+ interface InvoiceDocumentInput {
291
+ /**
292
+ * Invoice number — mandatory for all profiles.
293
+ * @see EN 16931 BT-1
294
+ */
295
+ id: string;
296
+ /**
297
+ * Issue date — mandatory, format `YYYY-MM-DD`.
298
+ * @see EN 16931 BT-2
299
+ */
300
+ issueDate: string;
301
+ /**
302
+ * Document type code (BT-3).
303
+ * Use the {@link DocumentTypeCode} enum for type-safe values.
304
+ * @default {@link DocumentTypeCode.COMMERCIAL_INVOICE} (`'380'`)
305
+ * @see EN 16931 BT-3
306
+ */
307
+ typeCode?: DocumentTypeCode;
308
+ /**
309
+ * Due date — optional at document level (often set via {@link PaymentInput.dueDate}).
310
+ * @see EN 16931 BT-9
311
+ */
312
+ dueDate?: string;
313
+ /**
314
+ * Document name / title — optional.
315
+ * @since EXTENDED
316
+ */
317
+ name?: string;
318
+ /**
319
+ * Language code (ISO 639-1, e.g. `"en"`, `"de"`, `"fr"`).
320
+ * @since EXTENDED
321
+ */
322
+ language?: string;
323
+ /**
324
+ * Buyer reference — often the purchase order or Leitweg-ID (XRechnung).
325
+ * @see EN 16931 BT-10
326
+ * @since MINIMUM
327
+ */
328
+ buyerReference?: string;
329
+ /**
330
+ * Notes attached to the invoice.
331
+ * @see EN 16931 BG-1
332
+ * @since BASIC_WL
333
+ */
334
+ notes?: NoteInput[];
335
+ /**
336
+ * Business process identifier (e.g. PEPPOL `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0`).
337
+ * @see EN 16931 BT-23
338
+ */
339
+ businessProcessId?: string;
340
+ }
341
+ /**
342
+ * Postal address.
343
+ *
344
+ * @see EN 16931 BT-35–BT-39 (Seller), BT-50–BT-54 (Buyer)
345
+ */
346
+ interface AddressInput {
347
+ /** Street and number (BT-35 / BT-50) */
348
+ line1: string;
349
+ /** Additional address line (BT-36 / BT-51) */
350
+ line2?: string;
351
+ /** Third address line */
352
+ line3?: string;
353
+ /** City (BT-37 / BT-52) — mandatory when address present */
354
+ city: string;
355
+ /** Postal code (BT-38 / BT-53) */
356
+ postalCode: string;
357
+ /**
358
+ * Country code (ISO 3166-1 alpha-2, e.g. `"DE"`, `"FR"`).
359
+ * @see EN 16931 BT-40 / BT-55
360
+ */
361
+ country: string;
362
+ /** Country subdivision (e.g. state/province) */
363
+ subdivision?: string;
364
+ }
365
+ /**
366
+ * Contact information.
367
+ *
368
+ * @see EN 16931 BG-6 (Seller contact), BG-9 (Buyer contact)
369
+ * @since EN16931
370
+ */
371
+ interface ContactInput {
372
+ /** Contact person name (BT-41 / BT-56) */
373
+ name?: string;
374
+ /** Department name */
375
+ department?: string;
376
+ /** Phone number (BT-42 / BT-57) */
377
+ phone?: string;
378
+ /** Email address (BT-43 / BT-58) */
379
+ email?: string;
380
+ }
381
+ /**
382
+ * Tax registration entry (VAT ID or local tax number).
383
+ *
384
+ * The `schemeId` distinguishes `"VA"` (VAT) from `"FC"` (fiscal/tax number).
385
+ * @since MINIMUM (VAT only)
386
+ */
387
+ interface TaxRegistrationInput {
388
+ /** Tax registration ID (e.g. `"DE123456789"`) */
389
+ id: string;
390
+ /**
391
+ * Scheme: `"VA"` for VAT, `"FC"` for fiscal/tax number.
392
+ * @default `"VA"`
393
+ */
394
+ schemeId?: "VA" | "FC";
395
+ }
396
+ /**
397
+ * Legal organization details.
398
+ *
399
+ * @see EN 16931 BT-30 (Seller legal registration), BT-47 (Buyer)
400
+ * @since MINIMUM
401
+ */
402
+ interface LegalOrganizationInput {
403
+ /** Registration identifier */
404
+ id?: string;
405
+ /** Trading business name */
406
+ tradingName?: string;
407
+ }
408
+ /**
409
+ * Trade party (seller, buyer, payee, etc.).
410
+ *
411
+ * @see EN 16931 BG-4 (Seller), BG-7 (Buyer)
412
+ */
413
+ interface TradePartyInput {
414
+ /**
415
+ * Party name — mandatory for all profiles.
416
+ * @see EN 16931 BT-27 (Seller), BT-44 (Buyer)
417
+ */
418
+ name: string;
419
+ /**
420
+ * Party identifiers (can have multiples, e.g. GLN).
421
+ * @see EN 16931 BT-29 / BT-46
422
+ */
423
+ id?: string | string[];
424
+ /**
425
+ * Global identifier with scheme (e.g. GLN `"0088:1234567890123"`).
426
+ * @see EN 16931 BT-29-1 / BT-46-1
427
+ */
428
+ globalId?: string;
429
+ /** Postal address — mandatory for BASIC_WL and above */
430
+ address?: AddressInput;
431
+ /**
432
+ * Contact information.
433
+ * @since EN16931
434
+ */
435
+ contact?: ContactInput;
436
+ /**
437
+ * Electronic address (e.g. email or URI for e-delivery).
438
+ * @see EN 16931 BT-34 / BT-49
439
+ */
440
+ electronicAddress?: string;
441
+ /**
442
+ * Tax registrations (VAT ID, fiscal number).
443
+ * @see EN 16931 BT-31 / BT-48
444
+ */
445
+ taxRegistrations?: TaxRegistrationInput[];
446
+ /**
447
+ * Legal organization info.
448
+ * @see EN 16931 BT-30 / BT-47
449
+ */
450
+ legalOrganization?: LegalOrganizationInput;
451
+ /**
452
+ * Description of the party.
453
+ * @since EN16931
454
+ */
455
+ description?: string;
456
+ }
457
+ /**
458
+ * Invoice line item.
459
+ * Required for BASIC, EN 16931, EXTENDED profiles.
460
+ *
461
+ * @see EN 16931 BG-25
462
+ */
463
+ interface InvoiceLineInput {
464
+ /**
465
+ * Line ID — mandatory.
466
+ * @see EN 16931 BT-126
467
+ */
468
+ id: string;
469
+ /**
470
+ * Item name/description — mandatory.
471
+ * @see EN 16931 BT-153
472
+ */
473
+ name: string;
474
+ /**
475
+ * Quantity — mandatory.
476
+ * @see EN 16931 BT-129
477
+ */
478
+ quantity: number;
479
+ /**
480
+ * Unit of measure (UN/CEFACT Rec 20).
481
+ * Use the {@link UnitCode} enum for common codes, or pass any
482
+ * valid Rec 20 string for codes not in the enum.
483
+ *
484
+ * @default {@link UnitCode.UNIT} (`'C62'`) when omitted
485
+ * @see EN 16931 BT-130
486
+ *
487
+ * @example
488
+ * ```ts
489
+ * unitCode: UnitCode.HOUR // 'HUR'
490
+ * unitCode: UnitCode.KILOGRAM // 'KGM'
491
+ * unitCode: 'XYZ' // any Rec 20 code
492
+ * ```
493
+ */
494
+ unitCode?: UnitCode | (string & Record<never, never>);
495
+ /**
496
+ * Net unit price — mandatory for line-level.
497
+ * @see EN 16931 BT-146
498
+ */
499
+ unitPrice: number;
500
+ /**
501
+ * Gross unit price (before allowances).
502
+ * @see EN 16931 BT-148
503
+ */
504
+ grossUnitPrice?: number;
505
+ /**
506
+ * Line total (net) — can be derived from `quantity * unitPrice`.
507
+ * @see EN 16931 BT-131
508
+ */
509
+ lineTotal?: number;
510
+ /**
511
+ * VAT category code (e.g. `"S"`, `"Z"`, `"E"`, `"G"`).
512
+ * @see EN 16931 BT-151
513
+ */
514
+ vatCategoryCode?: string;
515
+ /**
516
+ * VAT rate in percent (e.g. `19`, `7`, `0`).
517
+ * @see EN 16931 BT-152
518
+ */
519
+ vatRatePercent?: number;
520
+ /**
521
+ * Item description (longer than name).
522
+ * @see EN 16931 BT-154
523
+ */
524
+ description?: string;
525
+ /**
526
+ * Item standard identifier (e.g. GTIN/EAN).
527
+ * @see EN 16931 BT-157
528
+ */
529
+ standardIdentifier?: string;
530
+ /**
531
+ * Seller-assigned item identifier.
532
+ * @see EN 16931 BT-155
533
+ */
534
+ sellerAssignedId?: string;
535
+ /**
536
+ * Buyer-assigned item identifier.
537
+ * @see EN 16931 BT-156
538
+ */
539
+ buyerAssignedId?: string;
540
+ /**
541
+ * Item classification code (e.g. CPV, UNSPC).
542
+ * @see EN 16931 BT-158
543
+ */
544
+ classification?: string;
545
+ /**
546
+ * Country of origin (ISO 3166-1 alpha-2).
547
+ * @see EN 16931 BT-159
548
+ * @since EN16931
549
+ */
550
+ originCountry?: string;
551
+ /**
552
+ * Line note.
553
+ * @since BASIC
554
+ */
555
+ note?: string;
556
+ /**
557
+ * Buyer order line reference.
558
+ * @since EN16931
559
+ */
560
+ buyerOrderLineId?: string;
561
+ }
562
+ /**
563
+ * Allowance or charge at header or line level.
564
+ *
565
+ * @see EN 16931 BG-20 (document level allowances), BG-21 (charges)
566
+ * @since BASIC_WL
567
+ */
568
+ interface AllowanceChargeInput {
569
+ /**
570
+ * `true` = charge, `false` = allowance.
571
+ * @see EN 16931 BT-98 / BT-107
572
+ */
573
+ isCharge: boolean;
574
+ /**
575
+ * Amount.
576
+ * @see EN 16931 BT-99 / BT-92
577
+ */
578
+ amount: number;
579
+ /**
580
+ * Reason code (UNCL 5189 for allowances, UNCL 7161 for charges).
581
+ * @see EN 16931 BT-98 / BT-105
582
+ */
583
+ reasonCode?: string;
584
+ /** Reason text */
585
+ reason?: string;
586
+ /** Base amount (for percentage calculation) */
587
+ baseAmount?: number;
588
+ /** Percentage */
589
+ percent?: number;
590
+ /** VAT category code for this allowance/charge */
591
+ vatCategoryCode?: string;
592
+ /** VAT rate for this allowance/charge */
593
+ vatRatePercent?: number;
594
+ }
595
+ /**
596
+ * Payment information.
597
+ *
598
+ * @see EN 16931 BG-16
599
+ * @since BASIC_WL
600
+ */
601
+ interface PaymentInput {
602
+ /**
603
+ * Payment means code (UNCL 4461, e.g. `"30"` = credit transfer,
604
+ * `"58"` = SEPA credit transfer, `"59"` = SEPA direct debit).
605
+ * @see EN 16931 BT-81
606
+ */
607
+ meansCode?: string;
608
+ /**
609
+ * Payment due date.
610
+ * @see EN 16931 BT-9
611
+ */
612
+ dueDate?: string;
613
+ /**
614
+ * Payment reference / remittance information.
615
+ * @see EN 16931 BT-83
616
+ */
617
+ paymentReference?: string;
618
+ /**
619
+ * Creditor reference (for SEPA direct debit).
620
+ * @see EN 16931 BT-90
621
+ */
622
+ creditorReference?: string;
623
+ /**
624
+ * IBAN of the payee.
625
+ * @see EN 16931 BT-84
626
+ */
627
+ iban?: string;
628
+ /**
629
+ * Proprietary account ID (non-IBAN).
630
+ */
631
+ accountId?: string;
632
+ /**
633
+ * Account name.
634
+ * @see EN 16931 BT-85
635
+ * @since EN16931
636
+ */
637
+ accountName?: string;
638
+ /**
639
+ * BIC/SWIFT code.
640
+ * @see EN 16931 BT-86
641
+ * @since EN16931
642
+ */
643
+ bic?: string;
644
+ /**
645
+ * SEPA direct debit mandate ID.
646
+ * @see EN 16931 BT-89
647
+ */
648
+ mandateId?: string;
649
+ /**
650
+ * Debtor IBAN (for direct debit).
651
+ * @see EN 16931 BT-91
652
+ */
653
+ debtorIban?: string;
654
+ /**
655
+ * Payment terms description (free text).
656
+ * @see EN 16931 BT-20
657
+ */
658
+ termsDescription?: string;
659
+ }
660
+ /**
661
+ * Delivery information.
662
+ *
663
+ * @see EN 16931 BG-13
664
+ * @since BASIC_WL
665
+ */
666
+ interface DeliveryInput {
667
+ /**
668
+ * Actual delivery date.
669
+ * @see EN 16931 BT-72
670
+ */
671
+ date?: string;
672
+ /**
673
+ * Ship-to address.
674
+ * @see EN 16931 BG-15
675
+ */
676
+ location?: AddressInput;
677
+ /**
678
+ * Ship-to party name.
679
+ * @see EN 16931 BT-70
680
+ */
681
+ partyName?: string;
682
+ /**
683
+ * Despatch advice reference.
684
+ * @see EN 16931 BT-16
685
+ */
686
+ despatchAdviceReference?: string;
687
+ }
688
+ /**
689
+ * Invoice monetary totals — mandatory for all profiles.
690
+ *
691
+ * @see EN 16931 BG-22
692
+ */
693
+ interface InvoiceTotalsInput {
694
+ /**
695
+ * Sum of all line totals (net).
696
+ * @see EN 16931 BT-106
697
+ */
698
+ lineTotal: number;
699
+ /**
700
+ * Sum of allowances at document level.
701
+ * @see EN 16931 BT-107
702
+ */
703
+ allowanceTotal?: number;
704
+ /**
705
+ * Sum of charges at document level.
706
+ * @see EN 16931 BT-108
707
+ */
708
+ chargeTotal?: number;
709
+ /**
710
+ * Tax-exclusive amount (net total).
711
+ * @see EN 16931 BT-109
712
+ */
713
+ taxBasisTotal: number;
714
+ /**
715
+ * Total VAT amount.
716
+ * @see EN 16931 BT-110
717
+ */
718
+ taxTotal: number;
719
+ /**
720
+ * Grand total including VAT.
721
+ * @see EN 16931 BT-112
722
+ */
723
+ grandTotal: number;
724
+ /**
725
+ * Prepaid amount.
726
+ * @see EN 16931 BT-113
727
+ */
728
+ prepaidAmount?: number;
729
+ /**
730
+ * Due payable amount.
731
+ * @see EN 16931 BT-115
732
+ */
733
+ duePayableAmount: number;
734
+ /**
735
+ * Invoice currency code (ISO 4217, e.g. `"EUR"`).
736
+ * @see EN 16931 BT-5
737
+ */
738
+ currency: string;
739
+ /**
740
+ * Tax currency code (if different from invoice currency).
741
+ * @see EN 16931 BT-6
742
+ */
743
+ taxCurrency?: string;
744
+ }
745
+ /**
746
+ * VAT/tax breakdown entry — required for BASIC_WL and above.
747
+ *
748
+ * @see EN 16931 BG-23
749
+ */
750
+ interface VatBreakdownInput {
751
+ /**
752
+ * VAT category code (`"S"` = standard, `"Z"` = zero, `"E"` = exempt,
753
+ * `"G"` = free export, `"K"` = intra-community, `"AE"` = reverse charge, etc.).
754
+ * @see EN 16931 BT-118
755
+ */
756
+ categoryCode: string;
757
+ /**
758
+ * VAT rate in percent.
759
+ * @see EN 16931 BT-119
760
+ */
761
+ ratePercent: number;
762
+ /**
763
+ * Taxable amount (basis).
764
+ * @see EN 16931 BT-116
765
+ */
766
+ taxableAmount: number;
767
+ /**
768
+ * Tax amount.
769
+ * @see EN 16931 BT-117
770
+ */
771
+ taxAmount: number;
772
+ /**
773
+ * Exemption reason text.
774
+ * @see EN 16931 BT-120
775
+ */
776
+ exemptionReason?: string;
777
+ /**
778
+ * Exemption reason code.
779
+ * @see EN 16931 BT-121
780
+ */
781
+ exemptionReasonCode?: string;
782
+ }
783
+ /**
784
+ * Document reference (contract, order, preceding invoice, etc.).
785
+ *
786
+ * @see EN 16931 BT-12–BT-25
787
+ * @since MINIMUM (buyerOrderReference), BASIC_WL (others)
788
+ */
789
+ interface DocumentReferenceInput {
790
+ /**
791
+ * Reference ID.
792
+ * @see EN 16931 BT-13 (order), BT-12 (contract), BT-25 (preceding invoice)
793
+ */
794
+ id: string;
795
+ /**
796
+ * Reference type: determines where this reference is placed in XML.
797
+ * - `"order"` → BuyerOrderReferencedDocument
798
+ * - `"contract"` → ContractReferencedDocument
799
+ * - `"despatch"` → DespatchAdviceReferencedDocument
800
+ * - `"preceding"` → InvoiceReferencedDocument
801
+ * - `"seller-order"` → SellerOrderReferencedDocument (EN16931+)
802
+ * - `"project"` → SpecifiedProcuringProject (EN16931+)
803
+ *
804
+ * @default `"order"`
805
+ */
806
+ type?: "order" | "contract" | "despatch" | "preceding" | "seller-order" | "project";
807
+ /** Issue date of the referenced document */
808
+ issueDate?: string;
809
+ }
810
+ /**
811
+ * Billing/invoicing period.
812
+ *
813
+ * @see EN 16931 BG-14
814
+ * @since BASIC_WL
815
+ */
816
+ interface BillingPeriodInput {
817
+ /** Period start date (YYYY-MM-DD) */
818
+ startDate?: string;
819
+ /** Period end date (YYYY-MM-DD) */
820
+ endDate?: string;
821
+ }
822
+ /**
823
+ * Root input for Factur-X invoice generation.
824
+ *
825
+ * Use this object with {@link embedFacturX} or {@link toXRechnung}.
826
+ * The same structure supports all profiles; fields not applicable
827
+ * to the chosen profile are silently ignored.
828
+ *
829
+ * @example
830
+ * ```ts
831
+ * const input: FacturXInvoiceInput = {
832
+ * document: { id: 'INV-001', issueDate: '2025-03-01', typeCode: DocumentTypeCode.COMMERCIAL_INVOICE },
833
+ * seller: { name: 'StackForge UG (haftungsbeschränkt)', address: { line1: 'Bergstraße 4', city: 'Weihmichl', postalCode: '84107', country: 'DE' } },
834
+ * buyer: { name: 'Kite-Engineer by Stefan Merthan', address: { line1: 'Hauptstraße 6', city: 'Weihmichl', postalCode: '84107', country: 'DE' } },
835
+ * totals: { lineTotal: 100, taxBasisTotal: 100, taxTotal: 19, grandTotal: 119, duePayableAmount: 119, currency: 'EUR' },
836
+ * vatBreakdown: [{ categoryCode: 'S', ratePercent: 19, taxableAmount: 100, taxAmount: 19 }],
837
+ * };
838
+ * ```
839
+ *
840
+ * @see docs/INPUT_OBJECT_SPECIFICATION.md
841
+ */
842
+ interface FacturXInvoiceInput {
843
+ /** Document metadata — mandatory */
844
+ document: InvoiceDocumentInput;
845
+ /** Seller (supplier) party — mandatory */
846
+ seller: TradePartyInput;
847
+ /** Buyer party — mandatory */
848
+ buyer: TradePartyInput;
849
+ /**
850
+ * Invoice lines — required for BASIC, EN 16931, EXTENDED.
851
+ * @see EN 16931 BG-25
852
+ */
853
+ lines?: InvoiceLineInput[];
854
+ /**
855
+ * Document-level allowances and charges.
856
+ * @see EN 16931 BG-20, BG-21
857
+ * @since BASIC_WL
858
+ */
859
+ allowancesCharges?: AllowanceChargeInput[];
860
+ /**
861
+ * Payment information.
862
+ * @see EN 16931 BG-16
863
+ * @since BASIC_WL
864
+ */
865
+ payment?: PaymentInput;
866
+ /**
867
+ * Delivery information.
868
+ * @see EN 16931 BG-13
869
+ * @since BASIC_WL
870
+ */
871
+ delivery?: DeliveryInput;
872
+ /** Monetary totals — mandatory */
873
+ totals: InvoiceTotalsInput;
874
+ /**
875
+ * VAT breakdown — required for BASIC_WL and above.
876
+ * @see EN 16931 BG-23
877
+ */
878
+ vatBreakdown?: VatBreakdownInput[];
879
+ /**
880
+ * Document references (order, contract, preceding invoice, etc.).
881
+ * @see EN 16931 BG-3
882
+ */
883
+ references?: DocumentReferenceInput[];
884
+ /**
885
+ * Billing/invoicing period.
886
+ * @see EN 16931 BG-14
887
+ * @since BASIC_WL
888
+ */
889
+ billingPeriod?: BillingPeriodInput;
890
+ /**
891
+ * Payee (if different from seller).
892
+ * @see EN 16931 BG-10
893
+ * @since BASIC_WL
894
+ */
895
+ payee?: TradePartyInput;
896
+ /**
897
+ * Seller's tax representative.
898
+ * @see EN 16931 BG-11
899
+ * @since BASIC_WL
900
+ */
901
+ sellerTaxRepresentative?: TradePartyInput;
902
+ }
903
+
904
+ /**
905
+ * Flavor and Profile Constants
906
+ *
907
+ * Defines URNs, default document type codes, and standard sets
908
+ * for different country/system implementations.
909
+ *
910
+ * @module flavors/constants
911
+ */
912
+ /** Factur-X / ZUGFeRD profile levels */
913
+ declare enum Profile {
914
+ MINIMUM = "MINIMUM",
915
+ BASIC_WL = "BASIC_WL",
916
+ BASIC = "BASIC",
917
+ EN16931 = "EN16931",
918
+ EXTENDED = "EXTENDED"
919
+ }
920
+ /** Country/system flavor */
921
+ declare enum Flavor {
922
+ FACTUR_X = "factur-x",
923
+ ZUGFERD = "zugferd",
924
+ XRECHNUNG = "xrechnung",
925
+ CHRONO_PRO = "chrono-pro"
926
+ }
927
+ /** Profile URNs (GuidelineSpecifiedDocumentContextParameter) */
928
+ declare const PROFILE_URNS: Record<Profile, string>;
929
+
930
+ /**
931
+ * Default document type code per flavor.
932
+ * All flavors default to {@link DocumentTypeCode.COMMERCIAL_INVOICE} (`380`).
933
+ */
934
+ declare const FLAVOR_DEFAULT_TYPE_CODES: Record<Flavor, DocumentTypeCode>;
935
+ /**
936
+ * Schema directory names per profile (relative to schema/)
937
+ */
938
+ declare const PROFILE_SCHEMA_DIRS: Record<Profile, string>;
939
+ /**
940
+ * Main XSD filename per profile
941
+ */
942
+ declare const PROFILE_MAIN_XSD: Record<Profile, string>;
943
+
944
+ /**
945
+ * Flavor configuration registry.
946
+ *
947
+ * Provides flavor-specific settings (profiles, type codes, filenames, etc.)
948
+ * and validation/resolution utilities for invoice generation.
949
+ *
950
+ * @module flavors/registry
951
+ */
952
+
953
+ /** Configuration for a specific flavor */
954
+ interface FlavorConfig {
955
+ /** Display name */
956
+ name: string;
957
+ /** Supported profiles for this flavor */
958
+ supportedProfiles: Profile[];
959
+ /** Default document type code */
960
+ defaultTypeCode: DocumentTypeCode;
961
+ /** Business process URN (optional, e.g. PEPPOL for XRechnung) */
962
+ businessProcessUrn?: string;
963
+ /** XML attachment filename in the PDF */
964
+ attachmentFilename: string;
965
+ /** Whether this flavor embeds into PDF (false for xrechnung = XML only) */
966
+ embedInPdf: boolean;
967
+ /** Additional constraints or requirements description */
968
+ description: string;
969
+ }
970
+ /** Flavor configuration registry */
971
+ declare const FLAVOR_CONFIGS: Record<Flavor, FlavorConfig>;
972
+ /**
973
+ * Returns the configuration for a given flavor.
974
+ * @param flavor - The flavor to look up
975
+ * @returns The flavor configuration
976
+ */
977
+ declare function getFlavorConfig(flavor: Flavor): FlavorConfig;
978
+ /**
979
+ * Validates that the given profile is supported for the flavor.
980
+ * @param flavor - The flavor to validate against
981
+ * @param profile - The profile to validate
982
+ * @throws Error if the profile is not supported for the flavor
983
+ */
984
+ declare function validateFlavorProfile(flavor: Flavor, profile: Profile): void;
985
+ /**
986
+ * Resolves the document type code from input or flavor default.
987
+ * @param input - The invoice input
988
+ * @param flavor - The target flavor
989
+ * @returns The resolved type code (input's typeCode or flavor default)
990
+ */
991
+ declare function resolveTypeCode(input: FacturXInvoiceInput, flavor: Flavor): string;
992
+ /**
993
+ * Resolves the business process URN from input or flavor default.
994
+ * @param input - The invoice input
995
+ * @param flavor - The target flavor
996
+ * @returns The business process URN if set on input or flavor, otherwise undefined
997
+ */
998
+ declare function resolveBusinessProcessUrn(input: FacturXInvoiceInput, flavor: Flavor): string | undefined;
999
+
1000
+ /**
1001
+ * Escapes the five XML-reserved characters (`&`, `<`, `>`, `"`, `'`) and
1002
+ * strips control characters that are illegal in XML 1.0 (U+0000–U+0008,
1003
+ * U+000B–U+000C, U+000E–U+001F) so that arbitrary text can be safely
1004
+ * embedded in an XML document.
1005
+ */
1006
+ declare function escapeXml(value: string): string;
1007
+ /**
1008
+ * Builds a UN/CEFACT CrossIndustryInvoice XML string from structured input.
1009
+ *
1010
+ * The output conforms to the Factur-X 1.08 / ZUGFeRD 2.4 CII schema at the
1011
+ * requested {@link Profile} level. Elements that do not belong to the chosen
1012
+ * profile are silently omitted.
1013
+ *
1014
+ * @param input - Structured invoice data (see {@link FacturXInvoiceInput}).
1015
+ * @param profile - Target Factur-X profile (`MINIMUM` … `EXTENDED`).
1016
+ * @param flavor - Optional flavor; defaults to {@link Flavor.FACTUR_X}. Affects the
1017
+ * fallback document type code when `input.document.typeCode`
1018
+ * is not set.
1019
+ * @returns A complete XML document string (UTF-8 declaration, no BOM).
1020
+ */
1021
+ declare function buildXml(input: FacturXInvoiceInput, profile: Profile, flavor?: Flavor): string;
1022
+
1023
+ /**
1024
+ * Profile-based validation for Factur-X invoice input.
1025
+ *
1026
+ * Validates that a {@link FacturXInvoiceInput} contains all required fields
1027
+ * for a given profile level (MINIMUM → EXTENDED).
1028
+ *
1029
+ * @module validation/profile-validator
1030
+ */
1031
+
1032
+ /**
1033
+ * Describes a single validation error (missing or invalid required field).
1034
+ */
1035
+ interface ValidationError {
1036
+ /** Dot-path to the field (e.g. `"seller.address.country"`) */
1037
+ field: string;
1038
+ /** Human-readable error message */
1039
+ message: string;
1040
+ /** The profile level that requires this field */
1041
+ profile: Profile;
1042
+ }
1043
+ /**
1044
+ * Result of validating input against a profile.
1045
+ */
1046
+ interface ValidationResult {
1047
+ /** Whether validation passed (no errors) */
1048
+ valid: boolean;
1049
+ /** List of validation errors, empty when valid */
1050
+ errors: ValidationError[];
1051
+ }
1052
+ /**
1053
+ * Validates that the input contains all required fields for the given profile.
1054
+ * Requirements are cumulative: each profile includes all requirements of lower levels.
1055
+ *
1056
+ * @param input - Invoice input to validate
1057
+ * @param profile - Target profile (MINIMUM, BASIC_WL, BASIC, EN16931, or EXTENDED)
1058
+ * @returns Validation result with valid flag and any errors
1059
+ */
1060
+ declare function validateInput(input: FacturXInvoiceInput, profile: Profile): ValidationResult;
1061
+
1062
+ /**
1063
+ * XSD Schema Validation
1064
+ *
1065
+ * Validates generated CII XML against the official Factur-X / ZUGFeRD XSD
1066
+ * schemas using {@link https://github.com/jameslan/libxml2-wasm | libxml2-wasm}
1067
+ * (WebAssembly port of libxml2).
1068
+ *
1069
+ * Schema files are shipped with the package in `schema/` and loaded at
1070
+ * validation time. Because `libxml2-wasm` is ESM-only, this module uses
1071
+ * dynamic `import()` so the package stays consumable from both CJS and ESM.
1072
+ *
1073
+ * @module validation/xsd-validator
1074
+ * @license EUPL-1.2
1075
+ */
1076
+
1077
+ /**
1078
+ * A single XSD validation error.
1079
+ */
1080
+ interface XsdValidationError {
1081
+ /** Human-readable error message from the XSD validator */
1082
+ message: string;
1083
+ /** Line number in the XML document, if available */
1084
+ line?: number;
1085
+ /** Column number in the XML document, if available */
1086
+ column?: number;
1087
+ }
1088
+ /**
1089
+ * Result returned by {@link validateXsd}.
1090
+ */
1091
+ interface XsdValidationResult {
1092
+ /** Whether the XML is valid against the profile XSD */
1093
+ valid: boolean;
1094
+ /** List of XSD validation errors (empty when valid) */
1095
+ errors: XsdValidationError[];
1096
+ }
1097
+ /**
1098
+ * Options for {@link validateXsd}.
1099
+ */
1100
+ interface XsdValidateOptions {
1101
+ /**
1102
+ * Override the base path where the `schema/` folder is located.
1103
+ * Defaults to auto-detection from the package installation directory.
1104
+ */
1105
+ schemaBasePath?: string;
1106
+ }
1107
+ /**
1108
+ * Validates XML against the Factur-X XSD schema for a given profile.
1109
+ *
1110
+ * Uses `libxml2-wasm` (WASM port of libxml2) for full schema validation
1111
+ * including namespace imports. The library is loaded via dynamic `import()`
1112
+ * to keep the package compatible with CommonJS consumers.
1113
+ *
1114
+ * @param xml - The XML string to validate
1115
+ * @param profile - The Factur-X profile whose XSD to validate against
1116
+ * @param options - Optional settings (e.g. schema path override)
1117
+ * @returns Validation result with errors (if any)
1118
+ *
1119
+ * @example
1120
+ * ```ts
1121
+ * const result = await validateXsd(xmlString, Profile.EN16931);
1122
+ * if (!result.valid) {
1123
+ * console.error('XSD errors:', result.errors);
1124
+ * }
1125
+ * ```
1126
+ */
1127
+ declare function validateXsd(xml: string, profile: Profile, options?: XsdValidateOptions): Promise<XsdValidationResult>;
1128
+
1129
+ /**
1130
+ * Factur-X PDF Embedding
1131
+ *
1132
+ * Embeds structured invoice XML into a PDF document and ensures
1133
+ * PDF/A-3 compliance via XMP metadata.
1134
+ *
1135
+ * @module core/embed
1136
+ * @license EUPL-1.2
1137
+ */
1138
+
1139
+ /** Options for embedding Factur-X XML into a PDF. */
1140
+ interface EmbedOptions {
1141
+ /** Input PDF as Buffer or Uint8Array. */
1142
+ pdf: Uint8Array | Buffer;
1143
+ /** Pre-built XML string. If not provided, will build from {@link input}. */
1144
+ xml?: string;
1145
+ /** Structured invoice input. Used to build XML if {@link xml} is not provided. */
1146
+ input?: FacturXInvoiceInput;
1147
+ /** Profile level. */
1148
+ profile: Profile;
1149
+ /** Flavor (default: {@link Flavor.FACTUR_X}). */
1150
+ flavor?: Flavor;
1151
+ /** Validate input before generating XML (default: `true`). */
1152
+ validateBeforeEmbed?: boolean;
1153
+ /**
1154
+ * Run XSD schema validation on the generated XML (default: `false`).
1155
+ * Requires schema files to be present (shipped with the package).
1156
+ */
1157
+ validateXsd?: boolean;
1158
+ /** Add PDF/A-3 metadata (default: `true`). */
1159
+ addPdfA3Metadata?: boolean;
1160
+ /**
1161
+ * Override the AF relationship for the embedded XML attachment.
1162
+ *
1163
+ * Per the Factur-X specification:
1164
+ * - MINIMUM / BASIC_WL → `Data` (XML carries structured data only)
1165
+ * - BASIC / EN16931 / EXTENDED → `Alternative` (XML is a full representation)
1166
+ *
1167
+ * When not set, the correct value is derived automatically from {@link profile}.
1168
+ */
1169
+ afRelationship?: "Alternative" | "Data" | "Source";
1170
+ /** PDF metadata overrides. */
1171
+ meta?: {
1172
+ author?: string;
1173
+ title?: string;
1174
+ subject?: string;
1175
+ creator?: string;
1176
+ };
1177
+ }
1178
+ /** Result returned by {@link embedFacturX}. */
1179
+ interface EmbedResult {
1180
+ /** The resulting PDF bytes. */
1181
+ pdf: Uint8Array;
1182
+ /** The XML that was embedded. */
1183
+ xml: string;
1184
+ /** Profile validation result (if validation was performed). */
1185
+ validation?: ValidationResult;
1186
+ /** XSD schema validation result (if XSD validation was requested). */
1187
+ xsdValidation?: XsdValidationResult;
1188
+ }
1189
+ /**
1190
+ * Embeds Factur-X / ZUGFeRD XML into a PDF and sets PDF/A-3b metadata.
1191
+ *
1192
+ * Either provide a pre-built `xml` string or a structured `input` from which
1193
+ * the XML will be generated. The resulting PDF contains the XML as an
1194
+ * embedded attachment with the correct AF relationship and XMP metadata
1195
+ * declaring PDF/A-3b conformance.
1196
+ *
1197
+ * @param options - Embedding configuration
1198
+ * @returns The PDF bytes, embedded XML, and optional validation result
1199
+ *
1200
+ * @example
1201
+ * ```ts
1202
+ * const result = await embedFacturX({
1203
+ * pdf: existingPdfBytes,
1204
+ * input: invoiceData,
1205
+ * profile: Profile.EN16931,
1206
+ * });
1207
+ * fs.writeFileSync('invoice.pdf', result.pdf);
1208
+ * ```
1209
+ */
1210
+ declare function embedFacturX(options: EmbedOptions): Promise<EmbedResult>;
1211
+
1212
+ /**
1213
+ * Factur-X / ZUGFeRD XML Extraction from PDF
1214
+ *
1215
+ * Reads an embedded CII XML attachment from a PDF document.
1216
+ * Supports detection of all standard attachment filenames
1217
+ * (`factur-x.xml`, `xrechnung.xml`, `zugferd-invoice.xml`, `ZUGFeRD-invoice.xml`).
1218
+ *
1219
+ * @module core/extract
1220
+ * @license EUPL-1.2
1221
+ */
1222
+
1223
+ /**
1224
+ * Result returned by {@link extractXml}.
1225
+ */
1226
+ interface ExtractResult {
1227
+ /** The extracted XML string */
1228
+ xml: string;
1229
+ /** The filename of the embedded attachment */
1230
+ filename: string;
1231
+ /** The Factur-X profile detected from the XML (if identifiable) */
1232
+ profile?: Profile;
1233
+ }
1234
+ /**
1235
+ * Options for {@link extractXml}.
1236
+ */
1237
+ interface ExtractOptions {
1238
+ /**
1239
+ * Specific attachment filename to look for.
1240
+ * If not set, searches for all known Factur-X filenames.
1241
+ */
1242
+ filename?: string;
1243
+ }
1244
+ /**
1245
+ * Extracts Factur-X / ZUGFeRD XML from a PDF document.
1246
+ *
1247
+ * Searches the PDF's embedded files (Names → EmbeddedFiles) for a known
1248
+ * Factur-X attachment or a specific filename. Returns the XML content,
1249
+ * the filename, and the detected profile.
1250
+ *
1251
+ * @param pdf - Input PDF as `Uint8Array` or `Buffer`
1252
+ * @param options - Extraction options (e.g. specific filename)
1253
+ * @returns The extracted XML, filename, and detected profile
1254
+ *
1255
+ * @throws Error if no matching XML attachment is found
1256
+ *
1257
+ * @example
1258
+ * ```ts
1259
+ * import { extractXml } from '@stackforge-eu/factur-x';
1260
+ * import { readFile } from 'fs/promises';
1261
+ *
1262
+ * const pdf = await readFile('invoice.pdf');
1263
+ * const { xml, filename, profile } = await extractXml(pdf);
1264
+ * console.log(`Found ${filename} (profile: ${profile})`);
1265
+ * console.log(xml);
1266
+ * ```
1267
+ */
1268
+ declare function extractXml(pdf: Uint8Array | Buffer, options?: ExtractOptions): Promise<ExtractResult>;
1269
+
1270
+ /**
1271
+ * XRechnung Generation
1272
+ *
1273
+ * Generates standalone CII XML for German B2G (XRechnung) use.
1274
+ * XRechnung is a pure-XML format (no PDF embedding) that conforms
1275
+ * to EN 16931 with additional PEPPOL/German government requirements.
1276
+ *
1277
+ * @module core/xrechnung
1278
+ * @license EUPL-1.2
1279
+ */
1280
+
1281
+ /**
1282
+ * Options for XRechnung generation.
1283
+ */
1284
+ interface XRechnungOptions {
1285
+ /**
1286
+ * Profile level (default: {@link Profile.EN16931}).
1287
+ * XRechnung only supports EN16931.
1288
+ */
1289
+ profile?: Profile;
1290
+ /**
1291
+ * Validate input before generating XML (default: `true`).
1292
+ */
1293
+ validate?: boolean;
1294
+ }
1295
+ /**
1296
+ * Result of XRechnung generation.
1297
+ */
1298
+ interface XRechnungResult {
1299
+ /** The generated CII XML string */
1300
+ xml: string;
1301
+ /** Validation result (if validation was performed) */
1302
+ validation?: ValidationResult;
1303
+ }
1304
+ /**
1305
+ * Generates XRechnung-compliant CII XML from structured invoice input.
1306
+ *
1307
+ * XRechnung is a German B2G invoice format. It is a pure-XML format
1308
+ * (no PDF embedding) that uses the EN 16931 profile with a PEPPOL
1309
+ * business process identifier.
1310
+ *
1311
+ * The output can be uploaded directly to German government portals
1312
+ * (e.g. via PEPPOL or ZRE/OZG-RE).
1313
+ *
1314
+ * @param input - Structured invoice data
1315
+ * @param options - Generation options (profile, validation)
1316
+ * @returns The XRechnung CII XML and optional validation result
1317
+ *
1318
+ * @throws Error if input validation fails (when `validate` is `true`)
1319
+ * @throws Error if the profile is not supported for XRechnung
1320
+ *
1321
+ * @example
1322
+ * ```ts
1323
+ * const result = toXRechnung({
1324
+ * document: { id: 'INV-001', issueDate: '2025-03-01', buyerReference: '04011000-12345-67' },
1325
+ * seller: { name: 'StackForge UG (haftungsbeschränkt)', address: { line1: 'Bergstraße 4', city: 'Weihmichl', postalCode: '84107', country: 'DE' } },
1326
+ * buyer: { name: 'Kite-Engineer by Stefan Merthan', address: { line1: 'Hauptstraße 6', city: 'Weihmichl', postalCode: '84107', country: 'DE' } },
1327
+ * lines: [{ id: '1', name: 'Service', quantity: 1, unitPrice: 100, vatCategoryCode: 'S', vatRatePercent: 19 }],
1328
+ * totals: { lineTotal: 100, taxBasisTotal: 100, taxTotal: 19, grandTotal: 119, duePayableAmount: 119, currency: 'EUR' },
1329
+ * vatBreakdown: [{ categoryCode: 'S', ratePercent: 19, taxableAmount: 100, taxAmount: 19 }],
1330
+ * });
1331
+ * console.log(result.xml);
1332
+ * ```
1333
+ */
1334
+ declare function toXRechnung(input: FacturXInvoiceInput, options?: XRechnungOptions): XRechnungResult;
1335
+
1336
+ export { type AddressInput, type AllowanceChargeInput, type BillingPeriodInput, type ContactInput, type DeliveryInput, type DocumentReferenceInput, DocumentTypeCode, type EmbedOptions, type EmbedResult, type ExtractOptions, type ExtractResult, FLAVOR_CONFIGS, FLAVOR_DEFAULT_TYPE_CODES, type FacturXInvoiceInput, Flavor, type FlavorConfig, type InvoiceDocumentInput, type InvoiceLineInput, type InvoiceTotalsInput, type LegalOrganizationInput, type NoteInput, PROFILE_MAIN_XSD, PROFILE_SCHEMA_DIRS, PROFILE_URNS, type PaymentInput, Profile, type TaxRegistrationInput, type TradePartyInput, UnitCode, type ValidationError, type ValidationResult, type VatBreakdownInput, type XRechnungOptions, type XRechnungResult, type XsdValidateOptions, type XsdValidationError, type XsdValidationResult, buildXml, embedFacturX, escapeXml, extractXml, getFlavorConfig, resolveBusinessProcessUrn, resolveTypeCode, toXRechnung, validateFlavorProfile, validateInput, validateXsd };