@endevops/peppol-schema 0.1.3 → 0.1.5
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-XG-N6PcG.d.ts} +1702 -724
- package/dist/index-XG-N6PcG.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1247 -200
- 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 +458 -7
- 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 +1 -1
- 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/decoders/fields/decode-invoice-message-document-party.ts +2 -2
- package/src/decoders/fields/decode-parties-tax-scheme.ts +2 -2
- package/src/decoders/fields/decode-party-legal-entity.ts +2 -2
- package/src/decoders/fields/decode-party-tax-scheme.ts +2 -2
- package/src/decoders/fields/decode-tax-category.ts +1 -1
- package/src/decoders/fields/decode-tax-representative-party.ts +2 -2
- package/src/decoders/fields/encode-message-party.ts +2 -2
- package/src/decoders/fields/encode-parties-tax-scheme.ts +3 -3
- package/src/decoders/fields/encode-party-legal-entity.ts +1 -1
- package/src/decoders/fields/encode-party-tax-scheme.ts +2 -2
- package/src/decoders/fields/encode-tax-representative-party.ts +2 -2
- 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 +61 -20
- package/src/schemas/fields/peppol-address-schema.ts +25 -2
- package/src/schemas/fields/peppol-allowance-charge-schema.ts +63 -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 +56 -8
- package/src/schemas/fields/peppol-line-item-schema.ts +66 -6
- 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 +10 -2
- package/src/schemas/fields/peppol-party-tax-scheme-schema.ts +4 -4
- package/src/schemas/fields/peppol-payee-party-schema.ts +8 -8
- 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 +2 -2
- 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 +3 -3
- package/src/schemas/peppol-billing-base-schema.ts +49 -9
- package/src/schemas/peppol-credit-note-schema.ts +2 -2
- package/src/schemas/peppol-document-response-document-reference-schema.ts +12 -4
- package/src/schemas/peppol-document-response-document-schema.ts +5 -5
- package/src/schemas/peppol-document-response-line-response-content-schema.ts +22 -2
- package/src/schemas/peppol-document-response-line-response-schema.ts +23 -2
- package/src/schemas/peppol-document-schema.ts +69 -6
- package/src/schemas/peppol-invoice-response-document-actual-response-schema.ts +53 -4
- package/src/schemas/peppol-invoice-response-document-actual-response-status-schema.ts +22 -4
- package/src/schemas/peppol-invoice-response-schema.ts +54 -6
- package/src/schemas/peppol-invoice-response-status-reason-code-schema.ts +36 -8
- 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 +7 -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 +7 -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 +457 -11
- 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
|
@@ -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,17 @@ export class PeppolInvoiceResponseStatusReasonCodeAction extends opaque<PeppolIn
|
|
|
32
52
|
})
|
|
33
53
|
) {}
|
|
34
54
|
|
|
35
|
-
|
|
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 Schema.Union([
|
|
36
66
|
PeppolInvoiceResponseStatusReasonCodeAction,
|
|
37
67
|
PeppolInvoiceResponseStatusReasonCodeReason,
|
|
38
|
-
])
|
|
39
|
-
|
|
40
|
-
export type PeppolInvoiceResponseStatusReasonCode = typeof peppolInvoiceResponseStatusReasonCodeSchema.Type;
|
|
68
|
+
]) {}
|
|
@@ -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
|
}
|
|
@@ -25,9 +25,12 @@ const BASE64_RE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=
|
|
|
25
25
|
/**
|
|
26
26
|
* @description RFC 4648 base64 string (PEM / MIME / XML line endings tolerated). Effect port of `base64Schema` (`z.string().check(z.refine(...))`): strips CRLF /
|
|
27
27
|
* LF line endings before testing the quantum regex.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const value = 'SGVsbG8=';
|
|
32
|
+
* ```;
|
|
28
33
|
*/
|
|
29
|
-
export
|
|
34
|
+
export class PeppolBase64 extends Schema.String.check(Schema.makeFilter((val: string) => BASE64_RE.test(val.replace(/\r?\n/g, '')))).annotate({
|
|
30
35
|
message: 'Invalid base64',
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
export type Base64 = typeof peppolBase64Schema.Type;
|
|
36
|
+
}) {}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
3
|
import { isValidMod97_0208 } from '#/peppol-validations/is-valid-mod97-0208.ts';
|
|
4
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @description Belgian VAT number (`BE` + 10 digits with mod 97-0208 check digits). Effect port of the `BE` member of `vatRegexSchema`: prefix, exact length,
|
|
@@ -16,34 +17,41 @@ const belgianVat = Schema.String.check(
|
|
|
16
17
|
/**
|
|
17
18
|
* @description EU VAT identification number (one member per member-state prefix/pattern). Effect port of `vatRegexSchema` (`z.union([...])` of
|
|
18
19
|
* `z.string().check(...)` members): each member keeps its original prefix + pattern checks as `Schema.String.check` filters.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const value = 'DE123456789';
|
|
24
|
+
* ```;
|
|
19
25
|
*/
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
export class PeppolVatRegex extends opaque<PeppolVatRegex>()(
|
|
27
|
+
Schema.Union([
|
|
28
|
+
belgianVat,
|
|
29
|
+
Schema.String.check(Schema.isStartsWith('AT'), Schema.isPattern(/^ATU\d{8}$/)),
|
|
30
|
+
Schema.String.check(Schema.isStartsWith('BG'), Schema.isPattern(/^BG\d{9,10}$/)),
|
|
31
|
+
Schema.String.check(Schema.isStartsWith('CY'), Schema.isPattern(/^CY\d{8}L$/)),
|
|
32
|
+
Schema.String.check(Schema.isStartsWith('CZ'), Schema.isPattern(/^CZ\d{8,10}$/)),
|
|
33
|
+
Schema.String.check(Schema.isStartsWith('DE'), Schema.isPattern(/^DE\d{9}$/)),
|
|
34
|
+
Schema.String.check(Schema.isStartsWith('DK'), Schema.isPattern(/^DK\d{8}$/)),
|
|
35
|
+
Schema.String.check(Schema.isStartsWith('EE'), Schema.isPattern(/^EE\d{9}$/)),
|
|
36
|
+
Schema.String.check(Schema.isStartsWith('EL'), Schema.isPattern(/^EL\d{9}$/)),
|
|
37
|
+
Schema.String.check(Schema.isStartsWith('GR'), Schema.isPattern(/^GR\d{9}$/)),
|
|
38
|
+
Schema.String.check(Schema.isStartsWith('ES'), Schema.isPattern(/^ES[0-9A-Z]\d{7}[0-9A-Z]$/)),
|
|
39
|
+
Schema.String.check(Schema.isStartsWith('FI'), Schema.isPattern(/^FI\d{8}$/)),
|
|
40
|
+
Schema.String.check(Schema.isStartsWith('FR'), Schema.isPattern(/^FR[0-9A-Z]{2}\d{9}$/)),
|
|
41
|
+
Schema.String.check(Schema.isStartsWith('GB'), Schema.isPattern(/^GB(\d{9}(\d{3})?|[A-Z]{2}\d{3})$/)),
|
|
42
|
+
Schema.String.check(Schema.isStartsWith('HU'), Schema.isPattern(/^HU\d{8}$/)),
|
|
43
|
+
Schema.String.check(Schema.isStartsWith('IE'), Schema.isPattern(/^IE\dS\d{5}L$/)),
|
|
44
|
+
Schema.String.check(Schema.isStartsWith('IT'), Schema.isPattern(/^IT\d{11}$/)),
|
|
45
|
+
Schema.String.check(Schema.isStartsWith('LT'), Schema.isPattern(/^LT(\d{9}|\d{12})$/)),
|
|
46
|
+
Schema.String.check(Schema.isStartsWith('LU'), Schema.isPattern(/^LU\d{8}$/)),
|
|
47
|
+
Schema.String.check(Schema.isStartsWith('LV'), Schema.isPattern(/^LV\d{11}$/)),
|
|
48
|
+
Schema.String.check(Schema.isStartsWith('MT'), Schema.isPattern(/^MT\d{8}$/)),
|
|
49
|
+
Schema.String.check(Schema.isStartsWith('NL'), Schema.isPattern(/^NL\d{9}B\d{2}$/)),
|
|
50
|
+
Schema.String.check(Schema.isStartsWith('PL'), Schema.isPattern(/^PL\d{10}$/)),
|
|
51
|
+
Schema.String.check(Schema.isStartsWith('PT'), Schema.isPattern(/^PT\d{9}$/)),
|
|
52
|
+
Schema.String.check(Schema.isStartsWith('RO'), Schema.isPattern(/^RO\d{2,10}$/)),
|
|
53
|
+
Schema.String.check(Schema.isStartsWith('SE'), Schema.isPattern(/^SE\d{12}$/)),
|
|
54
|
+
Schema.String.check(Schema.isStartsWith('SI'), Schema.isPattern(/^SI\d{8}$/)),
|
|
55
|
+
Schema.String.check(Schema.isStartsWith('SK'), Schema.isPattern(/^SK\d{10}$/)),
|
|
56
|
+
])
|
|
57
|
+
) {}
|
|
@@ -17,9 +17,14 @@ const numberFromString = (value: string | undefined): number => {
|
|
|
17
17
|
/**
|
|
18
18
|
* @description Parse a timezone offset from a string. The string must be in the format `(+|-)HH:MM` where `HH` and `MM` are two digits.
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* parseZoneOffsetFromString('+01:00'); // a +01:00 zone offset
|
|
23
|
+
* ```;
|
|
21
24
|
*
|
|
22
|
-
* @
|
|
25
|
+
* @param tz - The timezone offset string.
|
|
26
|
+
*
|
|
27
|
+
* @returns A `DateTime.Zone` offset built from the parsed hours and minutes, or `undefined` when `tz` does not match the offset pattern.
|
|
23
28
|
*
|
|
24
29
|
* @internal
|
|
25
30
|
*/
|
|
@@ -36,6 +41,11 @@ export const parseZoneOffsetFromString = (tz: `+${number}:${number}` | `-${numbe
|
|
|
36
41
|
/**
|
|
37
42
|
* @description XSD `time` lexical value (`HH:MM:SS` with optional fractional seconds and timezone). Effect port of `xsdTime` (`z.string().check(z.regex(...))`):
|
|
38
43
|
* keeps the value as a plain string and only validates the shape.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const value = '12:30:45+01:00';
|
|
48
|
+
* ```;
|
|
39
49
|
*/
|
|
40
50
|
export class PeppolXsdTime extends opaque<PeppolXsdTime>()(
|
|
41
51
|
Schema.String.check(
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { PeppolQuantityUnitCode } from '#/schemas/values/quantity-unit-codes-schema.ts';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @description String union of `Intl.NumberFormat` unit identifiers for base units such as length, area, volume, mass, and temperature.
|
|
5
|
+
*/
|
|
3
6
|
export type BaseIntlUnit =
|
|
4
7
|
| 'acre'
|
|
5
8
|
| 'bit'
|
|
@@ -36,10 +39,26 @@ export type BaseIntlUnit =
|
|
|
36
39
|
| 'terabit'
|
|
37
40
|
| 'terabyte'
|
|
38
41
|
| 'yard';
|
|
42
|
+
/**
|
|
43
|
+
* @description String union of `Intl.NumberFormat` unit identifiers for time units, used on their own and as the denominator of a rate.
|
|
44
|
+
*/
|
|
39
45
|
export type TimeIntlUnit = 'nanosecond' | 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
|
40
46
|
|
|
47
|
+
/**
|
|
48
|
+
* @description Any `Intl.NumberFormat` unit identifier supported by this module: a {@link BaseIntlUnit}, a {@link TimeIntlUnit}, or a rate such as
|
|
49
|
+
* `'kilometer-per-hour'`.
|
|
50
|
+
*/
|
|
41
51
|
export type IntlUnit = BaseIntlUnit | TimeIntlUnit | `${BaseIntlUnit}-per-${TimeIntlUnit}`;
|
|
42
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @description Maps UN/ECE Rec 20 quantity unit codes to `Intl.NumberFormat` unit identifiers. Unmapped codes are omitted.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* quantityToIntlUnitMap.KGM; // 'kilogram'
|
|
59
|
+
* quantityToIntlUnitMap.KMH; // 'kilometer-per-hour'
|
|
60
|
+
* ```;
|
|
61
|
+
*/
|
|
43
62
|
export const quantityToIntlUnitMap = {
|
|
44
63
|
CMT: 'centimeter',
|
|
45
64
|
MTR: 'meter',
|
|
@@ -106,6 +125,21 @@ export const quantityToIntlUnitMap = {
|
|
|
106
125
|
'4M': 'gram-per-hour' as IntlUnit,
|
|
107
126
|
} satisfies Partial<Record<string, IntlUnit>>;
|
|
108
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @description Looks up the `Intl.NumberFormat` unit identifier for a UN/ECE Rec 20 quantity unit code.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* quantityUnitCodeToIntlUnit('KGM'); // 'kilogram'
|
|
134
|
+
* quantityUnitCodeToIntlUnit('EA'); // undefined
|
|
135
|
+
* ```;
|
|
136
|
+
*
|
|
137
|
+
* @param code - A quantity unit code, typed as {@link PeppolQuantityUnitCode} but accepting any string.
|
|
138
|
+
*
|
|
139
|
+
* @returns The matching {@link IntlUnit}, or `undefined` when the code has no `Intl` unit mapping.
|
|
140
|
+
*
|
|
141
|
+
* @see {@link quantityToIntlUnitMap}
|
|
142
|
+
*/
|
|
109
143
|
export function quantityUnitCodeToIntlUnit(code: PeppolQuantityUnitCode | (string & {})): IntlUnit | undefined {
|
|
110
144
|
return (quantityToIntlUnitMap as Record<string, IntlUnit>)[code];
|
|
111
145
|
}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { additionalDocumentReferenceCodesKeys } from '#/values/additional-document-reference-codes.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description
|
|
7
|
+
* @description An additional document reference code from the PEPPOL subset of UNCL 1153 (invoiced object identifier scheme).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @description Validates an additional document reference code against the PEPPOL subset of UNCL 1153 (reference qualifiers).
|
|
15
|
-
*
|
|
16
|
-
* @param error - The custom error message to use when validation fails. Defaults to the generic message.
|
|
17
|
-
*
|
|
18
|
-
* @returns An Effect schema that accepts only valid additional document reference codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'AAA';
|
|
12
|
+
* ```;
|
|
19
13
|
*
|
|
20
14
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL1153/
|
|
21
15
|
* @see {@link additionalDocumentReferenceCodesKeys}
|
|
22
16
|
*/
|
|
23
|
-
export
|
|
24
|
-
Schema.brand('PeppolAdditionalDocumentReferenceCode')
|
|
25
|
-
)
|
|
17
|
+
export class PeppolAdditionalDocumentReferenceCode extends opaque<PeppolAdditionalDocumentReferenceCode>()(
|
|
18
|
+
Schema.Literals(additionalDocumentReferenceCodesKeys).pipe(Schema.brand('PeppolAdditionalDocumentReferenceCode'))
|
|
19
|
+
) {}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { allowanceChargeReasonCodesKeys } from '#/values/allowance-charge-reason-codes.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description An allowance or charge reason code
|
|
7
|
+
* @description An allowance or charge reason code from the PEPPOL subset of UNCL 5189 (D.16B).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Validates an allowance or charge reason code against the PEPPOL subset of UNCL 5189 (D.16B).
|
|
14
|
-
*
|
|
15
|
-
* @param error - The custom error message to use when validation fails.
|
|
16
|
-
*
|
|
17
|
-
* @returns An Effect schema that accepts only valid allowance/charge reason codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* '41';
|
|
12
|
+
* ```;
|
|
18
13
|
*
|
|
19
14
|
* @validations
|
|
20
15
|
* - PEPPOL-EN16931-CL002: Document allowance reason code MUST be according to the subset of UNCL 5189 D.16B.
|
|
21
16
|
*
|
|
22
17
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL5189/
|
|
18
|
+
* @see {@link allowanceChargeReasonCodesKeys}
|
|
23
19
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export class PeppolAllowanceChargeReasonCode extends opaque<PeppolAllowanceChargeReasonCode>()(
|
|
21
|
+
Schema.Literals(allowanceChargeReasonCodesKeys)
|
|
22
|
+
.pipe(Schema.brand('PeppolAllowanceChargeReasonCode'))
|
|
23
|
+
.annotate({ documentation: 'PEPPOL-EN16931-CL002: Reason code MUST be according to subset of UNCL 5189 D.16B.' })
|
|
24
|
+
) {}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
5
4
|
import { applicationResponseTypeCodesKeys } from '#/values/application-response-type-codes.generated';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
* @description An application response type code
|
|
9
|
-
*
|
|
10
|
-
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4343/
|
|
11
|
-
*/
|
|
12
|
-
export type PeppolApplicationResponseTypeCode = ApplicationResponseTypeCodesKeys;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @description Validates an application response type code against the PEPPOL subset of UNCL 4343.
|
|
16
|
-
*
|
|
17
|
-
* @param error - The custom error message to use when validation fails.
|
|
7
|
+
* @description An application response type code from the PEPPOL subset of UNCL 4343.
|
|
18
8
|
*
|
|
19
|
-
* @
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'AB';
|
|
12
|
+
* ```;
|
|
20
13
|
*
|
|
21
14
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL4343/
|
|
15
|
+
* @see {@link applicationResponseTypeCodesKeys}
|
|
22
16
|
*/
|
|
23
|
-
export
|
|
17
|
+
export class PeppolApplicationResponseTypeCode extends opaque<PeppolApplicationResponseTypeCode>()(
|
|
18
|
+
Schema.Literals(applicationResponseTypeCodesKeys)
|
|
19
|
+
) {}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { Schema } from 'effect';
|
|
2
2
|
|
|
3
|
+
import { opaque } from '#/schemas/utils/opaque.ts';
|
|
3
4
|
import { chargeReasonCodesKeys } from '#/values/charge-reason-codes.generated';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* @description A charge reason code
|
|
7
|
+
* @description A charge reason code from the PEPPOL subset of UNCL 7161 (D.16B).
|
|
7
8
|
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Validates a charge reason code against the PEPPOL subset of UNCL 7161 (D.16B).
|
|
14
|
-
*
|
|
15
|
-
* @param error - The custom error message to use when validation fails.
|
|
16
|
-
*
|
|
17
|
-
* @returns An Effect schema that accepts only valid charge reason codes.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* 'AA';
|
|
12
|
+
* ```;
|
|
18
13
|
*
|
|
19
14
|
* @validations
|
|
20
15
|
* - PEPPOL-EN16931-CL003: Charge reason code MUST be according to UNCL 7161 D.16B.
|
|
21
16
|
*
|
|
22
17
|
* @see https://docs.peppol.eu/poacc/billing/3.0/codelist/UNCL7161/
|
|
18
|
+
* @see {@link chargeReasonCodesKeys}
|
|
23
19
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export class PeppolChargeReasonCode extends opaque<PeppolChargeReasonCode>()(
|
|
21
|
+
Schema.Literals(chargeReasonCodesKeys)
|
|
22
|
+
.pipe(Schema.brand('PeppolChargeReasonCode'))
|
|
23
|
+
.annotate({ documentation: 'PEPPOL-EN16931-CL003: Reason code MUST be according to UNCL 7161 D.16B.' })
|
|
24
|
+
) {}
|