@endevops/peppol-schema 0.1.2 → 0.1.4
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/README.md +5 -5
- package/dist/constants.d.ts +131 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +114 -1
- package/dist/constants.js.map +1 -1
- package/dist/{index-BBzPjq7o.d.ts → index-CILtZytZ.d.ts} +1710 -669
- package/dist/index-CILtZytZ.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1234 -187
- package/dist/index.js.map +1 -1
- package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js +36 -0
- package/dist/invoice-response-code-not-needs-schema-DNrfKYLh.js.map +1 -0
- package/dist/invoice-response-codes.d.ts +28 -0
- package/dist/invoice-response-codes.d.ts.map +1 -1
- package/dist/invoice-response-codes.js +11 -1
- package/dist/invoice-response-codes.js.map +1 -1
- package/dist/{is-valid-abn-160i38PG.js → is-valid-abn-D7eSygBG.js} +115 -2
- package/dist/is-valid-abn-D7eSygBG.js.map +1 -0
- package/dist/{is-valid-mod97-0208-CzMOXMO-.js → is-valid-mod97-0208-CjR324eG.js} +11 -1
- package/dist/is-valid-mod97-0208-CjR324eG.js.map +1 -0
- package/dist/message-level-response-profile-id-B9c0A7S_.js +27 -0
- package/dist/message-level-response-profile-id-B9c0A7S_.js.map +1 -0
- package/dist/{nodable-parser-CyDZtLCK.js → nodable-parser-CupS2H55.js} +31 -1
- package/dist/nodable-parser-CupS2H55.js.map +1 -0
- package/dist/schematron.d.ts +57 -1
- package/dist/schematron.d.ts.map +1 -1
- package/dist/schematron.js +453 -2
- package/dist/schematron.js.map +1 -1
- package/dist/validations.d.ts +132 -0
- package/dist/validations.d.ts.map +1 -1
- package/dist/validations.js +11 -2
- package/dist/validations.js.map +1 -1
- package/dist/values.d.ts +67 -2
- package/dist/values.d.ts.map +1 -1
- package/dist/xml.d.ts +30 -0
- package/dist/xml.d.ts.map +1 -1
- package/dist/xml.js +10 -1
- package/dist/xml.js.map +1 -1
- package/package.json +3 -2
- package/src/constants/credit-note-doctype-id.ts +9 -0
- package/src/constants/credit-note-process-id.ts +9 -0
- package/src/constants/document-scheme.ts +9 -0
- package/src/constants/invoice-doctype-id.ts +9 -0
- package/src/constants/invoice-process-id.ts +10 -0
- package/src/constants/invoice-response-doctype-id.ts +10 -0
- package/src/constants/invoice-response-process-id.ts +9 -0
- package/src/constants/invoice-response-profile-id.ts +9 -0
- package/src/constants/message-level-response-doctype-id.ts +10 -0
- package/src/constants/message-level-response-process-id.ts +9 -0
- package/src/constants/message-level-response-profile-id.ts +9 -0
- package/src/constants/participant-scheme.ts +10 -0
- package/src/constants/process-scheme.ts +9 -0
- package/src/constants/transport-profile.ts +10 -0
- package/src/invoice-response-codes/invoice-response-code-needs-schema.ts +9 -0
- package/src/invoice-response-codes/invoice-response-code-not-needs-schema.ts +9 -0
- package/src/invoice-response-codes/invoice-response-codes-order.ts +10 -0
- package/src/peppol-validations/add-piva.ts +12 -0
- package/src/peppol-validations/check-cf.ts +11 -0
- package/src/peppol-validations/check-cf16.ts +12 -0
- package/src/peppol-validations/check-piva-se-it.ts +11 -0
- package/src/peppol-validations/check-piva.ts +11 -0
- package/src/peppol-validations/check-se-orgnr.ts +9 -0
- package/src/peppol-validations/greek-tin-verification.ts +9 -0
- package/src/peppol-validations/is-valid-abn.ts +9 -0
- package/src/peppol-validations/is-valid-gln.ts +10 -0
- package/src/peppol-validations/is-valid-iban.ts +10 -0
- package/src/peppol-validations/is-valid-mod11.ts +9 -0
- package/src/peppol-validations/is-valid-mod97-0208.ts +10 -0
- package/src/peppol-validations/luhn-check.ts +9 -0
- package/src/schemas/fields/default-customization-id.ts +9 -0
- package/src/schemas/fields/default-profile-id.ts +9 -0
- package/src/schemas/fields/peppol-additional-document-reference-schema.ts +41 -2
- package/src/schemas/fields/peppol-address-schema.ts +25 -2
- package/src/schemas/fields/peppol-allowance-charge-schema.ts +65 -9
- package/src/schemas/fields/peppol-amount-schema.ts +15 -2
- package/src/schemas/fields/peppol-base-line-schema.ts +12 -2
- package/src/schemas/fields/peppol-billing-reference-schema.ts +13 -0
- package/src/schemas/fields/peppol-binary-object-schema.ts +12 -4
- package/src/schemas/fields/peppol-contact-schema.ts +11 -0
- package/src/schemas/fields/peppol-credit-note-line-schema.ts +7 -2
- package/src/schemas/fields/peppol-delivery-schema.ts +44 -2
- package/src/schemas/fields/peppol-identifier-schema.ts +8 -0
- package/src/schemas/fields/peppol-invoice-line-period-schema.ts +11 -0
- package/src/schemas/fields/peppol-invoice-line-schema.ts +9 -2
- package/src/schemas/fields/peppol-invoice-period-schema.ts +2 -2
- package/src/schemas/fields/peppol-item-classification-schema.ts +2 -2
- package/src/schemas/fields/peppol-line-allowance-charge-schema.ts +57 -9
- package/src/schemas/fields/peppol-line-item-schema.ts +69 -4
- package/src/schemas/fields/peppol-line-price-allowance-charge-schema.ts +20 -0
- package/src/schemas/fields/peppol-line-price-schema.ts +2 -0
- package/src/schemas/fields/peppol-order-reference-schema.ts +2 -0
- package/src/schemas/fields/peppol-party-base-schema.ts +36 -4
- package/src/schemas/fields/peppol-party-legal-entity-schema.ts +13 -0
- package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +5 -0
- package/src/schemas/fields/peppol-payee-party-schema.ts +2 -2
- package/src/schemas/fields/peppol-payment-means-schema.ts +62 -2
- package/src/schemas/fields/peppol-payment-terms-schema.ts +2 -0
- package/src/schemas/fields/peppol-quantity-schema.ts +4 -2
- package/src/schemas/fields/peppol-reference-schema.ts +20 -1
- package/src/schemas/fields/peppol-tax-category-schema.ts +12 -2
- package/src/schemas/fields/peppol-tax-representative-schema.ts +5 -0
- package/src/schemas/fields/peppol-tax-subtotal-category-schema.ts +3 -0
- package/src/schemas/fields/peppol-tax-subtotal-schema.ts +2 -0
- package/src/schemas/fields/peppol-tax-totals-base-schema.ts +5 -0
- package/src/schemas/peppol-billing-base-schema.ts +47 -7
- package/src/schemas/peppol-credit-note-schema.ts +2 -2
- package/src/schemas/peppol-document-response-document-reference-schema.ts +15 -2
- package/src/schemas/peppol-document-response-document-schema.ts +8 -3
- package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
- package/src/schemas/peppol-document-response-line-response-schema.ts +26 -0
- package/src/schemas/peppol-document-schema.ts +74 -9
- package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +58 -5
- package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +25 -2
- package/src/schemas/peppol-invoice-response-schema.ts +57 -4
- package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +37 -10
- package/src/schemas/peppol-invoice-schema.ts +30 -2
- package/src/schemas/peppol-message-level-response-document-response-schema.ts +10 -0
- package/src/schemas/peppol-message-level-response-party-schema.ts +10 -0
- package/src/schemas/peppol-message-level-response-schema.ts +18 -0
- package/src/schemas/utils/format-quantity-with-unit.ts +19 -0
- package/src/schemas/utils/get-credit-note-type-code-description.ts +12 -0
- package/src/schemas/utils/get-invoice-type-code-description.ts +12 -0
- package/src/schemas/utils/is-valid-credit-note-type-code.ts +13 -0
- package/src/schemas/utils/is-valid-invoice-type-code.ts +13 -0
- package/src/schemas/utils/is-valid-process.ts +13 -0
- package/src/schemas/utils/peppol-base-64-schema.ts +14 -4
- package/src/schemas/utils/peppol-vat-regex-schema.ts +38 -30
- package/src/schemas/utils/peppol-xsd-time-schema.ts +12 -2
- package/src/schemas/utils/quantity-unit-code-to-intl-unit.ts +34 -0
- package/src/schemas/values/additional-document-reference-code-schema.ts +9 -15
- package/src/schemas/values/allowance-charge-reason-code-schema.ts +12 -14
- package/src/schemas/values/application-response-type-code-schema.ts +10 -14
- package/src/schemas/values/charge-reason-code-schema.ts +12 -14
- package/src/schemas/values/credit-note-type-code-schema.ts +8 -14
- package/src/schemas/values/currency-code-schema.ts +13 -16
- package/src/schemas/values/document-type-schemes-schema.ts +9 -5
- package/src/schemas/values/document-type-values-schema.ts +5 -6
- package/src/schemas/values/duty-tax-fee-category-schema.ts +15 -13
- package/src/schemas/values/electronic-codes-schema.ts +10 -12
- package/src/schemas/values/icd-codes-schema.ts +8 -12
- package/src/schemas/values/invoice-status-code-schema.ts +10 -12
- package/src/schemas/values/invoice-type-code-schema.ts +10 -12
- package/src/schemas/values/item-classification-codes-schema.ts +10 -12
- package/src/schemas/values/mime-codes-schema.ts +12 -14
- package/src/schemas/values/op-status-action-schema.ts +10 -12
- package/src/schemas/values/op-status-reason-schema.ts +10 -12
- package/src/schemas/values/participant-identifier-code-schema.ts +10 -13
- package/src/schemas/values/payment-means-code-schema.ts +10 -12
- package/src/schemas/values/peppol-country-code-schema.ts +10 -9
- package/src/schemas/values/peppol-document-type-code-schema.ts +10 -12
- package/src/schemas/values/peppol-document-type-schema.ts +12 -21
- package/src/schemas/values/peppol-process-schema.ts +19 -15
- package/src/schemas/values/process-from-document-type-schema.ts +3 -3
- package/src/schemas/values/quantity-unit-codes-schema.ts +10 -12
- package/src/schemas/values/vat-date-code-schema.ts +12 -5
- package/src/schemas/values/vatex-code-schema.ts +8 -12
- package/src/schematron/errors.ts +14 -0
- package/src/schematron/helpers.ts +451 -0
- package/src/schematron/run-all-rules.ts +10 -0
- package/src/schematron/schematron.ts +25 -0
- package/src/xml/builder-options.ts +9 -0
- package/src/xml/common-xml-options.ts +9 -0
- package/src/xml/nodable-parser.ts +12 -0
- package/src/xml/parser-options.ts +9 -0
- package/dist/index-BBzPjq7o.d.ts.map +0 -1
- package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js +0 -18
- package/dist/invoice-response-code-not-needs-schema-p_RKKNLc.js.map +0 -1
- package/dist/is-valid-abn-160i38PG.js.map +0 -1
- package/dist/is-valid-mod97-0208-CzMOXMO-.js.map +0 -1
- package/dist/message-level-response-profile-id-DBpOW91B.js +0 -9
- package/dist/message-level-response-profile-id-DBpOW91B.js.map +0 -1
- package/dist/nodable-parser-CyDZtLCK.js.map +0 -1
- package/dist/vat-dates.generated-CxFvt7m3.d.ts +0 -68
- package/dist/vat-dates.generated-CxFvt7m3.d.ts.map +0 -1
|
@@ -22,6 +22,7 @@ import { PeppolCreditNote } from '#/schemas/peppol-credit-note-schema.ts';
|
|
|
22
22
|
import { PeppolInvoiceResponse } from '#/schemas/peppol-invoice-response-schema.ts';
|
|
23
23
|
import { PeppolInvoice } from '#/schemas/peppol-invoice-schema.ts';
|
|
24
24
|
import { PeppolMessageLevelResponse } from '#/schemas/peppol-message-level-response-schema.ts';
|
|
25
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
25
26
|
import { builderOptions } from '#/xml/builder-options.ts';
|
|
26
27
|
import { parseXmlNodable } from '#/xml/nodable-parser.ts';
|
|
27
28
|
|
|
@@ -37,9 +38,49 @@ type PeppolDocumentObject = typeof peppolDocumentObjectSchema.Encoded;
|
|
|
37
38
|
|
|
38
39
|
const parseXml = (value: string): XmlNode => parseXmlNodable(value);
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @description Type guard that returns `true` when a decoded value is a {@link PeppolInvoice}.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* isPeppolInvoice(doc); // true for a UBL Invoice
|
|
47
|
+
* ```;
|
|
48
|
+
*
|
|
49
|
+
* @see {@link PeppolDocumentSchema}
|
|
50
|
+
*/
|
|
40
51
|
export const isPeppolInvoice = Schema.is(PeppolInvoice);
|
|
52
|
+
/**
|
|
53
|
+
* @description Type guard that returns `true` when a decoded value is a {@link PeppolCreditNote}.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* isPeppolCreditNote(doc); // true for a UBL CreditNote
|
|
58
|
+
* ```;
|
|
59
|
+
*
|
|
60
|
+
* @see {@link PeppolDocumentSchema}
|
|
61
|
+
*/
|
|
41
62
|
export const isPeppolCreditNote = Schema.is(PeppolCreditNote);
|
|
63
|
+
/**
|
|
64
|
+
* @description Type guard that returns `true` when a decoded value is a {@link PeppolMessageLevelResponse}.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* isPeppolMessageLevelResponse(doc); // true for an MLR ApplicationResponse
|
|
69
|
+
* ```;
|
|
70
|
+
*
|
|
71
|
+
* @see {@link PeppolDocumentSchema}
|
|
72
|
+
*/
|
|
42
73
|
export const isPeppolMessageLevelResponse = Schema.is(PeppolMessageLevelResponse);
|
|
74
|
+
/**
|
|
75
|
+
* @description Type guard that returns `true` when a decoded value is a {@link PeppolInvoiceResponse}.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* isPeppolInvoiceResponse(doc); // true for an invoice response ApplicationResponse
|
|
80
|
+
* ```;
|
|
81
|
+
*
|
|
82
|
+
* @see {@link PeppolDocumentSchema}
|
|
83
|
+
*/
|
|
43
84
|
export const isPeppolInvoiceResponse = Schema.is(PeppolInvoiceResponse);
|
|
44
85
|
|
|
45
86
|
/**
|
|
@@ -94,17 +135,35 @@ const encodeDocumentXml = Effect.fn('encode-peppol-document-xml')(function* (val
|
|
|
94
135
|
|
|
95
136
|
/**
|
|
96
137
|
* @description Union of every supported PEPPOL business document. Members discriminate cleanly: invoice vs credit note via `invoiceLines`/`creditNoteLines`,
|
|
97
|
-
* message-level vs invoice response via the `profileId` literal.
|
|
138
|
+
* message-level vs invoice response via the `profileId` literal. Decodes and encodes XML strings by dispatching on the root element;
|
|
139
|
+
* `ApplicationResponse` is split on `cbc:ProfileID`.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* const doc = Schema.decodeUnknownSync(PeppolDocumentSchema)(xml); // decoded document union
|
|
144
|
+
* ```;
|
|
145
|
+
*
|
|
146
|
+
* @see {@link PeppolDocumentDecoded}
|
|
147
|
+
* @see {@link PeppolDocumentEncoded}
|
|
98
148
|
*/
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
149
|
+
export class PeppolDocumentSchema extends opaque<PeppolDocumentSchema>()(
|
|
150
|
+
peppolDocumentObjectSchema.pipe(
|
|
151
|
+
Schema.encodeTo(Schema.String, {
|
|
152
|
+
encode: SchemaGetter.transformEffect((value, options) => encodeDocumentXml(value, options)),
|
|
153
|
+
decode: SchemaGetter.transformEffect((value, options) => decodeDocumentXml(value, options)),
|
|
154
|
+
})
|
|
155
|
+
)
|
|
156
|
+
) {}
|
|
105
157
|
|
|
106
|
-
|
|
107
|
-
|
|
158
|
+
/**
|
|
159
|
+
* @description Encoded form of {@link PeppolDocumentSchema}: the XML string representation.
|
|
160
|
+
*/
|
|
161
|
+
export type PeppolDocumentEncoded = Schema.Codec.Encoded<typeof PeppolDocumentSchema>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @description Decoded form of {@link PeppolDocumentSchema}: the union of supported document classes.
|
|
165
|
+
*/
|
|
166
|
+
export type PeppolDocumentDecoded = Schema.Schema.Type<typeof PeppolDocumentSchema>;
|
|
108
167
|
|
|
109
168
|
/**
|
|
110
169
|
* @description This defines the types of documents that are sent/received through the peppol network.
|
|
@@ -114,5 +173,11 @@ export type PeppolDocument = PeppolInvoice | PeppolCreditNote;
|
|
|
114
173
|
* @description This defines the types of message that are sent/received through the peppol network.
|
|
115
174
|
*/
|
|
116
175
|
export type PeppolMessage = PeppolMessageLevelResponse | PeppolInvoiceResponse;
|
|
176
|
+
/**
|
|
177
|
+
* @description Every document type supported by {@link PeppolDocumentSchema}: the billing documents and the response messages.
|
|
178
|
+
*/
|
|
117
179
|
export type PeppolAllDocuments = PeppolDocument | PeppolMessage;
|
|
180
|
+
/**
|
|
181
|
+
* @description A line from either a {@link PeppolInvoice} or a {@link PeppolCreditNote}.
|
|
182
|
+
*/
|
|
118
183
|
export type PeppolDocumentLine = PeppolInvoiceLine | PeppolCreditNoteLine;
|
|
@@ -6,9 +6,40 @@ import { PeppolInvoiceResponseDocumentActualResponseStatus } from '#/schemas/pep
|
|
|
6
6
|
import { PeppolIsoDateString } from '#/schemas/peppol-iso-date-string.ts';
|
|
7
7
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @description Response codes that require a clarification in `cac:Status`: `UQ`, `RE` and `CA`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* withStatusCodes; // Schema.Literals(['UQ', 'RE', 'CA'])
|
|
15
|
+
* ```;
|
|
16
|
+
*
|
|
17
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponseWithStatus}
|
|
18
|
+
*/
|
|
9
19
|
export const withStatusCodes = Schema.Literals(invoiceResponseCodeNeedsSchema);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description Response codes that do not require a clarification in `cac:Status`: `AB`, `AP`, `IP` and `PD`.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* withoutStatusCodes; // Schema.Literals(['AB', 'AP', 'IP', 'PD'])
|
|
27
|
+
* ```;
|
|
28
|
+
*
|
|
29
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponseWithoutStatus}
|
|
30
|
+
*/
|
|
10
31
|
export const withoutStatusCodes = Schema.Literals(invoiceResponseCodeNotNeedsSchema);
|
|
11
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @description Invoice response for statuses that do not require a clarification; the `cac:Status` group is optional.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* { responseCode: 'AP', effectiveDate: '2018-08-02' }
|
|
39
|
+
* ```;
|
|
40
|
+
*
|
|
41
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponse}
|
|
42
|
+
*/
|
|
12
43
|
export class PeppolInvoiceResponseDocumentActualResponseWithoutStatus extends opaque<PeppolInvoiceResponseDocumentActualResponseWithoutStatus>()(
|
|
13
44
|
Schema.Struct({
|
|
14
45
|
/**
|
|
@@ -40,6 +71,16 @@ export class PeppolInvoiceResponseDocumentActualResponseWithoutStatus extends op
|
|
|
40
71
|
})
|
|
41
72
|
) {}
|
|
42
73
|
|
|
74
|
+
/**
|
|
75
|
+
* @description Invoice response for statuses that require a clarification; at least one `cac:Status` group is mandatory.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* { responseCode: 'RE', status: [{ statusReason: 'TAX reference not found' }] }
|
|
80
|
+
* ```;
|
|
81
|
+
*
|
|
82
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponse}
|
|
83
|
+
*/
|
|
43
84
|
export class PeppolInvoiceResponseDocumentActualResponseWithStatus extends opaque<PeppolInvoiceResponseDocumentActualResponseWithStatus>()(
|
|
44
85
|
Schema.Struct({
|
|
45
86
|
/**
|
|
@@ -74,9 +115,21 @@ export class PeppolInvoiceResponseDocumentActualResponseWithStatus extends opaqu
|
|
|
74
115
|
})
|
|
75
116
|
) {}
|
|
76
117
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
118
|
+
/**
|
|
119
|
+
* @description Union of the invoice response variants selected by `cbc:ResponseCode`: one that requires a clarification and one that does not.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* { responseCode: 'AP', effectiveDate: '2018-08-02' }
|
|
124
|
+
* ```;
|
|
125
|
+
*
|
|
126
|
+
* @see {@link PeppolInvoiceResponseDocumentResponse}
|
|
127
|
+
*/
|
|
128
|
+
export class PeppolInvoiceResponseDocumentActualResponse extends opaque<PeppolInvoiceResponseDocumentActualResponse>()(
|
|
129
|
+
Schema.Union([PeppolInvoiceResponseDocumentActualResponseWithStatus, PeppolInvoiceResponseDocumentActualResponseWithoutStatus])
|
|
130
|
+
) {}
|
|
81
131
|
|
|
82
|
-
|
|
132
|
+
/**
|
|
133
|
+
* @description Alias of {@link PeppolInvoiceResponseDocumentActualResponse}.
|
|
134
|
+
*/
|
|
135
|
+
export type InvoiceResponseDocumentActualResponse = PeppolInvoiceResponseDocumentActualResponse;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { PeppolInvoiceResponseStatusReasonCode } from '#/schemas/peppol-invoice-response-status-reason-code-schema.ts';
|
|
4
4
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @description Wraps `cac:Condition` inside a status: a detail code and its optional value that further explains the clarification.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* { attributeId: 'BT-75', description: 'EU123456789' }
|
|
12
|
+
* ```;
|
|
13
|
+
*
|
|
14
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponseStatus}
|
|
15
|
+
*/
|
|
6
16
|
export class PeppolInvoiceResponseCondition extends opaque<PeppolInvoiceResponseCondition>()(
|
|
7
17
|
Schema.Struct({
|
|
8
18
|
/**
|
|
@@ -30,6 +40,16 @@ export class PeppolInvoiceResponseCondition extends opaque<PeppolInvoiceResponse
|
|
|
30
40
|
})
|
|
31
41
|
) {}
|
|
32
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @description Wraps `cac:Status` inside an invoice response: an optional clarification code and description plus any condition details.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* { statusReasonCode: { value: 'REF', listId: 'OPStatusReason' }, statusReason: 'TAX reference not found' }
|
|
49
|
+
* ```;
|
|
50
|
+
*
|
|
51
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponse}
|
|
52
|
+
*/
|
|
33
53
|
export class PeppolInvoiceResponseDocumentActualResponseStatus extends opaque<PeppolInvoiceResponseDocumentActualResponseStatus>()(
|
|
34
54
|
Schema.Struct({
|
|
35
55
|
/**
|
|
@@ -39,7 +59,7 @@ export class PeppolInvoiceResponseDocumentActualResponseStatus extends opaque<Pe
|
|
|
39
59
|
*
|
|
40
60
|
* @name `cbc:StatusReasonCode`
|
|
41
61
|
*/
|
|
42
|
-
statusReasonCode: Schema.optional(
|
|
62
|
+
statusReasonCode: Schema.optional(PeppolInvoiceResponseStatusReasonCode),
|
|
43
63
|
/**
|
|
44
64
|
* @description The description of the clarification given for the invoice status.
|
|
45
65
|
*
|
|
@@ -60,4 +80,7 @@ export class PeppolInvoiceResponseDocumentActualResponseStatus extends opaque<Pe
|
|
|
60
80
|
})
|
|
61
81
|
) {}
|
|
62
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @description Alias of {@link PeppolInvoiceResponseDocumentActualResponseStatus}.
|
|
85
|
+
*/
|
|
63
86
|
export type InvoiceResponseDocumentActualResponseStatus = PeppolInvoiceResponseDocumentActualResponseStatus;
|
|
@@ -4,13 +4,23 @@ import { INVOICE_RESPONSE_PROFILE_ID } from '#/constants/invoice-response-profil
|
|
|
4
4
|
import { PeppolContact } from '#/schemas/fields/peppol-contact-schema.ts';
|
|
5
5
|
import { PeppolIdentifier } from '#/schemas/fields/peppol-identifier-schema.ts';
|
|
6
6
|
import { PeppolPartyLegalEntity } from '#/schemas/fields/peppol-party-legal-entity-schema.ts';
|
|
7
|
-
import {
|
|
7
|
+
import { PeppolInvoiceResponseDocumentActualResponse } from '#/schemas/peppol-invoice-response-document-actual-response-schema.ts';
|
|
8
8
|
import { PeppolIsoDateString } from '#/schemas/peppol-iso-date-string.ts';
|
|
9
9
|
import { PeppolMessageLevelResponseParty } from '#/schemas/peppol-message-level-response-party-schema.ts';
|
|
10
10
|
import { PeppolMessageLevelResponse } from '#/schemas/peppol-message-level-response-schema.ts';
|
|
11
11
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
12
|
-
import {
|
|
12
|
+
import { PeppolDocumentTypeCode } from '#/schemas/values/peppol-document-type-code-schema.ts';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* @description Wraps `cac:PartyName` for the seller or buyer on an invoice response: the party's legal or trading name.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* { name: 'Seller Business Name AS' }
|
|
20
|
+
* ```;
|
|
21
|
+
*
|
|
22
|
+
* @see {@link PeppolInvoiceResponseDocumentResponseParty}
|
|
23
|
+
*/
|
|
14
24
|
export class PeppolInvoiceResponseDocumentResponsePartyName extends opaque<PeppolInvoiceResponseDocumentResponsePartyName>()(
|
|
15
25
|
Schema.Struct({
|
|
16
26
|
/**
|
|
@@ -25,6 +35,16 @@ export class PeppolInvoiceResponseDocumentResponsePartyName extends opaque<Peppo
|
|
|
25
35
|
})
|
|
26
36
|
) {}
|
|
27
37
|
|
|
38
|
+
/**
|
|
39
|
+
* @description Party used for the sender and receiver of an invoice response. Extends {@link PeppolMessageLevelResponseParty}.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* { partyLegalEntity: { registrationName: 'Seller Business Name AS' } }
|
|
44
|
+
* ```;
|
|
45
|
+
*
|
|
46
|
+
* @see {@link PeppolInvoiceResponse}
|
|
47
|
+
*/
|
|
28
48
|
export class PeppolInvoiceResponseParty extends opaque<PeppolInvoiceResponseParty>()(
|
|
29
49
|
PeppolMessageLevelResponseParty.pipe(
|
|
30
50
|
Schema.fieldsAssign({
|
|
@@ -37,6 +57,16 @@ export class PeppolInvoiceResponseParty extends opaque<PeppolInvoiceResponsePart
|
|
|
37
57
|
)
|
|
38
58
|
) {}
|
|
39
59
|
|
|
60
|
+
/**
|
|
61
|
+
* @description Sender party of an invoice response. Extends {@link PeppolInvoiceResponseParty} with optional `cac:Contact` details.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* { partyLegalEntity: { registrationName: 'Seller Business Name AS' } }
|
|
66
|
+
* ```;
|
|
67
|
+
*
|
|
68
|
+
* @see {@link PeppolInvoiceResponse}
|
|
69
|
+
*/
|
|
40
70
|
export class PeppolInvoiceResponseSenderParty extends opaque<PeppolInvoiceResponseSenderParty>()(
|
|
41
71
|
PeppolInvoiceResponseParty.pipe(
|
|
42
72
|
Schema.fieldsAssign({
|
|
@@ -69,8 +99,21 @@ export class PeppolInvoiceResponseDocumentResponseParty extends opaque<PeppolInv
|
|
|
69
99
|
})
|
|
70
100
|
) {}
|
|
71
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @description Alias of {@link PeppolInvoiceResponseDocumentResponseParty}.
|
|
104
|
+
*/
|
|
72
105
|
export type PeppolInvoiceDocumentResponseParty = PeppolInvoiceResponseDocumentResponseParty;
|
|
73
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @description Wraps `cac:DocumentReference` inside an invoice response: identifies the invoice the status applies to.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* { id: 'inv-99876', issueDate: '2018-08-01', documentTypeCode: '380' }
|
|
113
|
+
* ```;
|
|
114
|
+
*
|
|
115
|
+
* @see {@link PeppolInvoiceResponseDocumentResponse}
|
|
116
|
+
*/
|
|
74
117
|
export class PeppolInvoiceResponseDocumentReference extends opaque<PeppolInvoiceResponseDocumentReference>()(
|
|
75
118
|
Schema.Struct({
|
|
76
119
|
/**
|
|
@@ -102,10 +145,20 @@ export class PeppolInvoiceResponseDocumentReference extends opaque<PeppolInvoice
|
|
|
102
145
|
*
|
|
103
146
|
* @summary Identifier type code
|
|
104
147
|
*/
|
|
105
|
-
documentTypeCode:
|
|
148
|
+
documentTypeCode: PeppolDocumentTypeCode,
|
|
106
149
|
})
|
|
107
150
|
) {}
|
|
108
151
|
|
|
152
|
+
/**
|
|
153
|
+
* @description Wraps `cac:DocumentResponse` inside an invoice response: the response, the referenced invoice and optional parties.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* { response: { responseCode: 'AP', effectiveDate: '2018-08-02' }, documentReference: { id: 'inv-99876', documentTypeCode: '380' } }
|
|
158
|
+
* ```;
|
|
159
|
+
*
|
|
160
|
+
* @see {@link PeppolInvoiceResponse}
|
|
161
|
+
*/
|
|
109
162
|
export class PeppolInvoiceResponseDocumentResponse extends opaque<PeppolInvoiceResponseDocumentResponse>()(
|
|
110
163
|
Schema.Struct({
|
|
111
164
|
/**
|
|
@@ -115,7 +168,7 @@ export class PeppolInvoiceResponseDocumentResponse extends opaque<PeppolInvoiceR
|
|
|
115
168
|
*
|
|
116
169
|
* @cardinality (1..1)
|
|
117
170
|
*/
|
|
118
|
-
response:
|
|
171
|
+
response: PeppolInvoiceResponseDocumentActualResponse,
|
|
119
172
|
/**
|
|
120
173
|
* @summary Document reference
|
|
121
174
|
*
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
3
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { PeppolOpStatusAction } from '#/schemas/values/op-status-action-schema.ts';
|
|
5
|
+
import { PeppolOpStatusReason } from '#/schemas/values/op-status-reason-schema.ts';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @description Status clarification reason (`cbc:StatusReasonCode` with `@listId="OPStatusReason"`), a value from the OPStatusReason code list.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* { value: 'REF', listId: 'OPStatusReason' }
|
|
13
|
+
* ```;
|
|
14
|
+
*
|
|
15
|
+
* @see {@link PeppolInvoiceResponseStatusReasonCode}
|
|
16
|
+
*/
|
|
7
17
|
export class PeppolInvoiceResponseStatusReasonCodeReason extends opaque<PeppolInvoiceResponseStatusReasonCodeReason>()(
|
|
8
18
|
Schema.Struct({
|
|
9
|
-
value:
|
|
19
|
+
value: PeppolOpStatusReason,
|
|
10
20
|
/**
|
|
11
21
|
* @description List identifier for clarification.
|
|
12
22
|
*
|
|
@@ -18,9 +28,19 @@ export class PeppolInvoiceResponseStatusReasonCodeReason extends opaque<PeppolIn
|
|
|
18
28
|
})
|
|
19
29
|
) {}
|
|
20
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @description Status clarification action (`cbc:StatusReasonCode` with `@listId="OPStatusAction"`), a value from the OPStatusAction code list.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* { value: 'PIN', listId: 'OPStatusAction' }
|
|
37
|
+
* ```;
|
|
38
|
+
*
|
|
39
|
+
* @see {@link PeppolInvoiceResponseStatusReasonCode}
|
|
40
|
+
*/
|
|
21
41
|
export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolInvoiceResponseStatusReasonCodeAction>()(
|
|
22
42
|
Schema.Struct({
|
|
23
|
-
value:
|
|
43
|
+
value: PeppolOpStatusAction,
|
|
24
44
|
/**
|
|
25
45
|
* @description List identifier for clarification.
|
|
26
46
|
*
|
|
@@ -32,9 +52,16 @@ export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolIn
|
|
|
32
52
|
})
|
|
33
53
|
) {}
|
|
34
54
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @description Union of the accepted status clarification reasons and actions on an invoice response.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* { value: 'REF', listId: 'OPStatusReason' }
|
|
61
|
+
* ```;
|
|
62
|
+
*
|
|
63
|
+
* @see {@link PeppolInvoiceResponseDocumentActualResponseStatus}
|
|
64
|
+
*/
|
|
65
|
+
export class PeppolInvoiceResponseStatusReasonCode extends opaque<PeppolInvoiceResponseStatusReasonCode>()(
|
|
66
|
+
Schema.Union([PeppolInvoiceResponseStatusReasonCodeAction, PeppolInvoiceResponseStatusReasonCodeReason])
|
|
67
|
+
) {}
|
|
@@ -4,10 +4,38 @@ import { PeppolInvoiceLine } from '#/schemas/fields/peppol-invoice-line-schema.t
|
|
|
4
4
|
import { PeppolBillingBase } from '#/schemas/peppol-billing-base-schema.ts';
|
|
5
5
|
import { PeppolIsoDateString } from '#/schemas/peppol-iso-date-string.ts';
|
|
6
6
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
7
|
-
import {
|
|
7
|
+
import { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-schema.ts';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @description Wraps the `cac:ProjectReference` element on an invoice: an identifier of the project the invoice relates to.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* { id: 'project-123' }
|
|
15
|
+
* ```;
|
|
16
|
+
*
|
|
17
|
+
* @see {@link PeppolInvoice}
|
|
18
|
+
*/
|
|
9
19
|
export class PeppolProjectReference extends opaque<PeppolProjectReference>()(Schema.Struct({ id: Schema.String })) {}
|
|
10
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @description UBL `Invoice` for PEPPOL BIS Billing 3.0. Extends {@link PeppolBillingBase} with the due date, type code, lines and project reference.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* {
|
|
27
|
+
* customizationId: 'urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0',
|
|
28
|
+
* profileId: 'urn:fdc:peppol.eu:2017:poacc:billing:01:1.0',
|
|
29
|
+
* id: '33445566',
|
|
30
|
+
* issueDate: '2017-11-01',
|
|
31
|
+
* documentCurrencyCode: 'EUR',
|
|
32
|
+
* invoiceTypeCode: '380'
|
|
33
|
+
* }
|
|
34
|
+
* ```;
|
|
35
|
+
*
|
|
36
|
+
* @see {@link PeppolBillingBase}
|
|
37
|
+
* @see {@link PeppolCreditNote}
|
|
38
|
+
*/
|
|
11
39
|
export class PeppolInvoice extends opaque<PeppolInvoice>()(
|
|
12
40
|
Schema.Struct({
|
|
13
41
|
...PeppolBillingBase.fields,
|
|
@@ -34,7 +62,7 @@ export class PeppolInvoice extends opaque<PeppolInvoice>()(
|
|
|
34
62
|
*
|
|
35
63
|
* @name cbc:InvoiceTypeCode
|
|
36
64
|
*/
|
|
37
|
-
invoiceTypeCode:
|
|
65
|
+
invoiceTypeCode: PeppolInvoiceTypeCode,
|
|
38
66
|
/**
|
|
39
67
|
* @summary PROJECT REFERENCE
|
|
40
68
|
*
|
|
@@ -5,6 +5,16 @@ import { PeppolDocumentResponseDocument } from '#/schemas/peppol-document-respon
|
|
|
5
5
|
import { PeppolDocumentResponseLineResponse } from '#/schemas/peppol-document-response-line-response-schema.ts';
|
|
6
6
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @description Wraps `cac:DocumentResponse` inside a message level response: the response, the document reference and any per-line responses.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* { response: { responseCode: 'RE' }, documentReference: { id: 'EnvelopeID-12345' }, lineResponse: [] }
|
|
14
|
+
* ```;
|
|
15
|
+
*
|
|
16
|
+
* @see {@link PeppolMessageLevelResponse}
|
|
17
|
+
*/
|
|
8
18
|
export class PeppolMessageLevelResponseDocumentResponse extends opaque<PeppolMessageLevelResponseDocumentResponse>()(
|
|
9
19
|
Schema.Struct({
|
|
10
20
|
/**
|
|
@@ -3,6 +3,16 @@ import { Schema } from 'effect';
|
|
|
3
3
|
import { PeppolIdentifier } from '#/schemas/fields/peppol-identifier-schema.ts';
|
|
4
4
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @description Party used as `cac:SenderParty` or `cac:ReceiverParty` on a message level response, holding the party's electronic address.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* { endpointId: { id: '7300010000001', schemeId: '0088' } }
|
|
12
|
+
* ```;
|
|
13
|
+
*
|
|
14
|
+
* @see {@link PeppolMessageLevelResponse}
|
|
15
|
+
*/
|
|
6
16
|
export class PeppolMessageLevelResponseParty extends opaque<PeppolMessageLevelResponseParty>()(
|
|
7
17
|
Schema.Struct({
|
|
8
18
|
/**
|
|
@@ -7,6 +7,24 @@ import { PeppolMessageLevelResponseParty } from '#/schemas/peppol-message-level-
|
|
|
7
7
|
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
8
8
|
import { PeppolXsdTime } from '#/schemas/utils/peppol-xsd-time-schema.ts';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @description UBL `ApplicationResponse` message level response for PEPPOL BIS Billing 3.0 (profile `urn:fdc:peppol.eu:poacc:bis:mlr:3`).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* {
|
|
16
|
+
* customizationId: 'urn:fdc:peppol.eu:poacc:trns:mlr:3',
|
|
17
|
+
* profileId: 'urn:fdc:peppol.eu:poacc:bis:mlr:3',
|
|
18
|
+
* id: '23',
|
|
19
|
+
* issueDate: '2017-11-01',
|
|
20
|
+
* senderParty: {},
|
|
21
|
+
* receiverParty: {},
|
|
22
|
+
* documentResponse: { response: { responseCode: 'RE' }, documentReference: { id: 'EnvelopeID-12345' }, lineResponse: [] }
|
|
23
|
+
* }
|
|
24
|
+
* ```;
|
|
25
|
+
*
|
|
26
|
+
* @see {@link PeppolInvoiceResponse}
|
|
27
|
+
*/
|
|
10
28
|
export class PeppolMessageLevelResponse extends opaque<PeppolMessageLevelResponse>()(
|
|
11
29
|
Schema.Struct({
|
|
12
30
|
/**
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import { quantityToIntlUnitMap } from '#/schemas/utils/quantity-unit-code-to-intl-unit.ts';
|
|
2
2
|
import { quantityUnitCodes } from '#/values/quantity-unit-codes.generated';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @description Formats a quantity and its unit code for a locale. Uses `Intl.NumberFormat` for mapped codes, otherwise the code list name.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* formatQuantityWithUnit(5, 'KGM', 'en-US', 'long'); // '5 kilograms'
|
|
10
|
+
* formatQuantityWithUnit(10, 'EA'); // '10 each'
|
|
11
|
+
* ```;
|
|
12
|
+
*
|
|
13
|
+
* @param value - The numeric quantity to format.
|
|
14
|
+
* @param code - The UN/ECE Rec 20 unit code to render, for example `KGM` or `MTR`.
|
|
15
|
+
* @param locale - BCP 47 locale tag passed to `Intl.NumberFormat`. Defaults to `'en-US'`.
|
|
16
|
+
* @param unitDisplay - `Intl` unit display style: `'short'`, `'narrow'`, or `'long'`. Defaults to `'short'`.
|
|
17
|
+
*
|
|
18
|
+
* @returns The formatted quantity and unit, for example `'5 kilograms'`. Falls back to `<number> <name>` when the code has no `Intl` unit or `Intl`
|
|
19
|
+
* rejects the unit.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link quantityUnitCodeToIntlUnit}
|
|
22
|
+
*/
|
|
4
23
|
export function formatQuantityWithUnit(
|
|
5
24
|
value: number,
|
|
6
25
|
code: string,
|
|
@@ -2,6 +2,18 @@ import type { PeppolCreditNoteTypeCode } from '#/schemas/values/credit-note-type
|
|
|
2
2
|
|
|
3
3
|
import { creditNoteTypeCodes } from '#/values/credit-notes-type-codes.generated';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @description Returns the human-readable description of a PEPPOL credit note type code (UNCL1001 subset).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* getCreditNoteTypeCodeDescription('381'); // 'Credit note'
|
|
11
|
+
* ```;
|
|
12
|
+
*
|
|
13
|
+
* @param code - A valid {@link PeppolCreditNoteTypeCode}, for example `'381'`.
|
|
14
|
+
*
|
|
15
|
+
* @returns The description registered for the code, for example `'Credit note'`.
|
|
16
|
+
*/
|
|
5
17
|
export function getCreditNoteTypeCodeDescription(code: PeppolCreditNoteTypeCode): string {
|
|
6
18
|
return (creditNoteTypeCodes as Record<string, string>)[code] as string;
|
|
7
19
|
}
|
|
@@ -2,6 +2,18 @@ import type { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-s
|
|
|
2
2
|
|
|
3
3
|
import { invoiceTypeCodes } from '#/values/invoice-type-codes.generated';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @description Returns the human-readable description of a PEPPOL invoice type code (UNCL1001 subset).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* getInvoiceTypeCodeDescription('380'); // 'Commercial invoice'
|
|
11
|
+
* ```;
|
|
12
|
+
*
|
|
13
|
+
* @param code - A valid {@link PeppolInvoiceTypeCode}, for example `'380'`.
|
|
14
|
+
*
|
|
15
|
+
* @returns The description registered for the code, for example `'Commercial invoice'`.
|
|
16
|
+
*/
|
|
5
17
|
export function getInvoiceTypeCodeDescription(code: PeppolInvoiceTypeCode): string {
|
|
6
18
|
return (invoiceTypeCodes as Record<string, string>)[code] as string;
|
|
7
19
|
}
|
|
@@ -2,6 +2,19 @@ import type { PeppolCreditNoteTypeCode } from '#/schemas/values/credit-note-type
|
|
|
2
2
|
|
|
3
3
|
import { creditNoteTypeCodes } from '#/values/credit-notes-type-codes.generated';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @description Type guard for PEPPOL credit note type codes (UNCL1001 subset).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* isValidCreditNoteTypeCode('381'); // true
|
|
11
|
+
* isValidCreditNoteTypeCode('UNKNOWN'); // false
|
|
12
|
+
* ```;
|
|
13
|
+
*
|
|
14
|
+
* @param code - The string to test.
|
|
15
|
+
*
|
|
16
|
+
* @returns `true` when `code` is a known credit note type code, narrowing it to {@link PeppolCreditNoteTypeCode}; otherwise `false`.
|
|
17
|
+
*/
|
|
5
18
|
export function isValidCreditNoteTypeCode(code: string): code is PeppolCreditNoteTypeCode {
|
|
6
19
|
return code in creditNoteTypeCodes;
|
|
7
20
|
}
|
|
@@ -2,6 +2,19 @@ import type { PeppolInvoiceTypeCode } from '#/schemas/values/invoice-type-code-s
|
|
|
2
2
|
|
|
3
3
|
import { invoiceTypeCodes } from '#/values/invoice-type-codes.generated';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @description Type guard for PEPPOL invoice type codes (UNCL1001 subset).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* isValidInvoiceTypeCode('380'); // true
|
|
11
|
+
* isValidInvoiceTypeCode('UNKNOWN'); // false
|
|
12
|
+
* ```;
|
|
13
|
+
*
|
|
14
|
+
* @param code - The string to test.
|
|
15
|
+
*
|
|
16
|
+
* @returns `true` when `code` is a known invoice type code, narrowing it to {@link PeppolInvoiceTypeCode}; otherwise `false`.
|
|
17
|
+
*/
|
|
5
18
|
export function isValidInvoiceTypeCode(code: string): code is PeppolInvoiceTypeCode {
|
|
6
19
|
return code in invoiceTypeCodes;
|
|
7
20
|
}
|
|
@@ -2,6 +2,19 @@ import type { PeppolProcesses } from '#/schemas/values/peppol-process-schema.ts'
|
|
|
2
2
|
|
|
3
3
|
import { processesList } from '#/values/processes.generated';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @description Type guard for PEPPOL business process identifiers of the form `<scheme>::<value>`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* isValidProcess('cenbii-procid-ubl::urn:fdc:peppol.eu:2017:poacc:billing:01:1.0'); // true
|
|
11
|
+
* isValidProcess('cenbii-procid-ubl::urn:not:a:process'); // false
|
|
12
|
+
* ```;
|
|
13
|
+
*
|
|
14
|
+
* @param code - The process identifier to test.
|
|
15
|
+
*
|
|
16
|
+
* @returns `true` when `code` appears in {@link processesList}, narrowing it to {@link PeppolProcesses}; otherwise `false`.
|
|
17
|
+
*/
|
|
5
18
|
export function isValidProcess(code: string): code is PeppolProcesses {
|
|
6
19
|
return processesList.includes(code);
|
|
7
20
|
}
|