@financica/ubl 0.16.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 +20 -0
- package/README.md +67 -26
- package/dist/build/index.d.ts +79 -193
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +525 -136
- 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 +192 -73
- package/dist/index.js.map +1 -1
- package/dist/types-DpwX8-Ix.d.ts +462 -0
- package/dist/types-DpwX8-Ix.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 +30 -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 +129 -22
- package/src/build/ubl/serialize.ts +894 -134
- package/src/build/utils.ts +12 -4
- package/src/errors.ts +16 -0
- package/src/index.ts +5 -1
- package/src/normalize.ts +24 -18
- package/src/parser.ts +246 -48
- package/src/types.ts +263 -23
- package/src/build/ubl/types.ts +0 -179
package/dist/index.d.ts
CHANGED
|
@@ -1,212 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface UblAddress {
|
|
3
|
-
street?: string | undefined;
|
|
4
|
-
additionalStreet?: string | undefined;
|
|
5
|
-
city?: string | undefined;
|
|
6
|
-
postalZone?: string | undefined;
|
|
7
|
-
countrySubentity?: string | undefined;
|
|
8
|
-
countryCode?: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
interface UblContact {
|
|
11
|
-
name?: string | undefined;
|
|
12
|
-
phone?: string | undefined;
|
|
13
|
-
email?: string | undefined;
|
|
14
|
-
}
|
|
15
|
-
interface UblPartyIdentification {
|
|
16
|
-
id: string;
|
|
17
|
-
schemeId?: string | undefined;
|
|
18
|
-
}
|
|
19
|
-
interface UblParty {
|
|
20
|
-
name?: string | undefined;
|
|
21
|
-
registrationName?: string | undefined;
|
|
22
|
-
companyLegalForm?: string | undefined;
|
|
23
|
-
vatId?: string | undefined;
|
|
24
|
-
taxSchemeId?: string | undefined;
|
|
25
|
-
companyId?: string | undefined;
|
|
26
|
-
companyIdSchemeId?: string | undefined;
|
|
27
|
-
endpointId?: string | undefined;
|
|
28
|
-
endpointSchemeId?: string | undefined;
|
|
29
|
-
partyIdentifications?: UblPartyIdentification[] | undefined;
|
|
30
|
-
address?: UblAddress | undefined;
|
|
31
|
-
contact?: UblContact | undefined;
|
|
32
|
-
}
|
|
33
|
-
interface UblItemProperty {
|
|
34
|
-
name: string;
|
|
35
|
-
value?: string | undefined;
|
|
36
|
-
}
|
|
37
|
-
interface UblLine {
|
|
38
|
-
id: string;
|
|
39
|
-
description?: string | undefined;
|
|
40
|
-
quantity?: number | undefined;
|
|
41
|
-
unitCode?: string | undefined;
|
|
42
|
-
unitPrice?: number | undefined;
|
|
43
|
-
lineExtensionAmount?: number | undefined;
|
|
44
|
-
taxPercent?: number | undefined;
|
|
45
|
-
taxAmount?: number | undefined;
|
|
46
|
-
taxCategoryId?: string | undefined;
|
|
47
|
-
taxSchemeId?: string | undefined;
|
|
48
|
-
taxSubtotals?: UblTaxSubtotal[] | undefined;
|
|
49
|
-
allowanceCharges?: UblAllowanceCharge[] | undefined;
|
|
50
|
-
discountAmount?: number | undefined;
|
|
51
|
-
chargeAmount?: number | undefined;
|
|
52
|
-
itemName?: string | undefined;
|
|
53
|
-
sellersItemId?: string | undefined;
|
|
54
|
-
buyersItemId?: string | undefined;
|
|
55
|
-
additionalItemProperties?: UblItemProperty[] | undefined;
|
|
56
|
-
/** EN 16931 BT-134/BT-135: the line's own service period. */
|
|
57
|
-
invoicePeriod?: UblInvoicePeriod | undefined;
|
|
58
|
-
}
|
|
59
|
-
interface UblAllowanceCharge {
|
|
60
|
-
chargeIndicator: boolean;
|
|
61
|
-
amount?: number | undefined;
|
|
62
|
-
baseAmount?: number | undefined;
|
|
63
|
-
multiplierFactorNumeric?: number | undefined;
|
|
64
|
-
reason?: string | undefined;
|
|
65
|
-
reasonCode?: string | undefined;
|
|
66
|
-
taxPercent?: number | undefined;
|
|
67
|
-
taxCategoryId?: string | undefined;
|
|
68
|
-
taxSchemeId?: string | undefined;
|
|
69
|
-
}
|
|
70
|
-
interface UblTaxSubtotal {
|
|
71
|
-
taxableAmount?: number | undefined;
|
|
72
|
-
taxAmount?: number | undefined;
|
|
73
|
-
taxPercent?: number | undefined;
|
|
74
|
-
taxCategoryId?: string | undefined;
|
|
75
|
-
taxSchemeId?: string | undefined;
|
|
76
|
-
taxExemptionReason?: string | undefined;
|
|
77
|
-
}
|
|
78
|
-
interface UblMonetaryTotal {
|
|
79
|
-
lineExtensionAmount?: number | undefined;
|
|
80
|
-
taxExclusiveAmount?: number | undefined;
|
|
81
|
-
taxInclusiveAmount?: number | undefined;
|
|
82
|
-
allowanceTotalAmount?: number | undefined;
|
|
83
|
-
chargeTotalAmount?: number | undefined;
|
|
84
|
-
prepaidAmount?: number | undefined;
|
|
85
|
-
payableRoundingAmount?: number | undefined;
|
|
86
|
-
payableAmount?: number | undefined;
|
|
87
|
-
}
|
|
88
|
-
interface UblPaymentMeans {
|
|
89
|
-
code?: string | undefined;
|
|
90
|
-
codeName?: string | undefined;
|
|
91
|
-
paymentId?: string | undefined;
|
|
92
|
-
iban?: string | undefined;
|
|
93
|
-
bic?: string | undefined;
|
|
94
|
-
accountName?: string | undefined;
|
|
95
|
-
mandateId?: string | undefined;
|
|
96
|
-
}
|
|
97
|
-
interface UblInvoicePeriod {
|
|
98
|
-
startDate?: string | undefined;
|
|
99
|
-
endDate?: string | undefined;
|
|
100
|
-
descriptionCode?: string | undefined;
|
|
101
|
-
}
|
|
102
|
-
interface UblAttachment {
|
|
103
|
-
id?: string | undefined;
|
|
104
|
-
filename?: string | undefined;
|
|
105
|
-
mimeCode?: string | undefined;
|
|
106
|
-
description?: string | undefined;
|
|
107
|
-
base64Content?: string | undefined;
|
|
108
|
-
externalUri?: string | undefined;
|
|
109
|
-
}
|
|
110
|
-
interface UblDocumentReference {
|
|
111
|
-
id?: string | undefined;
|
|
112
|
-
description?: string | undefined;
|
|
113
|
-
}
|
|
114
|
-
interface UblDelivery {
|
|
115
|
-
actualDeliveryDate?: string | undefined;
|
|
116
|
-
address?: UblAddress | undefined;
|
|
117
|
-
}
|
|
118
|
-
interface UblBillingReference {
|
|
119
|
-
invoiceId?: string | undefined;
|
|
120
|
-
invoiceIssueDate?: string | undefined;
|
|
121
|
-
}
|
|
122
|
-
interface UblInvoice {
|
|
123
|
-
documentType: "Invoice" | "CreditNote";
|
|
124
|
-
customizationId?: string | undefined;
|
|
125
|
-
profileId?: string | undefined;
|
|
126
|
-
id: string;
|
|
127
|
-
invoiceTypeCode?: string | undefined;
|
|
128
|
-
issueDate: string;
|
|
129
|
-
dueDate?: string | undefined;
|
|
130
|
-
taxPointDate?: string | undefined;
|
|
131
|
-
currency: string;
|
|
132
|
-
buyerReference?: string | undefined;
|
|
133
|
-
orderReference?: string | undefined;
|
|
134
|
-
salesOrderId?: string | undefined;
|
|
135
|
-
contractReference?: string | undefined;
|
|
136
|
-
projectReference?: string | undefined;
|
|
137
|
-
billingReference?: UblBillingReference | undefined;
|
|
138
|
-
seller: UblParty;
|
|
139
|
-
buyer: UblParty;
|
|
140
|
-
delivery?: UblDelivery | undefined;
|
|
141
|
-
lines: UblLine[];
|
|
142
|
-
taxSubtotals: UblTaxSubtotal[];
|
|
143
|
-
monetaryTotal: UblMonetaryTotal;
|
|
144
|
-
paymentMeans?: UblPaymentMeans | undefined;
|
|
145
|
-
paymentMeansList?: UblPaymentMeans[] | undefined;
|
|
146
|
-
invoicePeriod?: UblInvoicePeriod | undefined;
|
|
147
|
-
note?: string | undefined;
|
|
148
|
-
paymentTermsNote?: string | undefined;
|
|
149
|
-
attachments?: UblAttachment[] | undefined;
|
|
150
|
-
documentReferences?: UblDocumentReference[] | undefined;
|
|
151
|
-
allowanceCharges?: UblAllowanceCharge[] | undefined;
|
|
152
|
-
}
|
|
153
|
-
interface InvoiceExtractionDTO {
|
|
154
|
-
provider: string;
|
|
155
|
-
document_id: string;
|
|
156
|
-
invoice: {
|
|
157
|
-
invoice_number: string | null;
|
|
158
|
-
invoice_date: string | null;
|
|
159
|
-
due_date: string | null;
|
|
160
|
-
/** EN 16931 BT-73/BT-74: the period the document bills for. */
|
|
161
|
-
period_start: string | null;
|
|
162
|
-
period_end: string | null;
|
|
163
|
-
currency: string | null;
|
|
164
|
-
subtotal: number | null;
|
|
165
|
-
tax_total: number | null;
|
|
166
|
-
total: number | null;
|
|
167
|
-
amount_due: number | null;
|
|
168
|
-
amount_paid: number | null;
|
|
169
|
-
discount_total: number | null;
|
|
170
|
-
shipping_total: number | null;
|
|
171
|
-
/** EN 16931 BT-114, signed. Outside the VAT breakdown (BR-CO-16). */
|
|
172
|
-
rounding_total: number | null;
|
|
173
|
-
payment_terms: string | null;
|
|
174
|
-
po_number: string | null;
|
|
175
|
-
supplier: {
|
|
176
|
-
name: string | null;
|
|
177
|
-
address: string | null;
|
|
178
|
-
tax_id: string | null;
|
|
179
|
-
iban: string | null;
|
|
180
|
-
bic: string | null;
|
|
181
|
-
};
|
|
182
|
-
receiver: {
|
|
183
|
-
name: string | null;
|
|
184
|
-
address: string | null;
|
|
185
|
-
tax_id: string | null;
|
|
186
|
-
};
|
|
187
|
-
extra: Record<string, unknown>;
|
|
188
|
-
};
|
|
189
|
-
line_items: Array<{
|
|
190
|
-
description: string;
|
|
191
|
-
quantity: number | null;
|
|
192
|
-
unit: string | null;
|
|
193
|
-
unit_price: number | null;
|
|
194
|
-
amount: number | null;
|
|
195
|
-
tax_amount: number | null;
|
|
196
|
-
tax_rate: number | null;
|
|
197
|
-
product_code: string | null;
|
|
198
|
-
discount_amount: number | null;
|
|
199
|
-
/** EN 16931 BT-134/BT-135: the line's own service period. */
|
|
200
|
-
period_start: string | null;
|
|
201
|
-
period_end: string | null;
|
|
202
|
-
extra: Record<string, unknown>;
|
|
203
|
-
}>;
|
|
204
|
-
confidence: {
|
|
205
|
-
overall: number | null;
|
|
206
|
-
fields: Record<string, number>;
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
//#endregion
|
|
1
|
+
import { C as UblTaxSubtotal, E as UblParseError, S as UblTaxCategory, T as UblBuildError, _ as UblParty, a as UblBillingReference, c as UblContact, d as UblEndpoint, f as UblInvoice, g as UblMonetaryTotal, h as UblLine, i as UblAttachment, l as UblDelivery, m as UblItemProperty, n as UblAddress, p as UblInvoicePeriod, r as UblAllowanceCharge, s as UblCompanyId, t as InvoiceExtractionDTO, u as UblDocumentReference, v as UblPartyIdentification, w as UblTaxTotal, y as UblPaymentMeans } from "./types-DpwX8-Ix.js";
|
|
210
2
|
//#region src/attachments.d.ts
|
|
211
3
|
/**
|
|
212
4
|
* An embedded attachment extracted from a UBL document's
|
|
@@ -237,20 +29,6 @@ declare const extractUblEmbeddedAttachments: (xml: string) => UblEmbeddedAttachm
|
|
|
237
29
|
*/
|
|
238
30
|
declare const isPdfLikeAttachment: (attachment: Pick<UblAttachment, "filename" | "mimeCode">) => boolean;
|
|
239
31
|
//#endregion
|
|
240
|
-
//#region src/errors.d.ts
|
|
241
|
-
/**
|
|
242
|
-
* Thrown by the parse side of this package when input is broken: malformed
|
|
243
|
-
* XML, or a UBL document missing an element EN 16931 makes mandatory. A parser
|
|
244
|
-
* returns `null` instead when the input is well-formed but not the document
|
|
245
|
-
* type it parses.
|
|
246
|
-
*/
|
|
247
|
-
declare class UblParseError extends Error {
|
|
248
|
-
readonly cause?: unknown;
|
|
249
|
-
constructor(message: string, options?: {
|
|
250
|
-
cause?: unknown;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
//#endregion
|
|
254
32
|
//#region src/parser.d.ts
|
|
255
33
|
/**
|
|
256
34
|
* Parse a UBL 2.1 Invoice or CreditNote.
|
|
@@ -339,5 +117,5 @@ declare const parseUblInvoiceDocument: (params: {
|
|
|
339
117
|
providerJobId: string | null;
|
|
340
118
|
};
|
|
341
119
|
//#endregion
|
|
342
|
-
export { type InvoiceExtractionDTO, PEPPOL_MLR_DOCUMENT_TYPE_VALUE, PEPPOL_MLR_PROCESS_VALUE, type PeppolMessageLevelResponse, type UblAddress, type UblAllowanceCharge, type UblAttachment, type UblBillingReference, type UblContact, type UblDelivery, type UblDocumentReference, type UblEmbeddedAttachment, type UblInvoice, type UblInvoicePeriod, type UblItemProperty, type UblLine, type UblMonetaryTotal, UblParseError, type UblParty, type UblPartyIdentification, type UblPaymentMeans, type UblTaxSubtotal, decodeXmlBytes, extractUblEmbeddedAttachments, isPdfLikeAttachment, isPeppolMessageLevelResponse, normalizeCurrency, normalizeUblResponse, parseDate, parsePeppolMessageLevelResponse, parseUblInvoice, parseUblInvoiceDocument };
|
|
120
|
+
export { type InvoiceExtractionDTO, PEPPOL_MLR_DOCUMENT_TYPE_VALUE, PEPPOL_MLR_PROCESS_VALUE, type PeppolMessageLevelResponse, type UblAddress, type UblAllowanceCharge, type UblAttachment, type UblBillingReference, UblBuildError, type UblCompanyId, type UblContact, type UblDelivery, type UblDocumentReference, type UblEmbeddedAttachment, type UblEndpoint, type UblInvoice, type UblInvoicePeriod, type UblItemProperty, type UblLine, type UblMonetaryTotal, UblParseError, type UblParty, type UblPartyIdentification, type UblPaymentMeans, type UblTaxCategory, type UblTaxSubtotal, type UblTaxTotal, decodeXmlBytes, extractUblEmbeddedAttachments, isPdfLikeAttachment, isPeppolMessageLevelResponse, normalizeCurrency, normalizeUblResponse, parseDate, parsePeppolMessageLevelResponse, parseUblInvoice, parseUblInvoiceDocument };
|
|
343
121
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/attachments.ts","../src/parser.ts","../src/mlr.ts","../src/normalize.ts"],"mappings":";;;;;;;UASiB;EAChB;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;;;cAmBY,gCAA6B,gBAAkB;;;;;cAyB/C,sBAAmB,YACnB,KAAK;;;;;;;;;;;iBCqoBF,gBAAgB,cAAc;;;;;;;cC1rBjC;;cAIA;;;;;;UAOI;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;;;;;;cAuEY,+BAA4B;EACxC;EACA;EACA;;;;;;;cAsBY,kCAA+B,gBAEzC;;;cCpGU,oBAAiB;cAOjB,YAAS;;;;cAuHT,iBAAc,OAAW;;;;;;;;cAYzB,uBAAoB,aACrB;EAGX,WAAW;EACX,YAAY;;;;;cAiOA,0BAAuB;EACnC,OAAO;EACP;EACA;;;;;aAFO;EAYiB"}
|