@fin.cx/einvoice 8.3.1 → 10.0.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/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/einvoice.d.ts +26 -0
- package/dist_ts/einvoice.js +61 -3
- package/dist_ts/formats/base/base.decoder.d.ts +18 -1
- package/dist_ts/formats/base/base.decoder.js +30 -17
- package/dist_ts/formats/cii/cii.decoder.d.ts +89 -6
- package/dist_ts/formats/cii/cii.decoder.js +125 -30
- package/dist_ts/formats/cii/cii.encoder.d.ts +71 -1
- package/dist_ts/formats/cii/cii.encoder.js +195 -12
- package/dist_ts/formats/cii/cii.types.d.ts +2 -5
- package/dist_ts/formats/cii/cii.types.js +7 -9
- package/dist_ts/formats/cii/cii.validator.d.ts +13 -6
- package/dist_ts/formats/cii/cii.validator.js +29 -30
- package/dist_ts/formats/cii/facturx/facturx.decoder.js +19 -3
- package/dist_ts/formats/cii/facturx/facturx.encoder.d.ts +0 -6
- package/dist_ts/formats/cii/facturx/facturx.encoder.js +17 -26
- package/dist_ts/formats/cii/facturx/facturx.types.d.ts +0 -5
- package/dist_ts/formats/cii/facturx/facturx.types.js +1 -8
- package/dist_ts/formats/cii/facturx/facturx.validator.d.ts +0 -5
- package/dist_ts/formats/cii/facturx/facturx.validator.js +5 -29
- package/dist_ts/formats/cii/zugferd/zugferd.decoder.js +19 -2
- package/dist_ts/formats/cii/zugferd/zugferd.encoder.d.ts +0 -7
- package/dist_ts/formats/cii/zugferd/zugferd.encoder.js +15 -68
- package/dist_ts/formats/cii/zugferd/zugferd.types.d.ts +0 -5
- package/dist_ts/formats/cii/zugferd/zugferd.types.js +1 -8
- package/dist_ts/formats/cii/zugferd/zugferd.v1.decoder.d.ts +26 -0
- package/dist_ts/formats/cii/zugferd/zugferd.v1.decoder.js +47 -1
- package/dist_ts/formats/cii/zugferd/zugferd.validator.js +6 -2
- package/dist_ts/formats/semantic/semantic.adapter.js +29 -20
- package/dist_ts/formats/semantic/semantic.validator.js +17 -2
- package/dist_ts/formats/ubl/en16931.ubl.validator.d.ts +0 -4
- package/dist_ts/formats/ubl/en16931.ubl.validator.js +5 -42
- package/dist_ts/formats/ubl/generic/ubl.encoder.js +29 -26
- package/dist_ts/formats/ubl/ubl.decoder.d.ts +4 -0
- package/dist_ts/formats/ubl/ubl.decoder.js +9 -1
- package/dist_ts/formats/ubl/ubl.encoder.js +13 -5
- package/dist_ts/formats/ubl/ubl.validator.d.ts +13 -0
- package/dist_ts/formats/ubl/ubl.validator.js +28 -1
- package/dist_ts/formats/ubl/xrechnung/xrechnung.decoder.js +14 -1
- package/dist_ts/formats/ubl/xrechnung/xrechnung.encoder.d.ts +0 -7
- package/dist_ts/formats/ubl/xrechnung/xrechnung.encoder.js +30 -45
- package/dist_ts/formats/ubl/xrechnung.validator.d.ts +5 -4
- package/dist_ts/formats/ubl/xrechnung.validator.js +71 -68
- package/dist_ts/formats/utils/date.value.d.ts +11 -0
- package/dist_ts/formats/utils/date.value.js +33 -1
- package/dist_ts/formats/utils/document.totals.d.ts +1 -3
- package/dist_ts/formats/utils/document.totals.js +1 -2
- package/dist_ts/formats/utils/format.detector.js +16 -10
- package/dist_ts/formats/utils/paid.amount.d.ts +44 -0
- package/dist_ts/formats/utils/paid.amount.js +124 -0
- package/dist_ts/formats/utils/party.contact.d.ts +16 -0
- package/dist_ts/formats/utils/party.contact.js +16 -0
- package/dist_ts/formats/utils/party.identifier.d.ts +28 -0
- package/dist_ts/formats/utils/party.identifier.js +49 -0
- package/dist_ts/formats/utils/peppol.profile.d.ts +10 -0
- package/dist_ts/formats/utils/peppol.profile.js +12 -0
- package/dist_ts/formats/utils/preceding.invoice.d.ts +12 -2
- package/dist_ts/formats/utils/preceding.invoice.js +22 -3
- package/dist_ts/formats/utils/seller.identifier.d.ts +46 -0
- package/dist_ts/formats/utils/seller.identifier.js +78 -0
- package/dist_ts/formats/utils/stated.values.d.ts +80 -0
- package/dist_ts/formats/utils/stated.values.js +418 -0
- package/dist_ts/formats/utils/vat.category.d.ts +30 -2
- package/dist_ts/formats/utils/vat.category.js +36 -6
- package/dist_ts/formats/utils/vat.id.d.ts +18 -0
- package/dist_ts/formats/utils/vat.id.js +22 -0
- package/dist_ts/formats/validation/conformance.harness.js +6 -6
- package/dist_ts/formats/validation/en16931.business-rules.validator.js +4 -19
- package/dist_ts/formats/validation/facturx.validator.js +6 -6
- package/dist_ts/formats/validation/integrated.validator.js +4 -13
- package/dist_ts/formats/validation/peppol.validator.js +6 -13
- package/dist_ts/formats/validation/validation.types.d.ts +5 -0
- package/dist_ts/formats/validation/validation.types.js +6 -1
- package/dist_ts/formats/validation/vat-categories.validator.d.ts +21 -42
- package/dist_ts/formats/validation/vat-categories.validator.js +137 -431
- package/dist_ts/formats/validation/xrechnung.validator.d.ts +11 -58
- package/dist_ts/formats/validation/xrechnung.validator.js +58 -324
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +1 -1
- package/dist_ts/interfaces/common.d.ts +1 -0
- package/dist_ts/interfaces/en16931-metadata.d.ts +0 -5
- package/dist_ts/interfaces/stated.values.d.ts +93 -0
- package/dist_ts/interfaces/stated.values.js +2 -0
- package/package.json +2 -2
- package/readme.md +182 -6
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/einvoice.ts +70 -2
- package/ts/formats/base/base.decoder.ts +32 -29
- package/ts/formats/cii/cii.decoder.ts +159 -32
- package/ts/formats/cii/cii.encoder.ts +210 -14
- package/ts/formats/cii/cii.types.ts +7 -9
- package/ts/formats/cii/cii.validator.ts +30 -32
- package/ts/formats/cii/facturx/facturx.decoder.ts +21 -2
- package/ts/formats/cii/facturx/facturx.encoder.ts +19 -26
- package/ts/formats/cii/facturx/facturx.types.ts +0 -9
- package/ts/formats/cii/facturx/facturx.validator.ts +5 -43
- package/ts/formats/cii/zugferd/zugferd.decoder.ts +21 -1
- package/ts/formats/cii/zugferd/zugferd.encoder.ts +16 -73
- package/ts/formats/cii/zugferd/zugferd.types.ts +0 -9
- package/ts/formats/cii/zugferd/zugferd.v1.decoder.ts +66 -0
- package/ts/formats/cii/zugferd/zugferd.validator.ts +5 -1
- package/ts/formats/semantic/semantic.adapter.ts +28 -19
- package/ts/formats/semantic/semantic.validator.ts +17 -1
- package/ts/formats/ubl/en16931.ubl.validator.ts +5 -64
- package/ts/formats/ubl/generic/ubl.encoder.ts +31 -25
- package/ts/formats/ubl/ubl.decoder.ts +12 -0
- package/ts/formats/ubl/ubl.encoder.ts +12 -4
- package/ts/formats/ubl/ubl.validator.ts +29 -0
- package/ts/formats/ubl/xrechnung/xrechnung.decoder.ts +13 -0
- package/ts/formats/ubl/xrechnung/xrechnung.encoder.ts +33 -45
- package/ts/formats/ubl/xrechnung.validator.ts +75 -127
- package/ts/formats/utils/date.value.ts +33 -0
- package/ts/formats/utils/document.totals.ts +1 -4
- package/ts/formats/utils/format.detector.ts +15 -9
- package/ts/formats/utils/paid.amount.ts +160 -0
- package/ts/formats/utils/party.contact.ts +30 -0
- package/ts/formats/utils/party.identifier.ts +61 -0
- package/ts/formats/utils/peppol.profile.ts +13 -0
- package/ts/formats/utils/preceding.invoice.ts +23 -2
- package/ts/formats/utils/seller.identifier.ts +102 -0
- package/ts/formats/utils/stated.values.ts +499 -0
- package/ts/formats/utils/vat.category.ts +47 -5
- package/ts/formats/utils/vat.id.ts +24 -0
- package/ts/formats/validation/conformance.harness.ts +5 -5
- package/ts/formats/validation/en16931.business-rules.validator.ts +3 -26
- package/ts/formats/validation/facturx.validator.ts +5 -5
- package/ts/formats/validation/integrated.validator.ts +3 -16
- package/ts/formats/validation/peppol.validator.ts +5 -16
- package/ts/formats/validation/validation.types.ts +7 -1
- package/ts/formats/validation/vat-categories.validator.ts +179 -761
- package/ts/formats/validation/xrechnung.validator.ts +61 -382
- package/ts/index.ts +9 -0
- package/ts/interfaces/common.ts +1 -0
- package/ts/interfaces/en16931-metadata.ts +3 -8
- package/ts/interfaces/stated.values.ts +94 -0
- package/ts/readme.md +1 -1
- package/dist_ts/formats/utils/eu.memberstates.d.ts +0 -11
- package/dist_ts/formats/utils/eu.memberstates.js +0 -16
- package/ts/formats/utils/eu.memberstates.ts +0 -16
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contact a party states, as the encoders write it: the contact metadata first, otherwise
|
|
3
|
+
* the party's own name, telephone number and email address; none when the party states neither.
|
|
4
|
+
* @param party The seller or the buyer
|
|
5
|
+
*/
|
|
6
|
+
export const getPartyContact = (party) => {
|
|
7
|
+
const explicit = party?.metadata?.contactInformation;
|
|
8
|
+
if (explicit && (explicit.name || explicit.phone || explicit.email)) {
|
|
9
|
+
return explicit;
|
|
10
|
+
}
|
|
11
|
+
if (party?.email || party?.phone) {
|
|
12
|
+
return { name: party.name, phone: party.phone, email: party.email };
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFydHkuY29udGFjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL2Zvcm1hdHMvdXRpbHMvcGFydHkuY29udGFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFlQTs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sZUFBZSxHQUFHLENBQUMsS0FBb0MsRUFBNkIsRUFBRTtJQUNqRyxNQUFNLFFBQVEsR0FBSSxLQUErQyxFQUFFLFFBQVEsRUFBRSxrQkFBa0IsQ0FBQztJQUNoRyxJQUFJLFFBQVEsSUFBSSxDQUFDLFFBQVEsQ0FBQyxJQUFJLElBQUksUUFBUSxDQUFDLEtBQUssSUFBSSxRQUFRLENBQUMsS0FBSyxDQUFDLEVBQUUsQ0FBQztRQUNwRSxPQUFPLFFBQVEsQ0FBQztJQUNsQixDQUFDO0lBQ0QsSUFBSSxLQUFLLEVBQUUsS0FBSyxJQUFJLEtBQUssRUFBRSxLQUFLLEVBQUUsQ0FBQztRQUNqQyxPQUFPLEVBQUUsSUFBSSxFQUFFLEtBQUssQ0FBQyxJQUFJLEVBQUUsS0FBSyxFQUFFLEtBQUssQ0FBQyxLQUFLLEVBQUUsS0FBSyxFQUFFLEtBQUssQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUN0RSxDQUFDO0lBQ0QsT0FBTyxTQUFTLENBQUM7QUFDbkIsQ0FBQyxDQUFDIn0=
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TAccountingDoc } from '../../interfaces/common.js';
|
|
2
|
+
/** A party identifier: the seller identifier (BT-29) or the buyer identifier (BT-46), with its scheme */
|
|
3
|
+
export interface IPartyIdentifier {
|
|
4
|
+
value: string;
|
|
5
|
+
/** The identification scheme (BT-29-1, BT-46-1): an ISO/IEC 6523 ICD code, or SEPA for a creditor identifier */
|
|
6
|
+
scheme?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The party identifiers (BT-29 seller, BT-46 buyer) a party carries in
|
|
10
|
+
* `additionalIdentifiers`, where the decoders keep the ones a document states;
|
|
11
|
+
* the envelope has no typed field for them. Entries without a value are
|
|
12
|
+
* skipped, a blank scheme is none.
|
|
13
|
+
* @param party The seller or the buyer
|
|
14
|
+
*/
|
|
15
|
+
export declare const getPartyIdentifiers: (party: unknown) => IPartyIdentifier[];
|
|
16
|
+
/**
|
|
17
|
+
* Refuses a document whose buyer carries an identifier (BT-46) with the scheme
|
|
18
|
+
* SEPA, naming the rule. The SEPA scheme is the creditor identifier (BT-90) of
|
|
19
|
+
* the seller or the payee. The CEN artefacts 1.3.16 report it on a buyer as
|
|
20
|
+
* BR-CL-10, "Any identifier identification scheme identifier MUST be coded
|
|
21
|
+
* using one of the ISO 6523 ICD list.": UBL admits it in a party identification
|
|
22
|
+
* of the seller and the payee only, and CII in no `ram:GlobalID` at all, which
|
|
23
|
+
* is where CII writes an identifier with a scheme. Nothing is left out
|
|
24
|
+
* silently.
|
|
25
|
+
* @param accountingDoc The document
|
|
26
|
+
* @param targetFormat The format being written
|
|
27
|
+
*/
|
|
28
|
+
export declare const assertPartyIdentifiersWritable: (accountingDoc: Pick<TAccountingDoc, "to">, targetFormat: string) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EInvoiceFormatError } from '../../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* The party identifiers (BT-29 seller, BT-46 buyer) a party carries in
|
|
4
|
+
* `additionalIdentifiers`, where the decoders keep the ones a document states;
|
|
5
|
+
* the envelope has no typed field for them. Entries without a value are
|
|
6
|
+
* skipped, a blank scheme is none.
|
|
7
|
+
* @param party The seller or the buyer
|
|
8
|
+
*/
|
|
9
|
+
export const getPartyIdentifiers = (party) => {
|
|
10
|
+
const entries = party?.additionalIdentifiers;
|
|
11
|
+
if (!Array.isArray(entries)) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const identifiers = [];
|
|
15
|
+
for (const entry of entries) {
|
|
16
|
+
const { value, scheme } = (entry ?? {});
|
|
17
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const trimmedScheme = typeof scheme === 'string' ? scheme.trim() : '';
|
|
21
|
+
identifiers.push({ value: value.trim(), ...(trimmedScheme ? { scheme: trimmedScheme } : {}) });
|
|
22
|
+
}
|
|
23
|
+
return identifiers;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Refuses a document whose buyer carries an identifier (BT-46) with the scheme
|
|
27
|
+
* SEPA, naming the rule. The SEPA scheme is the creditor identifier (BT-90) of
|
|
28
|
+
* the seller or the payee. The CEN artefacts 1.3.16 report it on a buyer as
|
|
29
|
+
* BR-CL-10, "Any identifier identification scheme identifier MUST be coded
|
|
30
|
+
* using one of the ISO 6523 ICD list.": UBL admits it in a party identification
|
|
31
|
+
* of the seller and the payee only, and CII in no `ram:GlobalID` at all, which
|
|
32
|
+
* is where CII writes an identifier with a scheme. Nothing is left out
|
|
33
|
+
* silently.
|
|
34
|
+
* @param accountingDoc The document
|
|
35
|
+
* @param targetFormat The format being written
|
|
36
|
+
*/
|
|
37
|
+
export const assertPartyIdentifiersWritable = (accountingDoc, targetFormat) => {
|
|
38
|
+
const entries = accountingDoc.to?.additionalIdentifiers;
|
|
39
|
+
if (!Array.isArray(entries)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
entries.forEach((entry, index) => {
|
|
43
|
+
const { scheme } = (entry ?? {});
|
|
44
|
+
if (typeof scheme === 'string' && scheme.trim().toUpperCase() === 'SEPA') {
|
|
45
|
+
throw new EInvoiceFormatError(`BR-CL-10: Any identifier identification scheme identifier MUST be coded using one of the ISO 6523 ICD list. to.additionalIdentifiers[${index}] states the scheme SEPA, the creditor identifier (BT-90) of a seller or payee, which a buyer identifier (BT-46) cannot have`, { targetFormat, unsupportedFeatures: ['BR-CL-10'] });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFydHkuaWRlbnRpZmllci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL2Zvcm1hdHMvdXRpbHMvcGFydHkuaWRlbnRpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQVN0RDs7Ozs7O0dBTUc7QUFDSCxNQUFNLENBQUMsTUFBTSxtQkFBbUIsR0FBRyxDQUFDLEtBQWMsRUFBc0IsRUFBRTtJQUN4RSxNQUFNLE9BQU8sR0FBYSxLQUF5RCxFQUFFLHFCQUFxQixDQUFDO0lBQzNHLElBQUksQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUM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QU87SUFDVCxDQUFDO0lBQ0QsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFDLEtBQWMsRUFBRSxLQUFhLEVBQUUsRUFBRTtRQUNoRCxNQUFNLEVBQUUsTUFBTSxFQUFFLEdBQUcsQ0FBQyxLQUFLLElBQUksRUFBRSxDQUF5QixDQUFDO1FBQ3pELElBQUksT0FBTyxNQUFNLEtBQUssUUFBUSxJQUFJLE1BQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQyxXQUFXLEVBQUUsS0FBSyxNQUFNLEVBQUUsQ0FBQztZQUN6RSxNQUFNLElBQUksbUJBQW1CLENBQzNCLHdJQUF3SSxLQUFLLDhIQUE4SCxFQUMzUSxFQUFFLFlBQVksRUFBRSxtQkFBbUIsRUFBRSxDQUFDLFVBQVUsQ0FBQyxFQUFFLENBQ3BELENBQUM7UUFDSixDQUFDO0lBQ0gsQ0FBQyxDQUFDLENBQUM7QUFDTCxDQUFDLENBQUMifQ==
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a specification identifier (BT-24) is that of PEPPOL BIS Billing 3.0,
|
|
3
|
+
* `urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0`,
|
|
4
|
+
* the one identifier the PEPPOL BIS Billing 3.0 rules apply to. PINT, the
|
|
5
|
+
* A-NZ, Singapore and other PEPPOL derivatives, and the PEPPOL business process
|
|
6
|
+
* type (BT-23, `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0`), which an
|
|
7
|
+
* EN 16931 document may state as well, do not make a document one.
|
|
8
|
+
* @param customizationId The specification identifier
|
|
9
|
+
*/
|
|
10
|
+
export declare const isPeppolBisBilling3: (customizationId: string | undefined) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UBL_CUSTOMIZATION_IDS } from '../ubl/ubl.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a specification identifier (BT-24) is that of PEPPOL BIS Billing 3.0,
|
|
4
|
+
* `urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0`,
|
|
5
|
+
* the one identifier the PEPPOL BIS Billing 3.0 rules apply to. PINT, the
|
|
6
|
+
* A-NZ, Singapore and other PEPPOL derivatives, and the PEPPOL business process
|
|
7
|
+
* type (BT-23, `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0`), which an
|
|
8
|
+
* EN 16931 document may state as well, do not make a document one.
|
|
9
|
+
* @param customizationId The specification identifier
|
|
10
|
+
*/
|
|
11
|
+
export const isPeppolBisBilling3 = (customizationId) => (customizationId ?? '').trim() === UBL_CUSTOMIZATION_IDS.PEPPOL_BIS;
|
|
12
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGVwcG9sLnByb2ZpbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9mb3JtYXRzL3V0aWxzL3BlcHBvbC5wcm9maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVEOzs7Ozs7OztHQVFHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sbUJBQW1CLEdBQUcsQ0FBQyxlQUFtQyxFQUFXLEVBQUUsQ0FDbEYsQ0FBQyxlQUFlLElBQUksRUFBRSxDQUFDLENBQUMsSUFBSSxFQUFFLEtBQUsscUJBQXFCLENBQUMsVUFBVSxDQUFDIn0=
|
|
@@ -9,7 +9,13 @@ export type TPrecedingInvoiceReference = TCorrectedInvoiceReference;
|
|
|
9
9
|
* taken only from what the document states:
|
|
10
10
|
* - a corrected invoice: the invoice it corrects (`correctedInvoice`);
|
|
11
11
|
* - a corrected invoice or a credit note: every related document with the
|
|
12
|
-
* relation `'corrects'
|
|
12
|
+
* relation `'corrects'`;
|
|
13
|
+
* - a document that can be a final invoice (an invoice, a corrected invoice or
|
|
14
|
+
* a self-billed invoice): the advance invoice of every advance payment that
|
|
15
|
+
* states one (`advancePayments[].invoice`), after the references above. The
|
|
16
|
+
* amounts are the paid amount (BT-113); the deduction per rate that § 14
|
|
17
|
+
* Abs. 5 Satz 2 UStG asks of a final invoice has no element in EN 16931
|
|
18
|
+
* (BMF letter of 15 October 2024, Rn. 48).
|
|
13
19
|
* Other documents and other relations write none.
|
|
14
20
|
*/
|
|
15
21
|
export declare const getPrecedingInvoiceReferences: (accountingDoc: TAccountingDoc) => TPrecedingInvoiceReference[];
|
|
@@ -18,7 +24,11 @@ export declare const getPrecedingInvoiceReferences: (accountingDoc: TAccountingD
|
|
|
18
24
|
* inverse of {@link getPrecedingInvoiceReferences}: on a corrected invoice the
|
|
19
25
|
* first reference is the invoice it corrects and further ones are related
|
|
20
26
|
* documents it corrects; on a credit note every reference is a related
|
|
21
|
-
* document it corrects. Other documents keep no reference, as before.
|
|
27
|
+
* document it corrects. Other documents keep no reference, as before. The
|
|
28
|
+
* XML does not tell an advance invoice from a corrected one, so a corrected
|
|
29
|
+
* invoice's advance invoices read back as related documents it corrects, and
|
|
30
|
+
* an invoice's advance invoices are not read: `advancePayments` needs the net
|
|
31
|
+
* and the tax per rate of every payment, which the XML does not carry.
|
|
22
32
|
*/
|
|
23
33
|
export declare const getPrecedingInvoiceFields: (accountingDocType: TAccountingDocType, references: TPrecedingInvoiceReference[]) => {
|
|
24
34
|
correctedInvoice?: TCorrectedInvoiceReference;
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* taken only from what the document states:
|
|
4
4
|
* - a corrected invoice: the invoice it corrects (`correctedInvoice`);
|
|
5
5
|
* - a corrected invoice or a credit note: every related document with the
|
|
6
|
-
* relation `'corrects'
|
|
6
|
+
* relation `'corrects'`;
|
|
7
|
+
* - a document that can be a final invoice (an invoice, a corrected invoice or
|
|
8
|
+
* a self-billed invoice): the advance invoice of every advance payment that
|
|
9
|
+
* states one (`advancePayments[].invoice`), after the references above. The
|
|
10
|
+
* amounts are the paid amount (BT-113); the deduction per rate that § 14
|
|
11
|
+
* Abs. 5 Satz 2 UStG asks of a final invoice has no element in EN 16931
|
|
12
|
+
* (BMF letter of 15 October 2024, Rn. 48).
|
|
7
13
|
* Other documents and other relations write none.
|
|
8
14
|
*/
|
|
9
15
|
export const getPrecedingInvoiceReferences = (accountingDoc) => {
|
|
@@ -21,6 +27,15 @@ export const getPrecedingInvoiceReferences = (accountingDoc) => {
|
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
}
|
|
30
|
+
if ('advancePayments' in accountingDoc) {
|
|
31
|
+
for (const advancePayment of accountingDoc.advancePayments ?? []) {
|
|
32
|
+
if (advancePayment.invoice) {
|
|
33
|
+
references.push(advancePayment.invoice.issueDate === undefined
|
|
34
|
+
? { documentId: advancePayment.invoice.documentId }
|
|
35
|
+
: { documentId: advancePayment.invoice.documentId, issueDate: advancePayment.invoice.issueDate });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
24
39
|
return references;
|
|
25
40
|
};
|
|
26
41
|
/**
|
|
@@ -28,7 +43,11 @@ export const getPrecedingInvoiceReferences = (accountingDoc) => {
|
|
|
28
43
|
* inverse of {@link getPrecedingInvoiceReferences}: on a corrected invoice the
|
|
29
44
|
* first reference is the invoice it corrects and further ones are related
|
|
30
45
|
* documents it corrects; on a credit note every reference is a related
|
|
31
|
-
* document it corrects. Other documents keep no reference, as before.
|
|
46
|
+
* document it corrects. Other documents keep no reference, as before. The
|
|
47
|
+
* XML does not tell an advance invoice from a corrected one, so a corrected
|
|
48
|
+
* invoice's advance invoices read back as related documents it corrects, and
|
|
49
|
+
* an invoice's advance invoices are not read: `advancePayments` needs the net
|
|
50
|
+
* and the tax per rate of every payment, which the XML does not carry.
|
|
32
51
|
*/
|
|
33
52
|
export const getPrecedingInvoiceFields = (accountingDocType, references) => {
|
|
34
53
|
const asRelated = (reference) => ({
|
|
@@ -49,4 +68,4 @@ export const getPrecedingInvoiceFields = (accountingDocType, references) => {
|
|
|
49
68
|
}
|
|
50
69
|
return {};
|
|
51
70
|
};
|
|
52
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
71
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJlY2VkaW5nLmludm9pY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9mb3JtYXRzL3V0aWxzL3ByZWNlZGluZy5pbnZvaWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBOzs7Ozs7Ozs7Ozs7O0dBYUc7QUFDSCxNQUFNLENBQUMsTUFBTSw2QkFBNkIsR0FBRyxDQUMzQyxhQUE2QixFQUNDLEVBQUU7SUFDaEMsTUFBTSxVQUFVLEdBQWlDLEVBQUUsQ0FBQztJQUNwRCxJQUFJLGFBQWEsQ0FBQyxpQkFBaUIsS0FBSyxtQkFBbUIsSUFBSSxhQUFhLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQztRQUM5RixVQUFVLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0lBQ2xELENBQUM7SUFDRCxJQUNFLGFBQWEsQ0FBQyxpQkFBaUIsS0FBSyxtQkFBbUI7UUFDdkQsYUFBYSxDQUFDLGlCQUFpQixLQUFLLFlBQVksRUFDaEQsQ0FBQztRQUNELEtBQUssTUFBTSxlQUFlLElBQUksYUFBYSxDQUFDLGdCQUFnQixJQUFJLEVBQUUsRUFBRSxDQUFDO1lBQ25FLElBQUksZUFBZSxDQUFDLFlBQVksS0FBSyxVQUFVLEVBQUUsQ0FBQztnQkFDaEQsVUFBVSxDQUFDLElBQUksQ0FDYixlQUFlLENBQUMsU0FBUyxLQUFLLFNBQVM7b0JBQ3JDLENBQUMsQ0FBQyxFQUFFLFVBQVUsRUFBRSxlQUFlLENBQUMsVUFBVSxFQUFFO29CQUM1QyxDQU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FQUFFLENBQUM7UUFDNUIsT0FBTyxFQUFFLENBQUM7SUFDWixDQUFDO0lBQ0QsSUFBSSxpQkFBaUIsS0FBSyxtQkFBbUIsRUFBRSxDQUFDO1FBQzlDLE1BQU0sQ0FBQyxnQkFBZ0IsRUFBRSxHQUFHLGlCQUFpQixDQUFDLEdBQUcsVUFBVSxDQUFDO1FBQzVELE9BQU8saUJBQWlCLENBQUMsTUFBTSxLQUFLLENBQUM7WUFDbkMsQ0FBQyxDQUFDLEVBQUUsZ0JBQWdCLEVBQUU7WUFDdEIsQ0FBQyxDQUFDLEVBQUUsZ0JBQWdCLEVBQUUsZ0JBQWdCLEVBQUUsaUJBQWlCLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUM7SUFDL0UsQ0FBQztJQUNELElBQUksaUJBQWlCLEtBQUssWUFBWSxFQUFFLENBQUM7UUFDdkMsT0FBTyxFQUFFLGdCQUFnQixFQUFFLFVBQVUsQ0FBQyxHQUFHLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQztJQUN6RCxDQUFDO0lBQ0QsT0FBTyxFQUFFLENBQUM7QUFDWixDQUFDLENBQUMifQ==
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TAccountingDoc } from '../../interfaces/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* The official text of EN 16931 BR-CO-26 (CEN/TC 434 EN 16931 validation
|
|
4
|
+
* artefacts 1.3.16, fatal in UBL and CII)
|
|
5
|
+
*/
|
|
6
|
+
export declare const BR_CO_26_TEXT = "In order for the buyer to automatically identify a supplier, the Seller identifier (BT-29), the Seller legal registration identifier (BT-30) and/or the Seller VAT identifier (BT-31) shall be present.";
|
|
7
|
+
/**
|
|
8
|
+
* Whether the seller of a UBL document meets BR-CO-26, as the CEN artefacts
|
|
9
|
+
* check it on `cac:AccountingSupplierParty`: a VAT identifier (BT-31, a
|
|
10
|
+
* `cac:PartyTaxScheme` with the scheme VAT), a seller identifier (BT-29, a
|
|
11
|
+
* `cac:PartyIdentification` whose scheme is not SEPA) or a legal registration
|
|
12
|
+
* identifier (BT-30, `cac:PartyLegalEntity/cbc:CompanyID`). A document without
|
|
13
|
+
* a seller party is not checked; BR-06 and BR-08 report that.
|
|
14
|
+
* @param doc The UBL document
|
|
15
|
+
*/
|
|
16
|
+
export declare const ublSellerMeetsBrCo26: (doc: Document) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the seller of a CII document meets BR-CO-26, as the CEN artefacts
|
|
19
|
+
* check it on `ram:SellerTradeParty`: a seller identifier (BT-29, `ram:ID` or
|
|
20
|
+
* `ram:GlobalID`), a legal registration identifier (BT-30,
|
|
21
|
+
* `ram:SpecifiedLegalOrganization/ram:ID`) or a VAT identifier (BT-31,
|
|
22
|
+
* `ram:SpecifiedTaxRegistration/ram:ID` with the scheme VA).
|
|
23
|
+
* @param doc The CII document
|
|
24
|
+
*/
|
|
25
|
+
export declare const ciiSellerMeetsBrCo26: (doc: Document) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the seller of an envelope states an identifier BR-CO-26 accepts:
|
|
28
|
+
* the VAT identifier (BT-31, `registrationDetails.vatId`), the legal
|
|
29
|
+
* registration identifier (BT-30, `registrationDetails.registrationId`) or a
|
|
30
|
+
* seller identifier (BT-29), which a decoded UBL document keeps in the
|
|
31
|
+
* party's `additionalIdentifiers`. A tax number (BT-32) is none of them.
|
|
32
|
+
* @param accountingDoc The document
|
|
33
|
+
*/
|
|
34
|
+
export declare const envelopeSellerMeetsBrCo26: (accountingDoc: Pick<TAccountingDoc, "from">) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Refuses a written document whose seller fails BR-CO-26, naming the rule; no
|
|
37
|
+
* identifier is put in place of a missing one. The seller states its VAT
|
|
38
|
+
* identifier (`registrationDetails.vatId`, BT-31) or its legal registration
|
|
39
|
+
* identifier (`registrationDetails.registrationId`, BT-30); a tax number
|
|
40
|
+
* (BT-32) alone does not identify it. A seller identifier (BT-29) is written
|
|
41
|
+
* from the party's `additionalIdentifiers` (no typed field in the envelope).
|
|
42
|
+
* @param xml The written document
|
|
43
|
+
* @param syntax The syntax it is written in
|
|
44
|
+
* @param targetFormat The format being written
|
|
45
|
+
*/
|
|
46
|
+
export declare const assertSellerIdentified: (xml: string, syntax: "ubl" | "cii", targetFormat: string) => void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EInvoiceFormatError } from '../../errors.js';
|
|
2
|
+
import { DOMParser, xpath } from '../../plugins.js';
|
|
3
|
+
import { CII_NAMESPACES } from '../cii/cii.types.js';
|
|
4
|
+
import { UBL_NAMESPACES } from '../ubl/ubl.types.js';
|
|
5
|
+
import { getPartyIdentifiers } from './party.identifier.js';
|
|
6
|
+
/**
|
|
7
|
+
* The official text of EN 16931 BR-CO-26 (CEN/TC 434 EN 16931 validation
|
|
8
|
+
* artefacts 1.3.16, fatal in UBL and CII)
|
|
9
|
+
*/
|
|
10
|
+
export const BR_CO_26_TEXT = 'In order for the buyer to automatically identify a supplier, the Seller identifier (BT-29), the Seller legal registration identifier (BT-30) and/or the Seller VAT identifier (BT-31) shall be present.';
|
|
11
|
+
const ublSelect = xpath.useNamespaces({ cac: UBL_NAMESPACES.CAC, cbc: UBL_NAMESPACES.CBC });
|
|
12
|
+
const ciiSelect = xpath.useNamespaces({ rsm: CII_NAMESPACES.RSM, ram: CII_NAMESPACES.RAM });
|
|
13
|
+
const nodesOf = (result) => (Array.isArray(result) ? result : []);
|
|
14
|
+
/**
|
|
15
|
+
* Whether the seller of a UBL document meets BR-CO-26, as the CEN artefacts
|
|
16
|
+
* check it on `cac:AccountingSupplierParty`: a VAT identifier (BT-31, a
|
|
17
|
+
* `cac:PartyTaxScheme` with the scheme VAT), a seller identifier (BT-29, a
|
|
18
|
+
* `cac:PartyIdentification` whose scheme is not SEPA) or a legal registration
|
|
19
|
+
* identifier (BT-30, `cac:PartyLegalEntity/cbc:CompanyID`). A document without
|
|
20
|
+
* a seller party is not checked; BR-06 and BR-08 report that.
|
|
21
|
+
* @param doc The UBL document
|
|
22
|
+
*/
|
|
23
|
+
export const ublSellerMeetsBrCo26 = (doc) => {
|
|
24
|
+
const sellers = nodesOf(ublSelect('/*/cac:AccountingSupplierParty', doc));
|
|
25
|
+
return sellers.every((seller) => {
|
|
26
|
+
const vatSchemes = nodesOf(ublSelect('./cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID', seller)).filter((node) => (node.textContent ?? '').trim().toUpperCase() === 'VAT');
|
|
27
|
+
const hasVatIdentifier = vatSchemes.some((scheme) => nodesOf(ublSelect('../../cbc:CompanyID', scheme)).length > 0);
|
|
28
|
+
const hasSellerIdentifier = nodesOf(ublSelect("./cac:Party/cac:PartyIdentification/cbc:ID[not(@schemeID = 'SEPA')]", seller)).length > 0;
|
|
29
|
+
const hasLegalRegistration = nodesOf(ublSelect('./cac:Party/cac:PartyLegalEntity/cbc:CompanyID', seller)).length > 0;
|
|
30
|
+
return hasVatIdentifier || hasSellerIdentifier || hasLegalRegistration;
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Whether the seller of a CII document meets BR-CO-26, as the CEN artefacts
|
|
35
|
+
* check it on `ram:SellerTradeParty`: a seller identifier (BT-29, `ram:ID` or
|
|
36
|
+
* `ram:GlobalID`), a legal registration identifier (BT-30,
|
|
37
|
+
* `ram:SpecifiedLegalOrganization/ram:ID`) or a VAT identifier (BT-31,
|
|
38
|
+
* `ram:SpecifiedTaxRegistration/ram:ID` with the scheme VA).
|
|
39
|
+
* @param doc The CII document
|
|
40
|
+
*/
|
|
41
|
+
export const ciiSellerMeetsBrCo26 = (doc) => nodesOf(ciiSelect('//ram:SellerTradeParty', doc)).every((seller) => nodesOf(ciiSelect("./ram:ID | ./ram:GlobalID | ./ram:SpecifiedLegalOrganization/ram:ID | ./ram:SpecifiedTaxRegistration/ram:ID[@schemeID='VA']", seller)).length > 0);
|
|
42
|
+
/**
|
|
43
|
+
* Whether the seller of an envelope states an identifier BR-CO-26 accepts:
|
|
44
|
+
* the VAT identifier (BT-31, `registrationDetails.vatId`), the legal
|
|
45
|
+
* registration identifier (BT-30, `registrationDetails.registrationId`) or a
|
|
46
|
+
* seller identifier (BT-29), which a decoded UBL document keeps in the
|
|
47
|
+
* party's `additionalIdentifiers`. A tax number (BT-32) is none of them.
|
|
48
|
+
* @param accountingDoc The document
|
|
49
|
+
*/
|
|
50
|
+
export const envelopeSellerMeetsBrCo26 = (accountingDoc) => {
|
|
51
|
+
const seller = accountingDoc.from;
|
|
52
|
+
if (!seller) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
const details = seller.registrationDetails;
|
|
56
|
+
const hasSellerIdentifier = getPartyIdentifiers(seller).some((identifier) => identifier.scheme?.toUpperCase() !== 'SEPA');
|
|
57
|
+
return Boolean(details?.vatId?.trim() || details?.registrationId?.trim() || hasSellerIdentifier);
|
|
58
|
+
};
|
|
59
|
+
const writtenParser = new DOMParser();
|
|
60
|
+
/**
|
|
61
|
+
* Refuses a written document whose seller fails BR-CO-26, naming the rule; no
|
|
62
|
+
* identifier is put in place of a missing one. The seller states its VAT
|
|
63
|
+
* identifier (`registrationDetails.vatId`, BT-31) or its legal registration
|
|
64
|
+
* identifier (`registrationDetails.registrationId`, BT-30); a tax number
|
|
65
|
+
* (BT-32) alone does not identify it. A seller identifier (BT-29) is written
|
|
66
|
+
* from the party's `additionalIdentifiers` (no typed field in the envelope).
|
|
67
|
+
* @param xml The written document
|
|
68
|
+
* @param syntax The syntax it is written in
|
|
69
|
+
* @param targetFormat The format being written
|
|
70
|
+
*/
|
|
71
|
+
export const assertSellerIdentified = (xml, syntax, targetFormat) => {
|
|
72
|
+
const doc = writtenParser.parseFromString(xml, 'application/xml');
|
|
73
|
+
const meets = syntax === 'ubl' ? ublSellerMeetsBrCo26(doc) : ciiSellerMeetsBrCo26(doc);
|
|
74
|
+
if (!meets) {
|
|
75
|
+
throw new EInvoiceFormatError(`BR-CO-26: ${BR_CO_26_TEXT} The seller states none of them: set from.registrationDetails.vatId (BT-31) or .registrationId (BT-30), or give the seller a seller identifier (BT-29) in from.additionalIdentifiers, where a decoded document keeps it; a tax number (BT-32, .taxNumber) does not identify the seller`, { targetFormat, unsupportedFeatures: ['BR-CO-26'] });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VsbGVyLmlkZW50aWZpZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi90cy9mb3JtYXRzL3V0aWxzL3NlbGxlci5pZGVudGlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBQ3RELE9BQU8sRUFBRSxTQUFTLEVBQUUsS0FBSyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDcEQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ3JELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUNyRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUU1RDs7O0dBR0c7QUFDSCxNQUFNLENBQUMsTUFBTSxhQUFhLEdBQ3hCLHlNQUF5TSxDQUFDO0FBRTVNLE1BQU0sU0FBUyxHQUFHLEtBQUssQ0FBQyxhQUFhLENBQUMsRUFBRSxHQUFHLEVBQUUsY0FBYyxDQUFDLEdBQUcsRUFBRSxHQUFHLEVBQUUsY0FBYyxDQUFDLEdBQUcsRUFBRSxDQUFDLENBQUM7QUFDNUYsTUFBTSxTQUFTLEdBQUcsS0FBSyxDQUFDLGFBQWEsQ0FBQyxFQUFFLEdBQUcsRUFBRSxjQUFjLENBQUMsR0FBRyxFQUFFLEdBQUcsRUFB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sQ0FBQztJQUMxSCxPQUFPLE9BQU8sQ0FBQyxPQUFPLEVBQUUsS0FBSyxFQUFFLElBQUksRUFBRSxJQUFJLE9BQU8sRUFBRSxjQUFjLEVBQUUsSUFBSSxFQUFFLElBQUksbUJBQW1CLENBQUMsQ0FBQztBQUNuRyxDQUFDLENBQUM7QUFFRixNQUFNLGFBQWEsR0FBRyxJQUFJLFNBQVMsRUFBRSxDQUFDO0FBRXRDOzs7Ozs7Ozs7O0dBVUc7QUFDSCxNQUFNLENBQUMsTUFBTSxzQkFBc0IsR0FBRyxDQUFDLEdBQVcsRUFBRSxNQUFxQixFQUFFLFlBQW9CLEVBQVEsRUFBRTtJQUN2RyxNQUFNLEdBQUcsR0FBRyxhQUFhLENBQUMsZUFBZSxDQUFDLEdBQUcsRUFBRSxpQkFBaUIsQ0FBQyxDQUFDO0lBQ2xFLE1BQU0sS0FBSyxHQUFHLE1BQU0sS0FBSyxLQUFLLENBQUMsQ0FBQyxDQUFDLG9CQUFvQixDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQyxvQkFBb0IsQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUN2RixJQUFJLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDWCxNQUFNLElBQUksbUJBQW1CLENBQzNCLGFBQWEsYUFBYSx3UkFBd1IsRUFDbFQsRUFBRSxZQUFZLEVBQUUsbUJBQW1CLEVBQUUsQ0FBQyxVQUFVLENBQUMsRUFBRSxDQUNwRCxDQUFDO0lBQ0osQ0FBQztBQUNILENBQUMsQ0FBQyJ9
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { IEInvoiceStatedValues } from '../../interfaces/stated.values.js';
|
|
2
|
+
import type { IDocumentTotals } from './document.totals.js';
|
|
3
|
+
/** A stated value that is no decimal number, by business term and the text found */
|
|
4
|
+
export interface IStatedValueProblem {
|
|
5
|
+
businessTerm: string;
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The message for a stated amount that is no decimal number, as the paid
|
|
10
|
+
* amount's has been: "The paid amount (BT-113) is no decimal number: …"
|
|
11
|
+
* @param problem The problem
|
|
12
|
+
*/
|
|
13
|
+
export declare const statedValueProblemMessage: (problem: IStatedValueProblem) => string;
|
|
14
|
+
/** The stated values of a document, and the stated amounts that are no number */
|
|
15
|
+
export interface IStatedValuesRead {
|
|
16
|
+
values: IEInvoiceStatedValues;
|
|
17
|
+
problems: IStatedValueProblem[];
|
|
18
|
+
/** How many VAT totals (BT-110) in the document currency the document states; BR-CO-15 asks for exactly one */
|
|
19
|
+
documentCurrencyTaxTotals?: number;
|
|
20
|
+
/** Each `cac:TaxTotal` of a UBL document with its tax amount and the tax amounts of its own subtotals, which BR-CO-14 compares */
|
|
21
|
+
ublTaxTotals?: Array<{
|
|
22
|
+
taxAmount?: number;
|
|
23
|
+
subtotalTaxAmounts: Array<number | undefined>;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/** A finding on stated values: the rule, its official text and where it applies */
|
|
27
|
+
export interface IStatedValueFinding {
|
|
28
|
+
ruleId: string;
|
|
29
|
+
message: string;
|
|
30
|
+
location: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads the stated values of a UBL invoice or credit note: the document totals
|
|
34
|
+
* (`cac:LegalMonetaryTotal`, BT-106 to BT-115, the VAT total `cac:TaxTotal/cbc:TaxAmount`
|
|
35
|
+
* in the document currency for BT-110 and in the VAT accounting currency for
|
|
36
|
+
* BT-111), the VAT breakdown (`cac:TaxSubtotal`, BT-116 to BT-121), the line
|
|
37
|
+
* amounts (BT-126, BT-131, BT-151, BT-152) and the document level allowances
|
|
38
|
+
* and charges (`cac:AllowanceCharge`, BT-92 to BT-105)
|
|
39
|
+
* @param doc The UBL document
|
|
40
|
+
*/
|
|
41
|
+
export declare const readUblStatedValues: (doc: Document) => IStatedValuesRead;
|
|
42
|
+
/**
|
|
43
|
+
* Reads the stated values of a CII (D16B) document: the document totals of the
|
|
44
|
+
* header settlement (`ram:SpecifiedTradeSettlementHeaderMonetarySummation`,
|
|
45
|
+
* BT-106 to BT-115, `ram:TaxTotalAmount` in the invoice currency for BT-110 and
|
|
46
|
+
* in the VAT accounting currency for BT-111), the VAT breakdown (the header
|
|
47
|
+
* `ram:ApplicableTradeTax`, BT-116 to BT-121), the line amounts (BT-126,
|
|
48
|
+
* BT-131, BT-151, BT-152) and the document level allowances and charges (the
|
|
49
|
+
* header `ram:SpecifiedTradeAllowanceCharge`, BT-92 to BT-105)
|
|
50
|
+
* @param doc The CII document
|
|
51
|
+
*/
|
|
52
|
+
export declare const readCiiStatedValues: (doc: Document) => IStatedValuesRead;
|
|
53
|
+
/**
|
|
54
|
+
* Checks the stated values of a document against each other as the EN 16931
|
|
55
|
+
* rules BR-CO-10 to BR-CO-17 do in the CEN artefacts 1.3.16: each sum rounded
|
|
56
|
+
* to two decimals, BR-CO-17 with the artefacts' tolerance of one unit (UBL
|
|
57
|
+
* strictly within it, CII up to it). A rule whose amounts the document does
|
|
58
|
+
* not state is not checked; the rules on the presence of the totals (BR-12 to
|
|
59
|
+
* BR-15) report that.
|
|
60
|
+
* @param read The stated values read from the document
|
|
61
|
+
* @param syntax The document's syntax
|
|
62
|
+
*/
|
|
63
|
+
export declare const findStatedValueDisagreements: (read: IStatedValuesRead, syntax: "ubl" | "cii") => IStatedValueFinding[];
|
|
64
|
+
/** The package's code for a stated value the envelope computes differently */
|
|
65
|
+
export declare const STATED_VALUE_DIFFERS_CODE = "EINVOICE-STATED-DIFFERS";
|
|
66
|
+
/**
|
|
67
|
+
* The stated values of a loaded document that the envelope's computation
|
|
68
|
+
* (`computeDocumentTotals`, what `totalNet`, `totalVat`, `totalGross` and the
|
|
69
|
+
* encoders give) does not reproduce: the totals BT-106, BT-109, BT-110,
|
|
70
|
+
* BT-112 and BT-115, each line's net amount (BT-131) and VAT category
|
|
71
|
+
* (BT-151), and each VAT breakdown's category, rate and amounts (BG-23). No
|
|
72
|
+
* EN 16931 rule is broken by such a difference, so it is the package's own
|
|
73
|
+
* finding: the envelope has no document or line allowances and charges and no
|
|
74
|
+
* price base quantity, and every line is standard rated or reverse charge.
|
|
75
|
+
* Neither value is changed.
|
|
76
|
+
* @param values The stated values
|
|
77
|
+
* @param totals The envelope's computation
|
|
78
|
+
* @param paidAmount The envelope's paid amount (BT-113)
|
|
79
|
+
*/
|
|
80
|
+
export declare const findEnvelopeDifferences: (values: IEInvoiceStatedValues, totals: IDocumentTotals, paidAmount: number | undefined) => IStatedValueFinding[];
|