@financica/ubl 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/index.d.ts +384 -0
- package/dist/build/index.js +510 -0
- package/dist/build/index.js.map +1 -0
- package/dist/index.d.ts +43 -1
- package/dist/index.js +103 -10
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/** Peppol BIS Billing 3.0 / EN 16931 identifiers and fixed code values. */
|
|
2
|
+
/** EN 16931 + Peppol BIS Billing 3.0 customization (BT-24). */
|
|
3
|
+
declare const UBL_CUSTOMIZATION_ID = "urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0";
|
|
4
|
+
/** Peppol BIS Billing 3.0 process (BT-23). */
|
|
5
|
+
declare const UBL_PROFILE_ID = "urn:fdc:peppol.eu:2017:poacc:billing:01:1.0";
|
|
6
|
+
/** UNTDID 1001 — commercial invoice. */
|
|
7
|
+
declare const INVOICE_TYPE_CODE = "380";
|
|
8
|
+
/** UNTDID 1001 — credit note. */
|
|
9
|
+
declare const CREDIT_NOTE_TYPE_CODE = "381";
|
|
10
|
+
/** UN/ECE Recommendation 20 — "one / piece" (the default line unit). */
|
|
11
|
+
declare const DEFAULT_UNIT_CODE = "C62";
|
|
12
|
+
/** UNCL5153 — the VAT tax scheme identifier. */
|
|
13
|
+
declare const VAT_TAX_SCHEME_ID = "VAT";
|
|
14
|
+
/** ISO 3166-1 alpha-2 list identifier for `cbc:IdentificationCode`. */
|
|
15
|
+
declare const COUNTRY_CODE_LIST_ID = "ISO3166-1:Alpha2";
|
|
16
|
+
declare const NS_INVOICE = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2";
|
|
17
|
+
declare const NS_CREDIT_NOTE = "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2";
|
|
18
|
+
declare const NS_CAC = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2";
|
|
19
|
+
declare const NS_CBC = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A vendor-neutral model of a Peppol BIS Billing 3.0 document.
|
|
23
|
+
*
|
|
24
|
+
* This is the intermediate representation `stripe-ubl` produces from a Stripe
|
|
25
|
+
* invoice or credit note; {@link ../ubl/serialize.ts} turns it into UBL XML.
|
|
26
|
+
* It is deliberately a thin, construction-oriented mirror of the UBL fields we
|
|
27
|
+
* populate — not a full UBL object graph.
|
|
28
|
+
*/
|
|
29
|
+
interface UblAddress {
|
|
30
|
+
/** `cbc:StreetName` (BT-35). */
|
|
31
|
+
street: string | null;
|
|
32
|
+
/** `cbc:AdditionalStreetName` (BT-36). */
|
|
33
|
+
additionalStreet: string | null;
|
|
34
|
+
/** `cbc:CityName` (BT-37). */
|
|
35
|
+
city: string | null;
|
|
36
|
+
/** `cbc:PostalZone` (BT-38). */
|
|
37
|
+
postalZone: string | null;
|
|
38
|
+
/** `cbc:CountrySubentity` (BT-39). */
|
|
39
|
+
countrySubentity: string | null;
|
|
40
|
+
/** `cac:Country/cbc:IdentificationCode` (BT-40) — ISO 3166-1 alpha-2. */
|
|
41
|
+
countryCode: string | null;
|
|
42
|
+
}
|
|
43
|
+
/** Peppol participant identifier, e.g. scheme `0208`, value `0800279001`. */
|
|
44
|
+
interface UblEndpoint {
|
|
45
|
+
scheme: string;
|
|
46
|
+
value: string;
|
|
47
|
+
}
|
|
48
|
+
/** Legal registration identifier, e.g. a Belgian enterprise number. */
|
|
49
|
+
interface UblCompanyId {
|
|
50
|
+
value: string;
|
|
51
|
+
/** ICD scheme (e.g. `0208` for the Belgian CBE), when known. */
|
|
52
|
+
scheme?: string | null;
|
|
53
|
+
}
|
|
54
|
+
interface UblParty {
|
|
55
|
+
/** `cbc:EndpointID` (BT-49/BT-34) — the Peppol routing identifier. */
|
|
56
|
+
endpoint: UblEndpoint | null;
|
|
57
|
+
/** `cac:PartyName/cbc:Name` (BT-27/BT-44). */
|
|
58
|
+
name: string;
|
|
59
|
+
address: UblAddress;
|
|
60
|
+
/** `cac:PartyTaxScheme/cbc:CompanyID` with `VAT` scheme (BT-31/BT-48). */
|
|
61
|
+
vatNumber: string | null;
|
|
62
|
+
/** `cac:PartyLegalEntity/cbc:RegistrationName` (BT-27/BT-44). Defaults to `name`. */
|
|
63
|
+
legalName: string | null;
|
|
64
|
+
/** `cac:PartyLegalEntity/cbc:CompanyID` (BT-30/BT-47). */
|
|
65
|
+
companyId: UblCompanyId | null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* VAT breakdown category. `id` is a UNCL5305 code:
|
|
69
|
+
* - `S` Standard rate
|
|
70
|
+
* - `Z` Zero-rated goods
|
|
71
|
+
* - `E` Exempt from VAT
|
|
72
|
+
* - `AE` VAT reverse charge
|
|
73
|
+
* - `O` Services outside scope of tax
|
|
74
|
+
* - `K` Intra-community supply
|
|
75
|
+
* - `G` Export outside the EU
|
|
76
|
+
*/
|
|
77
|
+
interface UblTaxCategory {
|
|
78
|
+
id: string;
|
|
79
|
+
percent: number;
|
|
80
|
+
/** Required by EN 16931 (BR-E-10/BR-AE-10/…) for non-`S`/`Z` categories. */
|
|
81
|
+
exemptionReason?: string | null;
|
|
82
|
+
}
|
|
83
|
+
interface UblLine {
|
|
84
|
+
/** `cbc:ID` (BT-126) — line identifier. */
|
|
85
|
+
id: string;
|
|
86
|
+
/** `cac:Item/cbc:Name` (BT-153). */
|
|
87
|
+
name: string;
|
|
88
|
+
/** `cbc:InvoicedQuantity` / `cbc:CreditedQuantity` (BT-129). */
|
|
89
|
+
quantity: number;
|
|
90
|
+
/** UN/ECE Rec 20 unit code (BT-130). */
|
|
91
|
+
unitCode: string;
|
|
92
|
+
/** `cbc:LineExtensionAmount` (BT-131) — net of VAT, after line discounts. */
|
|
93
|
+
lineExtensionAmount: number;
|
|
94
|
+
/** `cac:Price/cbc:PriceAmount` (BT-146) — net unit price. */
|
|
95
|
+
priceAmount: number;
|
|
96
|
+
taxCategory: UblTaxCategory;
|
|
97
|
+
}
|
|
98
|
+
interface UblTaxSubtotal {
|
|
99
|
+
/** `cbc:TaxableAmount` (BT-116). */
|
|
100
|
+
taxableAmount: number;
|
|
101
|
+
/** `cbc:TaxAmount` (BT-117). */
|
|
102
|
+
taxAmount: number;
|
|
103
|
+
category: UblTaxCategory;
|
|
104
|
+
}
|
|
105
|
+
interface UblTaxTotal {
|
|
106
|
+
/** `cbc:TaxAmount` (BT-110) — sum of subtotal tax amounts. */
|
|
107
|
+
taxAmount: number;
|
|
108
|
+
subtotals: UblTaxSubtotal[];
|
|
109
|
+
}
|
|
110
|
+
interface UblMonetaryTotal {
|
|
111
|
+
/** BT-106 — sum of line net amounts. */
|
|
112
|
+
lineExtensionAmount: number;
|
|
113
|
+
/** BT-109 — total without VAT. */
|
|
114
|
+
taxExclusiveAmount: number;
|
|
115
|
+
/** BT-112 — total with VAT. */
|
|
116
|
+
taxInclusiveAmount: number;
|
|
117
|
+
/** BT-115 — amount due for payment. */
|
|
118
|
+
payableAmount: number;
|
|
119
|
+
}
|
|
120
|
+
/** An embedded supporting document (BG-24), e.g. the rendered PDF. */
|
|
121
|
+
interface UblAttachment {
|
|
122
|
+
/** `cac:AdditionalDocumentReference/cbc:ID` (BT-122). */
|
|
123
|
+
id: string;
|
|
124
|
+
/** `cbc:EmbeddedDocumentBinaryObject/@filename`. */
|
|
125
|
+
filename: string;
|
|
126
|
+
/** MIME type, e.g. `application/pdf`. */
|
|
127
|
+
mimeCode: string;
|
|
128
|
+
/** Base64-encoded document bytes. */
|
|
129
|
+
base64: string;
|
|
130
|
+
}
|
|
131
|
+
interface UblDocument {
|
|
132
|
+
documentType: "invoice" | "creditNote";
|
|
133
|
+
/** Invoice / credit note number (BT-1). */
|
|
134
|
+
id: string;
|
|
135
|
+
/** Issue date (BT-2), `YYYY-MM-DD`. */
|
|
136
|
+
issueDate: string;
|
|
137
|
+
/** Payment due date (BT-9). Invoices only. */
|
|
138
|
+
dueDate: string | null;
|
|
139
|
+
/** Free-text note (BT-22). */
|
|
140
|
+
note: string | null;
|
|
141
|
+
/** Document currency (BT-5). */
|
|
142
|
+
currency: string;
|
|
143
|
+
/** Buyer reference (BT-10). */
|
|
144
|
+
buyerReference: string | null;
|
|
145
|
+
/** For credit notes: the referenced original invoice number (BT-25). */
|
|
146
|
+
precedingInvoiceId: string | null;
|
|
147
|
+
supplier: UblParty;
|
|
148
|
+
customer: UblParty;
|
|
149
|
+
lines: UblLine[];
|
|
150
|
+
taxTotal: UblTaxTotal;
|
|
151
|
+
monetaryTotal: UblMonetaryTotal;
|
|
152
|
+
attachments: UblAttachment[];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Serialize a {@link UblDocument} into a Peppol BIS Billing 3.0 XML string. */
|
|
156
|
+
declare const serializeUblDocument: (doc: UblDocument) => string;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Supplier (seller) VAT status. Drives how zero-VAT lines are reported when the
|
|
160
|
+
* seller does not charge VAT:
|
|
161
|
+
*
|
|
162
|
+
* 1 — Subject to VAT (the normal case): line categories come from the data.
|
|
163
|
+
* 2 — Not subject to VAT.
|
|
164
|
+
* 3 — Small business / franchise exemption (e.g. Belgian Article 56bis).
|
|
165
|
+
*
|
|
166
|
+
* For statuses 2 and 3, {@link ../build.ts} coerces all line categories to a
|
|
167
|
+
* non-charging exempt category so no VAT is reported.
|
|
168
|
+
*/
|
|
169
|
+
type SupplierVatStatus = 1 | 2 | 3;
|
|
170
|
+
/**
|
|
171
|
+
* Caller-provided supplier data, normalized into a stable shape.
|
|
172
|
+
*
|
|
173
|
+
* Each consumer builds this from its own data store. Once a `UblSupplier`
|
|
174
|
+
* exists, the party builder no longer needs to know where it came from.
|
|
175
|
+
*/
|
|
176
|
+
interface UblSupplier {
|
|
177
|
+
/** Display + legal name shown on the invoice. */
|
|
178
|
+
name: string;
|
|
179
|
+
/** ISO 3166-1 alpha-2 country code (e.g. `"BE"`). */
|
|
180
|
+
countryCode: string;
|
|
181
|
+
/**
|
|
182
|
+
* Free-form address. Stripe-style fields (`line1`, `postal_code`, `country`)
|
|
183
|
+
* and legacy/internal fields (`street`, `zip_code`) are both accepted.
|
|
184
|
+
*/
|
|
185
|
+
address: unknown;
|
|
186
|
+
/** Country-specific company/registration number (e.g. BE enterprise number). */
|
|
187
|
+
companyNumber?: string | null;
|
|
188
|
+
/** VAT number with country prefix (e.g. `"BE0793904121"`). */
|
|
189
|
+
vatNumber?: string | null;
|
|
190
|
+
/** Whether the supplier charges VAT. See {@link SupplierVatStatus}. */
|
|
191
|
+
vatStatus: SupplierVatStatus;
|
|
192
|
+
/** Peppol participant identifier in `scheme:value` form (e.g. `"0208:0793904121"`). */
|
|
193
|
+
peppolID?: string | null;
|
|
194
|
+
}
|
|
195
|
+
/** Convert a {@link UblSupplier} into the supplier (seller) party. */
|
|
196
|
+
declare const buildSupplierParty: (supplier: UblSupplier) => UblParty;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Normalize a free-form address (Stripe shape, custom shape, or an internal
|
|
200
|
+
* shape) into a {@link UblAddress}.
|
|
201
|
+
*
|
|
202
|
+
* Accepts both `line1`/`postal_code`/`country` (Stripe) and `street`/`zip_code`
|
|
203
|
+
* (legacy/internal) keys. Falls back to `fallbackCountryCode` when the address
|
|
204
|
+
* has no country, but never silently substitutes a caller's country — pass
|
|
205
|
+
* `null` when "no country" is the right answer.
|
|
206
|
+
*/
|
|
207
|
+
declare const normalizeAddress: (address: unknown, fallbackCountryCode: string | null, fallbackLine?: string | null) => UblAddress;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Build a UBL embedded-document attachment (BG-24) from raw bytes — e.g. the
|
|
211
|
+
* rendered PDF of the invoice. Emitted as a `cac:AdditionalDocumentReference`
|
|
212
|
+
* with an inline base64 `cbc:EmbeddedDocumentBinaryObject`.
|
|
213
|
+
*/
|
|
214
|
+
declare const buildPdfAttachment: (params: {
|
|
215
|
+
filename: string;
|
|
216
|
+
bytes: Uint8Array;
|
|
217
|
+
/** Document reference ID (BT-122). Defaults to the filename. */
|
|
218
|
+
id?: string;
|
|
219
|
+
}) => UblAttachment;
|
|
220
|
+
/**
|
|
221
|
+
* Replace each attachment's base64 payload with `[omitted]` plus a length, so a
|
|
222
|
+
* {@link UblDocument} is safe to log or persist for audit.
|
|
223
|
+
*/
|
|
224
|
+
declare const sanitizeUblDocumentForAudit: (doc: UblDocument) => UblDocument;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Strip whitespace/punctuation from a country-specific company number.
|
|
228
|
+
* For Belgium, also strips an optional `BE` prefix.
|
|
229
|
+
*/
|
|
230
|
+
declare const normalizeCompanyNumberForCountry: (countryCode: string | null | undefined, companyNumber: string | null | undefined) => string;
|
|
231
|
+
/**
|
|
232
|
+
* Country code → Peppol/ISO 6523 ICD scheme for a legal registration number
|
|
233
|
+
* (`cac:PartyLegalEntity/cbc:CompanyID/@schemeID`).
|
|
234
|
+
*
|
|
235
|
+
* BE → 0208 (Belgian enterprise number, CBE/KBO/BCE)
|
|
236
|
+
* NL → 0106 (Netherlands KvK)
|
|
237
|
+
* FR → 0002 (France SIRENE)
|
|
238
|
+
*
|
|
239
|
+
* Falls back to inspecting the number's country prefix (e.g. `BE0793904121`).
|
|
240
|
+
* Returns `null` when the scheme can't be determined, in which case the
|
|
241
|
+
* CompanyID is emitted without a `schemeID` attribute.
|
|
242
|
+
*/
|
|
243
|
+
declare const resolveCompanyIdScheme: (params: {
|
|
244
|
+
countryCode: string | null;
|
|
245
|
+
companyNumber: string | null;
|
|
246
|
+
}) => string | null;
|
|
247
|
+
/**
|
|
248
|
+
* Build the `cac:PartyLegalEntity/cbc:CompanyID` value for a party, with the
|
|
249
|
+
* country-appropriate ICD scheme when known. Returns `null` when there is no
|
|
250
|
+
* company number.
|
|
251
|
+
*/
|
|
252
|
+
declare const buildCompanyId: (params: {
|
|
253
|
+
countryCode: string | null;
|
|
254
|
+
companyNumber: string | null;
|
|
255
|
+
}) => UblCompanyId | null;
|
|
256
|
+
/**
|
|
257
|
+
* Parse a Peppol participant identifier into a {@link UblEndpoint}.
|
|
258
|
+
*
|
|
259
|
+
* Accepts the canonical `scheme:value` form (e.g. `0208:0800279001`). Returns
|
|
260
|
+
* `null` for values without an explicit scheme, since `cbc:EndpointID` requires
|
|
261
|
+
* a `schemeID` and guessing one would mis-route the document.
|
|
262
|
+
*/
|
|
263
|
+
declare const parsePeppolEndpoint: (peppolId: string | null | undefined) => UblEndpoint | null;
|
|
264
|
+
interface CustomerTaxIdentifiers {
|
|
265
|
+
peppolID: string | null;
|
|
266
|
+
glnNumber: string | null;
|
|
267
|
+
taxNumber: string | null;
|
|
268
|
+
vatNumber: string | null;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Pick the first usable Peppol identifier, GLN, VAT number, and tax number
|
|
272
|
+
* from a Stripe-style `customer_tax_ids` array (`[{type, value}, …]`).
|
|
273
|
+
*
|
|
274
|
+
* Stripe stores VAT numbers under types like `eu_vat`, `gb_vat`, etc.
|
|
275
|
+
* Peppol IDs are typically stored as a custom `peppol_id` type.
|
|
276
|
+
*/
|
|
277
|
+
declare const extractCustomerTaxIdentifiers: (taxIds: unknown) => CustomerTaxIdentifiers;
|
|
278
|
+
/**
|
|
279
|
+
* Return the candidate identifiers a Peppol receiver lookup will accept,
|
|
280
|
+
* in priority order, with duplicates and nulls removed.
|
|
281
|
+
*/
|
|
282
|
+
declare const listPeppolReceiverIdentifierCandidates: (customer: {
|
|
283
|
+
peppolID?: string | null;
|
|
284
|
+
glnNumber?: string | null;
|
|
285
|
+
taxNumber?: string | null;
|
|
286
|
+
vatNumber?: string | null;
|
|
287
|
+
}) => string[];
|
|
288
|
+
|
|
289
|
+
/** Round a number to 2 decimal places (cents). */
|
|
290
|
+
declare const roundCurrency: (value: number) => number;
|
|
291
|
+
/** Convert an integer cent amount into a 2-decimal currency value. */
|
|
292
|
+
declare const centsToDecimal: (cents: number) => number;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Stripe Tax `taxability_reason` values that map to a VAT-exempt UBL category
|
|
296
|
+
* (`E`). Reverse charge is handled separately (category `AE`).
|
|
297
|
+
*/
|
|
298
|
+
declare const EXEMPT_TAXABILITY_REASONS: Set<string>;
|
|
299
|
+
interface TaxAmountInfo {
|
|
300
|
+
amount: number;
|
|
301
|
+
taxability_reason?: string | null;
|
|
302
|
+
tax_rate_percentage?: number | null;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Map an explicit UBL category hint, a Stripe `taxability_reason`, and/or a
|
|
306
|
+
* numeric rate into a {@link UblTaxCategory}.
|
|
307
|
+
*
|
|
308
|
+
* - Reverse charge → `AE` (0%, with exemption reason)
|
|
309
|
+
* - Any other exempt reason → `E` (0%, with exemption reason)
|
|
310
|
+
* - Category `Z` / rate ≤ 0 → `Z` (zero-rated, 0%)
|
|
311
|
+
* - Otherwise → `S` (standard, the line's rate)
|
|
312
|
+
*/
|
|
313
|
+
declare const taxCategoryFromReasonOrRate: (params: {
|
|
314
|
+
taxCategoryId?: string | null;
|
|
315
|
+
taxabilityReason: string | null;
|
|
316
|
+
rate: number;
|
|
317
|
+
}) => UblTaxCategory;
|
|
318
|
+
/**
|
|
319
|
+
* Resolve a {@link UblTaxCategory} from a line's Stripe tax info.
|
|
320
|
+
*
|
|
321
|
+
* Exempt / reverse-charge / zero-rated reasons take precedence over the rate;
|
|
322
|
+
* otherwise the rate decides standard (`S`) vs zero-rated (`Z`).
|
|
323
|
+
*/
|
|
324
|
+
declare const resolveTaxCategoryFromTaxAmounts: (taxAmounts: TaxAmountInfo[], rate: number) => UblTaxCategory;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Adjust the largest line's net amount so the line nets sum to the
|
|
328
|
+
* authoritative document total (e.g. Stripe's `invoice.total_excluding_tax`).
|
|
329
|
+
*
|
|
330
|
+
* Reconciling at the *line* level — rather than directly on the VAT breakdown —
|
|
331
|
+
* keeps the document consistent bottom-up: the VAT category taxable amounts
|
|
332
|
+
* (BR-S-08) and the line-extension total (BR-CO-13) both still derive from the
|
|
333
|
+
* lines. Discrepancies here are sub-cent rounding or a distributed invoice-level
|
|
334
|
+
* coupon; larger ones indicate a real upstream data problem.
|
|
335
|
+
*/
|
|
336
|
+
declare const reconcileLinesToExclTotal: (lines: UblLine[], authoritativeTotalExclVat: number) => UblLine[];
|
|
337
|
+
interface BuildTaxTotalsResult {
|
|
338
|
+
taxTotal: UblTaxTotal;
|
|
339
|
+
monetaryTotal: UblMonetaryTotal;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Group lines by `(category, percent)` into a VAT breakdown and compute the
|
|
343
|
+
* document monetary totals.
|
|
344
|
+
*
|
|
345
|
+
* Each VAT category's tax amount is **derived** as `taxable × percent / 100`,
|
|
346
|
+
* rounded to two decimals (EN 16931 BR-CO-17), rather than summed from the
|
|
347
|
+
* upstream per-line tax cents. This guarantees the breakdown is internally
|
|
348
|
+
* consistent and passes validation; it can differ by a cent from the figure a
|
|
349
|
+
* payment processor reported, which is an unavoidable artifact of representing
|
|
350
|
+
* a cents-rounded system as a rate-based VAT breakdown.
|
|
351
|
+
*/
|
|
352
|
+
declare const buildTaxTotals: (lines: UblLine[]) => BuildTaxTotalsResult;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Minimal, dependency-free XML builder + serializer.
|
|
356
|
+
*
|
|
357
|
+
* UBL is order-sensitive (every element sequence is fixed by the schema), so
|
|
358
|
+
* children are always explicit, ordered arrays. There is no attribute or text
|
|
359
|
+
* coercion magic beyond escaping — the UBL layer is responsible for emitting
|
|
360
|
+
* elements in the right order.
|
|
361
|
+
*/
|
|
362
|
+
type XmlAttrs = Record<string, string | number | null | undefined>;
|
|
363
|
+
interface XmlElement {
|
|
364
|
+
name: string;
|
|
365
|
+
attrs?: XmlAttrs;
|
|
366
|
+
/** Leaf text content. Mutually exclusive with `children`. */
|
|
367
|
+
text?: string | number | null;
|
|
368
|
+
/** Child elements. Mutually exclusive with `text`. */
|
|
369
|
+
children?: XmlElement[];
|
|
370
|
+
}
|
|
371
|
+
/** Falsy children are dropped, so callers can write `cond && el(...)`. */
|
|
372
|
+
type ChildSpec = XmlElement | null | undefined | false;
|
|
373
|
+
/**
|
|
374
|
+
* Build an XML element.
|
|
375
|
+
*
|
|
376
|
+
* el("cbc:ID", null, "INV-1") → <cbc:ID>INV-1</cbc:ID>
|
|
377
|
+
* el("cbc:Amount", { currencyID: "EUR" }, "10.00") → <cbc:Amount currencyID="EUR">10.00</cbc:Amount>
|
|
378
|
+
* el("cac:Party", null, [child, cond && child2]) → nested element
|
|
379
|
+
*/
|
|
380
|
+
declare const el: (name: string, attrs?: XmlAttrs | null, content?: string | number | null | ChildSpec[]) => XmlElement;
|
|
381
|
+
/** Serialize a root element into a UTF-8 XML document string. */
|
|
382
|
+
declare const serializeDocument: (root: XmlElement) => string;
|
|
383
|
+
|
|
384
|
+
export { type BuildTaxTotalsResult, COUNTRY_CODE_LIST_ID, CREDIT_NOTE_TYPE_CODE, type CustomerTaxIdentifiers, DEFAULT_UNIT_CODE, EXEMPT_TAXABILITY_REASONS, INVOICE_TYPE_CODE, NS_CAC, NS_CBC, NS_CREDIT_NOTE, NS_INVOICE, type SupplierVatStatus, type TaxAmountInfo, UBL_CUSTOMIZATION_ID, UBL_PROFILE_ID, type UblAddress, type UblAttachment, type UblCompanyId, type UblDocument, type UblEndpoint, type UblLine, type UblMonetaryTotal, type UblParty, type UblSupplier, type UblTaxCategory, type UblTaxSubtotal, type UblTaxTotal, VAT_TAX_SCHEME_ID, type XmlAttrs, type XmlElement, buildCompanyId, buildPdfAttachment, buildSupplierParty, buildTaxTotals, centsToDecimal, el, extractCustomerTaxIdentifiers, listPeppolReceiverIdentifierCandidates, normalizeAddress, normalizeCompanyNumberForCountry, parsePeppolEndpoint, reconcileLinesToExclTotal, resolveCompanyIdScheme, resolveTaxCategoryFromTaxAmounts, roundCurrency, sanitizeUblDocumentForAudit, serializeDocument, serializeUblDocument, taxCategoryFromReasonOrRate };
|