@fin.cx/einvoice 5.1.3 → 5.2.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/{npmextra.json → .smartconfig.json} +12 -6
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/einvoice.d.ts +14 -5
- package/dist_ts/einvoice.js +165 -60
- package/dist_ts/errors.js +14 -4
- package/dist_ts/formats/base/base.decoder.d.ts +4 -0
- package/dist_ts/formats/base/base.decoder.js +9 -1
- package/dist_ts/formats/base/base.validator.js +3 -2
- package/dist_ts/formats/cii/cii.decoder.d.ts +1 -0
- package/dist_ts/formats/cii/cii.decoder.js +20 -10
- package/dist_ts/formats/cii/cii.encoder.js +2 -5
- package/dist_ts/formats/cii/cii.validator.d.ts +1 -1
- package/dist_ts/formats/cii/cii.validator.js +19 -12
- package/dist_ts/formats/converters/xml-to-einvoice.converter.js +3 -3
- package/dist_ts/formats/factories/decoder.factory.d.ts +3 -1
- package/dist_ts/formats/factories/decoder.factory.js +4 -3
- package/dist_ts/formats/factories/validator.factory.d.ts +4 -1
- package/dist_ts/formats/factories/validator.factory.js +11 -8
- package/dist_ts/formats/pdf/extractors/base.extractor.js +49 -51
- package/dist_ts/formats/pdf/extractors/text.extractor.js +19 -22
- package/dist_ts/formats/pdf/pdf.extractor.js +2 -2
- package/dist_ts/formats/semantic/semantic.adapter.js +42 -12
- package/dist_ts/formats/semantic/semantic.validator.js +3 -1
- package/dist_ts/formats/ubl/en16931.ubl.validator.js +5 -3
- package/dist_ts/formats/ubl/generic/ubl.encoder.js +11 -7
- package/dist_ts/formats/ubl/ubl.decoder.d.ts +1 -0
- package/dist_ts/formats/ubl/ubl.decoder.js +18 -8
- package/dist_ts/formats/ubl/ubl.validator.d.ts +1 -1
- package/dist_ts/formats/ubl/ubl.validator.js +17 -10
- package/dist_ts/formats/ubl/xrechnung/xrechnung.decoder.js +37 -29
- package/dist_ts/formats/utils/currency.calculator.decimal.js +4 -1
- package/dist_ts/formats/utils/currency.utils.js +4 -1
- package/dist_ts/formats/utils/decimal.js +9 -2
- package/dist_ts/formats/utils/format.detector.js +47 -17
- package/dist_ts/formats/validation/codelist.validator.js +2 -4
- package/dist_ts/formats/validation/conformance.harness.js +13 -6
- package/dist_ts/formats/validation/en16931.business-rules.validator.js +4 -4
- package/dist_ts/formats/validation/en16931.validator.d.ts +6 -0
- package/dist_ts/formats/validation/en16931.validator.js +18 -12
- package/dist_ts/formats/validation/facturx.validator.js +147 -148
- package/dist_ts/formats/validation/integrated.validator.js +12 -4
- package/dist_ts/formats/validation/peppol.validator.js +2 -1
- package/dist_ts/formats/validation/schematron.downloader.js +13 -6
- package/dist_ts/formats/validation/schematron.integration.js +12 -5
- package/dist_ts/formats/validation/schematron.validator.js +17 -13
- package/dist_ts/formats/validation/schematron.worker.js +6 -5
- package/dist_ts/formats/validation/vat-categories.validator.js +3 -4
- package/dist_ts/formats/validation/xrechnung.validator.js +7 -7
- package/dist_ts/index.js +3 -2
- package/dist_ts/interfaces/common.js +1 -2
- package/dist_ts/plugins.d.ts +3 -4
- package/dist_ts/plugins.js +4 -5
- package/dist_ts/vendor/pako.d.ts +5 -0
- package/dist_ts/vendor/pako.js +3 -0
- package/dist_ts/vendor/saxonjs.d.ts +22 -0
- package/dist_ts/vendor/saxonjs.js +3 -0
- package/dist_ts/vendor/xmldom.d.ts +20 -0
- package/dist_ts/vendor/xmldom.js +5 -0
- package/dist_ts_install/download-schematron.d.ts +0 -3
- package/dist_ts_install/download-schematron.js +20 -11
- package/dist_ts_install/download-test-samples.d.ts +0 -3
- package/dist_ts_install/download-test-samples.js +4 -2
- package/dist_ts_install/download-xrechnung-rules.js +2 -1
- package/dist_ts_install/index.d.ts +0 -5
- package/dist_ts_install/index.js +26 -12
- package/license +21 -0
- package/package.json +25 -23
- package/readme.hints.md +24 -8
- package/readme.md +195 -328
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/einvoice.ts +148 -26
- package/ts/formats/base/base.decoder.ts +7 -0
- package/ts/formats/cii/cii.decoder.ts +17 -8
- package/ts/formats/cii/cii.validator.ts +18 -13
- package/ts/formats/converters/xml-to-einvoice.converter.ts +4 -5
- package/ts/formats/factories/decoder.factory.ts +7 -2
- package/ts/formats/factories/validator.factory.ts +14 -8
- package/ts/formats/semantic/semantic.adapter.ts +49 -15
- package/ts/formats/ubl/en16931.ubl.validator.ts +5 -3
- package/ts/formats/ubl/generic/ubl.encoder.ts +12 -7
- package/ts/formats/ubl/ubl.decoder.ts +18 -9
- package/ts/formats/ubl/ubl.validator.ts +17 -12
- package/ts/formats/ubl/xrechnung/xrechnung.decoder.ts +41 -28
- package/ts/formats/utils/format.detector.ts +57 -19
- package/ts/formats/validation/conformance.harness.ts +6 -4
- package/ts/formats/validation/en16931.validator.ts +20 -10
- package/ts/formats/validation/integrated.validator.ts +5 -3
- package/ts/formats/validation/schematron.downloader.ts +11 -6
- package/ts/formats/validation/schematron.integration.ts +7 -4
- package/ts/formats/validation/schematron.validator.ts +12 -11
- package/ts/index.ts +2 -1
- package/ts/interfaces/common.ts +1 -3
- package/ts/plugins.ts +3 -4
- package/ts/readme.md +55 -0
- package/ts/vendor/modules.d.ts +32 -0
- package/ts/vendor/pako.ts +8 -0
- package/ts/vendor/saxonjs.ts +28 -0
- package/ts/vendor/xmldom.ts +27 -0
package/ts/interfaces/common.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { business, finance } from '../plugins.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Supported electronic invoice formats
|
|
5
3
|
*/
|
|
@@ -88,4 +86,4 @@ export type { TCreditNote } from '@tsclass/tsclass/dist_ts/finance/index.js';
|
|
|
88
86
|
export type { TDebitNote } from '@tsclass/tsclass/dist_ts/finance/index.js';
|
|
89
87
|
export type { TContact } from '@tsclass/tsclass/dist_ts/business/index.js';
|
|
90
88
|
export type { TLetterEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
|
|
91
|
-
export type { TDocumentEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
|
|
89
|
+
export type { TDocumentEnvelope } from '@tsclass/tsclass/dist_ts/business/index.js';
|
package/ts/plugins.ts
CHANGED
|
@@ -21,15 +21,14 @@ import {
|
|
|
21
21
|
} from 'pdf-lib';
|
|
22
22
|
|
|
23
23
|
// XML-related imports
|
|
24
|
-
import { DOMParser, XMLSerializer } from 'xmldom';
|
|
25
|
-
import * as xmldom from 'xmldom';
|
|
24
|
+
import { DOMParser, XMLSerializer, xmldom } from './vendor/xmldom.js';
|
|
26
25
|
import * as xpath from 'xpath';
|
|
27
26
|
|
|
28
27
|
// XSLT/Schematron imports
|
|
29
|
-
import
|
|
28
|
+
import { SaxonJS } from './vendor/saxonjs.js';
|
|
30
29
|
|
|
31
30
|
// Compression-related imports
|
|
32
|
-
import
|
|
31
|
+
import { pako } from './vendor/pako.js';
|
|
33
32
|
|
|
34
33
|
// Business model imports
|
|
35
34
|
import { business, finance, general } from '@tsclass/tsclass';
|
package/ts/readme.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @fin.cx/einvoice
|
|
2
|
+
|
|
3
|
+
Source module for the main `@fin.cx/einvoice` package.
|
|
4
|
+
|
|
5
|
+
This directory contains the public TypeScript API for loading, validating, converting, and embedding European e-invoice XML.
|
|
6
|
+
|
|
7
|
+
## Issue Reporting and Security
|
|
8
|
+
|
|
9
|
+
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
10
|
+
|
|
11
|
+
## What this module exports
|
|
12
|
+
|
|
13
|
+
- `EInvoice`
|
|
14
|
+
- `createEInvoice()`
|
|
15
|
+
- `validateXml(xml, level?)`
|
|
16
|
+
- `FormatDetector`
|
|
17
|
+
- `PDFExtractor`, `PDFEmbedder`
|
|
18
|
+
- `DecoderFactory`, `EncoderFactory`, `ValidatorFactory`
|
|
19
|
+
- `BaseDecoder`, `BaseEncoder`, `BaseValidator`
|
|
20
|
+
- `UBLBase*` and `CIIBase*` extension points
|
|
21
|
+
- Factur-X and ZUGFeRD format-specific classes
|
|
22
|
+
- root types such as `TInvoice`, `ValidationResult`, `ExportFormat`, `IPdf`
|
|
23
|
+
|
|
24
|
+
## Main workflow
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { EInvoice, ValidationLevel } from '@fin.cx/einvoice';
|
|
28
|
+
|
|
29
|
+
const invoice = await EInvoice.fromFile('./invoice.xml');
|
|
30
|
+
const validation = await invoice.validate(ValidationLevel.BUSINESS);
|
|
31
|
+
const xml = await invoice.exportXml('facturx');
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Format support
|
|
35
|
+
|
|
36
|
+
| Format | Detect | Import | Export | Notes |
|
|
37
|
+
| --- | --- | --- | --- | --- |
|
|
38
|
+
| `ubl` | Yes | Yes | Yes | Generic UBL flow |
|
|
39
|
+
| `xrechnung` | Yes | Yes | Yes | UBL-based profile |
|
|
40
|
+
| `cii` | Yes | Yes | Yes | Generic export currently routes through the Factur-X encoder path |
|
|
41
|
+
| `facturx` | Yes | Yes | Yes | Main CII generation path |
|
|
42
|
+
| `zugferd` | Yes | Yes | Yes | Input supports v1 and v2+ |
|
|
43
|
+
| `fatturapa` | Yes | No | No | Detection only at the moment |
|
|
44
|
+
|
|
45
|
+
## Important implementation notes
|
|
46
|
+
|
|
47
|
+
- `peppol` is not a root-level XML export target.
|
|
48
|
+
- `FatturaPA` is not fully implemented for import/export.
|
|
49
|
+
- PDF support means extracting or embedding XML into existing PDFs, not generating invoice PDFs from scratch.
|
|
50
|
+
- Validation is useful and extensive, but should not be documented as blanket certification.
|
|
51
|
+
|
|
52
|
+
## Related directories
|
|
53
|
+
|
|
54
|
+
- `../readme.md`: full package README for end users
|
|
55
|
+
- `../ts_install/readme.md`: install-time resource bootstrap module
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare module 'xmldom' {
|
|
2
|
+
export class DOMParser {
|
|
3
|
+
parseFromString(source: string, mimeType: string): Document;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class XMLSerializer {
|
|
7
|
+
serializeToString(node: Node): string;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module 'pako' {
|
|
12
|
+
export function inflate(input: Uint8Array | ArrayBuffer | string, options?: unknown): Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare module 'saxon-js' {
|
|
16
|
+
export function compile(options: {
|
|
17
|
+
stylesheetText: string;
|
|
18
|
+
warnings?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}): Promise<unknown>;
|
|
21
|
+
|
|
22
|
+
export function transform(options: {
|
|
23
|
+
stylesheetInternal?: unknown;
|
|
24
|
+
sourceText: string;
|
|
25
|
+
destination?: string;
|
|
26
|
+
stylesheetParams?: Record<string, unknown>;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
principalResult: string;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as saxonJSRuntime from 'saxon-js';
|
|
2
|
+
|
|
3
|
+
export interface ISaxonJSCompileOptions {
|
|
4
|
+
stylesheetText: string;
|
|
5
|
+
warnings?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ISaxonJSTransformOptions {
|
|
10
|
+
stylesheetInternal?: unknown;
|
|
11
|
+
sourceText: string;
|
|
12
|
+
destination?: string;
|
|
13
|
+
stylesheetParams?: Record<string, unknown>;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ISaxonJSTransformResult {
|
|
18
|
+
principalResult: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ISaxonJSModule {
|
|
23
|
+
compile(options: ISaxonJSCompileOptions): Promise<unknown>;
|
|
24
|
+
transform(options: ISaxonJSTransformOptions): Promise<ISaxonJSTransformResult>;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SaxonJS: ISaxonJSModule = saxonJSRuntime as unknown as ISaxonJSModule;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as xmldomRuntime from 'xmldom';
|
|
2
|
+
|
|
3
|
+
export interface IDOMParser {
|
|
4
|
+
parseFromString(source: string, mimeType: string): Document;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface IDOMParserConstructor {
|
|
8
|
+
new (): IDOMParser;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IXMLSerializer {
|
|
12
|
+
serializeToString(node: Node): string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IXMLSerializerConstructor {
|
|
16
|
+
new (): IXMLSerializer;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IXmlDomModule {
|
|
20
|
+
DOMParser: IDOMParserConstructor;
|
|
21
|
+
XMLSerializer: IXMLSerializerConstructor;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const DOMParser: IDOMParserConstructor = xmldomRuntime.DOMParser as unknown as IDOMParserConstructor;
|
|
26
|
+
export const XMLSerializer: IXMLSerializerConstructor = xmldomRuntime.XMLSerializer as unknown as IXMLSerializerConstructor;
|
|
27
|
+
export const xmldom: IXmlDomModule = xmldomRuntime as unknown as IXmlDomModule;
|