@financica/ubl 0.17.0 → 0.18.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/CHANGELOG.md +13 -0
- package/README.md +47 -1
- package/dist/build/index.d.ts +37 -16
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +338 -48
- package/dist/build/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +115 -19
- package/dist/index.js.map +1 -1
- package/dist/{types-DossV2at.d.ts → types-DpwX8-Ix.d.ts} +77 -4
- package/dist/types-DpwX8-Ix.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/build/index.ts +11 -0
- package/src/build/tax-totals.ts +100 -4
- package/src/build/ubl/serialize.ts +656 -75
- package/src/normalize.ts +6 -1
- package/src/parser.ts +161 -18
- package/src/types.ts +78 -2
- package/dist/types-DossV2at.d.ts.map +0 -1
package/src/normalize.ts
CHANGED
|
@@ -232,7 +232,12 @@ export const normalizeUblResponse = (
|
|
|
232
232
|
tax_category_id: normalizeText(line.taxCategory?.id),
|
|
233
233
|
tax_scheme_id: normalizeText(line.taxCategory?.schemeId),
|
|
234
234
|
tax_subtotals: line.taxSubtotals ?? [],
|
|
235
|
-
allowance_charges: sanitizeAllowanceCharges(
|
|
235
|
+
allowance_charges: sanitizeAllowanceCharges([
|
|
236
|
+
...(line.allowanceCharges ?? []),
|
|
237
|
+
...(line.priceAllowance
|
|
238
|
+
? [{ chargeIndicator: false, ...line.priceAllowance }]
|
|
239
|
+
: []),
|
|
240
|
+
]),
|
|
236
241
|
charge_amount: toNumberOrNull(line.chargeAmount),
|
|
237
242
|
metadata: line.additionalItemProperties
|
|
238
243
|
? Object.fromEntries(
|
package/src/parser.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
UblAllowanceCharge,
|
|
5
5
|
UblAttachment,
|
|
6
6
|
UblBillingReference,
|
|
7
|
+
UblCommodityClassification,
|
|
7
8
|
UblContact,
|
|
8
9
|
UblDelivery,
|
|
9
10
|
UblDocumentReference,
|
|
@@ -15,6 +16,7 @@ import type {
|
|
|
15
16
|
UblParty,
|
|
16
17
|
UblPartyIdentification,
|
|
17
18
|
UblPaymentMeans,
|
|
19
|
+
UblSchemedId,
|
|
18
20
|
UblTaxCategory,
|
|
19
21
|
UblTaxSubtotal,
|
|
20
22
|
UblTaxTotal,
|
|
@@ -88,6 +90,15 @@ function cbcDirectNumber(parent: Element, tag: string): number | undefined {
|
|
|
88
90
|
const attribute = (el: Element | null | undefined, name: string): string | undefined =>
|
|
89
91
|
trimmed(el?.getAttribute(name));
|
|
90
92
|
|
|
93
|
+
/** A direct `cbc:<tag>` child with its `@schemeID`. */
|
|
94
|
+
function cbcDirectSchemedId(parent: Element, tag: string): UblSchemedId | undefined {
|
|
95
|
+
const element = childElementsByTagNs(parent, CBC_NS, tag)[0];
|
|
96
|
+
const value = trimmed(element?.textContent);
|
|
97
|
+
return value !== undefined
|
|
98
|
+
? { value, scheme: attribute(element, "schemeID") }
|
|
99
|
+
: undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
91
102
|
function cacDirectElement(parent: Element, tag: string): Element | null {
|
|
92
103
|
return childElementsByTagNs(parent, CAC_NS, tag)[0] ?? null;
|
|
93
104
|
}
|
|
@@ -151,10 +162,25 @@ function parsePartyIdentifications(party: Element): UblPartyIdentification[] {
|
|
|
151
162
|
}
|
|
152
163
|
|
|
153
164
|
function parseParty(root: Element, role: string): UblParty {
|
|
154
|
-
const wrapper =
|
|
165
|
+
const wrapper = cacDirectElement(root, role);
|
|
155
166
|
const party = wrapper ? cacElement(wrapper, "Party") : null;
|
|
156
|
-
|
|
167
|
+
return party ? parsePartyElement(party) : {};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* `cac:PayeeParty` (BG-10) and `cac:TaxRepresentativeParty` (BG-11) carry the
|
|
172
|
+
* party children directly, without a `cac:Party` wrapper.
|
|
173
|
+
*/
|
|
174
|
+
function parseUnwrappedParty(root: Element, tag: string): UblParty | undefined {
|
|
175
|
+
const party = cacDirectElement(root, tag);
|
|
176
|
+
if (!party) return undefined;
|
|
177
|
+
const parsed = parsePartyElement(party);
|
|
178
|
+
return Object.values(parsed).some((value) => value !== undefined)
|
|
179
|
+
? parsed
|
|
180
|
+
: undefined;
|
|
181
|
+
}
|
|
157
182
|
|
|
183
|
+
function parsePartyElement(party: Element): UblParty {
|
|
158
184
|
const partyName = cacElement(party, "PartyName");
|
|
159
185
|
const legalEntity = cacElement(party, "PartyLegalEntity");
|
|
160
186
|
const taxScheme = cacElement(party, "PartyTaxScheme");
|
|
@@ -246,9 +272,13 @@ function parseTaxSubtotalsFromTaxTotal(taxTotal: Element): UblTaxSubtotal[] {
|
|
|
246
272
|
function parseTaxTotal(root: Element): UblTaxTotal {
|
|
247
273
|
const taxTotals = cacDirectElements(root, "TaxTotal");
|
|
248
274
|
const first = taxTotals[0];
|
|
275
|
+
const second = taxTotals[1];
|
|
249
276
|
return {
|
|
250
277
|
taxAmount: first ? cbcDirectNumber(first, "TaxAmount") : undefined,
|
|
251
278
|
subtotals: taxTotals.flatMap(parseTaxSubtotalsFromTaxTotal),
|
|
279
|
+
taxAmountInTaxCurrency: second
|
|
280
|
+
? cbcDirectNumber(second, "TaxAmount")
|
|
281
|
+
: undefined,
|
|
252
282
|
};
|
|
253
283
|
}
|
|
254
284
|
|
|
@@ -321,14 +351,24 @@ function parseLines(root: Element, isCreditNote: boolean): UblLine[] {
|
|
|
321
351
|
taxPercent !== undefined && lineExtensionAmount !== undefined
|
|
322
352
|
? Number(((lineExtensionAmount * taxPercent) / 100).toFixed(2))
|
|
323
353
|
: undefined;
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
354
|
+
const allowanceCharges = parseAllowanceCharges(line);
|
|
355
|
+
// BT-147/BT-148: the one allowance UBL permits under cac:Price.
|
|
356
|
+
const priceAllowanceElement = price
|
|
357
|
+
? parseAllowanceCharges(price).find((charge) => !charge.chargeIndicator)
|
|
358
|
+
: undefined;
|
|
359
|
+
const priceAllowance = priceAllowanceElement
|
|
360
|
+
? {
|
|
361
|
+
amount: priceAllowanceElement.amount,
|
|
362
|
+
baseAmount: priceAllowanceElement.baseAmount,
|
|
363
|
+
reason: priceAllowanceElement.reason,
|
|
364
|
+
}
|
|
365
|
+
: undefined;
|
|
366
|
+
const discountAmount =
|
|
367
|
+
allowanceCharges.reduce(
|
|
368
|
+
(sum, charge) =>
|
|
369
|
+
charge.chargeIndicator ? sum : sum + Math.abs(charge.amount ?? 0),
|
|
370
|
+
0,
|
|
371
|
+
) + Math.abs(priceAllowance?.amount ?? 0);
|
|
332
372
|
const chargeAmount = allowanceCharges.reduce(
|
|
333
373
|
(sum, charge) =>
|
|
334
374
|
charge.chargeIndicator ? sum + Math.abs(charge.amount ?? 0) : sum,
|
|
@@ -361,8 +401,42 @@ function parseLines(root: Element, isCreditNote: boolean): UblLine[] {
|
|
|
361
401
|
? priceAmount / priceBaseQuantity
|
|
362
402
|
: priceAmount;
|
|
363
403
|
|
|
404
|
+
const orderLineReference = cacDirectElement(line, "OrderLineReference");
|
|
405
|
+
const lineDocumentReference = cacDirectElements(line, "DocumentReference").find(
|
|
406
|
+
(reference) => cbcDirectText(reference, "DocumentTypeCode") === "130",
|
|
407
|
+
);
|
|
408
|
+
const standardId = item
|
|
409
|
+
? cacDirectElement(item, "StandardItemIdentification")
|
|
410
|
+
: null;
|
|
411
|
+
const originCountry = item ? cacDirectElement(item, "OriginCountry") : null;
|
|
412
|
+
const commodityClassifications: UblCommodityClassification[] = [];
|
|
413
|
+
for (const classification of item
|
|
414
|
+
? cacDirectElements(item, "CommodityClassification")
|
|
415
|
+
: []) {
|
|
416
|
+
const codeElement = childElementsByTagNs(
|
|
417
|
+
classification,
|
|
418
|
+
CBC_NS,
|
|
419
|
+
"ItemClassificationCode",
|
|
420
|
+
)[0];
|
|
421
|
+
const value = trimmed(codeElement?.textContent);
|
|
422
|
+
if (value === undefined) continue;
|
|
423
|
+
commodityClassifications.push({
|
|
424
|
+
value,
|
|
425
|
+
listId: attribute(codeElement, "listID"),
|
|
426
|
+
listVersionId: attribute(codeElement, "listVersionID"),
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
364
430
|
return {
|
|
365
431
|
id: requiredCbcText(line, "ID", `${lineTag} identifier`),
|
|
432
|
+
note: cbcDirectText(line, "Note"),
|
|
433
|
+
objectIdentifier: lineDocumentReference
|
|
434
|
+
? cbcDirectSchemedId(lineDocumentReference, "ID")
|
|
435
|
+
: undefined,
|
|
436
|
+
orderLineReference: orderLineReference
|
|
437
|
+
? cbcDirectText(orderLineReference, "LineID")
|
|
438
|
+
: undefined,
|
|
439
|
+
accountingCost: cbcDirectText(line, "AccountingCost"),
|
|
366
440
|
description: item ? cbcText(item, "Description") : undefined,
|
|
367
441
|
quantity: cbcNumber(line, qtyTag),
|
|
368
442
|
unitCode: attribute(qtyEl, "unitCode"),
|
|
@@ -378,11 +452,22 @@ function parseLines(root: Element, isCreditNote: boolean): UblLine[] {
|
|
|
378
452
|
taxSubtotals: lineTaxSubtotals.length > 0 ? lineTaxSubtotals : undefined,
|
|
379
453
|
allowanceCharges:
|
|
380
454
|
allowanceCharges.length > 0 ? allowanceCharges : undefined,
|
|
455
|
+
priceAllowance,
|
|
381
456
|
discountAmount: discountAmount > 0 ? discountAmount : undefined,
|
|
382
457
|
chargeAmount: chargeAmount > 0 ? chargeAmount : undefined,
|
|
383
458
|
itemName: item ? cbcText(item, "Name") : undefined,
|
|
384
459
|
sellersItemId: sellersId ? cbcText(sellersId, "ID") : undefined,
|
|
385
460
|
buyersItemId: buyersId ? cbcText(buyersId, "ID") : undefined,
|
|
461
|
+
standardItemId: standardId
|
|
462
|
+
? cbcDirectSchemedId(standardId, "ID")
|
|
463
|
+
: undefined,
|
|
464
|
+
commodityClassifications:
|
|
465
|
+
commodityClassifications.length > 0
|
|
466
|
+
? commodityClassifications
|
|
467
|
+
: undefined,
|
|
468
|
+
originCountryCode: originCountry
|
|
469
|
+
? cbcDirectText(originCountry, "IdentificationCode")
|
|
470
|
+
: undefined,
|
|
386
471
|
additionalItemProperties:
|
|
387
472
|
additionalItemProperties.length > 0
|
|
388
473
|
? additionalItemProperties
|
|
@@ -412,6 +497,10 @@ function parsePaymentMeansElement(pm: Element): UblPaymentMeans {
|
|
|
412
497
|
const branch = account ? cacElement(account, "FinancialInstitutionBranch") : null;
|
|
413
498
|
const paymentMeansCodeEl = pm.getElementsByTagNameNS(CBC_NS, "PaymentMeansCode")[0];
|
|
414
499
|
const mandate = cacElement(pm, "PaymentMandate");
|
|
500
|
+
const debitedAccount = mandate
|
|
501
|
+
? cacElement(mandate, "PayerFinancialAccount")
|
|
502
|
+
: null;
|
|
503
|
+
const card = cacElement(pm, "CardAccount");
|
|
415
504
|
|
|
416
505
|
return {
|
|
417
506
|
code: cbcText(pm, "PaymentMeansCode"),
|
|
@@ -420,7 +509,10 @@ function parsePaymentMeansElement(pm: Element): UblPaymentMeans {
|
|
|
420
509
|
iban: account ? cbcText(account, "ID") : undefined,
|
|
421
510
|
bic: branch ? cbcText(branch, "ID") : undefined,
|
|
422
511
|
accountName: account ? cbcText(account, "Name") : undefined,
|
|
423
|
-
mandateId: mandate ?
|
|
512
|
+
mandateId: mandate ? cbcDirectText(mandate, "ID") : undefined,
|
|
513
|
+
debitedAccount: debitedAccount ? cbcText(debitedAccount, "ID") : undefined,
|
|
514
|
+
cardNumber: card ? cbcText(card, "PrimaryAccountNumberID") : undefined,
|
|
515
|
+
cardHolder: card ? cbcText(card, "HolderName") : undefined,
|
|
424
516
|
};
|
|
425
517
|
}
|
|
426
518
|
|
|
@@ -454,13 +546,20 @@ function parseDelivery(root: Element): UblDelivery | undefined {
|
|
|
454
546
|
if (!delivery) return undefined;
|
|
455
547
|
const actualDeliveryDate = cbcText(delivery, "ActualDeliveryDate");
|
|
456
548
|
const deliveryLocation = cacElement(delivery, "DeliveryLocation");
|
|
549
|
+
const locationId = deliveryLocation
|
|
550
|
+
? cbcDirectSchemedId(deliveryLocation, "ID")
|
|
551
|
+
: undefined;
|
|
457
552
|
const address = parseAddressFromElement(
|
|
458
553
|
deliveryLocation ? cacElement(deliveryLocation, "Address") : null,
|
|
459
554
|
);
|
|
460
|
-
|
|
555
|
+
const deliveryParty = cacElement(delivery, "DeliveryParty");
|
|
556
|
+
const partyName = deliveryParty ? cbcText(deliveryParty, "Name") : undefined;
|
|
557
|
+
if (!actualDeliveryDate && !locationId && !address && !partyName) return undefined;
|
|
461
558
|
return {
|
|
462
559
|
actualDeliveryDate,
|
|
560
|
+
locationId,
|
|
463
561
|
address,
|
|
562
|
+
partyName,
|
|
464
563
|
};
|
|
465
564
|
}
|
|
466
565
|
|
|
@@ -484,18 +583,38 @@ function parseNotes(root: Element): string | undefined {
|
|
|
484
583
|
return notes.length > 0 ? notes.join("\n") : undefined;
|
|
485
584
|
}
|
|
486
585
|
|
|
586
|
+
/**
|
|
587
|
+
* `cac:AdditionalDocumentReference` (BG-24), plus the two references EN 16931
|
|
588
|
+
* types by `cbc:DocumentTypeCode`: 130 is the invoiced object (BT-18) and 50
|
|
589
|
+
* is the tender or lot (BT-17), which on a credit note stands in for the
|
|
590
|
+
* project reference (BT-11) UBL's CreditNote has no element for.
|
|
591
|
+
*/
|
|
487
592
|
function parseAttachments(root: Element): {
|
|
488
593
|
attachments: UblAttachment[] | undefined;
|
|
489
594
|
documentReferences: UblDocumentReference[] | undefined;
|
|
595
|
+
invoicedObjectId: UblSchemedId | undefined;
|
|
596
|
+
typeCode50Reference: string | undefined;
|
|
490
597
|
} {
|
|
491
|
-
const refs =
|
|
598
|
+
const refs = cacDirectElements(root, "AdditionalDocumentReference");
|
|
492
599
|
const attachments: UblAttachment[] = [];
|
|
493
600
|
const documentReferences: UblDocumentReference[] = [];
|
|
601
|
+
let invoicedObjectId: UblSchemedId | undefined;
|
|
602
|
+
let typeCode50Reference: string | undefined;
|
|
494
603
|
|
|
495
604
|
for (const ref of refs) {
|
|
496
605
|
const attachment = cacElement(ref, "Attachment");
|
|
497
606
|
const refId = cbcText(ref, "ID");
|
|
498
607
|
const description = cbcText(ref, "DocumentDescription");
|
|
608
|
+
const typeCode = cbcDirectText(ref, "DocumentTypeCode");
|
|
609
|
+
|
|
610
|
+
if (typeCode === "130" && !attachment) {
|
|
611
|
+
invoicedObjectId ??= cbcDirectSchemedId(ref, "ID");
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
614
|
+
if (typeCode === "50" && !attachment) {
|
|
615
|
+
typeCode50Reference ??= refId;
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
499
618
|
|
|
500
619
|
if (!attachment) {
|
|
501
620
|
// Text-only document reference (e.g. terms & conditions, notices)
|
|
@@ -538,6 +657,8 @@ function parseAttachments(root: Element): {
|
|
|
538
657
|
attachments: attachments.length > 0 ? attachments : undefined,
|
|
539
658
|
documentReferences:
|
|
540
659
|
documentReferences.length > 0 ? documentReferences : undefined,
|
|
660
|
+
invoicedObjectId,
|
|
661
|
+
typeCode50Reference,
|
|
541
662
|
};
|
|
542
663
|
}
|
|
543
664
|
|
|
@@ -606,9 +727,17 @@ export function parseUblInvoice(xml: string): UblInvoice | null {
|
|
|
606
727
|
const currency = requiredCbcText(root, "DocumentCurrencyCode", "currency code");
|
|
607
728
|
const paymentMeansList = parsePaymentMeansList(root);
|
|
608
729
|
const orderReference = cacElement(root, "OrderReference");
|
|
609
|
-
const contractReference =
|
|
610
|
-
const projectReference =
|
|
611
|
-
const
|
|
730
|
+
const contractReference = cacDirectElement(root, "ContractDocumentReference");
|
|
731
|
+
const projectReference = cacDirectElement(root, "ProjectReference");
|
|
732
|
+
const despatchReference = cacDirectElement(root, "DespatchDocumentReference");
|
|
733
|
+
const receiptReference = cacDirectElement(root, "ReceiptDocumentReference");
|
|
734
|
+
const { attachments, documentReferences, invoicedObjectId, typeCode50Reference } =
|
|
735
|
+
parseAttachments(root);
|
|
736
|
+
// A credit note has no cbc:DueDate; BT-9 travels in the first PaymentMeans.
|
|
737
|
+
const paymentDueDate = (() => {
|
|
738
|
+
const first = cacDirectElements(root, "PaymentMeans")[0];
|
|
739
|
+
return first ? cbcDirectText(first, "PaymentDueDate") : undefined;
|
|
740
|
+
})();
|
|
612
741
|
|
|
613
742
|
return omitUndefined<UblInvoice>({
|
|
614
743
|
documentType,
|
|
@@ -618,9 +747,11 @@ export function parseUblInvoice(xml: string): UblInvoice | null {
|
|
|
618
747
|
invoiceTypeCode:
|
|
619
748
|
cbcText(root, "InvoiceTypeCode") ?? cbcText(root, "CreditNoteTypeCode"),
|
|
620
749
|
issueDate,
|
|
621
|
-
dueDate:
|
|
622
|
-
taxPointDate:
|
|
750
|
+
dueDate: cbcDirectText(root, "DueDate") ?? paymentDueDate,
|
|
751
|
+
taxPointDate: cbcDirectText(root, "TaxPointDate"),
|
|
623
752
|
currency,
|
|
753
|
+
taxCurrency: cbcDirectText(root, "TaxCurrencyCode"),
|
|
754
|
+
accountingCost: cbcDirectText(root, "AccountingCost"),
|
|
624
755
|
buyerReference: cbcText(root, "BuyerReference"),
|
|
625
756
|
orderReference: orderReference ? cbcText(orderReference, "ID") : undefined,
|
|
626
757
|
salesOrderId: orderReference
|
|
@@ -631,10 +762,22 @@ export function parseUblInvoice(xml: string): UblInvoice | null {
|
|
|
631
762
|
: undefined,
|
|
632
763
|
projectReference: projectReference
|
|
633
764
|
? cbcText(projectReference, "ID")
|
|
765
|
+
: isCreditNote
|
|
766
|
+
? typeCode50Reference
|
|
767
|
+
: undefined,
|
|
768
|
+
receivingAdviceReference: receiptReference
|
|
769
|
+
? cbcDirectText(receiptReference, "ID")
|
|
770
|
+
: undefined,
|
|
771
|
+
despatchReference: despatchReference
|
|
772
|
+
? cbcDirectText(despatchReference, "ID")
|
|
634
773
|
: undefined,
|
|
774
|
+
tenderReference: isCreditNote ? undefined : typeCode50Reference,
|
|
775
|
+
invoicedObjectId,
|
|
635
776
|
billingReference: parseBillingReference(root),
|
|
636
777
|
seller: parseParty(root, "AccountingSupplierParty"),
|
|
637
778
|
buyer: parseParty(root, "AccountingCustomerParty"),
|
|
779
|
+
payee: parseUnwrappedParty(root, "PayeeParty"),
|
|
780
|
+
taxRepresentative: parseUnwrappedParty(root, "TaxRepresentativeParty"),
|
|
638
781
|
delivery: parseDelivery(root),
|
|
639
782
|
lines: parseLines(root, isCreditNote),
|
|
640
783
|
taxTotal: parseTaxTotal(root),
|
package/src/types.ts
CHANGED
|
@@ -60,6 +60,12 @@ export interface UblCompanyId {
|
|
|
60
60
|
scheme?: string | undefined;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** An identifier with an optional `@schemeID`: BT-18, BT-71, BT-128, BT-157. */
|
|
64
|
+
export interface UblSchemedId {
|
|
65
|
+
value: string;
|
|
66
|
+
scheme?: string | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
/** `cac:PartyIdentification/cbc:ID` (BT-29/BT-46) with its `@schemeID`. */
|
|
64
70
|
export interface UblPartyIdentification {
|
|
65
71
|
id: string;
|
|
@@ -120,6 +126,14 @@ export interface UblItemProperty {
|
|
|
120
126
|
export interface UblLine {
|
|
121
127
|
/** `cbc:ID` (BT-126) — line identifier. */
|
|
122
128
|
id: string;
|
|
129
|
+
/** `cbc:Note` (BT-127). */
|
|
130
|
+
note?: string | undefined;
|
|
131
|
+
/** `cac:DocumentReference/cbc:ID` with `cbc:DocumentTypeCode` 130 (BT-128). */
|
|
132
|
+
objectIdentifier?: UblSchemedId | undefined;
|
|
133
|
+
/** `cac:OrderLineReference/cbc:LineID` (BT-132). */
|
|
134
|
+
orderLineReference?: string | undefined;
|
|
135
|
+
/** `cbc:AccountingCost` (BT-133). */
|
|
136
|
+
accountingCost?: string | undefined;
|
|
123
137
|
/** `cac:Item/cbc:Description` (BT-154). */
|
|
124
138
|
description?: string | undefined;
|
|
125
139
|
/** `cbc:InvoicedQuantity` / `cbc:CreditedQuantity` (BT-129). */
|
|
@@ -147,8 +161,14 @@ export interface UblLine {
|
|
|
147
161
|
taxAmount?: number | undefined;
|
|
148
162
|
/** Line-level `cac:TaxTotal/cac:TaxSubtotal` (not used by BIS Billing, seen in the wild). */
|
|
149
163
|
taxSubtotals?: UblTaxSubtotal[] | undefined;
|
|
164
|
+
/** Line-level allowances and charges (BG-27/BG-28); the price discount is `priceAllowance`. */
|
|
150
165
|
allowanceCharges?: UblAllowanceCharge[] | undefined;
|
|
151
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* `cac:Price/cac:AllowanceCharge` (BT-147/BT-148): the discount between
|
|
168
|
+
* the gross unit price (`baseAmount`) and the net one (BT-146).
|
|
169
|
+
*/
|
|
170
|
+
priceAllowance?: UblPriceAllowance | undefined;
|
|
171
|
+
/** Sum of line-level allowances plus the price allowance (absolute). */
|
|
152
172
|
discountAmount?: number | undefined;
|
|
153
173
|
/** Sum of line-level charges (absolute). */
|
|
154
174
|
chargeAmount?: number | undefined;
|
|
@@ -158,11 +178,35 @@ export interface UblLine {
|
|
|
158
178
|
sellersItemId?: string | undefined;
|
|
159
179
|
/** `cac:Item/cac:BuyersItemIdentification/cbc:ID` (BT-156). */
|
|
160
180
|
buyersItemId?: string | undefined;
|
|
181
|
+
/** `cac:Item/cac:StandardItemIdentification/cbc:ID` (BT-157), `@schemeID` an ICD. */
|
|
182
|
+
standardItemId?: UblSchemedId | undefined;
|
|
183
|
+
/** `cac:Item/cac:CommodityClassification` (BT-158). */
|
|
184
|
+
commodityClassifications?: UblCommodityClassification[] | undefined;
|
|
185
|
+
/** `cac:Item/cac:OriginCountry/cbc:IdentificationCode` (BT-159). */
|
|
186
|
+
originCountryCode?: string | undefined;
|
|
161
187
|
additionalItemProperties?: UblItemProperty[] | undefined;
|
|
162
188
|
/** `cac:InvoicePeriod` (BT-134/BT-135) — the line's own service period. */
|
|
163
189
|
invoicePeriod?: UblInvoicePeriod | undefined;
|
|
164
190
|
}
|
|
165
191
|
|
|
192
|
+
export interface UblPriceAllowance {
|
|
193
|
+
/** `cbc:Amount` (BT-147) — the discount per BT-149 units. */
|
|
194
|
+
amount?: number | undefined;
|
|
195
|
+
/** `cbc:BaseAmount` (BT-148) — the gross price per BT-149 units. */
|
|
196
|
+
baseAmount?: number | undefined;
|
|
197
|
+
/** `cbc:AllowanceChargeReason`, read when a document states one; not part of BIS and not written. */
|
|
198
|
+
reason?: string | undefined;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** `cac:CommodityClassification/cbc:ItemClassificationCode` (BT-158) and its list. */
|
|
202
|
+
export interface UblCommodityClassification {
|
|
203
|
+
value: string;
|
|
204
|
+
/** `@listID` (BT-158-1), a UNTDID 7143 code. */
|
|
205
|
+
listId?: string | undefined;
|
|
206
|
+
/** `@listVersionID` (BT-158-2). */
|
|
207
|
+
listVersionId?: string | undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
166
210
|
export interface UblAllowanceCharge {
|
|
167
211
|
/** `cbc:ChargeIndicator` — `true` for a charge, `false` for an allowance. */
|
|
168
212
|
chargeIndicator: boolean;
|
|
@@ -194,6 +238,8 @@ export interface UblTaxTotal {
|
|
|
194
238
|
taxAmount?: number | undefined;
|
|
195
239
|
/** `cac:TaxSubtotal` (BG-23) — the VAT breakdown. */
|
|
196
240
|
subtotals: UblTaxSubtotal[];
|
|
241
|
+
/** BT-111 — the VAT total in the VAT accounting currency (`UblInvoice.taxCurrency`). */
|
|
242
|
+
taxAmountInTaxCurrency?: number | undefined;
|
|
197
243
|
}
|
|
198
244
|
|
|
199
245
|
export interface UblMonetaryTotal {
|
|
@@ -236,6 +282,12 @@ export interface UblPaymentMeans {
|
|
|
236
282
|
accountName?: string | undefined;
|
|
237
283
|
/** `cac:PaymentMandate/cbc:ID` (BT-89). */
|
|
238
284
|
mandateId?: string | undefined;
|
|
285
|
+
/** `cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID` (BT-91). */
|
|
286
|
+
debitedAccount?: string | undefined;
|
|
287
|
+
/** `cac:CardAccount/cbc:PrimaryAccountNumberID` (BT-87). */
|
|
288
|
+
cardNumber?: string | undefined;
|
|
289
|
+
/** `cac:CardAccount/cbc:HolderName` (BT-88). */
|
|
290
|
+
cardHolder?: string | undefined;
|
|
239
291
|
}
|
|
240
292
|
|
|
241
293
|
/**
|
|
@@ -277,8 +329,12 @@ export interface UblDocumentReference {
|
|
|
277
329
|
export interface UblDelivery {
|
|
278
330
|
/** `cbc:ActualDeliveryDate` (BT-72). */
|
|
279
331
|
actualDeliveryDate?: string | undefined;
|
|
332
|
+
/** `cac:DeliveryLocation/cbc:ID` (BT-71). */
|
|
333
|
+
locationId?: UblSchemedId | undefined;
|
|
280
334
|
/** `cac:DeliveryLocation/cac:Address` (BG-15). */
|
|
281
335
|
address?: UblAddress | undefined;
|
|
336
|
+
/** `cac:DeliveryParty/cac:PartyName/cbc:Name` (BT-70). */
|
|
337
|
+
partyName?: string | undefined;
|
|
282
338
|
}
|
|
283
339
|
|
|
284
340
|
/** `cac:BillingReference/cac:InvoiceDocumentReference` (BT-25/BT-26). */
|
|
@@ -305,6 +361,10 @@ export interface UblInvoice {
|
|
|
305
361
|
taxPointDate?: string | undefined;
|
|
306
362
|
/** Document currency (BT-5). */
|
|
307
363
|
currency: string;
|
|
364
|
+
/** `cbc:TaxCurrencyCode` (BT-6); requires `taxTotal.taxAmountInTaxCurrency` (BR-53). */
|
|
365
|
+
taxCurrency?: string | undefined;
|
|
366
|
+
/** `cbc:AccountingCost` (BT-19). */
|
|
367
|
+
accountingCost?: string | undefined;
|
|
308
368
|
/** Buyer reference (BT-10). */
|
|
309
369
|
buyerReference?: string | undefined;
|
|
310
370
|
/** `cac:OrderReference/cbc:ID` (BT-13). */
|
|
@@ -313,12 +373,28 @@ export interface UblInvoice {
|
|
|
313
373
|
salesOrderId?: string | undefined;
|
|
314
374
|
/** `cac:ContractDocumentReference/cbc:ID` (BT-12). */
|
|
315
375
|
contractReference?: string | undefined;
|
|
316
|
-
/**
|
|
376
|
+
/**
|
|
377
|
+
* BT-11. `cac:ProjectReference/cbc:ID` on an invoice; a credit note has no
|
|
378
|
+
* such element, so there it is an additional document reference with
|
|
379
|
+
* `cbc:DocumentTypeCode` 50.
|
|
380
|
+
*/
|
|
317
381
|
projectReference?: string | undefined;
|
|
382
|
+
/** `cac:ReceiptDocumentReference/cbc:ID` (BT-15). */
|
|
383
|
+
receivingAdviceReference?: string | undefined;
|
|
384
|
+
/** `cac:DespatchDocumentReference/cbc:ID` (BT-16). */
|
|
385
|
+
despatchReference?: string | undefined;
|
|
386
|
+
/** BT-17, an additional document reference with `cbc:DocumentTypeCode` 50. Invoices only. */
|
|
387
|
+
tenderReference?: string | undefined;
|
|
388
|
+
/** BT-18, an additional document reference with `cbc:DocumentTypeCode` 130. */
|
|
389
|
+
invoicedObjectId?: UblSchemedId | undefined;
|
|
318
390
|
/** For credit notes: the referenced original invoice (BT-25). */
|
|
319
391
|
billingReference?: UblBillingReference | undefined;
|
|
320
392
|
seller: UblParty;
|
|
321
393
|
buyer: UblParty;
|
|
394
|
+
/** `cac:PayeeParty` (BG-10): name, identification and legal entity id only. */
|
|
395
|
+
payee?: UblParty | undefined;
|
|
396
|
+
/** `cac:TaxRepresentativeParty` (BG-11): name, VAT id and address only. */
|
|
397
|
+
taxRepresentative?: UblParty | undefined;
|
|
322
398
|
delivery?: UblDelivery | undefined;
|
|
323
399
|
lines: UblLine[];
|
|
324
400
|
taxTotal: UblTaxTotal;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-DossV2at.d.ts","names":[],"sources":["../src/errors.ts","../src/types.ts"],"mappings":";;;;;;;cAMa,sBAAsB;WAChB;EAElB,YAAY,iBAAiB;IAAY;;;;;;;;;cAa7B,sBAAsB;WAChB;EAElB,YAAY,iBAAiB;IAAY;;;;;UCRzB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;UAGgB;;EAEhB;;EAEA;;EAEA;;;;;;;UAQgB;EAChB;;EAEA;;;;;;UAOgB;EAChB;;EAEA;;;UAIgB;EAChB;EACA;;UAGgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,YAAY;;EAEZ,WAAW;EACX,uBAAuB;EACvB,UAAU;EACV,UAAU;;;;;;;;;;;;;UAcM;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;UAGgB;;EAEhB;;EAEA;;UAGgB;;EAEhB;;EAEA;;EAEA;;EAEA;;;;;EAKA;;EAEA;;;;;;;;EAQA;;EAEA,cAAc;;EAEd;;EAEA,eAAe;EACf,mBAAmB;;EAEnB;;EAEA;;EAEA;;EAEA;;EAEA;EACA,2BAA2B;;EAE3B,gBAAgB;;UAGA;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,cAAc;;UAGE;;EAEhB;;EAEA;;EAEA,WAAW;;UAGK;;EAEhB;;EAEA,WAAW;;UAGK;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;EAEA;;;;;EAKA;;UAGgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;UAQgB;;EAEhB;;EAEA;;EAEA;;;UAIgB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIgB;EAChB;EACA;;UAGgB;;EAEhB;;EAEA,UAAU;;;UAIM;EAChB;EACA;;UAGgB;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,mBAAmB;EACnB,QAAQ;EACR,OAAO;EACP,WAAW;EACX,OAAO;EACP,UAAU;EACV,eAAe;;EAEf,eAAe;EACf,mBAAmB;;EAEnB,gBAAgB;;EAEhB;;EAEA;EACA,cAAc;EACd,qBAAqB;;EAErB,mBAAmB;;UAKH;EAChB;EACA;EACA;IACC;IACA;IACA;;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;IAEA;IACA;IACA;IACA;MACC;MACA;MACA;MACA;MACA;;IAED;MACC;MACA;MACA;;IAED,OAAO;;EAER,YAAY;IACX;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;IAEA;IACA;IACA,OAAO;;EAER;IACC;IACA,QAAQ"}
|