@financica/ubl 0.16.0 → 0.17.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 +7 -0
- package/README.md +20 -25
- package/dist/build/index.d.ts +58 -193
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +229 -130
- package/dist/build/index.js.map +1 -1
- package/dist/errors-C9YYJ1xR.js +33 -0
- package/dist/errors-C9YYJ1xR.js.map +1 -0
- package/dist/index.d.ts +2 -224
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -55
- package/dist/index.js.map +1 -1
- package/dist/types-DossV2at.d.ts +389 -0
- package/dist/types-DossV2at.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/build/address.ts +9 -10
- package/src/build/attachment.ts +13 -9
- package/src/build/identifiers.ts +28 -28
- package/src/build/index.ts +19 -9
- package/src/build/numeric.ts +17 -11
- package/src/build/party.ts +16 -14
- package/src/build/tax-category.ts +5 -4
- package/src/build/tax-totals.ts +31 -20
- package/src/build/ubl/serialize.ts +281 -102
- package/src/build/utils.ts +12 -4
- package/src/errors.ts +16 -0
- package/src/index.ts +5 -1
- package/src/normalize.ts +18 -17
- package/src/parser.ts +85 -30
- package/src/types.ts +187 -23
- package/src/build/ubl/types.ts +0 -179
package/src/build/ubl/types.ts
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A vendor-neutral model of a Peppol BIS Billing 3.0 document.
|
|
3
|
-
*
|
|
4
|
-
* This is the intermediate representation the builders in `../` (and, for
|
|
5
|
-
* Stripe data, `stripe-ubl`) produce; `./serialize.ts` turns it into UBL XML.
|
|
6
|
-
* It is deliberately a thin, construction-oriented mirror of the UBL fields we
|
|
7
|
-
* populate — not a full UBL object graph.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export interface UblAddress {
|
|
11
|
-
/** `cbc:StreetName` (BT-35). */
|
|
12
|
-
street: string | null;
|
|
13
|
-
/** `cbc:AdditionalStreetName` (BT-36). */
|
|
14
|
-
additionalStreet: string | null;
|
|
15
|
-
/** `cbc:CityName` (BT-37). */
|
|
16
|
-
city: string | null;
|
|
17
|
-
/** `cbc:PostalZone` (BT-38). */
|
|
18
|
-
postalZone: string | null;
|
|
19
|
-
/** `cbc:CountrySubentity` (BT-39). */
|
|
20
|
-
countrySubentity: string | null;
|
|
21
|
-
/** `cac:Country/cbc:IdentificationCode` (BT-40) — ISO 3166-1 alpha-2. */
|
|
22
|
-
countryCode: string | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Peppol participant identifier, e.g. scheme `0208`, value `0800279001`. */
|
|
26
|
-
export interface UblEndpoint {
|
|
27
|
-
scheme: string;
|
|
28
|
-
value: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Legal registration identifier, e.g. a Belgian enterprise number. */
|
|
32
|
-
export interface UblCompanyId {
|
|
33
|
-
value: string;
|
|
34
|
-
/** ICD scheme (e.g. `0208` for the Belgian CBE), when known. */
|
|
35
|
-
scheme?: string | null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface UblParty {
|
|
39
|
-
/** `cbc:EndpointID` (BT-49/BT-34) — the Peppol routing identifier. */
|
|
40
|
-
endpoint: UblEndpoint | null;
|
|
41
|
-
/** `cac:PartyName/cbc:Name` (BT-27/BT-44). */
|
|
42
|
-
name: string;
|
|
43
|
-
address: UblAddress;
|
|
44
|
-
/** `cac:PartyTaxScheme/cbc:CompanyID` with `VAT` scheme (BT-31/BT-48). */
|
|
45
|
-
vatNumber: string | null;
|
|
46
|
-
/** `cac:PartyLegalEntity/cbc:RegistrationName` (BT-27/BT-44). Defaults to `name`. */
|
|
47
|
-
legalName: string | null;
|
|
48
|
-
/** `cac:PartyLegalEntity/cbc:CompanyID` (BT-30/BT-47). */
|
|
49
|
-
companyId: UblCompanyId | null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* VAT breakdown category. `id` is a UNCL5305 code:
|
|
54
|
-
* - `S` Standard rate
|
|
55
|
-
* - `Z` Zero-rated goods
|
|
56
|
-
* - `E` Exempt from VAT
|
|
57
|
-
* - `AE` VAT reverse charge
|
|
58
|
-
* - `O` Services outside scope of tax
|
|
59
|
-
* - `K` Intra-community supply
|
|
60
|
-
* - `G` Export outside the EU
|
|
61
|
-
*/
|
|
62
|
-
export interface UblTaxCategory {
|
|
63
|
-
id: string;
|
|
64
|
-
percent: number;
|
|
65
|
-
/** Required by EN 16931 (BR-E-10/BR-AE-10/…) for non-`S`/`Z` categories. */
|
|
66
|
-
exemptionReason?: string | null | undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface UblLine {
|
|
70
|
-
/** `cbc:ID` (BT-126) — line identifier. */
|
|
71
|
-
id: string;
|
|
72
|
-
/** `cac:Item/cbc:Name` (BT-153). */
|
|
73
|
-
name: string;
|
|
74
|
-
/** `cbc:InvoicedQuantity` / `cbc:CreditedQuantity` (BT-129). */
|
|
75
|
-
quantity: number;
|
|
76
|
-
/** UN/ECE Rec 20 unit code (BT-130). */
|
|
77
|
-
unitCode: string;
|
|
78
|
-
/** `cbc:LineExtensionAmount` (BT-131) — net of VAT, after line discounts. */
|
|
79
|
-
lineExtensionAmount: number;
|
|
80
|
-
/** `cac:Price/cbc:PriceAmount` (BT-146) — net unit price. */
|
|
81
|
-
priceAmount: number;
|
|
82
|
-
/**
|
|
83
|
-
* `cac:Price/cbc:BaseQuantity` (BT-149) — the number of units `priceAmount`
|
|
84
|
-
* covers. Omitted means 1. Set it when the net doesn't divide evenly into
|
|
85
|
-
* cents, so `quantity × (priceAmount ÷ baseQuantity)` reproduces the line
|
|
86
|
-
* net exactly (PEPPOL-EN16931-R120); see `deriveUnitPrice`.
|
|
87
|
-
*/
|
|
88
|
-
baseQuantity?: number | undefined;
|
|
89
|
-
/** `cac:InvoicePeriod` (BT-134/BT-135) — the line's own service period. */
|
|
90
|
-
invoicePeriod?: UblPeriod | null;
|
|
91
|
-
taxCategory: UblTaxCategory;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface UblTaxSubtotal {
|
|
95
|
-
/** `cbc:TaxableAmount` (BT-116). */
|
|
96
|
-
taxableAmount: number;
|
|
97
|
-
/** `cbc:TaxAmount` (BT-117). */
|
|
98
|
-
taxAmount: number;
|
|
99
|
-
category: UblTaxCategory;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface UblTaxTotal {
|
|
103
|
-
/** `cbc:TaxAmount` (BT-110) — sum of subtotal tax amounts. */
|
|
104
|
-
taxAmount: number;
|
|
105
|
-
subtotals: UblTaxSubtotal[];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface UblMonetaryTotal {
|
|
109
|
-
/** BT-106 — sum of line net amounts. */
|
|
110
|
-
lineExtensionAmount: number;
|
|
111
|
-
/** BT-109 — total without VAT. */
|
|
112
|
-
taxExclusiveAmount: number;
|
|
113
|
-
/** BT-112 — total with VAT. */
|
|
114
|
-
taxInclusiveAmount: number;
|
|
115
|
-
/**
|
|
116
|
-
* BT-113 — sum of amounts paid in advance. **Gross (VAT-inclusive)**, since
|
|
117
|
-
* BR-CO-16 subtracts it directly from BT-112. Omitted when absent or zero.
|
|
118
|
-
*/
|
|
119
|
-
prepaidAmount?: number;
|
|
120
|
-
/** BT-114 — rounding applied to the payable amount. Omitted when absent or zero. */
|
|
121
|
-
payableRoundingAmount?: number;
|
|
122
|
-
/**
|
|
123
|
-
* BT-115 — amount due for payment, i.e. the *outstanding* amount.
|
|
124
|
-
* BR-CO-16: `BT-115 = BT-112 − BT-113 + BT-114`.
|
|
125
|
-
*/
|
|
126
|
-
payableAmount: number;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** An embedded supporting document (BG-24), e.g. the rendered PDF. */
|
|
130
|
-
export interface UblAttachment {
|
|
131
|
-
/** `cac:AdditionalDocumentReference/cbc:ID` (BT-122). */
|
|
132
|
-
id: string;
|
|
133
|
-
/** `cbc:EmbeddedDocumentBinaryObject/@filename`. */
|
|
134
|
-
filename: string;
|
|
135
|
-
/** MIME type, e.g. `application/pdf`. */
|
|
136
|
-
mimeCode: string;
|
|
137
|
-
/** Base64-encoded document bytes. */
|
|
138
|
-
base64: string;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* A service period: BT-73/BT-74 on the document, BT-134/BT-135 on a line.
|
|
143
|
-
* Either bound may stand alone — UBL allows a half-open period — but a period
|
|
144
|
-
* with neither is omitted entirely.
|
|
145
|
-
*/
|
|
146
|
-
export interface UblPeriod {
|
|
147
|
-
/** `YYYY-MM-DD`. */
|
|
148
|
-
startDate: string | null;
|
|
149
|
-
/** `YYYY-MM-DD`, inclusive. */
|
|
150
|
-
endDate: string | null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export interface UblDocument {
|
|
154
|
-
documentType: "invoice" | "creditNote";
|
|
155
|
-
/** Invoice / credit note number (BT-1). */
|
|
156
|
-
id: string;
|
|
157
|
-
/** Issue date (BT-2), `YYYY-MM-DD`. */
|
|
158
|
-
issueDate: string;
|
|
159
|
-
/** Payment due date (BT-9). Invoices only. */
|
|
160
|
-
dueDate: string | null;
|
|
161
|
-
/** Free-text note (BT-22). */
|
|
162
|
-
note: string | null;
|
|
163
|
-
/** Payment terms note (BT-20, `cac:PaymentTerms/cbc:Note`). */
|
|
164
|
-
paymentTermsNote?: string | null;
|
|
165
|
-
/** Document currency (BT-5). */
|
|
166
|
-
currency: string;
|
|
167
|
-
/** Buyer reference (BT-10). */
|
|
168
|
-
buyerReference: string | null;
|
|
169
|
-
/** Invoicing period (BT-73/BT-74). */
|
|
170
|
-
invoicePeriod?: UblPeriod | null;
|
|
171
|
-
/** For credit notes: the referenced original invoice number (BT-25). */
|
|
172
|
-
precedingInvoiceId: string | null;
|
|
173
|
-
supplier: UblParty;
|
|
174
|
-
customer: UblParty;
|
|
175
|
-
lines: UblLine[];
|
|
176
|
-
taxTotal: UblTaxTotal;
|
|
177
|
-
monetaryTotal: UblMonetaryTotal;
|
|
178
|
-
attachments: UblAttachment[];
|
|
179
|
-
}
|