@fin.cx/einvoice 5.0.2
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_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/classes.decoder.d.ts +40 -0
- package/dist_ts/classes.decoder.js +320 -0
- package/dist_ts/classes.encoder.d.ts +51 -0
- package/dist_ts/classes.encoder.js +293 -0
- package/dist_ts/classes.xinvoice.d.ts +136 -0
- package/dist_ts/classes.xinvoice.js +352 -0
- package/dist_ts/einvoice.d.ts +217 -0
- package/dist_ts/einvoice.js +505 -0
- package/dist_ts/errors.d.ts +121 -0
- package/dist_ts/errors.js +241 -0
- package/dist_ts/formats/base/base.decoder.d.ts +32 -0
- package/dist_ts/formats/base/base.decoder.js +52 -0
- package/dist_ts/formats/base/base.encoder.d.ts +13 -0
- package/dist_ts/formats/base/base.encoder.js +7 -0
- package/dist_ts/formats/base/base.validator.d.ts +44 -0
- package/dist_ts/formats/base/base.validator.js +39 -0
- package/dist_ts/formats/base.decoder.d.ts +19 -0
- package/dist_ts/formats/base.decoder.js +130 -0
- package/dist_ts/formats/base.validator.d.ts +44 -0
- package/dist_ts/formats/base.validator.js +39 -0
- package/dist_ts/formats/cii/cii.decoder.d.ts +61 -0
- package/dist_ts/formats/cii/cii.decoder.js +111 -0
- package/dist_ts/formats/cii/cii.encoder.d.ts +43 -0
- package/dist_ts/formats/cii/cii.encoder.js +48 -0
- package/dist_ts/formats/cii/cii.types.d.ts +31 -0
- package/dist_ts/formats/cii/cii.types.js +40 -0
- package/dist_ts/formats/cii/cii.validator.d.ts +56 -0
- package/dist_ts/formats/cii/cii.validator.js +146 -0
- package/dist_ts/formats/cii/facturx/facturx.decoder.d.ts +43 -0
- package/dist_ts/formats/cii/facturx/facturx.decoder.js +207 -0
- package/dist_ts/formats/cii/facturx/facturx.encoder.d.ts +82 -0
- package/dist_ts/formats/cii/facturx/facturx.encoder.js +400 -0
- package/dist_ts/formats/cii/facturx/facturx.types.d.ts +10 -0
- package/dist_ts/formats/cii/facturx/facturx.types.js +15 -0
- package/dist_ts/formats/cii/facturx/facturx.validator.d.ts +32 -0
- package/dist_ts/formats/cii/facturx/facturx.validator.js +138 -0
- package/dist_ts/formats/cii/zugferd/zugferd.decoder.d.ts +43 -0
- package/dist_ts/formats/cii/zugferd/zugferd.decoder.js +218 -0
- package/dist_ts/formats/cii/zugferd/zugferd.encoder.d.ts +97 -0
- package/dist_ts/formats/cii/zugferd/zugferd.encoder.js +550 -0
- package/dist_ts/formats/cii/zugferd/zugferd.types.d.ts +10 -0
- package/dist_ts/formats/cii/zugferd/zugferd.types.js +15 -0
- package/dist_ts/formats/cii/zugferd/zugferd.v1.decoder.d.ts +49 -0
- package/dist_ts/formats/cii/zugferd/zugferd.v1.decoder.js +229 -0
- package/dist_ts/formats/cii/zugferd/zugferd.validator.d.ts +16 -0
- package/dist_ts/formats/cii/zugferd/zugferd.validator.js +29 -0
- package/dist_ts/formats/decoder.factory.d.ts +15 -0
- package/dist_ts/formats/decoder.factory.js +46 -0
- package/dist_ts/formats/factories/decoder.factory.d.ts +13 -0
- package/dist_ts/formats/factories/decoder.factory.js +56 -0
- package/dist_ts/formats/factories/encoder.factory.d.ts +14 -0
- package/dist_ts/formats/factories/encoder.factory.js +40 -0
- package/dist_ts/formats/factories/validator.factory.d.ts +12 -0
- package/dist_ts/formats/factories/validator.factory.js +110 -0
- package/dist_ts/formats/factorx.decoder.d.ts +18 -0
- package/dist_ts/formats/factorx.decoder.js +178 -0
- package/dist_ts/formats/factorx.encoder.d.ts +51 -0
- package/dist_ts/formats/factorx.encoder.js +293 -0
- package/dist_ts/formats/facturx.decoder.d.ts +18 -0
- package/dist_ts/formats/facturx.decoder.js +210 -0
- package/dist_ts/formats/facturx.encoder.d.ts +51 -0
- package/dist_ts/formats/facturx.encoder.js +293 -0
- package/dist_ts/formats/facturx.validator.d.ts +67 -0
- package/dist_ts/formats/facturx.validator.js +266 -0
- package/dist_ts/formats/pdf/extractors/associated.extractor.d.ts +14 -0
- package/dist_ts/formats/pdf/extractors/associated.extractor.js +68 -0
- package/dist_ts/formats/pdf/extractors/base.extractor.d.ts +92 -0
- package/dist_ts/formats/pdf/extractors/base.extractor.js +319 -0
- package/dist_ts/formats/pdf/extractors/index.d.ts +4 -0
- package/dist_ts/formats/pdf/extractors/index.js +5 -0
- package/dist_ts/formats/pdf/extractors/standard.extractor.d.ts +13 -0
- package/dist_ts/formats/pdf/extractors/standard.extractor.js +74 -0
- package/dist_ts/formats/pdf/extractors/text.extractor.d.ts +45 -0
- package/dist_ts/formats/pdf/extractors/text.extractor.js +151 -0
- package/dist_ts/formats/pdf/pdf.embedder.d.ts +69 -0
- package/dist_ts/formats/pdf/pdf.embedder.js +183 -0
- package/dist_ts/formats/pdf/pdf.extractor.d.ts +49 -0
- package/dist_ts/formats/pdf/pdf.extractor.js +98 -0
- package/dist_ts/formats/pdf/robust-pdf.extractor.d.ts +40 -0
- package/dist_ts/formats/pdf/robust-pdf.extractor.js +324 -0
- package/dist_ts/formats/ubl/en16931.ubl.validator.d.ts +18 -0
- package/dist_ts/formats/ubl/en16931.ubl.validator.js +169 -0
- package/dist_ts/formats/ubl/generic/ubl.encoder.d.ts +151 -0
- package/dist_ts/formats/ubl/generic/ubl.encoder.js +892 -0
- package/dist_ts/formats/ubl/ubl.decoder.d.ts +61 -0
- package/dist_ts/formats/ubl/ubl.decoder.js +95 -0
- package/dist_ts/formats/ubl/ubl.encoder.d.ts +38 -0
- package/dist_ts/formats/ubl/ubl.encoder.js +46 -0
- package/dist_ts/formats/ubl/ubl.types.d.ts +16 -0
- package/dist_ts/formats/ubl/ubl.types.js +21 -0
- package/dist_ts/formats/ubl/ubl.validator.d.ts +50 -0
- package/dist_ts/formats/ubl/ubl.validator.js +112 -0
- package/dist_ts/formats/ubl/xrechnung/xrechnung.decoder.d.ts +34 -0
- package/dist_ts/formats/ubl/xrechnung/xrechnung.decoder.js +424 -0
- package/dist_ts/formats/ubl/xrechnung/xrechnung.encoder.d.ts +75 -0
- package/dist_ts/formats/ubl/xrechnung/xrechnung.encoder.js +555 -0
- package/dist_ts/formats/ubl/xrechnung.validator.d.ts +15 -0
- package/dist_ts/formats/ubl/xrechnung.validator.js +107 -0
- package/dist_ts/formats/ubl.validator.d.ts +82 -0
- package/dist_ts/formats/ubl.validator.js +306 -0
- package/dist_ts/formats/utils/format.detector.d.ts +62 -0
- package/dist_ts/formats/utils/format.detector.js +249 -0
- package/dist_ts/formats/validation/en16931.validator.d.ts +23 -0
- package/dist_ts/formats/validation/en16931.validator.js +119 -0
- package/dist_ts/formats/validator.factory.d.ts +18 -0
- package/dist_ts/formats/validator.factory.js +78 -0
- package/dist_ts/formats/xinvoice.decoder.d.ts +28 -0
- package/dist_ts/formats/xinvoice.decoder.js +332 -0
- package/dist_ts/formats/xinvoice.encoder.d.ts +19 -0
- package/dist_ts/formats/xinvoice.encoder.js +282 -0
- package/dist_ts/index.d.ts +51 -0
- package/dist_ts/index.js +90 -0
- package/dist_ts/interfaces/common.d.ts +79 -0
- package/dist_ts/interfaces/common.js +24 -0
- package/dist_ts/interfaces.d.ts +87 -0
- package/dist_ts/interfaces.js +23 -0
- package/dist_ts/plugins.d.ts +14 -0
- package/dist_ts/plugins.js +31 -0
- package/npmextra.json +35 -0
- package/package.json +71 -0
- package/readme.hints.md +1107 -0
- package/readme.howtofixtests.md +38 -0
- package/readme.literature.md +1 -0
- package/readme.md +998 -0
- package/readme.plan.md +481 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/einvoice.ts +603 -0
- package/ts/errors.ts +341 -0
- package/ts/formats/base/base.decoder.ts +68 -0
- package/ts/formats/base/base.encoder.ts +14 -0
- package/ts/formats/base/base.validator.ts +64 -0
- package/ts/formats/cii/cii.decoder.ts +139 -0
- package/ts/formats/cii/cii.encoder.ts +64 -0
- package/ts/formats/cii/cii.types.ts +44 -0
- package/ts/formats/cii/cii.validator.ts +171 -0
- package/ts/formats/cii/facturx/facturx.decoder.ts +243 -0
- package/ts/formats/cii/facturx/facturx.encoder.ts +483 -0
- package/ts/formats/cii/facturx/facturx.types.ts +18 -0
- package/ts/formats/cii/facturx/facturx.validator.ts +180 -0
- package/ts/formats/cii/zugferd/zugferd.decoder.ts +256 -0
- package/ts/formats/cii/zugferd/zugferd.encoder.ts +661 -0
- package/ts/formats/cii/zugferd/zugferd.types.ts +18 -0
- package/ts/formats/cii/zugferd/zugferd.v1.decoder.ts +267 -0
- package/ts/formats/cii/zugferd/zugferd.validator.ts +31 -0
- package/ts/formats/factories/decoder.factory.ts +62 -0
- package/ts/formats/factories/encoder.factory.ts +47 -0
- package/ts/formats/factories/validator.factory.ts +134 -0
- package/ts/formats/pdf/extractors/associated.extractor.ts +78 -0
- package/ts/formats/pdf/extractors/base.extractor.ts +355 -0
- package/ts/formats/pdf/extractors/index.ts +4 -0
- package/ts/formats/pdf/extractors/standard.extractor.ts +86 -0
- package/ts/formats/pdf/extractors/text.extractor.ts +162 -0
- package/ts/formats/pdf/pdf.embedder.ts +242 -0
- package/ts/formats/pdf/pdf.extractor.ts +141 -0
- package/ts/formats/ubl/en16931.ubl.validator.ts +216 -0
- package/ts/formats/ubl/generic/ubl.encoder.ts +1041 -0
- package/ts/formats/ubl/ubl.decoder.ts +121 -0
- package/ts/formats/ubl/ubl.encoder.ts +63 -0
- package/ts/formats/ubl/ubl.types.ts +22 -0
- package/ts/formats/ubl/ubl.validator.ts +133 -0
- package/ts/formats/ubl/xrechnung/xrechnung.decoder.ts +471 -0
- package/ts/formats/ubl/xrechnung/xrechnung.encoder.ts +619 -0
- package/ts/formats/ubl/xrechnung.validator.ts +185 -0
- package/ts/formats/utils/format.detector.ts +306 -0
- package/ts/formats/validation/en16931.validator.ts +135 -0
- package/ts/index.ts +164 -0
- package/ts/interfaces/common.ts +90 -0
- package/ts/interfaces.ts +98 -0
- package/ts/plugins.ts +61 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseDecoder } from '../base/base.decoder.js';
|
|
2
|
+
import type { TInvoice, TCreditNote, TDebitNote } from '../../interfaces/common.js';
|
|
3
|
+
import { UBLDocumentType } from './ubl.types.js';
|
|
4
|
+
import { xpath } from '../../plugins.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base decoder for UBL-based invoice formats
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class UBLBaseDecoder extends BaseDecoder {
|
|
9
|
+
protected doc: Document;
|
|
10
|
+
protected namespaces: Record<string, string>;
|
|
11
|
+
protected select: xpath.XPathSelect;
|
|
12
|
+
constructor(xml: string, skipValidation?: boolean);
|
|
13
|
+
/**
|
|
14
|
+
* Decodes UBL XML into a TInvoice object
|
|
15
|
+
* @returns Promise resolving to a TInvoice object
|
|
16
|
+
*/
|
|
17
|
+
decode(): Promise<TInvoice>;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the UBL document type
|
|
20
|
+
* @returns UBL document type
|
|
21
|
+
*/
|
|
22
|
+
protected getDocumentType(): UBLDocumentType;
|
|
23
|
+
/**
|
|
24
|
+
* Decodes a UBL credit note
|
|
25
|
+
* @returns Promise resolving to a TCreditNote object
|
|
26
|
+
*/
|
|
27
|
+
protected abstract decodeCreditNote(): Promise<TCreditNote>;
|
|
28
|
+
/**
|
|
29
|
+
* Decodes a UBL debit note (invoice)
|
|
30
|
+
* @returns Promise resolving to a TDebitNote object
|
|
31
|
+
*/
|
|
32
|
+
protected abstract decodeDebitNote(): Promise<TDebitNote>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets a text value from an XPath expression
|
|
35
|
+
* @param xpath XPath expression
|
|
36
|
+
* @param context Optional context node
|
|
37
|
+
* @returns Text value or empty string if not found
|
|
38
|
+
*/
|
|
39
|
+
protected getText(xpathExpr: string, context?: Node): string;
|
|
40
|
+
/**
|
|
41
|
+
* Gets a number value from an XPath expression
|
|
42
|
+
* @param xpath XPath expression
|
|
43
|
+
* @param context Optional context node
|
|
44
|
+
* @returns Number value or 0 if not found or not a number
|
|
45
|
+
*/
|
|
46
|
+
protected getNumber(xpathExpr: string, context?: Node): number;
|
|
47
|
+
/**
|
|
48
|
+
* Gets a date value from an XPath expression
|
|
49
|
+
* @param xpath XPath expression
|
|
50
|
+
* @param context Optional context node
|
|
51
|
+
* @returns Date timestamp or current time if not found or invalid
|
|
52
|
+
*/
|
|
53
|
+
protected getDate(xpathExpr: string, context?: Node): number;
|
|
54
|
+
/**
|
|
55
|
+
* Checks if a node exists
|
|
56
|
+
* @param xpath XPath expression
|
|
57
|
+
* @param context Optional context node
|
|
58
|
+
* @returns True if node exists
|
|
59
|
+
*/
|
|
60
|
+
protected exists(xpathExpr: string, context?: Node): boolean;
|
|
61
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseDecoder } from '../base/base.decoder.js';
|
|
2
|
+
import { UBLDocumentType, UBL_NAMESPACES } from './ubl.types.js';
|
|
3
|
+
import { DOMParser, xpath } from '../../plugins.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base decoder for UBL-based invoice formats
|
|
6
|
+
*/
|
|
7
|
+
export class UBLBaseDecoder extends BaseDecoder {
|
|
8
|
+
constructor(xml, skipValidation = false) {
|
|
9
|
+
super(xml, skipValidation);
|
|
10
|
+
// Parse XML document
|
|
11
|
+
this.doc = new DOMParser().parseFromString(xml, 'application/xml');
|
|
12
|
+
// Set up namespaces for XPath queries
|
|
13
|
+
this.namespaces = {
|
|
14
|
+
cbc: UBL_NAMESPACES.CBC,
|
|
15
|
+
cac: UBL_NAMESPACES.CAC
|
|
16
|
+
};
|
|
17
|
+
// Create XPath selector with namespaces
|
|
18
|
+
this.select = xpath.useNamespaces(this.namespaces);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Decodes UBL XML into a TInvoice object
|
|
22
|
+
* @returns Promise resolving to a TInvoice object
|
|
23
|
+
*/
|
|
24
|
+
async decode() {
|
|
25
|
+
// Determine document type
|
|
26
|
+
const documentType = this.getDocumentType();
|
|
27
|
+
if (documentType === UBLDocumentType.CREDIT_NOTE) {
|
|
28
|
+
return this.decodeCreditNote();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return this.decodeDebitNote();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets the UBL document type
|
|
36
|
+
* @returns UBL document type
|
|
37
|
+
*/
|
|
38
|
+
getDocumentType() {
|
|
39
|
+
const rootName = this.doc.documentElement.nodeName;
|
|
40
|
+
if (rootName === UBLDocumentType.CREDIT_NOTE) {
|
|
41
|
+
return UBLDocumentType.CREDIT_NOTE;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return UBLDocumentType.INVOICE;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Gets a text value from an XPath expression
|
|
49
|
+
* @param xpath XPath expression
|
|
50
|
+
* @param context Optional context node
|
|
51
|
+
* @returns Text value or empty string if not found
|
|
52
|
+
*/
|
|
53
|
+
getText(xpathExpr, context) {
|
|
54
|
+
const node = this.select(xpathExpr, context || this.doc)[0];
|
|
55
|
+
return node ? (node.textContent || '') : '';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets a number value from an XPath expression
|
|
59
|
+
* @param xpath XPath expression
|
|
60
|
+
* @param context Optional context node
|
|
61
|
+
* @returns Number value or 0 if not found or not a number
|
|
62
|
+
*/
|
|
63
|
+
getNumber(xpathExpr, context) {
|
|
64
|
+
const text = this.getText(xpathExpr, context);
|
|
65
|
+
const num = parseFloat(text);
|
|
66
|
+
return isNaN(num) ? 0 : num;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets a date value from an XPath expression
|
|
70
|
+
* @param xpath XPath expression
|
|
71
|
+
* @param context Optional context node
|
|
72
|
+
* @returns Date timestamp or current time if not found or invalid
|
|
73
|
+
*/
|
|
74
|
+
getDate(xpathExpr, context) {
|
|
75
|
+
const text = this.getText(xpathExpr, context);
|
|
76
|
+
if (!text)
|
|
77
|
+
return Date.now();
|
|
78
|
+
const date = new Date(text);
|
|
79
|
+
return isNaN(date.getTime()) ? Date.now() : date.getTime();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Checks if a node exists
|
|
83
|
+
* @param xpath XPath expression
|
|
84
|
+
* @param context Optional context node
|
|
85
|
+
* @returns True if node exists
|
|
86
|
+
*/
|
|
87
|
+
exists(xpathExpr, context) {
|
|
88
|
+
const nodes = this.select(xpathExpr, context || this.doc);
|
|
89
|
+
if (Array.isArray(nodes)) {
|
|
90
|
+
return nodes.length > 0;
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidWJsLmRlY29kZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9mb3JtYXRzL3VibC91YmwuZGVjb2Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFdEQsT0FBTyxFQUFFLGVBQWUsRUFBRSxjQUFjLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUNqRSxPQUFPLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXBEOztHQUVHO0FBQ0gsTUFBTSxPQUFnQixjQUFlLFNBQVEsV0FBVztJQUt0RCxZQUFZLEdBQVcsRUFBRSxpQkFBMEIsS0FBSztRQUN0RCxLQUFLLENBQUMsR0FBRyxFQUFFLGNBQWMsQ0FBQyxDQUFDO1FBRTNCLHFCQUFxQjtRQUNyQixJQUFJLENBQUMsR0FBRyxHQUFHLElBQUksU0FBUyxFQUFFLENBQUMsZUFBZSxDQUFDLEdBQUcsRUFBRSxpQkFBaUIsQ0FBQyx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WlCLEVBQUUsT0FBYztRQUNoRCxNQUFNLEtBQUssR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDLFNBQVMsRUFBRSxPQUFPLElBQUksSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQzFELElBQUksS0FBSyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1lBQ3pCLE9BQU8sS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7UUFDMUIsQ0FBQztRQUNELE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztDQUNGIn0=
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BaseEncoder } from '../base/base.encoder.js';
|
|
2
|
+
import type { TInvoice, TCreditNote, TDebitNote } from '../../interfaces/common.js';
|
|
3
|
+
import { UBLDocumentType } from './ubl.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base encoder for UBL-based invoice formats
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class UBLBaseEncoder extends BaseEncoder {
|
|
8
|
+
/**
|
|
9
|
+
* Encodes a TInvoice object into UBL XML
|
|
10
|
+
* @param invoice TInvoice object to encode
|
|
11
|
+
* @returns UBL XML string
|
|
12
|
+
*/
|
|
13
|
+
encode(invoice: TInvoice): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Encodes a TCreditNote object into UBL XML
|
|
16
|
+
* @param creditNote TCreditNote object to encode
|
|
17
|
+
* @returns UBL XML string
|
|
18
|
+
*/
|
|
19
|
+
protected abstract encodeCreditNote(creditNote: TCreditNote): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Encodes a TDebitNote object into UBL XML
|
|
22
|
+
* @param debitNote TDebitNote object to encode
|
|
23
|
+
* @returns UBL XML string
|
|
24
|
+
*/
|
|
25
|
+
protected abstract encodeDebitNote(debitNote: TDebitNote): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates the XML declaration and root element
|
|
28
|
+
* @param documentType UBL document type
|
|
29
|
+
* @returns XML string with declaration and root element
|
|
30
|
+
*/
|
|
31
|
+
protected createXmlRoot(documentType: UBLDocumentType): string;
|
|
32
|
+
/**
|
|
33
|
+
* Formats a date as an ISO string (YYYY-MM-DD)
|
|
34
|
+
* @param timestamp Timestamp to format
|
|
35
|
+
* @returns Formatted date string
|
|
36
|
+
*/
|
|
37
|
+
protected formatDate(timestamp: number): string;
|
|
38
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BaseEncoder } from '../base/base.encoder.js';
|
|
2
|
+
import { UBLDocumentType, UBL_NAMESPACES } from './ubl.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Base encoder for UBL-based invoice formats
|
|
5
|
+
*/
|
|
6
|
+
export class UBLBaseEncoder extends BaseEncoder {
|
|
7
|
+
/**
|
|
8
|
+
* Encodes a TInvoice object into UBL XML
|
|
9
|
+
* @param invoice TInvoice object to encode
|
|
10
|
+
* @returns UBL XML string
|
|
11
|
+
*/
|
|
12
|
+
async encode(invoice) {
|
|
13
|
+
// TInvoice is always an invoice, treat it as debit note for encoding
|
|
14
|
+
return this.encodeDebitNote(invoice);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates the XML declaration and root element
|
|
18
|
+
* @param documentType UBL document type
|
|
19
|
+
* @returns XML string with declaration and root element
|
|
20
|
+
*/
|
|
21
|
+
createXmlRoot(documentType) {
|
|
22
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
23
|
+
<${documentType} xmlns="urn:oasis:names:specification:ubl:schema:xsd:${documentType}-2"
|
|
24
|
+
xmlns:cac="${UBL_NAMESPACES.CAC}"
|
|
25
|
+
xmlns:cbc="${UBL_NAMESPACES.CBC}">
|
|
26
|
+
</${documentType}>`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Formats a date as an ISO string (YYYY-MM-DD)
|
|
30
|
+
* @param timestamp Timestamp to format
|
|
31
|
+
* @returns Formatted date string
|
|
32
|
+
*/
|
|
33
|
+
formatDate(timestamp) {
|
|
34
|
+
// Ensure timestamp is valid
|
|
35
|
+
if (!timestamp || isNaN(timestamp)) {
|
|
36
|
+
timestamp = Date.now();
|
|
37
|
+
}
|
|
38
|
+
const date = new Date(timestamp);
|
|
39
|
+
// Check if date is valid
|
|
40
|
+
if (isNaN(date.getTime())) {
|
|
41
|
+
return new Date().toISOString().split('T')[0];
|
|
42
|
+
}
|
|
43
|
+
return date.toISOString().split('T')[0];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidWJsLmVuY29kZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9mb3JtYXRzL3VibC91YmwuZW5jb2Rlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFdEQsT0FBTyxFQUFFLGVBQWUsRUFBRSxjQUFjLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUVqRTs7R0FFRztBQUNILE1BQU0sT0FBZ0IsY0FBZSxTQUFRLFdBQVc7SUFDdEQ7Ozs7T0FJRztJQUNJLEtBQUssQ0FBQyxNQUFNLENBQUMsT0FBaUI7UUFDbkMscUVBQXFFO1FBQ3JFLE9BQU8sSUFBSSxDQUFDLGVBQWUsQ0FBQyxPQUFnQyxDQUFDLENBQUM7SUFDaEUsQ0FBQztJQWdCRDs7OztPQUlHO0lBQ08sYUFBYSxDQUFDLFlBQTZCO1FBQ25ELE9BQU87R0FDUixZQUFZLHdEQUF3RCxZQUFZO2VBQ3BFLGNBQWMsQ0FBQyxHQUFHO2VBQ2xCLGNBQWMsQ0FBQyxHQUFHO0lBQzdCLFlBQVksR0FBRyxDQUFDO0lBQ2xCLENBQUM7SUFFRDs7OztPQUlHO0lBQ08sVUFBVSxDQUFDLFNBQWlCO1FBQ3BDLDRCQUE0QjtRQUM1QixJQUFJLENBQUMsU0FBUyxJQUFJLEtBQUssQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDO1lBQ25DLFNBQVMsR0FBRyxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUM7UUFDekIsQ0FBQztRQUNELE1BQU0sSUFBSSxHQUFHLElBQUksSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ2pDLHlCQUF5QjtRQUN6QixJQUFJLEtBQUssQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLENBQUMsRUFBRSxDQUFDO1lBQzFCLE9BQU8sSUFBSSxJQUFJLEVBQUUsQ0FBQyxXQUFXLEVBQUUsQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDaEQsQ0FBQztRQUNELE9BQU8sSUFBSSxDQUFDLFdBQVcsRUFBRSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUMxQyxDQUFDO0NBQ0YifQ==
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UBL-specific types and constants
|
|
3
|
+
*/
|
|
4
|
+
export declare const UBL_NAMESPACES: {
|
|
5
|
+
CBC: string;
|
|
6
|
+
CAC: string;
|
|
7
|
+
UBL: string;
|
|
8
|
+
};
|
|
9
|
+
export declare enum UBLDocumentType {
|
|
10
|
+
INVOICE = "Invoice",
|
|
11
|
+
CREDIT_NOTE = "CreditNote"
|
|
12
|
+
}
|
|
13
|
+
export declare const UBL_CUSTOMIZATION_IDS: {
|
|
14
|
+
XRECHNUNG: string;
|
|
15
|
+
PEPPOL_BIS: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UBL-specific types and constants
|
|
3
|
+
*/
|
|
4
|
+
// UBL namespaces
|
|
5
|
+
export const UBL_NAMESPACES = {
|
|
6
|
+
CBC: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
|
|
7
|
+
CAC: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
|
|
8
|
+
UBL: 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
|
|
9
|
+
};
|
|
10
|
+
// UBL document types
|
|
11
|
+
export var UBLDocumentType;
|
|
12
|
+
(function (UBLDocumentType) {
|
|
13
|
+
UBLDocumentType["INVOICE"] = "Invoice";
|
|
14
|
+
UBLDocumentType["CREDIT_NOTE"] = "CreditNote";
|
|
15
|
+
})(UBLDocumentType || (UBLDocumentType = {}));
|
|
16
|
+
// UBL customization IDs for different formats
|
|
17
|
+
export const UBL_CUSTOMIZATION_IDS = {
|
|
18
|
+
XRECHNUNG: 'urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0',
|
|
19
|
+
PEPPOL_BIS: 'urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0'
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidWJsLnR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vdHMvZm9ybWF0cy91YmwvdWJsLnR5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsaUJBQWlCO0FBQ2pCLE1BQU0sQ0FBQyxNQUFNLGNBQWMsR0FBRztJQUM1QixHQUFHLEVBQUUsc0VBQXNFO0lBQzNFLEdBQUcsRUFBRSwwRUFBMEU7SUFDL0UsR0FBRyxFQUFFLHdEQUF3RDtDQUM5RCxDQUFDO0FBRUYscUJBQXFCO0FBQ3JCLE1BQU0sQ0FBTixJQUFZLGVBR1g7QUFIRCxXQUFZLGVBQWU7SUFDekIsc0NBQW1CLENBQUE7SUFDbkIsNkNBQTBCLENBQUE7QUFDNUIsQ0FBQyxFQUhXLGVBQWUsS0FBZixlQUFlLFFBRzFCO0FBRUQsOENBQThDO0FBQzlDLE1BQU0sQ0FBQyxNQUFNLHFCQUFxQixHQUFHO0lBQ25DLFNBQVMsRUFBRSw0RUFBNEU7SUFDdkYsVUFBVSxFQUFFLDRFQUE0RTtDQUN6RixDQUFDIn0=
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BaseValidator } from '../base/base.validator.js';
|
|
2
|
+
import { ValidationLevel } from '../../interfaces/common.js';
|
|
3
|
+
import type { ValidationResult } from '../../interfaces/common.js';
|
|
4
|
+
import { xpath } from '../../plugins.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base validator for UBL-based invoice formats
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class UBLBaseValidator extends BaseValidator {
|
|
9
|
+
protected doc: Document;
|
|
10
|
+
protected namespaces: Record<string, string>;
|
|
11
|
+
protected select: xpath.XPathSelect;
|
|
12
|
+
constructor(xml: string);
|
|
13
|
+
/**
|
|
14
|
+
* Validates UBL XML against the specified level of validation
|
|
15
|
+
* @param level Validation level
|
|
16
|
+
* @returns Result of validation
|
|
17
|
+
*/
|
|
18
|
+
validate(level?: ValidationLevel): ValidationResult;
|
|
19
|
+
/**
|
|
20
|
+
* Validates UBL XML against schema
|
|
21
|
+
* @returns True if schema validation passed
|
|
22
|
+
*/
|
|
23
|
+
protected validateSchema(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Validates structure of the UBL XML document
|
|
26
|
+
* @returns True if structure validation passed
|
|
27
|
+
*/
|
|
28
|
+
protected abstract validateStructure(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Gets a text value from an XPath expression
|
|
31
|
+
* @param xpath XPath expression
|
|
32
|
+
* @param context Optional context node
|
|
33
|
+
* @returns Text value or empty string if not found
|
|
34
|
+
*/
|
|
35
|
+
protected getText(xpathExpr: string, context?: Node): string;
|
|
36
|
+
/**
|
|
37
|
+
* Gets a number value from an XPath expression
|
|
38
|
+
* @param xpath XPath expression
|
|
39
|
+
* @param context Optional context node
|
|
40
|
+
* @returns Number value or 0 if not found or not a number
|
|
41
|
+
*/
|
|
42
|
+
protected getNumber(xpathExpr: string, context?: Node): number;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a node exists
|
|
45
|
+
* @param xpath XPath expression
|
|
46
|
+
* @param context Optional context node
|
|
47
|
+
* @returns True if node exists
|
|
48
|
+
*/
|
|
49
|
+
protected exists(xpathExpr: string, context?: Node): boolean;
|
|
50
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BaseValidator } from '../base/base.validator.js';
|
|
2
|
+
import { ValidationLevel } from '../../interfaces/common.js';
|
|
3
|
+
import { UBLDocumentType } from './ubl.types.js';
|
|
4
|
+
import { DOMParser, xpath } from '../../plugins.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base validator for UBL-based invoice formats
|
|
7
|
+
*/
|
|
8
|
+
export class UBLBaseValidator extends BaseValidator {
|
|
9
|
+
constructor(xml) {
|
|
10
|
+
super(xml);
|
|
11
|
+
try {
|
|
12
|
+
// Parse XML document
|
|
13
|
+
this.doc = new DOMParser().parseFromString(xml, 'application/xml');
|
|
14
|
+
// Set up namespaces for XPath queries
|
|
15
|
+
this.namespaces = {
|
|
16
|
+
cbc: 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
|
|
17
|
+
cac: 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'
|
|
18
|
+
};
|
|
19
|
+
// Create XPath selector with namespaces
|
|
20
|
+
this.select = xpath.useNamespaces(this.namespaces);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
this.addError('UBL-PARSE', `Failed to parse XML: ${error}`, '/');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates UBL XML against the specified level of validation
|
|
28
|
+
* @param level Validation level
|
|
29
|
+
* @returns Result of validation
|
|
30
|
+
*/
|
|
31
|
+
validate(level = ValidationLevel.SYNTAX) {
|
|
32
|
+
// Reset errors
|
|
33
|
+
this.errors = [];
|
|
34
|
+
// Check if document was parsed successfully
|
|
35
|
+
if (!this.doc) {
|
|
36
|
+
return {
|
|
37
|
+
valid: false,
|
|
38
|
+
errors: this.errors,
|
|
39
|
+
level: level
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Perform validation based on level
|
|
43
|
+
let valid = true;
|
|
44
|
+
if (level === ValidationLevel.SYNTAX) {
|
|
45
|
+
valid = this.validateSchema();
|
|
46
|
+
}
|
|
47
|
+
else if (level === ValidationLevel.SEMANTIC) {
|
|
48
|
+
valid = this.validateSchema() && this.validateStructure();
|
|
49
|
+
}
|
|
50
|
+
else if (level === ValidationLevel.BUSINESS) {
|
|
51
|
+
valid = this.validateSchema() &&
|
|
52
|
+
this.validateStructure() &&
|
|
53
|
+
this.validateBusinessRules();
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
valid,
|
|
57
|
+
errors: this.errors,
|
|
58
|
+
level
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validates UBL XML against schema
|
|
63
|
+
* @returns True if schema validation passed
|
|
64
|
+
*/
|
|
65
|
+
validateSchema() {
|
|
66
|
+
// Basic schema validation (simplified for now)
|
|
67
|
+
if (!this.doc)
|
|
68
|
+
return false;
|
|
69
|
+
// Check for root element
|
|
70
|
+
const root = this.doc.documentElement;
|
|
71
|
+
if (!root || (root.nodeName !== UBLDocumentType.INVOICE && root.nodeName !== UBLDocumentType.CREDIT_NOTE)) {
|
|
72
|
+
this.addError('UBL-SCHEMA-1', `Root element must be ${UBLDocumentType.INVOICE} or ${UBLDocumentType.CREDIT_NOTE}`, '/');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets a text value from an XPath expression
|
|
79
|
+
* @param xpath XPath expression
|
|
80
|
+
* @param context Optional context node
|
|
81
|
+
* @returns Text value or empty string if not found
|
|
82
|
+
*/
|
|
83
|
+
getText(xpathExpr, context) {
|
|
84
|
+
const node = this.select(xpathExpr, context || this.doc)[0];
|
|
85
|
+
return node ? (node.textContent || '') : '';
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets a number value from an XPath expression
|
|
89
|
+
* @param xpath XPath expression
|
|
90
|
+
* @param context Optional context node
|
|
91
|
+
* @returns Number value or 0 if not found or not a number
|
|
92
|
+
*/
|
|
93
|
+
getNumber(xpathExpr, context) {
|
|
94
|
+
const text = this.getText(xpathExpr, context);
|
|
95
|
+
const num = parseFloat(text);
|
|
96
|
+
return isNaN(num) ? 0 : num;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Checks if a node exists
|
|
100
|
+
* @param xpath XPath expression
|
|
101
|
+
* @param context Optional context node
|
|
102
|
+
* @returns True if node exists
|
|
103
|
+
*/
|
|
104
|
+
exists(xpathExpr, context) {
|
|
105
|
+
const nodes = this.select(xpathExpr, context || this.doc);
|
|
106
|
+
if (Array.isArray(nodes)) {
|
|
107
|
+
return nodes.length > 0;
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidWJsLnZhbGlkYXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL2Zvcm1hdHMvdWJsL3VibC52YWxpZGF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBQzFELE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUU3RCxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sZ0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UFBRSxPQUFPLElBQUksSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQzFELElBQUksS0FBSyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1lBQ3pCLE9BQU8sS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7UUFDMUIsQ0FBQztRQUNELE9BQU8sS0FBSyxDQUFDO0lBQ2YsQ0FBQztDQUNGIn0=
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { UBLBaseDecoder } from '../ubl.decoder.js';
|
|
2
|
+
import type { TCreditNote, TDebitNote } from '../../../interfaces/common.js';
|
|
3
|
+
/**
|
|
4
|
+
* Decoder for XRechnung (UBL) format
|
|
5
|
+
* Implements decoding of XRechnung invoices to TInvoice
|
|
6
|
+
*/
|
|
7
|
+
export declare class XRechnungDecoder extends UBLBaseDecoder {
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a UBL credit note
|
|
10
|
+
* @returns Promise resolving to a TCreditNote object
|
|
11
|
+
*/
|
|
12
|
+
protected decodeCreditNote(): Promise<TCreditNote>;
|
|
13
|
+
/**
|
|
14
|
+
* Decodes a UBL debit note (invoice)
|
|
15
|
+
* @returns Promise resolving to a TDebitNote object
|
|
16
|
+
*/
|
|
17
|
+
protected decodeDebitNote(): Promise<TDebitNote>;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts common invoice data from XRechnung XML
|
|
20
|
+
* @returns Common invoice data
|
|
21
|
+
*/
|
|
22
|
+
private extractCommonData;
|
|
23
|
+
/**
|
|
24
|
+
* Extracts party information from XML
|
|
25
|
+
* @param partyPath XPath to the party element
|
|
26
|
+
* @returns TContact object
|
|
27
|
+
*/
|
|
28
|
+
private extractParty;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an empty TContact object
|
|
31
|
+
* @returns Empty TContact object
|
|
32
|
+
*/
|
|
33
|
+
private createEmptyContact;
|
|
34
|
+
}
|