diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0863c47..0d7a21e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -34,7 +34,7 @@ jobs: # fixtures. services: phorm: - image: phelger/phorm:latest + image: phelger/phorm:2.2.15 ports: - 8080:8080 diff --git a/README.md b/README.md index f554661..78b61ed 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ This module implements the Peppol billing models as a set of GOBL tax addons: beyond VAT (such as GST). Jurisdiction-specific rules are applied according to the document's tax regime: Australian (`AU`) and New Zealand (`NZ`) documents are also validated against the - [PINT A-NZ](https://docs.peppol.eu/poac/aunz/pint-aunz/bis/) rules. + [PINT A-NZ](https://docs.peppol.eu/poac/aunz/pint-aunz/bis/) rules, and UAE + (`AE`) documents against the + [PINT AE](https://docs.peppol.eu/poac/ae/pint-ae/) rules. A document must declare the addon that applies to it. @@ -52,6 +54,25 @@ $addons: See the [`examples`](./examples) directory for complete invoices. +### PINT AE + +UAE documents with the PINT addon are modelled as usual in GOBL, plus: + +- **Transaction type** (BTAE-02): set from the tags `free-trade-zone`, + `deemed-supply`, `margin-scheme`, `summary`, `continuous-supply`, + `disclosed-agent`, `e-commerce` and `export`. +- **Out of scope documents**: the `outside-tax-scope` tag (type codes 480 + and 81). +- **Profit margin scheme**: the AE regime's `margin-scheme` tag with the + `exempt` VAT key on every line; the lines are written in category `N`. +- **Exemption reasons**: `cef-vatex` on exempt VAT combos, with the UAE codes + `DL8.46.1` to `DL8.46.4`. +- **Deemed supplies** go to the predefined endpoint `0235:9900000097`. + +PINT allows one note on the document and one per line, and only the payment +due date (IBT-009) is written, so invoices with more notes, more than one due +date or a due date for part of the amount are rejected. + ## Layout - `addon/` — the GOBL addons: normalizers, scenarios and validation rules that @@ -86,6 +107,7 @@ import, and the exported XML carries them back: | `FormatBIS` | `ubl+peppol+bis-v3` | `urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0` | `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0` | | `FormatPINT` | `ubl+peppol+pint` | `urn:peppol:pint:billing-1` | `urn:peppol:bis:billing` | | `FormatAUNZ` | `ubl+peppol+pint+aunz` | `urn:peppol:pint:billing-1@aunz-1` | `urn:peppol:bis:billing` | +| `FormatAE` | `ubl+peppol+pint+ae` | `urn:peppol:pint:billing-1@ae-1` | `urn:peppol:bis:billing` | `FormatBIS` writes self-billed invoices with `SpecificationBISSelfBilling` (Peppol BIS Self-Billing 3.0) and statuses (`bill.Status`) as Peppol Invoice @@ -97,12 +119,17 @@ as Peppol BIS allows a single note. `FormatAUNZ` writes self-billed invoices (those tagged `self-billed`) with its `SpecificationAUNZSelfBilling` instead: `urn:peppol:pint:selfbilling-1@aunz-1` and `urn:peppol:bis:selfbilling`. Documents carrying either are imported with -`FormatAUNZ`. +`FormatAUNZ`. `FormatAE` does the same with `SpecificationAESelfBilling` +(`urn:peppol:pint:selfbilling-1@ae-1`). + +`FormatAE` also writes the PINT AE fields and adjustments the rules ask for +(such as the invoice UUID, the transaction type, line amounts with VAT in AED +and the exchange rate to AED) and reads them back. Each one's Peppol document type identifier is `urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##::2.1`, with `CreditNote-2::CreditNote` replacing `Invoice-2::Invoice` for credit notes. -The A-NZ formats also claim the wildcard customizations the SMP registrations +The A-NZ and AE formats also claim the wildcard customizations the SMP registrations are made under, and `FormatPINT` is the jurisdiction-neutral base: it takes any other `urn:peppol:pint:billing-1@…` specialization and validates it against the base PINT rule set. diff --git a/addon/pint/bill.go b/addon/pint/bill.go index 2ac53b3..99f5891 100644 --- a/addon/pint/bill.go +++ b/addon/pint/bill.go @@ -1,17 +1,32 @@ package pint import ( + "github.com/invopop/gobl/addons/eu/en16931" "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/currency" + "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/ae" "github.com/invopop/gobl/rules" "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" ) +// billInvoiceRules validates invoices on PINT documents. func billInvoiceRules() *rules.Set { return rules.For(new(bill.Invoice), + // PINT has no BR-E-10, BR-O-10 or BR-AE-10; PINT AE asks for the UAE reason per line, discount and charge. + rules.Ignore("GOBL-EU-EN16931-BILL-INVOICE-08"), + + // Supplier and customer rules.Field("supplier", - rules.Assert("01", "invoice supplier must have a tax ID or identity (IBR-CO-26)", - is.Func("has identifier", partyHasIdentifier), + rules.When( + is.Not(org.PartyHasTaxIDCode()), + rules.Field("identities", + rules.Assert("01", "invoice supplier must have a tax ID or identity (IBR-CO-26)", is.Present), + ), ), rules.Field("endpoints", rules.Assert("02", "invoice supplier electronic address is required (IBR-081)", is.Present), @@ -23,12 +38,689 @@ func billInvoiceRules() *rules.Set { rules.Assert("04", "invoice customer electronic address is required (IBR-080)", is.Present), ), ), + // Electronic addresses and customer identification + // gobl.ubl writes emails as EndpointID scheme EM, which PINT doesn't list (ibr-cl-25). + rules.Field("supplier", + rules.Field("endpoints", rules.Each( + rules.Field("uri", + rules.Assert("05", "supplier electronic address must not be an email address (IBR-081, ibr-cl-25)", + is.Not(cbc.URISchemeIn(endpointSchemeMailto)), + ), + ), + )), + rules.Field("inboxes", rules.Each( + rules.Field("email", + rules.Assert("06", "supplier inbox must not be an email address (IBR-081, ibr-cl-25)", is.Empty), + ), + )), + ), + rules.Field("customer", + rules.Field("endpoints", rules.Each( + rules.Field("uri", + rules.Assert("07", "customer electronic address must not be an email address (IBR-080, ibr-cl-25)", + is.Not(cbc.URISchemeIn(endpointSchemeMailto)), + ), + ), + )), + rules.Field("inboxes", rules.Each( + rules.Field("email", + rules.Assert("08", "customer inbox must not be an email address (IBR-080, ibr-cl-25)", is.Empty), + ), + )), + rules.AssertIfPresent("09", "customer can have at most one identity besides its first legal one and its tax ones (ibr-sr-16)", + is.Func("at most one buyer identifier", partyHasOneIdentification), + ), + // EN 16931 already allows one tax scope identity, so with a tax ID code there must be none. + rules.When( + org.PartyHasTaxIDCode(), + rules.Field("identities", + rules.Assert("10", "customer must have at most one tax registration (ibr-104, IBR-179-AE)", + is.Not(is.Func("has tax scope identity", identitiesScopeIn(org.IdentityScopeTax))), + ), + ), + ), + ), + // Payee + rules.Field("payment", + rules.Field("payee", + rules.Field("name", + rules.Assert("11", "payee name is required (ibr-017)", is.Present), + ), + ), + ), + rules.Assert("12", "payee must differ from the supplier by legal identity, identity or name (ibr-017)", + is.Func("payee is not the supplier", payeeIsNotSupplier), + ), + // Notes + rules.Field("notes", + rules.Assert("13", "invoice can have at most one note (ibr-sr-51)", is.Length(0, 1)), + ), + rules.Field("lines", rules.Each( + rules.Field("notes", + rules.Assert("14", "line can have at most one note (ibr-sr-34)", is.Length(0, 1)), + ), + )), + // Due dates + // Our own limit, not a PINT rule: only the payment due date (IBT-009) is written, with no amount. + rules.Field("payment", + rules.Field("terms", + rules.Field("due_dates", + rules.Assert("15", "invoice can have at most one due date, as only the payment due date is written (IBT-009)", + is.Length(0, 1), + ), + ), + ), + ), + rules.Assert("16", "due date must be for the whole amount due, as the payment due date has no amount (IBT-009)", + is.Func("due date is for the amount due", dueDatesCoverAmountDue), + ), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + // AE supplier + rules.Field("supplier", + rules.Field("addresses", + rules.Each( + rules.Field("street", + rules.Assert("17", "supplier address street is required (IBR-143-AE)", is.Present), + ), + rules.Field("locality", + rules.Assert("18", "supplier address city is required (IBR-143-AE)", is.Present), + ), + rules.Field("region", + rules.Assert("19", "supplier address region is required (IBR-143-AE)", is.Present), + ), + ), + ), + // IBR-150-AE only applies with a 0235 endpoint, which every UAE supplier gets (normalizeSupplierAE). + rules.Field("identities", + rules.Assert("20", "supplier legal identity is required (IBR-150-AE)", + is.Func("has legal scope identity", identitiesScopeIn(org.IdentityScopeLegal)), + ), + ), + rules.Field("identities", rules.Each( + rules.When( + is.Func("tax scope", identityScopeIn(org.IdentityScopeTax)), + rules.Assert("21", "supplier tax scope identity must be a TIN (IBR-148-AE)", + org.IdentityTypeIn(ae.IdentityTypeTIN), + ), + ), + )), + ), + + // AE customer + rules.Field("customer", + rules.Field("addresses", + rules.Each( + rules.Field("street", + rules.Assert("22", "customer address street is required (IBR-144-AE)", is.Present), + ), + rules.Field("locality", + rules.Assert("23", "customer address city is required (IBR-144-AE)", is.Present), + ), + rules.Field("region", + rules.Assert("24", "customer address region is required (IBR-144-AE)", is.Present), + ), + ), + ), + rules.When( + is.Func("has UAE Peppol endpoint other than 1XXXXXXXXX or 9XXXXXXXXX", partyHasUAEEndpoint(endpointPattern1or9, false)), + rules.Field("identities", + rules.Assert("25", "customer legal identity is required with a UAE Peppol endpoint other than 1XXXXXXXXX or 9XXXXXXXXX (IBR-149-AE)", + is.Func("has legal scope identity", identitiesScopeIn(org.IdentityScopeLegal)), + ), + ), + ), + ), + + // AE currency + rules.Assert("26", "exchange_rates must have a rate from the invoice currency to AED (IBR-159-AE)", + currency.CanConvertTo(currency.AED), + ), + rules.Assert("27", "exchange rate to AED must have at most 6 decimals (IBR-002-AE)", + is.Func("AED rate has at most 6 decimals", exchangeRateToAEDHasAtMost6Decimals), + ), + + // AE VAT point date + rules.Assert("28", "VAT point date must be before the invoice issue date (IBR-141-AE)", + is.Func("VAT point date before issue date", pointDateBeforeIssueDate), + ), + + // AE payment + rules.When( + is.Not(is.Or( + bill.InvoiceTypeIn(bill.InvoiceTypeCreditNote), + is.Func("deemed supply", invoiceHasTags(TagDeemedSupply)), + )), + rules.Field("payment", + rules.Assert("29", "payment details required, except on credit notes and deemed supplies (IBR-191-AE)", + is.Present, + ), + rules.Field("instructions", + rules.Assert("30", "payment instructions required, except on credit notes and deemed supplies (IBR-191-AE)", + is.Present, + ), + ), + ), + ), + // The IBR-127-AE test also exempts 261, which its text doesn't name; we follow the test. + rules.When( + is.Not(is.Or( + is.Func("document type is 381, 81 or 261", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeCreditNote, docTypeCreditNoteGoodsServices, docTypeSelfBilledCreditNote)), + is.Func("deemed supply", invoiceHasTags(TagDeemedSupply)), + )), + rules.When( + is.Func("amount due is positive", invoiceIsDue), + rules.Field("payment", + rules.Field("terms", + rules.Assert("31", "payment terms are required when the amount due is positive, except on credit notes and deemed supplies (IBR-127-AE)", + is.Present, + ), + rules.Field("due_dates", + rules.Assert("32", "payment due date is required when the amount due is positive, except on credit notes and deemed supplies (IBR-127-AE)", + is.Present, + ), + ), + ), + ), + ), + ), + + // AE document types + rules.When( + is.Not(is.Func("document type is invoice outside scope or credit note related to goods and services", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeInvoiceOutsideScope, docTypeCreditNoteGoodsServices))), + rules.Field("supplier", + rules.Assert("33", "supplier tax ID code is required, except on outside scope documents (IBR-134-AE)", + org.PartyHasTaxIDCode(), + ), + ), + ), + + // AE outside scope documents + rules.When( + is.Func("document type is invoice outside scope or credit note related to goods and services", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeInvoiceOutsideScope, docTypeCreditNoteGoodsServices)), + rules.Field("customer", + rules.Field("identities", + rules.Assert("34", "customer legal identity is required on outside scope documents or credit notes related to goods and services (IBR-136-AE)", + is.Func("has legal scope identity", identitiesScopeIn(org.IdentityScopeLegal)), + ), + ), + ), + rules.Field("lines", rules.Each( + rules.Field("taxes", rules.Each( + rules.Field("ext", + rules.Assert("35", "line VAT category code must be E or O on outside scope documents or credit notes related to goods and services (IBR-122-AE)", + tax.ExtensionsRequire(untdid.ExtKeyTaxCategory), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, taxCategoryCodesOutsideScope...), + ), + ), + )), + )), + rules.Field("discounts", rules.Each( + rules.Field("taxes", rules.Each( + rules.Field("ext", + rules.Assert("36", "discount VAT category code must be E or O on outside scope documents or credit notes related to goods and services (IBR-122-AE)", + tax.ExtensionsRequire(untdid.ExtKeyTaxCategory), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, taxCategoryCodesOutsideScope...), + ), + ), + )), + )), + rules.Field("charges", rules.Each( + rules.Field("taxes", rules.Each( + rules.Field("ext", + rules.Assert("37", "charge VAT category code must be E or O on outside scope documents or credit notes related to goods and services (IBR-122-AE)", + tax.ExtensionsRequire(untdid.ExtKeyTaxCategory), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, taxCategoryCodesOutsideScope...), + ), + ), + )), + )), + rules.Assert("38", "transaction type cannot be summary, deemed supply or margin scheme on outside scope documents or credit notes related to goods and services (IBR-157-AE)", + is.Not(is.Or( + is.Func("summary", invoiceHasTags(TagSummary)), + is.Func("deemed supply", invoiceHasTags(TagDeemedSupply)), + is.Func("margin scheme", invoiceHasTags(TagMarginScheme)), + )), + ), + ), + + // AE commercial invoices and credit notes + rules.When( + is.Func("document type is 380 or 381", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeCommercialInvoice, docTypeCreditNote)), + rules.Assert("39", "at least one line combo must be something other than E or O (IBR-151-AE)", + is.Func("has at least one line combo other than E or O", invoiceHasLineComboOtherThanEorO), + ), + ), + + // AE credit notes + // IBR-158-AE names only 381, but the IBR-055-AE test also fails 81 without a reason. + rules.When( + is.Func("document type is credit note or credit note related to goods and services", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeCreditNote, docTypeCreditNoteGoodsServices)), + rules.Field("value_date", + rules.Assert("40", "VAT point date must not be there on credit notes or credit notes related to goods and services (IBR-124-AE)", + is.Not(is.Present), + ), + ), + rules.Field("tax", + rules.Field("ext", + rules.Assert("41", "credit note reason is required (IBR-158-AE, IBR-055-AE)", + tax.ExtensionsRequire(ExtKeyCreditNoteReason), + ), + ), + ), + rules.When( + is.Not(is.Func("credit note reason is missing or volume discount", + invoiceExtIn(ExtKeyCreditNoteReason, cbc.CodeEmpty, CreditNoteReasonVolumeDiscount))), + rules.Field("preceding", + rules.Assert("42", "preceding invoice is required on credit notes, except for volume discounts (IBR-055-AE)", + is.Present, + ), + ), + ), + rules.When( + is.Func("credit note reason is volume discount", invoiceExtIn(ExtKeyCreditNoteReason, CreditNoteReasonVolumeDiscount)), + rules.Field("preceding", + rules.Assert("43", "preceding invoice must not be there on volume discount credit notes (IBR-055-AE)", + is.Not(is.Present), + ), + ), + ), + ), + + // AE transaction type + rules.When( + is.Func("free trade zone", invoiceHasTags(TagFreeTradeZone)), + rules.Field("tax", + rules.Field("ext", + rules.Assert("44", "beneficiary ID is required on free trade zone supplies (IBR-007-AE)", + tax.ExtensionsRequire(ExtKeyBeneficiaryID), + ), + ), + ), + ), + rules.When( + is.Func("deemed supply", invoiceHasTags(TagDeemedSupply)), + rules.Field("customer", + rules.AssertIfPresent("45", "customer electronic address must be the predefined endpoint 0235:9900000097 on deemed supplies (PINT AE BIS 1.5.3, IBT-049)", + is.Func("has UAE Peppol endpoint 9900000097", partyHasUAEEndpoint(endpointPatternDeemedSupply, true)), + ), + ), + ), + rules.When( + is.Func("margin scheme", invoiceHasTags(TagMarginScheme)), + rules.Field("lines", rules.Each( + rules.Field("taxes", rules.Each( + rules.Field("ext", + rules.Assert("46", "margin scheme invoice lines must be exempt without a UAE exemption reason, mapped to the margin scheme category N (IBR-116-AE)", + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, TaxCategoryMarginScheme), + ), + ), + )), + )), + // Discounts and charges need a VAT category (BR-32, BR-37), and it can't be N (IBR-114-AE, IBR-115-AE). + rules.Field("discounts", + rules.Assert("47", "margin scheme invoice can't have discounts (IBR-116-AE)", is.Empty), + ), + rules.Field("charges", + rules.Assert("48", "margin scheme invoice can't have charges (IBR-116-AE)", is.Empty), + ), + ), + rules.When( + is.Func("summary invoice", invoiceHasTags(TagSummary)), + rules.Field("ordering", + rules.Assert("49", "ordering is required on summary invoices (IBR-138-AE)", + is.Present, + ), + rules.Field("period", + rules.Assert("50", "ordering period is required on summary invoices (IBR-138-AE)", + is.Present, + ), + ), + ), + ), + rules.When( + is.Func("disclosed agent billing", invoiceHasTags(TagDisclosedAgent)), + rules.Field("tax", + rules.Field("ext", + rules.Assert("51", "principal ID is required on disclosed agent billing (IBR-137-AE)", + tax.ExtensionsRequire(ExtKeyPrincipalID), + ), + ), + ), + ), + // IBR-134-AE already requires the TRN elsewhere, so IBR-177-AE is only checked on 480 and 81. + rules.When( + is.Func("document type is invoice outside scope or credit note related to goods and services", + invoiceExtIn(untdid.ExtKeyDocumentType, docTypeInvoiceOutsideScope, docTypeCreditNoteGoodsServices)), + rules.Field("supplier", + rules.When( + is.Not(org.PartyHasTaxIDCode()), + rules.Field("identities", + rules.Assert("52", "supplier TRN or TIN is required on outside scope documents or credit notes related to goods and services (IBR-177-AE)", + is.Func("has tax scope identity", identitiesScopeIn(org.IdentityScopeTax)), + ), + ), + ), + ), + ), + rules.When( + is.Or( + is.Func("e-commerce supply", invoiceHasTags(TagECommerce)), + is.Func("export", invoiceHasTags(tax.TagExport)), + ), + rules.Field("delivery", + rules.Assert("53", "delivery is required on e-commerce supplies and exports (IBR-142-AE, IBR-152-AE)", is.Present), + rules.Field("receiver", + rules.Assert("54", "delivery receiver is required on e-commerce supplies and exports (IBR-142-AE, IBR-152-AE)", is.Present), + rules.Field("addresses", + rules.Assert("55", "delivery address is required on e-commerce supplies and exports (IBR-142-AE, IBR-152-AE)", is.Present), + ), + ), + ), + ), + rules.When( + is.Func("e-commerce supply", invoiceHasTags(TagECommerce)), + rules.Field("delivery", + rules.Field("receiver", + rules.Field("addresses", + rules.Each( + rules.Field("street", + rules.Assert("56", "e-commerce delivery address street is required (IBR-142-AE)", is.Present), + ), + rules.Field("locality", + rules.Assert("57", "e-commerce delivery address city is required (IBR-142-AE)", is.Present), + ), + rules.Field("region", + rules.Assert("58", "e-commerce delivery address region is required (IBR-142-AE)", is.Present), + ), + ), + ), + ), + ), + ), + // IBR-152-AE's text forbids an AE delivery country on exports, but its test accepts one; we follow the test. + rules.When( + is.Func("export", invoiceHasTags(tax.TagExport)), + rules.Field("delivery", + rules.Field("receiver", + rules.Field("addresses", + rules.Each( + rules.When( + is.Not(is.Func("UAE address", addressIsAE)), + rules.Field("street", + rules.Assert("59", "export delivery address street is required (IBR-152-AE)", is.Present), + ), + rules.Field("locality", + rules.Assert("60", "export delivery address city is required (IBR-152-AE)", is.Present), + ), + rules.Field("region", + rules.Assert("61", "export delivery address region is required (IBR-152-AE)", is.Present), + ), + ), + ), + ), + ), + ), + ), + rules.When( + is.Not(is.Func("export", invoiceHasTags(tax.TagExport))), + rules.Field("customer", + rules.When( + is.Func("has UAE Peppol endpoint that is not a TIN", partyHasUAEEndpoint(ae.TINPattern, false)), + // gobl.ubl writes unscoped identities as cac:PartyIdentification. + rules.When( + is.Not(org.PartyHasTaxIDCode()), + rules.Field("identities", + rules.Assert("62", "customer identity or tax registration is required with a UAE Peppol endpoint that is not a TIN, except on exports (IBR-135-AE)", + is.Func("has tax scope or unscoped identity", identitiesScopeIn(org.IdentityScopeTax, cbc.KeyEmpty)), + ), + ), + ), + ), + ), + ), + + // AE reverse charge + rules.When( + is.Func("has reverse charge lines", invoiceHasReverseChargeLine), + rules.Field("customer", + rules.When( + is.Not(org.PartyHasTaxIDCode()), + rules.Field("identities", + rules.Assert("63", "customer tax registration is required with reverse charge (IBR-103-AE)", + is.Func("has tax scope identity", identitiesScopeIn(org.IdentityScopeTax)), + ), + ), + ), + ), + ), + + // AE tax extensions + rules.Field("tax", + rules.Field("ext", + rules.Assert("64", "credit note reason must be from the Reasons for credit note code list (IBR-001-AE)", + tax.ExtensionHasValidCode(ExtKeyCreditNoteReason), + ), + rules.Assert("65", "principal ID must be a TRN of 15 digits starting with 1 and ending with 03 (IBR-132-AE)", + tax.ExtensionHasValidCode(ExtKeyPrincipalID), + ), + ), + rules.Field("point", + rules.Assert("66", "tax point must not be set, as PINT AE uses its element for the billing frequency (IBR-005-AE)", + is.Not(is.Present), + ), + ), + ), + + // AE document type list + rules.Field("tax", + rules.Field("ext", + rules.Assert("67", "document type must be 380, 480, 381, 81, 389 or 261 (ibr-cl-01)", + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, docTypesAE...), + ), + ), + ), + ), + + // Currency decimals + // PINT AE validates against PINT 1.1.4, which allows each currency's precision; the others use 1.1.3, which allows 2. + // TODO: use the currency precision everywhere once the other VESIDs move to PINT 1.1.4. + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.Field("currency", + rules.Assert("68", "currency must not have more decimals than PINT allows for it (ibr-091, ibr-121, ibr-122, ibr-123, ibr-124, ibr-125)", + is.Func("currency decimals within the PINT precision", currencyHasPINTDecimals), + ), + ), + ), + rules.When( + is.Not(is.InContext(tax.RegimeIn(regimesAE...))), + rules.Field("currency", + rules.Assert("68", "currency must have at most 2 decimals (ibr-091, ibr-121, ibr-122, ibr-123, ibr-124, ibr-125)", + is.Func("currency has at most 2 decimals", currencyHasAtMost2Decimals), + ), + ), + ), + + // Tags + // GOBL can't limit an addon's tags to a regime, so the PINT AE ones are rejected elsewhere. + rules.When( + is.Not(is.InContext(tax.RegimeIn(regimesAE...))), + rules.Assert("69", "PINT AE tags can only be used on UAE documents", + is.Func("has no PINT AE tags", invoiceHasNoAETags), + ), + ), ) } -// partyHasIdentifier reports whether the party can be identified through a tax -// identity code or at least one organisation identity. -func partyHasIdentifier(val any) bool { - p, ok := val.(*org.Party) - return ok && p != nil && ((p.TaxID != nil && p.TaxID.Code != "") || len(p.Identities) > 0) +// invoiceExtIn returns a predicate that reports whether the invoice's tax +// extension for the key is one of the codes. A missing extension is the empty +// code. +func invoiceExtIn(key cbc.Key, codes ...cbc.Code) func(any) bool { + return func(val any) bool { + inv, ok := val.(*bill.Invoice) + return ok && inv != nil && inv.Tax.GetExt(key).In(codes...) + } +} + +// invoiceHasNoAETags reports whether the invoice has none of the tags only the PINT addon defines. +// Tags that the regime, another addon or GOBL also define don't count. +func invoiceHasNoAETags(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil { + return false + } + others := bill.DefaultInvoiceTags() + if r := inv.RegimeDef(); r != nil { + others = others.Merge(tax.TagSetForSchema(r.Tags, bill.ShortSchemaInvoice)) + } + for _, a := range inv.AddonDefs() { + if a.Key != V1 { + others = others.Merge(tax.TagSetForSchema(a.Tags, bill.ShortSchemaInvoice)) + } + } + keys := others.Keys() + for _, def := range invoiceTags.List { + if inv.HasTags(def.Key) && !def.Key.In(keys...) { + return false + } + } + return true +} + +// currencyDecimalsPINT are the currencies whose official precision in PINT 1.1.4 +// is other than 2 decimals. PINT also gives UYW 4, but GOBL has no UYW. +var currencyDecimalsPINT = map[currency.Code]uint32{ + currency.BHD: 3, currency.IQD: 3, currency.JOD: 3, currency.KWD: 3, + currency.LYD: 3, currency.OMR: 3, currency.TND: 3, + currency.CLF: 4, +} + +// currencyHasPINTDecimals reports whether GOBL's decimals for the currency fit its PINT 1.1.4 precision. +func currencyHasPINTDecimals(val any) bool { + code, ok := val.(currency.Code) + if !ok { + return false + } + def := code.Def() + if def == nil { + return false + } + limit, ok := currencyDecimalsPINT[code] + if !ok { + limit = 2 + } + return def.Subunits <= limit +} + +// currencyHasAtMost2Decimals reports whether GOBL's decimals for the currency are 2 at most (PINT 1.1.3). +func currencyHasAtMost2Decimals(val any) bool { + code, ok := val.(currency.Code) + if !ok { + return false + } + def := code.Def() + return def != nil && def.Subunits <= 2 +} + +// exchangeRateToAEDHasAtMost6Decimals reports whether the rate to AED, if any, has at most 6 decimals. +func exchangeRateToAEDHasAtMost6Decimals(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil { + return true + } + rate := currency.MatchExchangeRate(inv.ExchangeRates, inv.Currency, currency.AED) + return rate == nil || rate.Amount.Exp() <= 6 +} + +// invoiceHasReverseChargeLine reports whether any line of the invoice has a +// VAT combo with the reverse charge category AE. +func invoiceHasReverseChargeLine(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil { + return false + } + for _, l := range inv.Lines { + if lineHasReverseChargeVAT(l) { + return true + } + } + return false +} + +// invoiceHasLineComboOtherThanEorO reports whether any line has a VAT category other than E or O. +func invoiceHasLineComboOtherThanEorO(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil { + return false + } + for _, l := range inv.Lines { + if l == nil { + continue + } + for _, c := range l.Taxes { + if c == nil || c.Category != tax.CategoryVAT { + continue + } + if cat := c.Ext.Get(untdid.ExtKeyTaxCategory); cat != en16931.TaxCategoryExempt && cat != en16931.TaxCategoryOutsideScope { + return true + } + } + } + return false +} + +// pointDateBeforeIssueDate reports whether the value date, if any, is before the issue date. +func pointDateBeforeIssueDate(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil { + return false + } + if inv.ValueDate == nil { + return true + } + return inv.IssueDate.DaysSince(inv.ValueDate.Date) > 0 +} + +// dueDatesCoverAmountDue reports whether each due date is for the whole amount due, as 100% or as +// that amount. Due dates with neither pass. +func dueDatesCoverAmountDue(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil || inv.Payment == nil || inv.Payment.Terms == nil || inv.Totals == nil { + return true + } + due := inv.Totals.Payable + if inv.Totals.Due != nil { + due = *inv.Totals.Due + } + for _, dd := range inv.Payment.Terms.DueDates { + switch { + case dd == nil: + case dd.Percent != nil: + if !dd.Percent.Equals(num.MakePercentage(1, 0)) { + return false + } + case dd.Amount != nil && !dd.Amount.Equals(due): + return false + } + } + return true +} + +// invoiceIsDue reports whether the amount gobl.ubl writes as cbc:PayableAmount, the due total +// when set or the payable total otherwise, is greater than zero. +func invoiceIsDue(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil || inv.Totals == nil { + return false + } + if inv.Totals.Due != nil { + return inv.Totals.Due.IsPositive() + } + return inv.Totals.Payable.IsPositive() } diff --git a/addon/pint/bill_line.go b/addon/pint/bill_line.go new file mode 100644 index 0000000..1c97815 --- /dev/null +++ b/addon/pint/bill_line.go @@ -0,0 +1,70 @@ +package pint + +import ( + "github.com/invopop/gobl/addons/eu/en16931" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// billLineRules validates invoice lines on UAE documents. +func billLineRules() *rules.Set { + return rules.For(new(bill.Line), + // TODO: extend IBR-145-AE to A-NZ (ALIGNED-IBRP-050/059-AUNZ). + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.Field("taxes", + rules.Assert("01", "line must have a VAT tax combo (IBR-145-AE)", + tax.SetHasCategory(tax.CategoryVAT), + ), + ), + rules.Field("item", + rules.Field("description", + rules.Assert("02", "item description is required (IBR-125-AE)", is.Present), + ), + ), + rules.When( + is.Func("reverse charge VAT", lineHasReverseChargeVAT), + rules.Field("item", + rules.Field("ext", + rules.Assert("03", "reverse charge line item needs the type of goods or services (IBR-166-AE)", + tax.ExtensionsRequire(ExtKeyGoodsType), + ), + ), + ), + ), + // The IBR-006-AE test checks every goods type, not only those of reverse charge lines as its text says. + rules.Field("item", + rules.Field("ext", + rules.Assert("04", "type of goods or services must be from the PINT AE code list (IBR-006-AE)", + tax.ExtensionHasValidCode(ExtKeyGoodsType), + ), + ), + ), + rules.When( + is.Func("reverse charge VAT", lineHasReverseChargeVAT), + rules.Field("item", + rules.Field("identities", + rules.Assert("05", "reverse charge line item needs a GTIN identity, scheme 0160 (IBR-174-AE)", + org.IdentitiesExtensionIn(iso.ExtKeySchemeID, IdentitySchemeGTIN), + ), + ), + ), + ), + ), + ) +} + +// lineHasReverseChargeVAT reports whether the line's VAT category is AE, reverse charge. +func lineHasReverseChargeVAT(val any) bool { + l, ok := val.(*bill.Line) + if !ok || l == nil { + return false + } + c := l.Taxes.Get(tax.CategoryVAT) + return c != nil && c.Ext.Get(untdid.ExtKeyTaxCategory) == en16931.TaxCategoryReverseCharge +} diff --git a/addon/pint/bill_line_test.go b/addon/pint/bill_line_test.go new file mode 100644 index 0000000..5be2eeb --- /dev/null +++ b/addon/pint/bill_line_test.go @@ -0,0 +1,90 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestBillLineRulesAE(t *testing.T) { + const ( + faultLineVAT = "GOBL-PEPPOL-PINT-BILL-LINE-01" + faultLineDescription = "GOBL-PEPPOL-PINT-BILL-LINE-02" + ) + + t.Run("line without a VAT combo is rejected (IBR-145-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Taxes = nil + out := aeFaults(t, inv) + assert.Contains(t, out, faultLineVAT) + assert.Contains(t, out, "$.lines[0].taxes") + }) + + t.Run("item description is required (IBR-125-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Item.Description = "" + out := aeFaults(t, inv) + assert.Contains(t, out, faultLineDescription) + assert.Contains(t, out, "$.lines[0].item.description") + }) + + t.Run("line rules do not apply outside AE", func(t *testing.T) { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard) + require.NoError(t, inv.Calculate()) + err := rules.Validate(inv, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.AU.Tax())) + if err != nil { + assert.NotContains(t, err.Error(), faultLineDescription) + } + }) +} + +func TestBillGoodsTypeRulesAE(t *testing.T) { + const ( + faultGoodsType = "GOBL-PEPPOL-PINT-BILL-LINE-03" + faultGoodsTypeValue = "GOBL-PEPPOL-PINT-BILL-LINE-04" + faultGTIN = "GOBL-PEPPOL-PINT-BILL-LINE-05" + ) + gtin := func(scheme cbc.Code) []*org.Identity { + return []*org.Identity{{Code: "4006381333931", Ext: tax.ExtensionsOf(cbc.CodeMap{iso.ExtKeySchemeID: scheme})}} + } + reverseCharge := func(goodsType cbc.Code, ids []*org.Identity) *bill.Invoice { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyReverseCharge)} + inv.Lines[0].Item.Identities = ids + if goodsType != "" { + inv.Lines[0].Item.Ext = tax.ExtensionsOf(cbc.CodeMap{pint.ExtKeyGoodsType: goodsType}) + } + return inv + } + + t.Run("reverse charge item needs the goods type (IBR-166-AE)", func(t *testing.T) { + assert.Contains(t, aeFaults(t, reverseCharge("", gtin("0160"))), faultGoodsType) + out := aeFaults(t, reverseCharge("DL8.48.3.1", gtin("0160"))) + assert.NotContains(t, out, faultGoodsType) + assert.NotContains(t, out, faultGoodsTypeValue) + assert.NotContains(t, out, faultGTIN) + }) + + t.Run("goods type must be from the AE list on any line (IBR-006-AE)", func(t *testing.T) { + assert.NotContains(t, aeFaults(t, reverseCharge("DL8.48.8.3", gtin("0160"))), faultGoodsTypeValue) + assert.Contains(t, aeFaults(t, reverseCharge("DL8.48.9", gtin("0160"))), faultGoodsTypeValue) + + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Item.Ext = tax.ExtensionsOf(cbc.CodeMap{pint.ExtKeyGoodsType: "OTHER"}) + assert.Contains(t, aeFaults(t, inv), faultGoodsTypeValue) + }) + + t.Run("reverse charge item needs a GTIN (IBR-174-AE)", func(t *testing.T) { + assert.Contains(t, aeFaults(t, reverseCharge("DL8.48.3.1", nil)), faultGTIN) + assert.Contains(t, aeFaults(t, reverseCharge("DL8.48.3.1", gtin("0088"))), faultGTIN) + }) +} diff --git a/addon/pint/bill_test.go b/addon/pint/bill_test.go index aa744a9..2fb60fb 100644 --- a/addon/pint/bill_test.go +++ b/addon/pint/bill_test.go @@ -4,12 +4,23 @@ import ( "testing" "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/addons/eu/en16931" "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/catalogues/cef" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/catalogues/untdid" "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/currency" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pay" + "github.com/invopop/gobl/regimes/ae" "github.com/invopop/gobl/rules" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func validEndpoints(code string) []*org.Endpoint { @@ -31,6 +42,17 @@ func baseInvoice() *bill.Invoice { } } +// faults validates the invoice with the PINT addon, in the given contexts too, +// and returns the faults raised, or "" if there are none. +func faults(t *testing.T, inv *bill.Invoice, ctx ...rules.WithContext) string { + t.Helper() + err := rules.Validate(inv, append([]rules.WithContext{tax.AddonContext(pint.V1)}, ctx...)...) + if err == nil { + return "" + } + return err.Error() +} + func TestBillInvoiceRules(t *testing.T) { validate := func(inv *bill.Invoice) error { return rules.Validate(inv, tax.AddonContext(pint.V1)) @@ -87,3 +109,1209 @@ func TestBillInvoiceRules(t *testing.T) { } }) } + +func TestBillPartyRules(t *testing.T) { + const ( + faultCustomer = "GOBL-PEPPOL-PINT-BILL-INVOICE-03" + faultSupplierEndpoint = "GOBL-PEPPOL-PINT-BILL-INVOICE-05" + faultSupplierInbox = "GOBL-PEPPOL-PINT-BILL-INVOICE-06" + faultCustomerEndpoint = "GOBL-PEPPOL-PINT-BILL-INVOICE-07" + faultCustomerInbox = "GOBL-PEPPOL-PINT-BILL-INVOICE-08" + faultCustomerIDs = "GOBL-PEPPOL-PINT-BILL-INVOICE-09" + faultCustomerTaxCount = "GOBL-PEPPOL-PINT-BILL-INVOICE-10" + faultPayeeName = "GOBL-PEPPOL-PINT-BILL-INVOICE-11" + faultPayeeIsSupplier = "GOBL-PEPPOL-PINT-BILL-INVOICE-12" + ) + + t.Run("electronic address must not be an email address (IBR-081, IBR-080, ibr-cl-25)", func(t *testing.T) { + // An email address is written with the scheme EM, which PINT doesn't + // accept (ibr-cl-25), even next to a Peppol endpoint. + inv := baseInvoice() + inv.Supplier.Endpoints = append(inv.Supplier.Endpoints, &org.Endpoint{URI: "mailto:sales@example.com"}) + inv.Customer.Endpoints = append(inv.Customer.Endpoints, &org.Endpoint{URI: "mailto:billing@example.com"}) + out := faults(t, inv) + assert.Contains(t, out, faultSupplierEndpoint) + assert.Contains(t, out, faultCustomerEndpoint) + + inv = baseInvoice() + inv.Supplier.Inboxes = []*org.Inbox{{Email: "sales@example.com"}} + inv.Customer.Inboxes = []*org.Inbox{{Email: "billing@example.com"}} + out = faults(t, inv) + assert.Contains(t, out, faultSupplierInbox) + assert.Contains(t, out, faultCustomerInbox) + + inv = baseInvoice() + inv.Supplier.Inboxes = []*org.Inbox{{Scheme: "0151", Code: "51824753556"}} + inv.Customer.Inboxes = []*org.Inbox{{Scheme: "0151", Code: "53004085616"}} + out = faults(t, inv) + assert.NotContains(t, out, faultSupplierEndpoint) + assert.NotContains(t, out, faultSupplierInbox) + assert.NotContains(t, out, faultCustomerEndpoint) + assert.NotContains(t, out, faultCustomerInbox) + }) + + t.Run("customer has at most one identifier besides its legal one (ibr-sr-16)", func(t *testing.T) { + legal := &org.Identity{Scope: org.IdentityScopeLegal, Code: "53004085616"} + gln := &org.Identity{Code: "5790000435975"} + duns := &org.Identity{Code: "123456789"} + + inv := baseInvoice() + inv.Customer.Identities = []*org.Identity{legal, gln} + assert.NotContains(t, faults(t, inv), faultCustomerIDs) + + inv.Customer.Identities = []*org.Identity{legal, gln, duns} + assert.Contains(t, faults(t, inv), faultCustomerIDs) + }) + + t.Run("customer has at most one tax registration (ibr-104)", func(t *testing.T) { + inv := baseInvoice() + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeTax, Code: "123456789"}} + assert.Contains(t, faults(t, inv), faultCustomerTaxCount) + + inv.Customer.TaxID = nil + assert.NotContains(t, faults(t, inv), faultCustomerTaxCount) + }) + + t.Run("a missing customer raises no customer faults but its own (IBR-007)", func(t *testing.T) { + inv := baseInvoice() + inv.Customer = nil + out := faults(t, inv) + assert.Contains(t, out, faultCustomer) + assert.NotContains(t, out, faultCustomerEndpoint) + assert.NotContains(t, out, faultCustomerIDs) + assert.NotContains(t, out, faultCustomerTaxCount) + }) + + t.Run("payee needs a name (ibr-017)", func(t *testing.T) { + inv := baseInvoice() + inv.Payment = &bill.PaymentDetails{Payee: &org.Party{Alias: "Factor"}} + assert.Contains(t, faults(t, inv), faultPayeeName) + + inv.Payment.Payee.Name = "Factor Pty Ltd" + assert.NotContains(t, faults(t, inv), faultPayeeName) + }) + + t.Run("payee must not be the supplier (ibr-017)", func(t *testing.T) { + gln := func(code cbc.Code) *org.Identity { + return &org.Identity{Code: code, Ext: tax.ExtensionsOf(cbc.CodeMap{iso.ExtKeySchemeID: "0088"})} + } + legal := func(code cbc.Code) *org.Identity { + id := gln(code) + id.Scope = org.IdentityScopeLegal + return id + } + tests := []struct { + name string + supplier []*org.Identity + payee *org.Party + same bool + }{ + {"same name", nil, &org.Party{Name: " seller pty ltd"}, true}, + {"same name as alias", nil, &org.Party{Name: "Factor", Alias: "SELLER PTY LTD"}, true}, + {"other name", nil, &org.Party{Name: "Factor Pty Ltd"}, false}, + {"same legal identity", []*org.Identity{legal("5790000435975")}, + &org.Party{Name: "Factor", Identities: []*org.Identity{legal("5790000435975")}}, true}, + {"other legal identity, same name", []*org.Identity{legal("5790000435975")}, + &org.Party{Name: "Seller Pty Ltd", Identities: []*org.Identity{legal("5790000435982")}}, false}, + {"same identity", []*org.Identity{gln("5790000435975")}, + &org.Party{Name: "Factor", Identities: []*org.Identity{gln("5790000435975")}}, true}, + {"same code in another scheme", []*org.Identity{gln("5790000435975")}, + &org.Party{Name: "Factor", Identities: []*org.Identity{{Code: "5790000435975"}}}, false}, + {"only one legal identity, same name", []*org.Identity{legal("5790000435975")}, + &org.Party{Name: "Seller Pty Ltd", Identities: []*org.Identity{gln("5790000435982")}}, true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + inv := baseInvoice() + inv.Supplier.Identities = tt.supplier + inv.Payment = &bill.PaymentDetails{Payee: tt.payee} + if tt.same { + assert.Contains(t, faults(t, inv), faultPayeeIsSupplier) + } else { + assert.NotContains(t, faults(t, inv), faultPayeeIsSupplier) + } + }) + } + }) +} + +func TestBillNoteRules(t *testing.T) { + const ( + faultInvoiceNotes = "GOBL-PEPPOL-PINT-BILL-INVOICE-13" + faultLineNotes = "GOBL-PEPPOL-PINT-BILL-INVOICE-14" + ) + note := func(text string) *org.Note { return &org.Note{Text: text} } + + t.Run("one note on the invoice and on each line is fine", func(t *testing.T) { + inv := baseInvoice() + inv.Notes = []*org.Note{note("First")} + inv.Lines = []*bill.Line{{Notes: []*org.Note{note("First")}}} + out := faults(t, inv) + assert.NotContains(t, out, faultInvoiceNotes) + assert.NotContains(t, out, faultLineNotes) + }) + + t.Run("more notes are rejected, not joined (ibr-sr-51, ibr-sr-34)", func(t *testing.T) { + inv := baseInvoice() + inv.Notes = []*org.Note{note("First"), note("Second")} + inv.Lines = []*bill.Line{{Notes: []*org.Note{note("First"), note("Second")}}} + out := faults(t, inv) + assert.Contains(t, out, faultInvoiceNotes) + assert.Contains(t, out, faultLineNotes) + }) +} + +func TestBillDueDateRules(t *testing.T) { + const ( + faultDueDates = "GOBL-PEPPOL-PINT-BILL-INVOICE-15" + faultDueDateWhole = "GOBL-PEPPOL-PINT-BILL-INVOICE-16" + ) + withDueDates := func(dds ...*pay.DueDate) *bill.Invoice { + inv := baseInvoice() + inv.Totals = &bill.Totals{Payable: num.MakeAmount(100000, 2)} + inv.Payment = &bill.PaymentDetails{Terms: &pay.Terms{DueDates: dds}} + return inv + } + date := cal.NewDate(2026, 2, 1) + percent := func(p int64) *num.Percentage { v := num.MakePercentage(p, 2); return &v } + amount := func(a int64) *num.Amount { v := num.MakeAmount(a, 2); return &v } + + t.Run("one due date for the whole amount is fine", func(t *testing.T) { + for _, dd := range []*pay.DueDate{ + {Date: date, Percent: percent(100)}, + {Date: date, Amount: amount(100000)}, + {Date: date}, + } { + out := faults(t, withDueDates(dd)) + assert.NotContains(t, out, faultDueDates) + assert.NotContains(t, out, faultDueDateWhole) + } + }) + + t.Run("more due dates are rejected", func(t *testing.T) { + inv := withDueDates(&pay.DueDate{Date: date, Percent: percent(50)}, &pay.DueDate{Date: date, Percent: percent(50)}) + assert.Contains(t, faults(t, inv), faultDueDates) + }) + + t.Run("a due date for part of the amount is rejected", func(t *testing.T) { + assert.Contains(t, faults(t, withDueDates(&pay.DueDate{Date: date, Percent: percent(50)})), faultDueDateWhole) + assert.Contains(t, faults(t, withDueDates(&pay.DueDate{Date: date, Amount: amount(50000)})), faultDueDateWhole) + }) + + t.Run("after advances, the whole amount is what remains due", func(t *testing.T) { + inv := withDueDates(&pay.DueDate{Date: date, Amount: amount(60000)}) + due := num.MakeAmount(60000, 2) + inv.Totals.Due = &due + assert.NotContains(t, faults(t, inv), faultDueDateWhole) + }) +} + +func TestBillExemptionNoteRules(t *testing.T) { + t.Run("VAT breakdowns outside the scope need no exemption note (BR-O-10 is not in PINT)", func(t *testing.T) { + inv := scenarioInvoice(l10n.GB.Tax(), bill.InvoiceTypeStandard) + inv.Currency = currency.GBP + require.NoError(t, inv.Calculate()) + err := rules.Validate(inv, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(l10n.GB.Tax())) + if err != nil { + assert.NotContains(t, err.Error(), "GOBL-EU-EN16931-BILL-INVOICE-08") + } + }) +} + +func TestBillInvoiceRulesAE(t *testing.T) { + const ( + faultRate = "GOBL-PEPPOL-PINT-BILL-INVOICE-26" + faultDecimals = "GOBL-PEPPOL-PINT-BILL-INVOICE-27" + faultPayment = "GOBL-PEPPOL-PINT-BILL-INVOICE-29" + faultInstructions = "GOBL-PEPPOL-PINT-BILL-INVOICE-30" + ) + inAE := tax.RegimeContext(l10n.AE.Tax()) + standard := func() *bill.Invoice { return aeDocument(bill.InvoiceTypeStandard) } + usdToAED := func(amount num.Amount) []*currency.ExchangeRate { + return []*currency.ExchangeRate{{From: currency.USD, To: currency.AED, Amount: amount}} + } + + t.Run("AED invoice needs no exchange rate (IBR-159-AE)", func(t *testing.T) { + inv := standard() + inv.ExchangeRates = nil + assert.NotContains(t, faults(t, inv, inAE), faultRate) + }) + + t.Run("non-AED invoice with a rate to AED with 6 decimals is accepted (IBR-159-AE, IBR-002-AE)", func(t *testing.T) { + inv := standard() + inv.Currency = currency.USD + inv.ExchangeRates = usdToAED(num.MakeAmount(3672500, 6)) + out := faults(t, inv, inAE) + assert.NotContains(t, out, faultRate) + assert.NotContains(t, out, faultDecimals) + }) + + t.Run("non-AED invoice without a rate is rejected (IBR-159-AE)", func(t *testing.T) { + inv := standard() + inv.Currency = currency.USD + assert.Contains(t, faults(t, inv, inAE), faultRate) + }) + + t.Run("non-AED invoice with a rate to another currency is rejected (IBR-159-AE)", func(t *testing.T) { + inv := standard() + inv.Currency = currency.USD + inv.ExchangeRates = []*currency.ExchangeRate{ + {From: currency.USD, To: currency.EUR, Amount: num.MakeAmount(92, 2)}, + } + assert.Contains(t, faults(t, inv, inAE), faultRate) + }) + + t.Run("exchange rate with 7 decimals is rejected (IBR-002-AE)", func(t *testing.T) { + inv := standard() + inv.Currency = currency.USD + inv.ExchangeRates = usdToAED(num.MakeAmount(36725000, 7)) + assert.Contains(t, faults(t, inv, inAE), faultDecimals) + }) + + t.Run("only the rate to AED is checked, as it is the one written (IBR-002-AE)", func(t *testing.T) { + toEUR := ¤cy.ExchangeRate{From: currency.USD, To: currency.EUR, Amount: num.MakeAmount(9212345, 7)} + inv := standard() + inv.Currency = currency.USD + inv.ExchangeRates = append(usdToAED(num.MakeAmount(3672500, 6)), toEUR) + assert.NotContains(t, faults(t, inv, inAE), faultDecimals) + + inv = standard() + inv.ExchangeRates = []*currency.ExchangeRate{ + {From: currency.AED, To: currency.EUR, Amount: num.MakeAmount(2512345, 7)}, + } + assert.NotContains(t, faults(t, inv, inAE), faultDecimals) + }) + + t.Run("invoice without payment is rejected (IBR-191-AE)", func(t *testing.T) { + inv := standard() + inv.Payment = nil + assert.Contains(t, faults(t, inv, inAE), faultPayment) + }) + + t.Run("invoice with payment but no instructions is rejected (IBR-191-AE)", func(t *testing.T) { + inv := standard() + inv.Payment = &bill.PaymentDetails{} + out := faults(t, inv, inAE) + assert.NotContains(t, out, faultPayment) + assert.Contains(t, out, faultInstructions) + }) + + t.Run("credit note without payment is accepted (IBR-191-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeCreditNote) + inv.Payment = nil + assert.NotContains(t, faults(t, inv, inAE), faultPayment) + }) + + t.Run("AE invoice rules do not apply outside AE", func(t *testing.T) { + inv := standard() + inv.Currency = currency.USD + inv.ExchangeRates = usdToAED(num.MakeAmount(36725000, 7)) + inv.Payment = nil + for _, regime := range []l10n.TaxCountryCode{l10n.SG.Tax(), l10n.AU.Tax()} { + inv.Regime = tax.WithRegime(regime) + out := faults(t, inv, tax.RegimeContext(regime)) + assert.NotContains(t, out, faultRate, "regime %s", regime) + assert.NotContains(t, out, faultDecimals, "regime %s", regime) + assert.NotContains(t, out, faultPayment, "regime %s", regime) + } + }) +} + +// aeDocument is an uncalculated UAE document of the given type and tags that +// passes every PINT AE rule: AE parties with valid TRNs and full addresses, a +// standard-rated line with a description, payment instructions and a due date. +// Out-of-scope documents get an outside-scope line and a customer legal +// identity. Tests change one thing and check for that rule's fault code. +func aeDocument(typ cbc.Key, tags ...cbc.Key) *bill.Invoice { + inv := scenarioInvoice(l10n.AE.Tax(), typ, tags...) + inv.Supplier = &org.Party{ + Name: "Seller LLC", + TaxID: &tax.Identity{Country: "AE", Code: "100000001600003"}, + Identities: []*org.Identity{tradeLicense("112345678900003")}, + Endpoints: validEndpoints("100000001600003"), + Addresses: aeAddress("DXB"), + } + inv.Customer = &org.Party{ + Name: "Buyer LLC", + TaxID: &tax.Identity{Country: "AE", Code: "100000002400003"}, + Endpoints: validEndpoints("100000002400003"), + Addresses: aeAddress("AUH"), + } + inv.Lines[0].Item.Description = "Consulting services" + inv.Lines[0].Taxes = tax.Set{standardVAT()} + if inv.HasTags(pint.TagOutsideTaxScope) { + inv.Lines[0].Taxes = tax.Set{{Category: tax.CategoryVAT, Key: tax.KeyOutsideScope}} + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeLegal, Code: "CN-1234567"}} + } + if typ == bill.InvoiceTypeCreditNote { + inv.Preceding = []*org.DocumentRef{{Code: "INV-001"}} + inv.Tax = &bill.Tax{Ext: tax.ExtensionsOf(cbc.CodeMap{pint.ExtKeyCreditNoteReason: "DL8.61.1.E"})} + } + due := cal.MakeDate(2026, 12, 10) + inv.Payment = &bill.PaymentDetails{ + Instructions: &pay.Instructions{ + Key: pay.MeansKeyCreditTransfer, + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyPaymentMeans: "30"}), + CreditTransfer: []*pay.CreditTransfer{{IBAN: "AE070331234567890123456"}}, + }, + Terms: &pay.Terms{ + DueDates: []*pay.DueDate{{Date: &due, Percent: num.NewPercentage(100, 2)}}, + }, + } + return inv +} + +// aeAddress is a complete UAE address in the given emirate. +func aeAddress(emirate string) []*org.Address { + return []*org.Address{{ + Street: "Sheikh Zayed Road", + Locality: "Dubai", + Region: emirate, + Country: "AE", + }} +} + +// standardVAT returns a standard-rated VAT combo at 5%, the UAE rate. +func standardVAT() *tax.Combo { + return &tax.Combo{Category: tax.CategoryVAT, Key: tax.KeyStandard, Percent: num.NewPercentage(5, 2)} +} + +// lineCombo returns a VAT combo with the given key and no rate, for the +// zero, exempt, outside-scope and reverse charge keys. +func lineCombo(key cbc.Key) *tax.Combo { + return &tax.Combo{Category: tax.CategoryVAT, Key: key} +} + +// aeFaults calculates the document, so the scenarios set its document type, and +// returns the faults raised under the AE regime, or "" if there are none. +func aeFaults(t *testing.T, inv *bill.Invoice) string { + t.Helper() + require.NoError(t, inv.Calculate()) + return faults(t, inv, tax.RegimeContext(l10n.AE.Tax())) +} + +func TestBillDocumentRulesAE(t *testing.T) { + const ( + faultSellerTRN = "GOBL-PEPPOL-PINT-BILL-INVOICE-33" + faultReverseCharge = "GOBL-PEPPOL-PINT-BILL-INVOICE-63" + faultBuyerLegalID = "GOBL-PEPPOL-PINT-BILL-INVOICE-34" + faultLineCategory = "GOBL-PEPPOL-PINT-BILL-INVOICE-35" + faultDiscountCat = "GOBL-PEPPOL-PINT-BILL-INVOICE-36" + faultChargeCategory = "GOBL-PEPPOL-PINT-BILL-INVOICE-37" + faultOnlyExempt = "GOBL-PEPPOL-PINT-BILL-INVOICE-39" + faultCreditPointDate = "GOBL-PEPPOL-PINT-BILL-INVOICE-40" + faultPointDate = "GOBL-PEPPOL-PINT-BILL-INVOICE-28" + faultTaxPoint = "GOBL-PEPPOL-PINT-BILL-INVOICE-66" + faultPayment = "GOBL-PEPPOL-PINT-BILL-INVOICE-29" + faultDueTerms = "GOBL-PEPPOL-PINT-BILL-INVOICE-31" + faultDueDate = "GOBL-PEPPOL-PINT-BILL-INVOICE-32" + faultDocumentType = "GOBL-PEPPOL-PINT-BILL-INVOICE-67" + ) + standard := func() *bill.Invoice { return aeDocument(bill.InvoiceTypeStandard) } + outsideScope := func() *bill.Invoice { + return aeDocument(bill.InvoiceTypeStandard, pint.TagOutsideTaxScope) + } + outsideScopeCredit := func() *bill.Invoice { + return aeDocument(bill.InvoiceTypeCreditNote, pint.TagOutsideTaxScope) + } + + t.Run("valid documents raise no PINT faults", func(t *testing.T) { + for name, inv := range map[string]*bill.Invoice{ + "380": standard(), + "381": aeDocument(bill.InvoiceTypeCreditNote), + "480": outsideScope(), + "81": outsideScopeCredit(), + } { + assert.NotContains(t, aeFaults(t, inv), "GOBL-PEPPOL-PINT", name) + } + }) + + t.Run("seller TRN is required (IBR-134-AE)", func(t *testing.T) { + inv := standard() + inv.Supplier.TaxID = &tax.Identity{Country: "AE"} + assert.Contains(t, aeFaults(t, inv), faultSellerTRN) + }) + + t.Run("seller TRN is not required on 480 and 81 (IBR-134-AE)", func(t *testing.T) { + for _, inv := range []*bill.Invoice{outsideScope(), outsideScopeCredit()} { + inv.Supplier.TaxID = &tax.Identity{Country: "AE"} + assert.NotContains(t, aeFaults(t, inv), faultSellerTRN) + } + }) + + t.Run("reverse charge needs a buyer tax registration (IBR-103-AE)", func(t *testing.T) { + inv := standard() + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyReverseCharge)} + inv.Customer.TaxID = nil + assert.Contains(t, aeFaults(t, inv), faultReverseCharge) + }) + + t.Run("reverse charge accepts a tax scope identity (IBR-103-AE)", func(t *testing.T) { + inv := standard() + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyReverseCharge)} + inv.Customer.TaxID = nil + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeTax, Code: "100000002400003"}} + assert.NotContains(t, aeFaults(t, inv), faultReverseCharge) + }) + + t.Run("buyer tax registration is not required without reverse charge (IBR-103-AE)", func(t *testing.T) { + inv := standard() + inv.Customer.TaxID = nil + assert.NotContains(t, aeFaults(t, inv), faultReverseCharge) + }) + + t.Run("480 and 81 need a buyer legal identity (IBR-136-AE)", func(t *testing.T) { + for _, inv := range []*bill.Invoice{outsideScope(), outsideScopeCredit()} { + inv.Customer.Identities = nil + assert.Contains(t, aeFaults(t, inv), faultBuyerLegalID) + } + }) + + t.Run("a tax scope identity is not a legal identity (IBR-136-AE)", func(t *testing.T) { + inv := outsideScope() + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeTax, Code: "100000002400003"}} + assert.Contains(t, aeFaults(t, inv), faultBuyerLegalID) + }) + + t.Run("buyer legal identity is not required on 380 (IBR-136-AE)", func(t *testing.T) { + assert.NotContains(t, aeFaults(t, standard()), faultBuyerLegalID) + }) + + t.Run("480 and 81 accept E and O lines (IBR-122-AE)", func(t *testing.T) { + for _, key := range []cbc.Key{tax.KeyExempt, tax.KeyOutsideScope} { + inv := outsideScope() + inv.Lines[0].Taxes = tax.Set{lineCombo(key)} + assert.NotContains(t, aeFaults(t, inv), faultLineCategory, key) + } + }) + + t.Run("480 and 81 reject standard and zero rated lines (IBR-122-AE)", func(t *testing.T) { + for _, inv := range []*bill.Invoice{outsideScope(), outsideScopeCredit()} { + inv.Lines[0].Taxes = tax.Set{standardVAT()} + assert.Contains(t, aeFaults(t, inv), faultLineCategory) + } + inv := outsideScope() + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyZero)} + assert.Contains(t, aeFaults(t, inv), faultLineCategory) + }) + + t.Run("480 rejects standard rated discounts and charges (IBR-122-AE)", func(t *testing.T) { + inv := outsideScope() + inv.Discounts = []*bill.Discount{{ + Reason: "Loyalty", Amount: num.MakeAmount(1000, 2), + Taxes: tax.Set{standardVAT()}, + }} + inv.Charges = []*bill.Charge{{ + Reason: "Shipping", Amount: num.MakeAmount(1000, 2), + Taxes: tax.Set{standardVAT()}, + }} + out := aeFaults(t, inv) + assert.Contains(t, out, faultDiscountCat) + assert.Contains(t, out, faultChargeCategory) + }) + + t.Run("380 rejects only exempt and outside scope lines (IBR-151-AE)", func(t *testing.T) { + inv := standard() + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyExempt)} + inv.Lines = append(inv.Lines, &bill.Line{ + Quantity: num.MakeAmount(1, 0), + Item: &org.Item{Name: "Other", Description: "Other", Price: num.NewAmount(100, 2)}, + Taxes: tax.Set{lineCombo(tax.KeyOutsideScope)}, + }) + assert.Contains(t, aeFaults(t, inv), faultOnlyExempt) + }) + + t.Run("380 accepts a zero rated line (IBR-151-AE)", func(t *testing.T) { + inv := standard() + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyZero)} + assert.NotContains(t, aeFaults(t, inv), faultOnlyExempt) + }) + + t.Run("381 and 81 reject a VAT point date (IBR-124-AE)", func(t *testing.T) { + for _, inv := range []*bill.Invoice{aeDocument(bill.InvoiceTypeCreditNote), outsideScopeCredit()} { + vd := cal.MakeDate(2026, 11, 1) + inv.ValueDate = &vd + assert.Contains(t, aeFaults(t, inv), faultCreditPointDate) + } + }) + + t.Run("380 accepts a VAT point date before the issue date (IBR-124-AE, IBR-141-AE)", func(t *testing.T) { + inv := standard() + vd := cal.MakeDate(2026, 11, 1) + inv.ValueDate = &vd + out := aeFaults(t, inv) + assert.NotContains(t, out, faultCreditPointDate) + assert.NotContains(t, out, faultPointDate) + }) + + t.Run("VAT point date on or after the issue date is rejected (IBR-141-AE)", func(t *testing.T) { + for _, day := range []int{10, 20} { + inv := standard() + vd := cal.MakeDate(2026, 11, day) + inv.ValueDate = &vd + assert.Contains(t, aeFaults(t, inv), faultPointDate, "day %d", day) + } + }) + + t.Run("tax point is rejected, as its element holds the billing frequency (IBR-005-AE)", func(t *testing.T) { + inv := standard() + inv.Tax = &bill.Tax{Point: tax.PointDelivery} + assert.Contains(t, aeFaults(t, inv), faultTaxPoint) + }) + + t.Run("due date is required when an amount is due (IBR-127-AE)", func(t *testing.T) { + inv := standard() + inv.Payment.Terms.DueDates = nil + assert.Contains(t, aeFaults(t, inv), faultDueDate) + + inv = standard() + inv.Payment.Terms = nil + assert.Contains(t, aeFaults(t, inv), faultDueTerms) + + inv = standard() + inv.Payment = nil + assert.Contains(t, aeFaults(t, inv), faultPayment) + }) + + t.Run("due date is not required when nothing is due (IBR-127-AE)", func(t *testing.T) { + inv := standard() + inv.Payment.Terms = nil + inv.Payment.Advances = []*pay.Record{{Description: "Paid in full", Percent: num.NewPercentage(100, 2)}} + assert.NotContains(t, aeFaults(t, inv), faultDueTerms) + }) + + t.Run("due date is not required when the amount due is negative (IBR-127-AE)", func(t *testing.T) { + inv := standard() + inv.Payment.Terms = nil + inv.Payment.Advances = []*pay.Record{{Description: "Overpaid", Percent: num.NewPercentage(150, 2)}} + out := aeFaults(t, inv) + require.True(t, inv.Totals.Due.IsNegative()) + assert.NotContains(t, out, faultDueTerms) + }) + + t.Run("due date is not required on 381, 81 and 261 (IBR-127-AE)", func(t *testing.T) { + for name, inv := range map[string]*bill.Invoice{ + "381": aeDocument(bill.InvoiceTypeCreditNote), + "81": outsideScopeCredit(), + "261": aeDocument(bill.InvoiceTypeCreditNote, tax.TagSelfBilled), + } { + inv.Payment.Terms = nil + assert.NotContains(t, aeFaults(t, inv), faultDueTerms, name) + } + }) + + t.Run("document type must be in the PINT AE list (ibr-cl-01)", func(t *testing.T) { + for name, inv := range map[string]*bill.Invoice{ + "380": standard(), + "381": aeDocument(bill.InvoiceTypeCreditNote), + "480": outsideScope(), + "81": outsideScopeCredit(), + "389": aeDocument(bill.InvoiceTypeStandard, tax.TagSelfBilled), + "261": aeDocument(bill.InvoiceTypeCreditNote, tax.TagSelfBilled), + } { + assert.NotContains(t, aeFaults(t, inv), faultDocumentType, name) + } + for name, inv := range map[string]*bill.Invoice{ + "325 pro forma": aeDocument(bill.InvoiceTypeProforma), + "384 corrective": aeDocument(bill.InvoiceTypeCorrective), + "383 debit note": aeDocument(bill.InvoiceTypeDebitNote), + "326 partial": aeDocument(bill.InvoiceTypeStandard, tax.TagPartial), + "386 prepayment": aeDocument(bill.InvoiceTypeStandard, tax.TagPrepayment), + "393 factoring": aeDocument(bill.InvoiceTypeStandard, tax.TagFactoring), + "396 credit note": aeDocument(bill.InvoiceTypeCreditNote, tax.TagFactoring), + } { + assert.Contains(t, aeFaults(t, inv), faultDocumentType, name) + } + }) + + t.Run("document rules do not apply outside AE", func(t *testing.T) { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeProforma) + inv.Currency = currency.BHD + require.NoError(t, inv.Calculate()) + err := rules.Validate(inv, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.AU.Tax())) + require.Error(t, err) + for _, code := range []string{faultSellerTRN, faultDueDate, faultOnlyExempt, faultDocumentType} { + assert.NotContains(t, err.Error(), code) + } + }) +} + +func TestBillCurrencyDecimalsRules(t *testing.T) { + const fault = "GOBL-PEPPOL-PINT-BILL-INVOICE-68" + ae := func(cur currency.Code) *bill.Invoice { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Currency = cur + inv.ExchangeRates = []*currency.ExchangeRate{{From: cur, To: currency.AED, Amount: num.MakeAmount(100, 2)}} + return inv + } + + t.Run("currencies within the PINT precision pass (ibr-091)", func(t *testing.T) { + for _, cur := range []currency.Code{currency.USD, currency.JPY, currency.BHD, currency.KWD, currency.OMR, currency.CLF} { + assert.NotContains(t, aeFaults(t, ae(cur)), fault, cur) + } + }) + + t.Run("currencies with more decimals than PINT allows fail (ibr-091)", func(t *testing.T) { + for _, cur := range []currency.Code{currency.MGA, currency.MRU} { + assert.Contains(t, aeFaults(t, ae(cur)), fault, cur) + } + }) + + t.Run("other regimes allow at most 2 decimals (ibr-091)", func(t *testing.T) { + au := func(cur currency.Code) error { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard) + inv.Currency = cur + inv.ExchangeRates = []*currency.ExchangeRate{{From: cur, To: currency.AUD, Amount: num.MakeAmount(100, 2)}} + require.NoError(t, inv.Calculate()) + return rules.Validate(inv, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.AU.Tax())) + } + for _, cur := range []currency.Code{currency.USD, currency.JPY} { + err := au(cur) + if err != nil { + assert.NotContains(t, err.Error(), fault, cur) + } + } + for _, cur := range []currency.Code{currency.BHD, currency.CLF, currency.MGA} { + err := au(cur) + require.Error(t, err, cur) + assert.Contains(t, err.Error(), fault, cur) + } + }) +} + +func TestBillAddressRulesAE(t *testing.T) { + const ( + faultSupplierStreet = "GOBL-PEPPOL-PINT-BILL-INVOICE-17" + faultSupplierCity = "GOBL-PEPPOL-PINT-BILL-INVOICE-18" + faultSupplierRegion = "GOBL-PEPPOL-PINT-BILL-INVOICE-19" + faultCustomerStreet = "GOBL-PEPPOL-PINT-BILL-INVOICE-22" + faultCustomerCity = "GOBL-PEPPOL-PINT-BILL-INVOICE-23" + faultCustomerRegion = "GOBL-PEPPOL-PINT-BILL-INVOICE-24" + ) + standard := func() *bill.Invoice { return aeDocument(bill.InvoiceTypeStandard) } + + t.Run("supplier address needs street, city and region (IBR-143-AE)", func(t *testing.T) { + for fault, clear := range map[string]func(a *org.Address){ + faultSupplierStreet: func(a *org.Address) { a.Street = "" }, + faultSupplierCity: func(a *org.Address) { a.Locality = "" }, + faultSupplierRegion: func(a *org.Address) { a.Region = "" }, + } { + inv := standard() + clear(inv.Supplier.Addresses[0]) + assert.Contains(t, aeFaults(t, inv), fault) + } + }) + + t.Run("customer address needs street, city and region (IBR-144-AE)", func(t *testing.T) { + inv := standard() + inv.Customer.Addresses[0].Locality = "" + assert.Contains(t, aeFaults(t, inv), faultCustomerCity) + }) + + t.Run("foreign customer address also needs a region (IBR-144-AE)", func(t *testing.T) { + inv := standard() + inv.Customer.Addresses = []*org.Address{{Street: "Hauptstr. 1", Locality: "Berlin", Country: "DE"}} + assert.Contains(t, aeFaults(t, inv), faultCustomerRegion) + }) + + t.Run("every address is checked (IBR-143-AE)", func(t *testing.T) { + inv := standard() + inv.Supplier.Addresses = append(inv.Supplier.Addresses, &org.Address{Country: "AE", Region: "DXB"}) + assert.Contains(t, aeFaults(t, inv), faultSupplierStreet) + }) + + t.Run("party without addresses is left to EN 16931 (BR-8, BR-10)", func(t *testing.T) { + inv := standard() + inv.Customer.Addresses = nil + inv.Customer.TaxID = nil + out := aeFaults(t, inv) + for _, fault := range []string{faultCustomerStreet, faultCustomerCity, faultCustomerRegion} { + assert.NotContains(t, out, fault) + } + }) +} + +func uaeEndpoints(code string) []*org.Endpoint { + return []*org.Endpoint{{URI: cbc.URI("iso6523-actorid-upis::0235:" + code)}} +} + +func tradeLicense(code string) *org.Identity { + return &org.Identity{Type: ae.IdentityTypeTradeLicense, Code: cbc.Code(code), Description: "Dubai Economy and Tourism"} +} + +// aeIdentityDocument returns a valid UAE invoice whose parties have UAE Peppol +// endpoints and trade licences, the case the legal registration rules apply to. +func aeIdentityDocument() *bill.Invoice { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Supplier.Endpoints = uaeEndpoints("1357902467") + inv.Supplier.Identities = []*org.Identity{tradeLicense("112345678900003")} + inv.Customer.Endpoints = uaeEndpoints("1345678906") + inv.Customer.Identities = []*org.Identity{tradeLicense("112345679000001")} + return inv +} + +func TestBillIdentityRulesAE(t *testing.T) { + const ( + faultSupplierLegalRequired = "GOBL-PEPPOL-PINT-BILL-INVOICE-20" + faultSupplierTIN = "GOBL-PEPPOL-PINT-BILL-INVOICE-21" + faultCustomerLegalRequired = "GOBL-PEPPOL-PINT-BILL-INVOICE-25" + faultCustomerTaxCount = "GOBL-PEPPOL-PINT-BILL-INVOICE-10" + ) + + t.Run("supplier needs a legal identity (IBR-150-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities = nil + assert.Contains(t, aeFaults(t, inv), faultSupplierLegalRequired) + }) + + t.Run("supplier TIN before the legal identity is accepted (IBR-148-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities = append([]*org.Identity{ + {Type: ae.IdentityTypeTIN, Code: "1234567897"}, + }, inv.Supplier.Identities...) + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("supplier tax identity must be a TIN (IBR-148-AE)", func(t *testing.T) { + for _, typ := range []cbc.Code{"", "TAX"} { + inv := aeIdentityDocument() + inv.Supplier.Identities = append(inv.Supplier.Identities, + &org.Identity{Scope: org.IdentityScopeTax, Type: typ, Code: "1234567897"}) + assert.Contains(t, aeFaults(t, inv), faultSupplierTIN, typ) + } + }) + + t.Run("the supplier TIN's format is left to the AE regime (IBR-148-AE)", func(t *testing.T) { + for _, code := range []cbc.Code{"2234567890", "123456789"} { + inv := aeIdentityDocument() + inv.Supplier.Identities = append(inv.Supplier.Identities, + &org.Identity{Scope: org.IdentityScopeTax, Type: ae.IdentityTypeTIN, Code: code}) + assert.NotContains(t, aeFaults(t, inv), faultSupplierTIN, code) + } + }) + + t.Run("customer with a UAE endpoint that is not 1XXXXXXXXX or 9XXXXXXXXX needs a legal identity (IBR-149-AE)", func(t *testing.T) { + for _, code := range []string{"2345678901", "134567890", "13456789061"} { + inv := aeIdentityDocument() + inv.Customer.Identities = nil + inv.Customer.Endpoints = uaeEndpoints(code) + assert.Contains(t, aeFaults(t, inv), faultCustomerLegalRequired, code) + } + }) + + t.Run("customer with a UAE endpoint of 1XXXXXXXXX or 9XXXXXXXXX needs no legal identity (IBR-149-AE)", func(t *testing.T) { + for _, code := range []string{"1345678906", "9345678901"} { + inv := aeIdentityDocument() + inv.Customer.Identities = nil + inv.Customer.Endpoints = uaeEndpoints(code) + assert.NotContains(t, aeFaults(t, inv), faultCustomerLegalRequired, code) + } + }) + + t.Run("customer legal identity is enough without a tax registration (IBR-149-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Customer.TaxID = nil + inv.Customer.Endpoints = uaeEndpoints("2345678901") + assert.NotContains(t, aeFaults(t, inv), faultCustomerLegalRequired) + }) + + t.Run("customer TIN with the tax scope is a second tax registration (ibr-104, IBR-179-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities = append(inv.Supplier.Identities, + &org.Identity{Type: ae.IdentityTypeTIN, Code: "1234567897"}) + inv.Customer.Identities = append(inv.Customer.Identities, + &org.Identity{Scope: org.IdentityScopeTax, Code: "1345678906"}) + assert.Contains(t, aeFaults(t, inv), faultCustomerTaxCount) + }) + + t.Run("customer TIN without a scope is a plain identity (ibr-104, IBR-179-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Customer.Identities = append(inv.Customer.Identities, + &org.Identity{Type: ae.IdentityTypeTIN, Code: "1345678906"}) + out := aeFaults(t, inv) + assert.Empty(t, inv.Customer.Identities[1].Scope) + assert.NotContains(t, out, faultCustomerTaxCount) + }) +} + +func TestBillTransactionTypeRulesAE(t *testing.T) { + const ( + faultPaymentInstructions = "GOBL-PEPPOL-PINT-BILL-INVOICE-30" + faultDueDate = "GOBL-PEPPOL-PINT-BILL-INVOICE-32" + faultBeneficiary = "GOBL-PEPPOL-PINT-BILL-INVOICE-44" + faultDeemedEndpoint = "GOBL-PEPPOL-PINT-BILL-INVOICE-45" + faultSummaryOrdering = "GOBL-PEPPOL-PINT-BILL-INVOICE-49" + faultSummaryPeriod = "GOBL-PEPPOL-PINT-BILL-INVOICE-50" + faultPrincipal = "GOBL-PEPPOL-PINT-BILL-INVOICE-51" + faultPrincipalTRN = "GOBL-PEPPOL-PINT-BILL-INVOICE-65" + faultSupplierTax = "GOBL-PEPPOL-PINT-BILL-INVOICE-52" + faultDelivery = "GOBL-PEPPOL-PINT-BILL-INVOICE-53" + faultDeliveryAddress = "GOBL-PEPPOL-PINT-BILL-INVOICE-55" + faultECommerceStreet = "GOBL-PEPPOL-PINT-BILL-INVOICE-56" + faultExportStreet = "GOBL-PEPPOL-PINT-BILL-INVOICE-59" + faultExportRegion = "GOBL-PEPPOL-PINT-BILL-INVOICE-61" + faultOutsideScopeFlags = "GOBL-PEPPOL-PINT-BILL-INVOICE-38" + faultCustomerIdentifier = "GOBL-PEPPOL-PINT-BILL-INVOICE-62" + ) + setExt := func(inv *bill.Invoice, key cbc.Key, code cbc.Code) { + if inv.Tax == nil { + inv.Tax = new(bill.Tax) + } + inv.Tax.Ext = inv.Tax.Ext.Set(key, code) + } + receiver := func(a *org.Address) *bill.DeliveryDetails { + return &bill.DeliveryDetails{Receiver: &org.Party{Name: "Receiver", Addresses: []*org.Address{a}}} + } + foreign := &org.Address{Street: "Baker Street 221B", Locality: "London", Region: "Greater London", Country: "GB"} + + t.Run("deemed supplies need no payment instructions or due date (IBR-191-AE, IBR-127-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDeemedSupply) + inv.Payment = &bill.PaymentDetails{Terms: &pay.Terms{Notes: "No consideration"}} + out := aeFaults(t, inv) + assert.NotContains(t, out, faultPaymentInstructions) + assert.NotContains(t, out, faultDueDate) + }) + + t.Run("deemed supply buyer has the predefined endpoint 9900000097 (PINT AE BIS 1.5.3)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDeemedSupply) + inv.Customer.Endpoints = uaeEndpoints("9900000097") + assert.NotContains(t, aeFaults(t, inv), faultDeemedEndpoint) + + inv.Customer.Endpoints = uaeEndpoints("1000000024") + assert.Contains(t, aeFaults(t, inv), faultDeemedEndpoint) + + inv = aeDocument(bill.InvoiceTypeStandard) + inv.Customer.Endpoints = uaeEndpoints("1000000024") + assert.NotContains(t, aeFaults(t, inv), faultDeemedEndpoint) + }) + + t.Run("free trade zone needs the beneficiary ID (IBR-007-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagFreeTradeZone) + assert.Contains(t, aeFaults(t, inv), faultBeneficiary) + setExt(inv, pint.ExtKeyBeneficiaryID, "189098765401003") + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("summary invoice needs the ordering period (IBR-138-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagSummary) + assert.Contains(t, aeFaults(t, inv), faultSummaryOrdering) + inv.Ordering = &bill.Ordering{Code: "PO-1"} + assert.Contains(t, aeFaults(t, inv), faultSummaryPeriod) + start, end := cal.MakeDate(2026, 10, 1), cal.MakeDate(2026, 10, 31) + inv.Ordering.Period = &cal.Period{Start: &start, End: &end} + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("disclosed agent needs the principal ID (IBR-137-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDisclosedAgent) + assert.Contains(t, aeFaults(t, inv), faultPrincipal) + setExt(inv, pint.ExtKeyPrincipalID, "155667745601003") + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("principal ID must be a TRN ending with 03 (IBR-132-AE)", func(t *testing.T) { + for _, code := range []cbc.Code{"255667745601003", "15566774560100", "1556677456010A3", "155667745601004"} { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDisclosedAgent) + setExt(inv, pint.ExtKeyPrincipalID, code) + assert.Contains(t, aeFaults(t, inv), faultPrincipalTRN, code) + } + + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDisclosedAgent) + setExt(inv, pint.ExtKeyPrincipalID, "155667745601003") + assert.NotContains(t, aeFaults(t, inv), faultPrincipalTRN) + + // It is checked without the disclosed agent tag too, as it is + // written whenever it is there. + inv = aeDocument(bill.InvoiceTypeStandard) + setExt(inv, pint.ExtKeyPrincipalID, "P-1234") + assert.Contains(t, aeFaults(t, inv), faultPrincipalTRN) + }) + + t.Run("supplier needs a TRN or TIN on outside scope documents (IBR-177-AE)", func(t *testing.T) { + // Elsewhere the TRN is already required (IBR-134-AE), so only that + // rule fails. + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagDisclosedAgent) + setExt(inv, pint.ExtKeyPrincipalID, "155667745601003") + inv.Supplier.TaxID = &tax.Identity{Country: "AE"} + out := aeFaults(t, inv) + assert.Contains(t, out, "GOBL-PEPPOL-PINT-BILL-INVOICE-33") + assert.NotContains(t, out, faultSupplierTax) + + for _, typ := range []cbc.Key{bill.InvoiceTypeStandard, bill.InvoiceTypeCreditNote} { + inv = aeDocument(typ, pint.TagOutsideTaxScope) + inv.Supplier.TaxID = &tax.Identity{Country: "AE"} + assert.Contains(t, aeFaults(t, inv), faultSupplierTax, typ) + + // The TIN is enough on 480 and 81 (IBR-134-AE). + inv.Supplier.Identities = append(inv.Supplier.Identities, + &org.Identity{Type: ae.IdentityTypeTIN, Code: "1234567897"}) + assert.Empty(t, aeFaults(t, inv), typ) + } + }) + + t.Run("e-commerce needs a complete delivery address (IBR-142-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagECommerce) + assert.Contains(t, aeFaults(t, inv), faultDelivery) + inv.Delivery = &bill.DeliveryDetails{Receiver: &org.Party{Name: "Warehouse"}} + assert.Contains(t, aeFaults(t, inv), faultDeliveryAddress) + inv.Delivery = receiver(&org.Address{Locality: "Dubai", Region: "DXB", Country: "AE"}) + assert.Contains(t, aeFaults(t, inv), faultECommerceStreet) + inv.Delivery = receiver(aeAddress("DXB")[0]) + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("export needs a complete delivery address outside the UAE (IBR-152-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, tax.TagExport) + assert.Contains(t, aeFaults(t, inv), faultDelivery) + inv.Delivery = receiver(&org.Address{Locality: "London", Country: "GB"}) + out := aeFaults(t, inv) + assert.Contains(t, out, faultExportStreet) + assert.Contains(t, out, faultExportRegion) + inv.Delivery = receiver(foreign) + assert.Empty(t, aeFaults(t, inv)) + inv.Delivery = receiver(&org.Address{Locality: "Dubai", Country: "AE"}) + out = aeFaults(t, inv) + assert.NotContains(t, out, faultExportStreet) + assert.NotContains(t, out, faultExportRegion) + }) + + t.Run("outside scope documents can't be summary, deemed supply or margin scheme (IBR-157-AE)", func(t *testing.T) { + for _, tag := range []cbc.Key{pint.TagSummary, pint.TagDeemedSupply, pint.TagMarginScheme} { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagOutsideTaxScope, tag) + assert.Contains(t, aeFaults(t, inv), faultOutsideScopeFlags, tag) + } + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagOutsideTaxScope, pint.TagContinuousSupply) + assert.NotContains(t, aeFaults(t, inv), faultOutsideScopeFlags) + }) + + t.Run("customer with a UAE endpoint not starting with 1 needs an identifier (IBR-135-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Customer.TaxID = nil + inv.Customer.Endpoints = uaeEndpoints("9345678901") + assert.Contains(t, aeFaults(t, inv), faultCustomerIdentifier) + + inv.Customer.Identities = []*org.Identity{{Type: "XYZ", Code: "12345"}} + assert.NotContains(t, aeFaults(t, inv), faultCustomerIdentifier) + }) + + t.Run("exports and endpoints starting with 1 need no customer identifier (IBR-135-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, tax.TagExport) + inv.Customer.TaxID = nil + inv.Customer.Endpoints = uaeEndpoints("9345678901") + assert.NotContains(t, aeFaults(t, inv), faultCustomerIdentifier) + + inv = aeDocument(bill.InvoiceTypeStandard) + inv.Customer.TaxID = nil + inv.Customer.Endpoints = uaeEndpoints("1345678906") + assert.NotContains(t, aeFaults(t, inv), faultCustomerIdentifier) + }) +} + +func TestBillCreditNoteReasonRulesAE(t *testing.T) { + const ( + faultReasonRequired = "GOBL-PEPPOL-PINT-BILL-INVOICE-41" + faultPrecedingMissing = "GOBL-PEPPOL-PINT-BILL-INVOICE-42" + faultPrecedingVD = "GOBL-PEPPOL-PINT-BILL-INVOICE-43" + faultReasonCode = "GOBL-PEPPOL-PINT-BILL-INVOICE-64" + ) + withReason := func(inv *bill.Invoice, code cbc.Code) *bill.Invoice { + if inv.Tax == nil { + inv.Tax = new(bill.Tax) + } + inv.Tax.Ext = inv.Tax.Ext.Set(pint.ExtKeyCreditNoteReason, code) + return inv + } + + t.Run("credit note needs a reason (IBR-158-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeCreditNote) + inv.Tax.Ext = inv.Tax.Ext.Delete(pint.ExtKeyCreditNoteReason) + out := aeFaults(t, inv) + assert.Contains(t, out, faultReasonRequired) + assert.NotContains(t, out, faultPrecedingMissing) + assert.NotContains(t, out, faultPrecedingVD) + }) + + t.Run("credit note related to goods and services needs a reason (IBR-055-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeCreditNote, pint.TagOutsideTaxScope) + inv.Tax.Ext = inv.Tax.Ext.Delete(pint.ExtKeyCreditNoteReason) + assert.Contains(t, aeFaults(t, inv), faultReasonRequired) + }) + + t.Run("invoices and self-billed credit notes need no reason", func(t *testing.T) { + assert.NotContains(t, aeFaults(t, aeDocument(bill.InvoiceTypeStandard)), faultReasonRequired) + inv := aeDocument(bill.InvoiceTypeCreditNote, tax.TagSelfBilled) + inv.Tax.Ext = inv.Tax.Ext.Delete(pint.ExtKeyCreditNoteReason) + assert.NotContains(t, aeFaults(t, inv), faultReasonRequired) + }) + + t.Run("credit note needs a preceding invoice, except for volume discounts (IBR-055-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeCreditNote) + inv.Preceding = nil + assert.Contains(t, aeFaults(t, inv), faultPrecedingMissing) + + inv = withReason(aeDocument(bill.InvoiceTypeCreditNote), pint.CreditNoteReasonVolumeDiscount) + inv.Preceding = nil + assert.Empty(t, aeFaults(t, inv)) + }) + + t.Run("volume discount credit note has no preceding invoice (IBR-055-AE)", func(t *testing.T) { + inv := withReason(aeDocument(bill.InvoiceTypeCreditNote), pint.CreditNoteReasonVolumeDiscount) + out := aeFaults(t, inv) + assert.Contains(t, out, faultPrecedingVD) + assert.NotContains(t, out, faultPrecedingMissing) + }) + + t.Run("reason must be from the code list (IBR-001-AE)", func(t *testing.T) { + inv := withReason(aeDocument(bill.InvoiceTypeCreditNote), "DL8.61.1.A") + assert.Empty(t, aeFaults(t, inv)) + inv = withReason(aeDocument(bill.InvoiceTypeCreditNote), "DL8.61.1.F") + assert.Contains(t, aeFaults(t, inv), faultReasonCode) + }) +} + +func TestBillExemptionRulesAE(t *testing.T) { + const faultExemptionCode = "GOBL-PEPPOL-PINT-TAX-COMBO-07" + exempt := func(code cbc.Code) *tax.Combo { + c := lineCombo(tax.KeyExempt) + c.Ext = tax.ExtensionsOf(cbc.CodeMap{cef.ExtKeyVATEX: code}) + return c + } + + t.Run("exemption reason must be a UAE one", func(t *testing.T) { + for _, code := range []cbc.Code{"DL8.46.5", "VATEX-EU-132"} { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Taxes = tax.Set{exempt(code)} + assert.Contains(t, aeFaults(t, inv), faultExemptionCode, code) + } + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Taxes = tax.Set{exempt("DL8.46.2")} + assert.NotContains(t, aeFaults(t, inv), faultExemptionCode) + }) +} + +func TestBillMarginSchemeRulesAE(t *testing.T) { + const ( + faultLineExemption = "GOBL-PEPPOL-PINT-TAX-COMBO-06" + faultMarginLine = "GOBL-PEPPOL-PINT-BILL-INVOICE-46" + faultMarginDiscount = "GOBL-PEPPOL-PINT-BILL-INVOICE-47" + faultMarginCharge = "GOBL-PEPPOL-PINT-BILL-INVOICE-48" + ) + margin := func(tags ...cbc.Key) *bill.Invoice { + inv := aeDocument(bill.InvoiceTypeStandard, tags...) + inv.Lines[0].Taxes = tax.Set{lineCombo(tax.KeyExempt)} + return inv + } + statements := func(inv *bill.Invoice) []*tax.Note { + var notes []*tax.Note + for _, n := range inv.Tax.Notes { + if n.Key == pint.TagMarginScheme { + notes = append(notes, n) + } + } + return notes + } + + t.Run("exempt lines are N without VAT", func(t *testing.T) { + inv := margin(pint.TagMarginScheme) + assert.Empty(t, aeFaults(t, inv)) + c := inv.Lines[0].Taxes[0] + assert.Equal(t, pint.TaxCategoryMarginScheme, c.Ext.Get(untdid.ExtKeyTaxCategory)) + assert.Nil(t, c.Percent) + assert.Equal(t, cbc.Code("00100000"), inv.Tax.GetExt(pint.ExtKeyTransactionType)) + }) + + t.Run("an imported statement isn't added again", func(t *testing.T) { + inv := margin(pint.TagMarginScheme) + inv.Tax = &bill.Tax{Notes: []*tax.Note{{ + Category: tax.CategoryVAT, + Text: "VAT charged under the Profit Margin Scheme", + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyTaxCategory: pint.TaxCategoryMarginScheme}), + }}} + require.NoError(t, inv.Calculate()) + notes := statements(inv) + require.Len(t, notes, 1) + assert.Len(t, inv.Tax.Notes, 1) + }) + + t.Run("exempt lines without the tag stay E", func(t *testing.T) { + inv := margin() + assert.Contains(t, aeFaults(t, inv), faultLineExemption) + assert.Equal(t, cbc.Code("E"), inv.Lines[0].Taxes[0].Ext.Get(untdid.ExtKeyTaxCategory)) + assert.Empty(t, statements(inv)) + }) + + t.Run("removing the tag maps the lines back to E", func(t *testing.T) { + inv := margin(pint.TagMarginScheme) + require.NoError(t, inv.Calculate()) + inv.Tags = tax.Tags{} + require.NoError(t, inv.Calculate()) + assert.Equal(t, cbc.Code("E"), inv.Lines[0].Taxes[0].Ext.Get(untdid.ExtKeyTaxCategory)) + }) + + t.Run("margin scheme invoices only have exempt lines (IBR-116-AE)", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagMarginScheme) + assert.Contains(t, aeFaults(t, inv), faultMarginLine) + + inv = margin(pint.TagMarginScheme) + inv.Lines = append(inv.Lines, &bill.Line{ + Quantity: num.MakeAmount(1, 0), + Item: &org.Item{Name: "Watch strap", Description: "Leather strap", Price: num.NewAmount(1000, 2)}, + Taxes: tax.Set{standardVAT()}, + }) + assert.Contains(t, aeFaults(t, inv), faultMarginLine) + + // A line with a UAE exemption reason is a real exempt supply, not a + // margin scheme one. + inv = margin(pint.TagMarginScheme) + inv.Lines[0].Taxes[0].Ext = tax.ExtensionsOf(cbc.CodeMap{cef.ExtKeyVATEX: "DL8.46.1"}) + assert.Contains(t, aeFaults(t, inv), faultMarginLine) + assert.Equal(t, cbc.Code("E"), inv.Lines[0].Taxes[0].Ext.Get(untdid.ExtKeyTaxCategory)) + + for _, key := range []cbc.Key{tax.KeyExempt, tax.KeyStandard} { + inv = margin(pint.TagMarginScheme) + inv.Discounts = []*bill.Discount{{Reason: "Loyalty", Amount: num.MakeAmount(100, 2), Taxes: tax.Set{lineCombo(key)}}} + inv.Charges = []*bill.Charge{{Reason: "Delivery", Amount: num.MakeAmount(100, 2), Taxes: tax.Set{lineCombo(key)}}} + out := aeFaults(t, inv) + assert.Contains(t, out, faultMarginDiscount, key) + assert.Contains(t, out, faultMarginCharge, key) + } + }) +} + +func TestBillTagsOutsideAE(t *testing.T) { + const faultTags = "GOBL-PEPPOL-PINT-BILL-INVOICE-69" + tagFaults := func(t *testing.T, inv *bill.Invoice) string { + t.Helper() + require.NoError(t, inv.Calculate()) + return faults(t, inv, tax.RegimeContext(inv.GetRegime())) + } + aeTags := []cbc.Key{ + pint.TagOutsideTaxScope, pint.TagFreeTradeZone, pint.TagDeemedSupply, pint.TagMarginScheme, + pint.TagSummary, pint.TagContinuousSupply, pint.TagDisclosedAgent, pint.TagECommerce, tax.TagExport, + } + + t.Run("UAE documents can use every tag", func(t *testing.T) { + inv := scenarioInvoice(l10n.AE.Tax(), bill.InvoiceTypeStandard, aeTags...) + assert.NotContains(t, tagFaults(t, inv), faultTags) + }) + + t.Run("other documents can't use the PINT AE tags", func(t *testing.T) { + for _, tag := range aeTags { + if tag == pint.TagMarginScheme { + // The UAE regime defines it, so GOBL rejects it first. + continue + } + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard, tag) + assert.Contains(t, tagFaults(t, inv), faultTags, tag) + } + }) + + t.Run("other documents keep the tags GOBL and their regime define", func(t *testing.T) { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard, tax.TagSelfBilled) + assert.NotContains(t, tagFaults(t, inv), faultTags) + + // The Spanish regime has its own "summary" tag. + inv = scenarioInvoice(l10n.ES.Tax(), bill.InvoiceTypeStandard, pint.TagSummary) + assert.NotContains(t, tagFaults(t, inv), faultTags) + }) +} diff --git a/addon/pint/extensions.go b/addon/pint/extensions.go new file mode 100644 index 0000000..510dde6 --- /dev/null +++ b/addon/pint/extensions.go @@ -0,0 +1,175 @@ +package pint + +import ( + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/i18n" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pkg/here" + "github.com/invopop/gobl/regimes/ae" +) + +// PINT AE extension keys, for the BTAE fields GOBL has no place for. +const ( + ExtKeyTransactionType cbc.Key = "peppol-pint-ae-transaction-type" + ExtKeyBeneficiaryID cbc.Key = "peppol-pint-ae-beneficiary-id" // free trade zone beneficiary + ExtKeyPrincipalID cbc.Key = "peppol-pint-ae-principal-id" // principal a disclosed agent bills for + ExtKeyCreditNoteReason cbc.Key = "peppol-pint-ae-credit-note-reason" + ExtKeyGoodsType cbc.Key = "peppol-pint-ae-goods-type" // goods or services under reverse charge +) + +// CreditNoteReasonVolumeDiscount is the credit note reason for a volume discount. +const CreditNoteReasonVolumeDiscount cbc.Code = "VD" + +// principalIDPattern is a UAE TRN ending with 03, as PINT AE asks of the principal ID (IBR-132-AE). +const principalIDPattern = `^1\d{12}03$` + +// Usages of the PINT AE extensions, under the AE regime. +var ( + usageAEInvoiceTax = &cbc.Usage{ + Keys: []cbc.Key{V1}, + Codes: []cbc.Code{ae.CountryCode}, + Schemas: []string{bill.ShortSchemaTax}, + } + usageAEItem = &cbc.Usage{ + Keys: []cbc.Key{V1}, + Codes: []cbc.Code{ae.CountryCode}, + Schemas: []string{org.ShortSchemaItem}, + } +) + +// extensions are the extensions the PINT addon defines. They are only used +// on UAE documents. +var extensions = []*cbc.Definition{ + { + Key: ExtKeyTransactionType, + Usage: usageAEInvoiceTax, + Name: i18n.String{ + i18n.EN: "PINT AE: Transaction Type", + }, + Desc: i18n.String{ + i18n.EN: here.Doc(` + PINT AE invoice transaction type (BTAE-02): 8 flags of 0 or 1, in this + order: free trade zone, deemed supply, profit margin scheme, summary + invoice, continuous supply, disclosed agent billing, supply through + e-commerce, and exports. "00000000" when none applies. + + It is built from the invoice tags with the same names + ("free-trade-zone", "deemed-supply", "margin-scheme", "summary", + "continuous-supply", "disclosed-agent", "e-commerce" and "export"). + A code set directly is replaced. + `), + }, + Sources: []*cbc.Source{ + { + Title: i18n.NewString("Peppol PINT AE Billing specification"), + URL: "https://docs.peppol.eu/poac/ae/pint-ae/bis/", + }, + }, + Pattern: transactionTypePattern, + }, + { + Key: ExtKeyBeneficiaryID, + Usage: usageAEInvoiceTax, + Name: i18n.String{ + i18n.EN: "PINT AE: Beneficiary ID", + }, + Desc: i18n.String{ + i18n.EN: here.Doc(` + Identifier of the beneficiary of a supply in a free trade zone (BTAE-01), + required with the "free-trade-zone" transaction type (IBR-007-AE). + `), + }, + }, + { + Key: ExtKeyPrincipalID, + Usage: usageAEInvoiceTax, + Name: i18n.String{ + i18n.EN: "PINT AE: Principal ID", + }, + Desc: i18n.String{ + i18n.EN: here.Doc(` + Identifier of the principal a disclosed agent bills on behalf of + (BTAE-14), required with the "disclosed-agent" transaction type + (IBR-137-AE). It is the principal's TRN: 15 digits starting with 1 + and ending with 03 (IBR-132-AE). + `), + }, + Pattern: principalIDPattern, + }, + { + Key: ExtKeyCreditNoteReason, + Usage: usageAEInvoiceTax, + Name: i18n.String{ + i18n.EN: "PINT AE: Credit Note Reason", + }, + Desc: i18n.String{ + i18n.EN: here.Doc(` + Reason for a PINT AE credit note (BTAE-03), from the Reasons for credit + note code list. Required on credit notes (IBR-158-AE). Volume discounts + ("VD") have no preceding invoice; every other reason needs one + (IBR-055-AE). + `), + }, + Sources: []*cbc.Source{ + { + Title: i18n.NewString("PINT AE Reasons for credit note"), + URL: "https://docs.peppol.eu/poac/ae/pint-ae/trn-creditnote/codelist/CreditReason/", + }, + }, + Values: []*cbc.Definition{ + { + Code: "DL8.61.1.A", + Name: i18n.String{i18n.EN: "If the supply was cancelled."}, + }, + { + Code: "DL8.61.1.B", + Name: i18n.String{i18n.EN: "If the tax treatment of the supply has changed due to a change in the nature of the supply."}, + }, + { + Code: "DL8.61.1.C", + Name: i18n.String{i18n.EN: "If the previously agreed consideration for the supply was altered for any reason (i.e. bad debt relief)."}, + }, + { + Code: "DL8.61.1.D", + Name: i18n.String{i18n.EN: "If the recipient of goods or recipient of services returned them to the registrant in full or in part and the Consideration was returned in full or in part."}, + }, + { + Code: "DL8.61.1.E", + Name: i18n.String{i18n.EN: "If the tax was charged or tax treatment was applied in error."}, + }, + { + Code: CreditNoteReasonVolumeDiscount, + Name: i18n.String{i18n.EN: "Volume Discount."}, + }, + }, + }, + { + Key: ExtKeyGoodsType, + Usage: usageAEItem, + Name: i18n.String{ + i18n.EN: "PINT AE: Type of Goods or Services", + }, + Desc: i18n.String{ + i18n.EN: here.Doc(` + Type of goods or services subject to the reverse charge mechanism + (BTAE-09), from the PINT AE code list (IBR-006-AE). Required on the + items of reverse charge lines (IBR-166-AE). + `), + }, + Sources: []*cbc.Source{ + { + Title: i18n.NewString("PINT AE Type of goods or services subject to RCM"), + URL: "https://docs.peppol.eu/poac/ae/pint-ae/trn-invoice/codelist/GoodsType/", + }, + }, + Values: []*cbc.Definition{ + {Code: "DL8.48.8.2", Name: i18n.String{i18n.EN: "Electronic Devices"}}, + {Code: "DL8.48.8.1", Name: i18n.String{i18n.EN: "Gold and Diamonds"}}, + {Code: "DL8.48.8.3", Name: i18n.String{i18n.EN: "Metal Scrap Trading"}}, + {Code: "DL8.48.3.1", Name: i18n.String{i18n.EN: "Crude or refined oil"}}, + {Code: "DL8.48.3.2", Name: i18n.String{i18n.EN: "Unprocessed or processed natural gas"}}, + {Code: "DL8.48.3.3", Name: i18n.String{i18n.EN: "Pure hydrocarbons"}}, + }, + }, +} diff --git a/addon/pint/org_address.go b/addon/pint/org_address.go new file mode 100644 index 0000000..ad03b20 --- /dev/null +++ b/addon/pint/org_address.go @@ -0,0 +1,35 @@ +package pint + +import ( + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// emiratePattern matches the emirate codes PINT AE accepts, its own list rather than ISO 3166-2. +const emiratePattern = `^(AUH|DXB|SHJ|UAQ|FUJ|AJM|RAK)$` + +// orgAddressRules validates addresses on UAE documents. +func orgAddressRules() *rules.Set { + return rules.For(new(org.Address), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.When( + is.Func("UAE address", addressIsAE), + rules.Field("region", + rules.Assert("01", "region must be an emirate code when the country is AE (IBR-128-AE)", + is.Present, is.Matches(emiratePattern), + ), + ), + ), + ), + ) +} + +// addressIsAE reports whether an address is in the UAE. +func addressIsAE(val any) bool { + a, ok := val.(*org.Address) + return ok && a != nil && a.Country == l10n.AE.ISO() +} diff --git a/addon/pint/org_address_test.go b/addon/pint/org_address_test.go new file mode 100644 index 0000000..e2f5b5e --- /dev/null +++ b/addon/pint/org_address_test.go @@ -0,0 +1,68 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pay" + "github.com/stretchr/testify/assert" +) + +func TestOrgAddressRulesAE(t *testing.T) { + const fault = "GOBL-PEPPOL-PINT-ORG-ADDRESS-01" + standard := func() *bill.Invoice { return aeDocument(bill.InvoiceTypeStandard) } + + t.Run("UAE address region must be an emirate code (IBR-128-AE)", func(t *testing.T) { + for _, region := range []string{"Dubai", "DBX", ""} { + inv := standard() + inv.Customer.Addresses[0].Region = region + assert.Contains(t, aeFaults(t, inv), fault, region) + } + }) + + t.Run("every emirate code is accepted (IBR-128-AE)", func(t *testing.T) { + for _, code := range []string{"AUH", "DXB", "SHJ", "UAQ", "FUJ", "AJM", "RAK"} { + inv := standard() + inv.Supplier.Addresses[0].Region = code + assert.NotContains(t, aeFaults(t, inv), fault, code) + } + }) + + t.Run("every party's UAE address is checked (IBR-128-AE)", func(t *testing.T) { + for name, set := range map[string]func(inv *bill.Invoice, p *org.Party){ + "tax representative": func(inv *bill.Invoice, p *org.Party) { inv.Ordering = &bill.Ordering{Seller: p} }, + "issuer": func(inv *bill.Invoice, p *org.Party) { inv.Ordering = &bill.Ordering{Issuer: p} }, + "line seller": func(inv *bill.Invoice, p *org.Party) { inv.Lines[0].Seller = p }, + "delivery receiver": func(inv *bill.Invoice, p *org.Party) { inv.Delivery = &bill.DeliveryDetails{Receiver: p} }, + "payee": func(inv *bill.Invoice, p *org.Party) { inv.Payment = &bill.PaymentDetails{Payee: p} }, + } { + inv := standard() + set(inv, &org.Party{Name: "Party", Addresses: aeAddress("Dubai")}) + assert.Contains(t, aeFaults(t, inv), fault, name) + + inv = standard() + set(inv, &org.Party{Name: "Party", Addresses: aeAddress("DXB")}) + assert.NotContains(t, aeFaults(t, inv), fault, name) + } + }) + + t.Run("bank branch UAE address is checked too (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Payment = &bill.PaymentDetails{Instructions: &pay.Instructions{ + Key: pay.MeansKeyCreditTransfer, + CreditTransfer: []*pay.CreditTransfer{{ + IBAN: "AE070331234567890123456", + Branch: &org.Address{Locality: "Dubai", Region: "Dubai", Country: "AE"}, + }}, + }} + assert.Contains(t, aeFaults(t, inv), fault) + }) + + t.Run("foreign address region is not checked (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Customer.TaxID = nil + inv.Customer.Addresses = []*org.Address{{Street: "Hauptstr. 1", Locality: "Berlin", Region: "Berlin", Country: "DE"}} + assert.NotContains(t, aeFaults(t, inv), fault) + }) +} diff --git a/addon/pint/org_identity.go b/addon/pint/org_identity.go new file mode 100644 index 0000000..87d58c2 --- /dev/null +++ b/addon/pint/org_identity.go @@ -0,0 +1,151 @@ +package pint + +import ( + "slices" + + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// IdentityTypePassport is the PINT AE legal registration type of a passport (BTAE-15, BTAE-16). +const IdentityTypePassport cbc.Code = "PAS" + +// identityTypesAE are the AE regime's identity types that are PINT AE legal +// registration identifier types. +var identityTypesAE = []cbc.Code{ + ae.IdentityTypeTradeLicense, + ae.IdentityTypeEmiratesID, + ae.IdentityTypeCabinetDecision, +} + +// orgIdentityRules validates identities on UAE documents. +func orgIdentityRules() *rules.Set { + return rules.For(new(org.Identity), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.When( + org.IdentityKeyIn(org.IdentityKeyPassport), + rules.Field("country", + rules.Assert("01", "passport must have the issuing country (IBR-012-AE, IBR-010-AE)", is.Present), + ), + ), + // IBR-101-AE exempts the endpoints 9900000098 and 9900000099, but an identity can't see its party's endpoint. + rules.When( + org.IdentityTypeIn(ae.IdentityTypeTradeLicense), + rules.Field("description", + rules.Assert("02", "trade license must have the issuing authority in the description (IBR-172-AE, IBR-101-AE)", is.Present), + ), + ), + ), + ) +} + +// IdentityTypeAE returns the PINT AE legal registration identifier type of an +// identity, or an empty code if it has none. +func IdentityTypeAE(id *org.Identity) cbc.Code { + switch { + case id == nil: + return "" + case id.Key == org.IdentityKeyPassport: + return IdentityTypePassport + case id.Type.In(identityTypesAE...): + return id.Type + } + return "" +} + +// SetIdentityTypeAE sets the identity's key or type from a PINT AE legal +// registration identifier type, and reports whether the type is known. +func SetIdentityTypeAE(id *org.Identity, typ cbc.Code) bool { + switch { + case typ == IdentityTypePassport: + id.Key = org.IdentityKeyPassport + case typ.In(identityTypesAE...): + id.Type = typ + default: + return false + } + return true +} + +// normalizeIdentityScopes scopes the supplier and customer identities where PINT AE reads them: legal +// for the registration types, and tax for the supplier's TIN. +func normalizeIdentityScopes(inv *bill.Invoice) { + if inv == nil { + return + } + setIdentityScopes(inv.Supplier, org.IdentityScopeLegal, org.IdentityScopeTax) + setIdentityScopes(inv.Customer, org.IdentityScopeLegal) +} + +// setIdentityScopes gives unscoped identities their PINT AE scope, if it's one of scopes and still free, as +// EN 16931 allows one identity per scope. +func setIdentityScopes(p *org.Party, scopes ...cbc.Key) { + if p == nil { + return + } + taken := make(map[cbc.Key]bool) + for _, id := range p.Identities { + if id != nil { + taken[id.Scope] = true + } + } + for _, id := range p.Identities { + if id == nil || id.Scope != "" { + continue + } + if scope := identityScopeAE(id); scope.In(scopes...) && !taken[scope] { + id.Scope = scope + taken[scope] = true + } + } +} + +// identityScopeAE returns the scope PINT AE reads an identity from, or an +// empty key if it has none. +func identityScopeAE(id *org.Identity) cbc.Key { + if id.Type == ae.IdentityTypeTIN { + return org.IdentityScopeTax + } + if IdentityTypeAE(id) != "" { + return org.IdentityScopeLegal + } + return "" +} + +// IdentitySchemeGTIN is the ISO 6523 scheme of a GTIN. +const IdentitySchemeGTIN cbc.Code = "0160" + +// GTINIdentity returns the first identity with the GTIN scheme, or nil. +func GTINIdentity(ids []*org.Identity) *org.Identity { + for _, id := range ids { + if id != nil && id.Ext.Get(iso.ExtKeySchemeID) == IdentitySchemeGTIN { + return id + } + } + return nil +} + +// identityScopeIn returns a predicate that reports whether an identity has one of the scopes, "" for none. +func identityScopeIn(scopes ...cbc.Key) func(any) bool { + return func(val any) bool { + id, ok := val.(*org.Identity) + return ok && id != nil && id.Scope.In(scopes...) + } +} + +// identitiesScopeIn returns a predicate that reports whether any of the +// identities has one of the scopes, the empty one for none. +func identitiesScopeIn(scopes ...cbc.Key) func(any) bool { + match := identityScopeIn(scopes...) + return func(val any) bool { + ids, ok := val.([]*org.Identity) + return ok && slices.ContainsFunc(ids, func(id *org.Identity) bool { return match(id) }) + } +} diff --git a/addon/pint/org_identity_test.go b/addon/pint/org_identity_test.go new file mode 100644 index 0000000..91d84c1 --- /dev/null +++ b/addon/pint/org_identity_test.go @@ -0,0 +1,177 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/addons/eu/en16931" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/norm" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" +) + +func TestIdentityTypeAE(t *testing.T) { + tests := []struct { + id *org.Identity + want cbc.Code + }{ + {&org.Identity{Type: ae.IdentityTypeTradeLicense}, "TL"}, + {&org.Identity{Type: ae.IdentityTypeEmiratesID}, "EID"}, + {&org.Identity{Key: org.IdentityKeyPassport}, pint.IdentityTypePassport}, + {&org.Identity{Type: ae.IdentityTypeCabinetDecision}, "CD"}, + {&org.Identity{Type: ae.IdentityTypeTIN}, ""}, + {&org.Identity{}, ""}, + {nil, ""}, + } + for _, tt := range tests { + assert.Equal(t, tt.want, pint.IdentityTypeAE(tt.id), tt.id) + } +} + +func TestSetIdentityTypeAE(t *testing.T) { + tests := map[cbc.Code]org.Identity{ + "TL": {Type: ae.IdentityTypeTradeLicense}, + "EID": {Type: ae.IdentityTypeEmiratesID}, + "PAS": {Key: org.IdentityKeyPassport}, + "CD": {Type: ae.IdentityTypeCabinetDecision}, + "XYZ": {}, + "": {}, + } + for typ, want := range tests { + id := new(org.Identity) + known := want.Key != "" || want.Type != "" + assert.Equal(t, known, pint.SetIdentityTypeAE(id, typ), typ) + assert.Equal(t, want, *id, typ) + } +} + +func TestNormalizeIdentityScopes(t *testing.T) { + scopes := func(p *org.Party) []cbc.Key { + out := make([]cbc.Key, len(p.Identities)) + for i, id := range p.Identities { + out[i] = id.Scope + } + return out + } + // normalize returns the scopes the identities get on the supplier and on + // the customer. + normalize := func(regime l10n.TaxCountryCode, ids func() []*org.Identity) (supplier, customer []cbc.Key) { + inv := &bill.Invoice{ + Supplier: &org.Party{Name: "Supplier", Identities: ids()}, + Customer: &org.Party{Name: "Customer", Identities: ids()}, + } + norm.Normalize(inv, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(regime)) + return scopes(inv.Supplier), scopes(inv.Customer) + } + tin := func() *org.Identity { return &org.Identity{Type: ae.IdentityTypeTIN, Code: "1234567897"} } + eid := func() *org.Identity { return &org.Identity{Type: ae.IdentityTypeEmiratesID, Code: "784199012345671"} } + passport := func() *org.Identity { + return &org.Identity{Key: org.IdentityKeyPassport, Code: "P1234567890", Country: "IN"} + } + list := func(ids ...func() *org.Identity) func() []*org.Identity { + return func() []*org.Identity { + out := make([]*org.Identity, len(ids)) + for i, id := range ids { + out[i] = id() + } + return out + } + } + + t.Run("legal registrations get the legal scope, and the supplier's TIN the tax scope", func(t *testing.T) { + supplier, customer := normalize(l10n.AE.Tax(), list(tin, passport)) + assert.Equal(t, []cbc.Key{org.IdentityScopeTax, org.IdentityScopeLegal}, supplier) + assert.Equal(t, []cbc.Key{"", org.IdentityScopeLegal}, customer, "PINT AE has no customer TIN registration") + + for _, typ := range []cbc.Code{ae.IdentityTypeTradeLicense, ae.IdentityTypeEmiratesID, ae.IdentityTypeCabinetDecision} { + id := func() *org.Identity { return &org.Identity{Type: typ, Code: "784199012345671"} } + supplier, customer = normalize(l10n.AE.Tax(), list(id)) + assert.Equal(t, []cbc.Key{org.IdentityScopeLegal}, supplier, typ) + assert.Equal(t, []cbc.Key{org.IdentityScopeLegal}, customer, typ) + } + }) + + t.Run("only the first identity of each scope gets it", func(t *testing.T) { + supplier, customer := normalize(l10n.AE.Tax(), list(eid, passport)) + assert.Equal(t, []cbc.Key{org.IdentityScopeLegal, ""}, supplier) + assert.Equal(t, []cbc.Key{org.IdentityScopeLegal, ""}, customer) + supplier, _ = normalize(l10n.AE.Tax(), list(tin, tin)) + assert.Equal(t, []cbc.Key{org.IdentityScopeTax, ""}, supplier) + }) + + t.Run("a scope another identity already has is not given again", func(t *testing.T) { + legal := func() *org.Identity { return &org.Identity{Scope: org.IdentityScopeLegal, Code: "CN-1234567"} } + supplier, _ := normalize(l10n.AE.Tax(), list(passport, legal)) + assert.Equal(t, []cbc.Key{"", org.IdentityScopeLegal}, supplier) + }) + + t.Run("an explicit scope is kept", func(t *testing.T) { + id := func() *org.Identity { + id := eid() + id.Scope = org.IdentityScopeTax + return id + } + supplier, _ := normalize(l10n.AE.Tax(), list(id)) + assert.Equal(t, []cbc.Key{org.IdentityScopeTax}, supplier) + }) + + t.Run("other identities get no scope", func(t *testing.T) { + other := func() *org.Identity { return &org.Identity{Type: "XYZ", Code: "123"} } + supplier, _ := normalize(l10n.AE.Tax(), list(other)) + assert.Equal(t, []cbc.Key{""}, supplier) + }) + + t.Run("other parties are left alone", func(t *testing.T) { + inv := &bill.Invoice{ + Supplier: &org.Party{Name: "Supplier"}, + Ordering: &bill.Ordering{Seller: &org.Party{Name: "Tax Rep", Identities: []*org.Identity{eid()}}}, + } + norm.Normalize(inv, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(l10n.AE.Tax())) + assert.Empty(t, inv.Ordering.Seller.Identities[0].Scope) + }) + + t.Run("only under the AE regime", func(t *testing.T) { + supplier, customer := normalize(l10n.AU.Tax(), list(tin, passport)) + assert.Equal(t, []cbc.Key{"", ""}, supplier) + assert.Equal(t, []cbc.Key{"", ""}, customer) + }) +} + +func TestOrgIdentityRulesAE(t *testing.T) { + const ( + fault = "GOBL-PEPPOL-PINT-ORG-IDENTITY-01" + faultAuthority = "GOBL-PEPPOL-PINT-ORG-IDENTITY-02" + ) + + t.Run("passport needs the issuing country (IBR-012-AE, IBR-010-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities = []*org.Identity{{Key: org.IdentityKeyPassport, Code: "P9876543210"}} + assert.Contains(t, aeFaults(t, inv), fault) + + inv = aeIdentityDocument() + inv.Customer.Identities = []*org.Identity{{Key: org.IdentityKeyPassport, Code: "P1234567890"}} + assert.Contains(t, aeFaults(t, inv), fault) + + inv = aeIdentityDocument() + inv.Customer.Identities = []*org.Identity{{Key: org.IdentityKeyPassport, Code: "P1234567890", Country: "IN"}} + assert.NotContains(t, aeFaults(t, inv), fault) + }) + t.Run("trade licence needs the issuing authority (IBR-172-AE, IBR-101-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities[0].Description = "" + assert.Contains(t, aeFaults(t, inv), faultAuthority) + + // IBR-101-AE exempts these buyers, but the rule can't see the endpoint. + inv = aeIdentityDocument() + inv.Customer.Endpoints = uaeEndpoints("9900000098") + inv.Customer.Identities[0].Description = "" + assert.Contains(t, aeFaults(t, inv), faultAuthority) + + assert.NotContains(t, aeFaults(t, aeIdentityDocument()), faultAuthority) + }) +} diff --git a/addon/pint/org_item.go b/addon/pint/org_item.go new file mode 100644 index 0000000..44d7c95 --- /dev/null +++ b/addon/pint/org_item.go @@ -0,0 +1,131 @@ +package pint + +import ( + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// ItemKeyGoodsServices is the item key for PINT AE's item type B, both goods and services. +const ItemKeyGoodsServices cbc.Key = "goods-services" + +// PINT AE item types, written as the item's +// cac:CommodityClassification/cbc:CommodityCode (BTAE-13). +const ( + ItemTypeGoods cbc.Code = "G" + ItemTypeServices cbc.Code = "S" + ItemTypeGoodsServices cbc.Code = "B" +) + +// Labels of the item identities PINT AE uses. +const ( + IdentityLabelHS = "HS" // HS item classification + IdentityLabelSAC = "SAC" // service accounting code +) + +// ItemTypeAE returns the PINT AE item type for an item key, or an empty code +// if the key has none. +func ItemTypeAE(key cbc.Key) cbc.Code { + switch key { + case org.ItemKeyGoods: + return ItemTypeGoods + case org.ItemKeyServices: + return ItemTypeServices + case ItemKeyGoodsServices: + return ItemTypeGoodsServices + } + return "" +} + +// ItemKeyAE returns the item key for a PINT AE item type, or an empty key if +// the type is unknown. +func ItemKeyAE(typ cbc.Code) cbc.Key { + switch typ { + case ItemTypeGoods: + return org.ItemKeyGoods + case ItemTypeServices: + return org.ItemKeyServices + case ItemTypeGoodsServices: + return ItemKeyGoodsServices + } + return "" +} + +// orgItemRules validates items on UAE documents. +func orgItemRules() *rules.Set { + return rules.For(new(org.Item), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.When( + is.Func("goods", itemKeyIs(org.ItemKeyGoods)), + rules.Field("identities", + rules.Assert("01", "goods item needs an HS item classification (IBR-184-AE)", + is.Func("has HS", identitiesHaveLabel(IdentityLabelHS)), + ), + ), + ), + rules.When( + is.Func("goods and services", itemKeyIs(ItemKeyGoodsServices)), + rules.Field("identities", + rules.Assert("02", "goods and services item needs an HS item classification (IBR-186-AE)", + is.Func("has HS", identitiesHaveLabel(IdentityLabelHS)), + ), + ), + ), + // IBR-188-AE's text wants every classification to be HS, but its test passes when any one is. + rules.Field("identities", + rules.Assert("03", "item classifications must include one from the HS list (IBR-188-AE)", + is.Func("classifications include HS", identitiesClassifiedWithHS), + ), + ), + ), + ) +} + +// itemKeyIs returns a predicate that reports whether an item has the key. +func itemKeyIs(key cbc.Key) func(any) bool { + return func(val any) bool { + it, ok := val.(*org.Item) + return ok && it != nil && it.Key == key + } +} + +// identitiesHaveLabel returns a predicate that reports whether one of the item classifications, +// the identities with a label and no scheme ID, has the label. +func identitiesHaveLabel(label string) func(any) bool { + return func(val any) bool { + ids, ok := val.([]*org.Identity) + if !ok { + return false + } + for _, id := range ids { + if id != nil && id.Label == label && !id.Ext.Has(iso.ExtKeySchemeID) { + return true + } + } + return false + } +} + +// identitiesClassifiedWithHS reports whether the item classifications, if any, include an HS one. +// SAC codes don't count. +func identitiesClassifiedWithHS(val any) bool { + ids, ok := val.([]*org.Identity) + if !ok { + return false + } + classified := false + for _, id := range ids { + if id == nil || id.Label == "" || id.Label == IdentityLabelSAC || id.Ext.Has(iso.ExtKeySchemeID) { + continue + } + if id.Label == IdentityLabelHS { + return true + } + classified = true + } + return !classified +} diff --git a/addon/pint/org_item_test.go b/addon/pint/org_item_test.go new file mode 100644 index 0000000..5a02b0e --- /dev/null +++ b/addon/pint/org_item_test.go @@ -0,0 +1,77 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" +) + +func TestItemKeyAE(t *testing.T) { + tests := map[cbc.Code]cbc.Key{ + "G": org.ItemKeyGoods, + "S": org.ItemKeyServices, + "B": pint.ItemKeyGoodsServices, + "X": "", + "": "", + } + for typ, want := range tests { + assert.Equal(t, want, pint.ItemKeyAE(typ), typ) + } +} + +func TestOrgItemRulesAE(t *testing.T) { + const ( + faultGoodsHS = "GOBL-PEPPOL-PINT-ORG-ITEM-01" + faultGoodsServices = "GOBL-PEPPOL-PINT-ORG-ITEM-02" + faultClassification = "GOBL-PEPPOL-PINT-ORG-ITEM-03" + ) + hs := &org.Identity{Label: pint.IdentityLabelHS, Code: "8471"} + sac := &org.Identity{Label: pint.IdentityLabelSAC, Code: "998713"} + item := func(key cbc.Key, ids ...*org.Identity) *bill.Invoice { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Lines[0].Item.Key = key + inv.Lines[0].Item.Identities = ids + return inv + } + + t.Run("goods need an HS classification (IBR-184-AE)", func(t *testing.T) { + assert.Contains(t, aeFaults(t, item(org.ItemKeyGoods)), faultGoodsHS) + assert.Contains(t, aeFaults(t, item(org.ItemKeyGoods, sac)), faultGoodsHS) + assert.NotContains(t, aeFaults(t, item(org.ItemKeyGoods, hs)), faultGoodsHS) + + // An identity with a scheme ID isn't written as a classification. + withScheme := &org.Identity{Label: pint.IdentityLabelHS, Code: "8471", Ext: tax.ExtensionsOf(cbc.CodeMap{iso.ExtKeySchemeID: "0088"})} + assert.Contains(t, aeFaults(t, item(org.ItemKeyGoods, withScheme)), faultGoodsHS) + }) + + t.Run("goods and services need an HS classification (IBR-186-AE)", func(t *testing.T) { + assert.Contains(t, aeFaults(t, item(pint.ItemKeyGoodsServices)), faultGoodsServices) + assert.Contains(t, aeFaults(t, item(pint.ItemKeyGoodsServices, sac)), faultGoodsServices) + assert.NotContains(t, aeFaults(t, item(pint.ItemKeyGoodsServices, hs)), faultGoodsServices) + }) + + t.Run("no item type needs neither", func(t *testing.T) { + out := aeFaults(t, item("")) + assert.NotContains(t, out, faultGoodsHS) + assert.NotContains(t, out, faultGoodsServices) + }) + + t.Run("item classifications must include an HS one (IBR-188-AE)", func(t *testing.T) { + cpv := &org.Identity{Label: "CPV", Code: "30200000"} + assert.Contains(t, aeFaults(t, item("", cpv)), faultClassification) + assert.Contains(t, aeFaults(t, item("", cpv, sac)), faultClassification) + assert.NotContains(t, aeFaults(t, item("", hs, cpv)), faultClassification) + assert.NotContains(t, aeFaults(t, item("", hs, sac)), faultClassification) + assert.NotContains(t, aeFaults(t, item("", sac)), faultClassification) + + // Identities with a scheme ID aren't classifications. + gtin := &org.Identity{Label: "GTIN", Code: "4006381333931", Ext: tax.ExtensionsOf(cbc.CodeMap{iso.ExtKeySchemeID: "0160"})} + assert.NotContains(t, aeFaults(t, item("", gtin)), faultClassification) + }) +} diff --git a/addon/pint/org_party.go b/addon/pint/org_party.go new file mode 100644 index 0000000..5691568 --- /dev/null +++ b/addon/pint/org_party.go @@ -0,0 +1,242 @@ +package pint + +import ( + "regexp" + "slices" + "strings" + + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pkg/luhn" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// endpointSchemeMailto is the URI scheme of email endpoints, which gobl.ubl +// writes as cbc:EndpointID with the scheme endpointSchemeEmail. +const endpointSchemeMailto = "mailto" + +// endpointSchemeEmail is the electronic address scheme gobl.ubl writes for +// email addresses. +const endpointSchemeEmail cbc.Code = "EM" + +// orgPartyRules validates parties on UAE documents. +// +// TODO: a delivery receiver with a UAE tax ID and a foreign address gets an emirate error PINT AE wouldn't. +func orgPartyRules() *rules.Set { + return rules.For(new(org.Party), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + // gobl.ubl writes a UAE tax ID's country over the address's, so the address counts as UAE. + rules.When( + is.Func("UAE tax ID", partyHasAETaxID), + rules.Field("addresses", + rules.Assert("01", "address is required with a UAE tax ID (IBR-128-AE)", is.Present), + rules.Each( + rules.When( + is.Not(is.Func("UAE address", addressIsAE)), + rules.Field("region", + rules.Assert("02", "region must be an emirate code with a UAE tax ID (IBR-128-AE)", + is.Present, is.Matches(emiratePattern), + ), + ), + ), + ), + ), + ), + // IBR-183-AE also exempts other 1XXXXXXXXX endpoints, but IBR-180-AE still asks them for a type. + rules.When( + is.Func("has UAE Peppol endpoint other than 9900000098 or 9900000099", partyHasUAEEndpoint(endpointPatternPredefined, false)), + rules.Field("identities", rules.Each( + rules.When( + is.Func("legal scope", identityScopeIn(org.IdentityScopeLegal)), + rules.Assert("03", "legal identity must be a trade license, Emirates ID, passport or Cabinet Decision with a UAE Peppol endpoint other than 9900000098 or 9900000099 (IBR-173-AE, IBR-181-AE, IBR-180-AE, IBR-183-AE)", + is.Or(org.IdentityKeyIn(org.IdentityKeyPassport), org.IdentityTypeIn(identityTypesAE...)), + ), + ), + )), + ), + ), + ) +} + +// partyHasAETaxID reports whether the party has a UAE tax ID with a code, +// which gobl.ubl writes with its country. +func partyHasAETaxID(val any) bool { + p, ok := val.(*org.Party) + return ok && p != nil && p.TaxID != nil && p.TaxID.Code != "" && p.TaxID.Country.Code() == l10n.AE +} + +// partyHasOneIdentification reports whether gobl.ubl writes at most one cac:PartyIdentification. +func partyHasOneIdentification(val any) bool { + p, ok := val.(*org.Party) + return ok && p != nil && len(partyIdentifications(p)) <= 1 +} + +// payeeIsNotSupplier reports whether the payee differs from the supplier by legal identity, else by +// identification, else by name. +func payeeIsNotSupplier(val any) bool { + inv, ok := val.(*bill.Invoice) + if !ok || inv == nil || inv.Payment == nil || inv.Payment.Payee == nil || inv.Supplier == nil { + return true + } + payee, supplier := inv.Payment.Payee, inv.Supplier + if p, s := partyFirstLegalIdentity(payee), partyFirstLegalIdentity(supplier); p != nil && s != nil { + return p.Code != s.Code || p.Ext.Get(iso.ExtKeySchemeID) != s.Ext.Get(iso.ExtKeySchemeID) + } + if ps, ss := partyIdentifications(payee), partyIdentifications(supplier); len(ps) > 0 && len(ss) > 0 { + for _, p := range ps { + if slices.ContainsFunc(ss, func(s *org.Identity) bool { + return p.Code == s.Code && identificationScheme(p) == identificationScheme(s) + }) { + return false + } + } + return true + } + name := payee.Name + if payee.Alias != "" { + // gobl.ubl writes the alias as the payee's cac:PartyName. + name = payee.Alias + } + return name == "" || supplier.Name == "" || + !strings.EqualFold(strings.TrimSpace(name), strings.TrimSpace(supplier.Name)) +} + +// partyIdentifications returns the party's identities gobl.ubl writes as +// cac:PartyIdentification: all but the tax scope ones and the first legal +// one. +func partyIdentifications(p *org.Party) []*org.Identity { + legal := partyFirstLegalIdentity(p) + var ids []*org.Identity + for _, id := range p.Identities { + if id != nil && id != legal && id.Scope != org.IdentityScopeTax { + ids = append(ids, id) + } + } + return ids +} + +// identificationScheme returns the scheme gobl.ubl writes as the @schemeID +// of an identity's cac:PartyIdentification: its ISO 6523 scheme, or its type +// when it has no extensions. +func identificationScheme(id *org.Identity) cbc.Code { + if id.Ext.IsZero() { + return id.Type + } + return id.Ext.Get(iso.ExtKeySchemeID) +} + +// partyEndpointID returns the scheme and code gobl.ubl writes as the party's cbc:EndpointID. +func partyEndpointID(p *org.Party) (cbc.Code, string) { + if e := p.Endpoint(iso.ActorIDScheme); e != nil { + // An ISO 6523 URI reads "iso6523-actorid-upis:::". + scheme, code, ok := strings.Cut(strings.TrimPrefix(e.URI.Opaque(), ":"), ":") + if ok && scheme != "" && code != "" { + return cbc.Code(scheme), code + } + } + if e := p.Endpoint(endpointSchemeMailto); e != nil && e.URI.Opaque() != "" { + return endpointSchemeEmail, e.URI.Opaque() + } + for _, ib := range p.Inboxes { + if ib == nil { + continue + } + if ib.Email != "" { + return endpointSchemeEmail, ib.Email + } + if ib.Scheme != "" { + return ib.Scheme, ib.Code.String() + } + } + return "", "" +} + +// Patterns of the UAE Peppol endpoint codes the PINT AE rules depend on. +const ( + endpointPatternPredefined = `^99000000(98|99)$` + endpointPatternDeemedSupply = `^9900000097$` + endpointPattern1or9 = `^[19]\d{9}$` +) + +// partyHasUAEEndpoint returns a predicate that reports whether the party's +// electronic address, as gobl.ubl chooses it, uses the UAE Peppol scheme 0235 +// with a code that matches the pattern, or that doesn't when match is false. +func partyHasUAEEndpoint(pattern string, match bool) func(any) bool { + re := regexp.MustCompile(pattern) + return func(val any) bool { + p, ok := val.(*org.Party) + if !ok || p == nil { + return false + } + scheme, code := partyEndpointID(p) + return scheme == ae.TINScheme && re.MatchString(code) == match + } +} + +// partyFirstLegalIdentity returns the party's first identity with the legal +// scope, the one gobl.ubl writes as cac:PartyLegalEntity/cbc:CompanyID, or nil +// if there is none. +func partyFirstLegalIdentity(val any) *org.Identity { + p, ok := val.(*org.Party) + if !ok || p == nil { + return nil + } + for _, id := range p.Identities { + if id != nil && id.Scope == org.IdentityScopeLegal { + return id + } + } + return nil +} + +// trnRegexpAE matches a UAE TRN, in the AE regime's format. Its first 10 +// digits are the TIN. +var trnRegexpAE = regexp.MustCompile(ae.TRNPattern) + +// normalizeSupplierAE adds the TIN identity (IBT-032) and 0235: endpoint a UAE supplier's TRN implies, +// unless it already has a TIN or tax identity, or any endpoint or inbox. +// TODO: derive the customer's endpoint from its TRN too. +func normalizeSupplierAE(inv *bill.Invoice) { + if inv == nil || inv.Supplier == nil { + return + } + p := inv.Supplier + tin := partyTINFromTRN(p) + if tin == "" { + return + } + if !slices.ContainsFunc(p.Identities, func(id *org.Identity) bool { + return id != nil && (id.Type == ae.IdentityTypeTIN || id.Scope == org.IdentityScopeTax) + }) { + p.Identities = append(p.Identities, &org.Identity{ + Type: ae.IdentityTypeTIN, + Code: tin, + Scope: org.IdentityScopeTax, + }) + } + if len(p.Endpoints) == 0 && len(p.Inboxes) == 0 { + p.Endpoints = append(p.Endpoints, &org.Endpoint{ + URI: cbc.URI(iso.ActorIDScheme + "::" + ae.TINScheme.String() + ":" + tin.String()), + }) + } +} + +// partyTINFromTRN returns the TIN a valid UAE TRN starts with, or "", so an invalid TRN gives one error, +// not a second one on a derived TIN. +func partyTINFromTRN(p *org.Party) cbc.Code { + if p.TaxID == nil || p.TaxID.Country != l10n.AE.Tax() { + return "" + } + code := p.TaxID.Code.String() + if !trnRegexpAE.MatchString(code) || !luhn.Check(cbc.Code(code[:10])) { + return "" + } + return cbc.Code(code[:10]) +} diff --git a/addon/pint/org_party_test.go b/addon/pint/org_party_test.go new file mode 100644 index 0000000..30c1bc9 --- /dev/null +++ b/addon/pint/org_party_test.go @@ -0,0 +1,209 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/addons/eu/en16931" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/norm" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" +) + +func TestNormalizeSupplierAE(t *testing.T) { + // normalize returns the supplier after normalizing an invoice under the + // regime. + normalize := func(regime l10n.TaxCountryCode, p *org.Party) *org.Party { + inv := &bill.Invoice{Supplier: p} + norm.Normalize(inv, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(regime)) + return inv.Supplier + } + trn := func() *org.Party { + return &org.Party{Name: "Supplier", TaxID: &tax.Identity{Country: "AE", Code: "100000001600003"}} + } + tinIdentity := &org.Identity{Type: ae.IdentityTypeTIN, Code: "1000000016", Scope: org.IdentityScopeTax} + tinEndpoint := &org.Endpoint{URI: "iso6523-actorid-upis::0235:1000000016"} + + t.Run("the TRN gives the TIN identity and the UAE Peppol endpoint", func(t *testing.T) { + p := normalize(l10n.AE.Tax(), trn()) + assert.Equal(t, []*org.Identity{tinIdentity}, p.Identities) + assert.Equal(t, []*org.Endpoint{tinEndpoint}, p.Endpoints) + }) + + t.Run("a TIN or tax scope identity is kept", func(t *testing.T) { + for _, id := range []*org.Identity{ + {Type: ae.IdentityTypeTIN, Code: "1234567897"}, + {Scope: org.IdentityScopeTax, Code: "1234567897"}, + } { + p := trn() + p.Identities = []*org.Identity{id} + p = normalize(l10n.AE.Tax(), p) + assert.Len(t, p.Identities, 1) + assert.Equal(t, cbc.Code("1234567897"), p.Identities[0].Code) + } + }) + + t.Run("a Peppol endpoint is kept", func(t *testing.T) { + p := trn() + p.Endpoints = []*org.Endpoint{{URI: "iso6523-actorid-upis::0088:5790000435975"}} + assert.Len(t, normalize(l10n.AE.Tax(), p).Endpoints, 1) + }) + + t.Run("an existing Peppol inbox stops the UAE endpoint", func(t *testing.T) { + p := trn() + p.Inboxes = []*org.Inbox{{Scheme: "0235", Code: "1234567897"}} + assert.Empty(t, normalize(l10n.AE.Tax(), p).Endpoints) + }) + + t.Run("an email endpoint or inbox is kept, without the UAE Peppol endpoint", func(t *testing.T) { + p := trn() + p.Endpoints = []*org.Endpoint{{URI: "mailto:billing@example.com"}} + assert.NotContains(t, normalize(l10n.AE.Tax(), p).Endpoints, tinEndpoint) + + p = trn() + p.Inboxes = []*org.Inbox{{Email: "billing@example.com"}} + assert.Empty(t, normalize(l10n.AE.Tax(), p).Endpoints) + }) + + t.Run("a tax ID that is not a valid TRN gives nothing", func(t *testing.T) { + // The last one has the TRN format, but its TIN fails the check digit. + for _, code := range []cbc.Code{"", "10000000160000", "200000001600003", "1000000016000A3", "100000001700003"} { + p := trn() + p.TaxID.Code = code + p = normalize(l10n.AE.Tax(), p) + assert.Empty(t, p.Identities, code) + assert.Empty(t, p.Endpoints, code) + } + p := trn() + p.TaxID = &tax.Identity{Country: "SA", Code: "100000001600003"} + p = normalize(l10n.AE.Tax(), p) + assert.Empty(t, p.Identities) + assert.Empty(t, p.Endpoints) + }) + + t.Run("only under the AE regime", func(t *testing.T) { + p := normalize(l10n.AU.Tax(), trn()) + assert.Empty(t, p.Identities) + assert.Empty(t, p.Endpoints) + }) +} + +func TestOrgPartyRulesAE(t *testing.T) { + const ( + faultAddress = "GOBL-PEPPOL-PINT-ORG-PARTY-01" + faultEmirate = "GOBL-PEPPOL-PINT-ORG-PARTY-02" + faultLegalType = "GOBL-PEPPOL-PINT-ORG-PARTY-03" + ) + standard := func() *bill.Invoice { return aeDocument(bill.InvoiceTypeStandard) } + trn := func() *tax.Identity { return &tax.Identity{Country: "AE", Code: "100000003200003"} } + oman := func() []*org.Address { + return []*org.Address{{Street: "Street 1", Locality: "Muscat", Region: "Muscat", Country: "OM"}} + } + + t.Run("a UAE tax ID makes every address count as in the UAE (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Supplier.Addresses = oman() + assert.Contains(t, aeFaults(t, inv), faultEmirate) + + inv = standard() + inv.Ordering = &bill.Ordering{Seller: &org.Party{Name: "Tax Rep", TaxID: trn(), Addresses: oman()}} + assert.Contains(t, aeFaults(t, inv), faultEmirate) + + inv = standard() + inv.Supplier.Addresses = oman() + inv.Supplier.Addresses[0].Region = "DXB" + assert.NotContains(t, aeFaults(t, inv), faultEmirate) + }) + + t.Run("a UAE tax ID needs an address, as one is written (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Ordering = &bill.Ordering{Issuer: &org.Party{Name: "Issuer", TaxID: trn()}} + assert.Contains(t, aeFaults(t, inv), faultAddress) + + inv = standard() + inv.Payment = &bill.PaymentDetails{Payee: &org.Party{Name: "Payee", TaxID: trn()}} + assert.Contains(t, aeFaults(t, inv), faultAddress) + }) + + t.Run("UAE addresses are left to the address rules (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Supplier.Addresses[0].Region = "Dubai" + assert.NotContains(t, aeFaults(t, inv), faultEmirate) + }) + + t.Run("other parties are not checked (IBR-128-AE)", func(t *testing.T) { + inv := standard() + inv.Lines[0].Seller = &org.Party{ + Name: "Maker", + TaxID: &tax.Identity{Country: "DE", Code: "111111125"}, + Addresses: []*org.Address{{Street: "Hauptstr. 1", Locality: "Berlin", Region: "Berlin", Country: "DE"}}, + } + inv.Ordering = &bill.Ordering{Issuer: &org.Party{Name: "Issuer"}} + out := aeFaults(t, inv) + assert.NotContains(t, out, faultAddress) + assert.NotContains(t, out, faultEmirate) + }) + + t.Run("legal identity needs a PINT AE type with a UAE endpoint (IBR-173-AE, IBR-181-AE, IBR-180-AE, IBR-183-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Supplier.Identities = []*org.Identity{{Scope: org.IdentityScopeLegal, Code: "CN-1234567"}} + assert.Contains(t, aeFaults(t, inv), faultLegalType) + + inv = aeIdentityDocument() + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeLegal, Code: "CN-7654321"}} + assert.Contains(t, aeFaults(t, inv), faultLegalType) + }) + + t.Run("customer legal identity without a type is fine without a UAE endpoint", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Customer.Endpoints = validEndpoints("1345678906") + inv.Customer.Identities = []*org.Identity{{Scope: org.IdentityScopeLegal, Code: "CN-7654321"}} + assert.NotContains(t, aeFaults(t, inv), faultLegalType) + }) + + t.Run("customer with a predefined UAE endpoint needs no legal identity type (IBR-180-AE, IBR-183-AE)", func(t *testing.T) { + for _, code := range []string{"9900000098", "9900000099"} { + inv := aeIdentityDocument() + inv.Customer.Endpoints = uaeEndpoints(code) + inv.Customer.Identities = []*org.Identity{ + {Scope: org.IdentityScopeLegal, Code: "CN-7654321"}, + } + assert.NotContains(t, aeFaults(t, inv), faultLegalType, code) + } + }) + + t.Run("customer with another predefined UAE endpoint still needs one (IBR-180-AE, IBR-183-AE)", func(t *testing.T) { + inv := aeIdentityDocument() + inv.Customer.Endpoints = uaeEndpoints("9900000097") + inv.Customer.Identities = []*org.Identity{ + {Scope: org.IdentityScopeLegal, Code: "CN-7654321"}, + } + assert.Contains(t, aeFaults(t, inv), faultLegalType) + }) + + t.Run("each PINT AE type is accepted (IBR-173-AE, IBR-183-AE)", func(t *testing.T) { + for _, id := range []*org.Identity{ + {Type: ae.IdentityTypeEmiratesID, Code: "784199012345671"}, + {Key: org.IdentityKeyPassport, Code: "P1234567890", Country: "IN"}, + {Type: ae.IdentityTypeCabinetDecision, Code: "CD-12-2020"}, + } { + inv := aeIdentityDocument() + inv.Supplier.Identities = []*org.Identity{id} + assert.Empty(t, aeFaults(t, inv), id.Key) + } + }) + + t.Run("every legal identity is checked (IBR-173-AE)", func(t *testing.T) { + // EN 16931 already rejects a second legal identity. + inv := aeIdentityDocument() + inv.Supplier.Identities[0].Scope = org.IdentityScopeLegal + inv.Supplier.Identities = append(inv.Supplier.Identities, + &org.Identity{Scope: org.IdentityScopeLegal, Code: "CN-1234567"}) + assert.Contains(t, aeFaults(t, inv), faultLegalType) + }) +} diff --git a/addon/pint/pay.go b/addon/pint/pay.go index 45549a6..c79a600 100644 --- a/addon/pint/pay.go +++ b/addon/pint/pay.go @@ -16,18 +16,31 @@ const ( meansCodeSEPACreditTransfer cbc.Code = "58" ) -// payInstructionsRules enforces the A-NZ payment instruction rules on -// Australian and New Zealand documents. +// payInstructionsRules validates payment instructions on A-NZ and UAE documents. func payInstructionsRules() *rules.Set { return rules.For(new(pay.Instructions), rules.When( is.InContext(tax.RegimeIn(regimesAUNZ...)), - rules.When(is.Func("payment means is credit transfer", instructionsMeanCreditTransfer), + rules.When(is.Func("payment means is credit transfer", instructionsMeansIn(meansCodeCreditTransfer, meansCodeSEPACreditTransfer)), rules.Field("credit_transfer", rules.Assert("01", "invoice credit transfer instructions must include a payment account identifier (ALIGNED-IBRP-018)", is.Present), ), ), ), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + // IBR-192-AE checks only 30, not 58. Every credit transfer needs an account, though gobl.ubl writes only the first. + rules.When(is.Func("payment means is credit transfer", instructionsMeansIn(meansCodeCreditTransfer)), + rules.Field("credit_transfer", + rules.Assert("02", "credit transfer is required with the payment means 30 (IBR-192-AE)", is.Present), + rules.Each( + rules.Assert("03", "credit transfer must include an IBAN or account number with the payment means 30 (IBR-192-AE)", + is.Func("has IBAN or account number", creditTransferHasAccountID), + ), + ), + ), + ), + ), ) } @@ -44,16 +57,13 @@ func creditTransferRules() *rules.Set { ) } -// instructionsMeanCreditTransfer reports whether the payment means code -// (ibt-081) of the instructions identifies a local, non-SEPA international or -// SEPA credit transfer. -func instructionsMeanCreditTransfer(val any) bool { - instr, ok := val.(*pay.Instructions) - if !ok || instr == nil { - return false +// instructionsMeansIn returns a predicate that reports whether the payment +// means code (ibt-081) of the instructions is one of the codes. +func instructionsMeansIn(codes ...cbc.Code) func(any) bool { + return func(val any) bool { + instr, ok := val.(*pay.Instructions) + return ok && instr != nil && instr.Ext.Get(untdid.ExtKeyPaymentMeans).In(codes...) } - code := instr.Ext.Get(untdid.ExtKeyPaymentMeans) - return code == meansCodeCreditTransfer || code == meansCodeSEPACreditTransfer } // creditTransferHasAccountID reports whether the credit transfer carries an diff --git a/addon/pint/pay_test.go b/addon/pint/pay_test.go index 59f835a..dc1e040 100644 --- a/addon/pint/pay_test.go +++ b/addon/pint/pay_test.go @@ -11,6 +11,7 @@ import ( "github.com/invopop/gobl/rules" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func instructionsWithMeansCode(code string) *pay.Instructions { @@ -87,3 +88,73 @@ func TestPayInstructionsRules(t *testing.T) { assert.NoError(t, err) }) } + +func TestPayInstructionsRulesAE(t *testing.T) { + validate := func(instr *pay.Instructions) error { + return rules.Validate(instr, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.AE.Tax())) + } + + t.Run("credit transfer with IBAN is accepted", func(t *testing.T) { + instr := instructionsWithMeansCode("30") + instr.CreditTransfer = []*pay.CreditTransfer{{IBAN: "AE070331234567890123456"}} + assert.NoError(t, validate(instr)) + }) + + t.Run("credit transfer with account number is accepted", func(t *testing.T) { + instr := instructionsWithMeansCode("30") + instr.CreditTransfer = []*pay.CreditTransfer{{Number: "1234567897"}} + assert.NoError(t, validate(instr)) + }) + + t.Run("credit transfer without credit transfer details is rejected (IBR-192-AE)", func(t *testing.T) { + err := validate(instructionsWithMeansCode("30")) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-PAY-INSTRUCTIONS-02") + }) + + t.Run("credit transfer without IBAN or account number is rejected (IBR-192-AE)", func(t *testing.T) { + instr := instructionsWithMeansCode("30") + instr.CreditTransfer = []*pay.CreditTransfer{{BIC: "EBILAEAD", Name: "Emirates NBD"}} + err := validate(instr) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-PAY-INSTRUCTIONS-03") + }) + + t.Run("every credit transfer needs an IBAN or account number (IBR-192-AE)", func(t *testing.T) { + instr := instructionsWithMeansCode("30") + instr.CreditTransfer = []*pay.CreditTransfer{ + {IBAN: "AE070331234567890123456"}, + {Name: "Emirates NBD"}, + } + err := validate(instr) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-PAY-INSTRUCTIONS-03") + }) + + t.Run("other payment means are not checked", func(t *testing.T) { + for _, code := range []string{"58", "31"} { + instr := instructionsWithMeansCode(code) + assert.NoError(t, validate(instr), "means %s", code) + instr.CreditTransfer = []*pay.CreditTransfer{{BIC: "EBILAEAD"}} + assert.NoError(t, validate(instr), "means %s with BIC only", code) + } + }) + + t.Run("the A-NZ account rules do not apply", func(t *testing.T) { + instr := &pay.Instructions{ + Key: pay.MeansKeyOnline, + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyPaymentMeans: "68"}), + CreditTransfer: []*pay.CreditTransfer{{Name: "Emirates NBD"}}, + } + assert.NoError(t, validate(instr)) + }) + + t.Run("the AE rule does not apply outside AE", func(t *testing.T) { + instr := instructionsWithMeansCode("30") + instr.CreditTransfer = []*pay.CreditTransfer{{BIC: "EBILAEAD"}} + err := rules.Validate(instr, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.SG.Tax())) + assert.NoError(t, err) + + // A-NZ documents get their own rule for the same case, not the AE one. + err = rules.Validate(instr, tax.AddonContext(pint.V1), tax.RegimeContext(l10n.AU.Tax())) + require.Error(t, err) + assert.NotContains(t, err.Error(), "GOBL-PEPPOL-PINT-PAY-INSTRUCTIONS-03") + }) +} diff --git a/addon/pint/pint.go b/addon/pint/pint.go index ed76db3..f53a63d 100644 --- a/addon/pint/pint.go +++ b/addon/pint/pint.go @@ -28,6 +28,9 @@ const ( // regimesAUNZ lists the tax regimes the PINT A-NZ jurisdiction rules apply to. var regimesAUNZ = []l10n.TaxCountryCode{l10n.AU.Tax(), l10n.NZ.Tax()} +// regimesAE lists the tax regimes the PINT AE jurisdiction rules apply to. +var regimesAE = []l10n.TaxCountryCode{l10n.AE.Tax()} + func init() { tax.RegisterAddonDef(newV1Addon()) rules.RegisterWithGuard( @@ -35,14 +38,28 @@ func init() { rules.GOBL.Add(Namespace), is.InContext(tax.AddonIn(V1)), billInvoiceRules(), + billLineRules(), taxComboRules(), taxCategoryTotalRules(), + taxIdentityRules(), + orgPartyRules(), + orgAddressRules(), + orgItemRules(), + orgIdentityRules(), payInstructionsRules(), creditTransferRules(), ) norm.RegisterWithGuard( is.InContext(tax.AddonIn(V1)), norm.For(normalizeTaxCombo), + norm.When( + is.InContext(tax.RegimeIn(regimesAE...)), + norm.For(normalizeTransactionType), + norm.For(normalizeSupplierAE), + norm.For(normalizeIdentityScopes), + norm.For(normalizeMarginSchemeAE), + norm.For(normalizeMarginSchemeNoteAE), + ), ) } @@ -68,7 +85,8 @@ func newV1Addon() *tax.AddonDef { Jurisdiction-specific requirements are applied according to the document's tax regime: Australian and New Zealand documents are also - validated against the PINT A-NZ rules. + validated against the PINT A-NZ rules, and UAE documents against the + PINT AE rules. `), }, Sources: []*cbc.Source{ @@ -84,6 +102,17 @@ func newV1Addon() *tax.AddonDef { Title: i18n.NewString("PINT A-NZ jurisdiction-aligned rules"), URL: "https://docs.peppol.eu/poac/aunz/pint-aunz/trn-invoice/rule/PINT-jurisdiction-aligned-rules/", }, + { + Title: i18n.NewString("PINT AE jurisdiction-aligned rules"), + URL: "https://docs.peppol.eu/poac/ae/pint-ae/trn-invoice/rule/PINT-jurisdiction-aligned-rules/", + }, + }, + Extensions: extensions, + Tags: []*tax.TagSet{ + invoiceTags, + }, + Scenarios: []*tax.ScenarioSet{ + invoiceScenarios, }, } } diff --git a/addon/pint/scenarios.go b/addon/pint/scenarios.go new file mode 100644 index 0000000..34a04c7 --- /dev/null +++ b/addon/pint/scenarios.go @@ -0,0 +1,86 @@ +package pint + +import ( + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/i18n" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/tax" +) + +// Document tags and the UNTDID 1001 codes they map to. +const ( + // TagOutsideTaxScope marks a PINT AE document as out of scope of VAT, + // the UAE "commercial invoice". + TagOutsideTaxScope cbc.Key = "outside-tax-scope" + + // UNTDID 1001 codes PINT AE uses for out-of-scope documents. 480 is in + // UNTDID D.23A but not in the EN 16931 code list, so it lives here. + docTypeInvoiceOutsideScope cbc.Code = "480" + docTypeCreditNoteGoodsServices cbc.Code = "81" + + // UNTDID 1001 codes the EN 16931 scenarios set. + docTypeCommercialInvoice cbc.Code = "380" + docTypeCreditNote cbc.Code = "381" + docTypeSelfBilledCreditNote cbc.Code = "261" + docTypeSelfBilledInvoice cbc.Code = "389" +) + +// docTypesAE are the UNTDID 1001 codes PINT AE accepts: ibr-cl-01's list for +// billing, and the self-billing codes. +var docTypesAE = []cbc.Code{ + docTypeCommercialInvoice, + docTypeInvoiceOutsideScope, + docTypeCreditNote, + docTypeCreditNoteGoodsServices, + docTypeSelfBilledInvoice, + docTypeSelfBilledCreditNote, +} + +// invoiceTags are the document tags the PINT addon adds to invoices. +var invoiceTags = &tax.TagSet{ + Schema: bill.ShortSchemaInvoice, + List: append([]*cbc.Definition{ + { + Key: TagOutsideTaxScope, + Name: i18n.String{ + i18n.EN: "Outside Tax Scope", + }, + Desc: i18n.String{ + i18n.EN: "Marks a PINT AE document as out of scope of VAT, the UAE 'commercial invoice'. Invoices are sent with document type 480 and credit notes with 81. Only for UAE documents.", + }, + }, + }, transactionTypeTags...), +} + +// invoiceScenarios set 480 and 81 on out-of-scope documents, replacing the 380 or 381 that EN 16931 sets first. +var invoiceScenarios = &tax.ScenarioSet{ + Schema: bill.ShortSchemaInvoice, + List: []*tax.Scenario{ + // ** Out of scope of VAT (UAE only) ** + { + Types: []cbc.Key{bill.InvoiceTypeStandard}, + Tags: []cbc.Key{TagOutsideTaxScope}, + Filter: invoiceIsAE, + Ext: tax.ExtensionsOf(cbc.CodeMap{ + untdid.ExtKeyDocumentType: docTypeInvoiceOutsideScope, + }), + }, + { + Types: []cbc.Key{bill.InvoiceTypeCreditNote}, + Tags: []cbc.Key{TagOutsideTaxScope}, + Filter: invoiceIsAE, + Ext: tax.ExtensionsOf(cbc.CodeMap{ + untdid.ExtKeyDocumentType: docTypeCreditNoteGoodsServices, + }), + }, + }, +} + +// invoiceIsAE reports whether the scenario document is a UAE invoice, as the addon's scenarios +// apply under every regime. +func invoiceIsAE(doc any) bool { + inv, ok := doc.(*bill.Invoice) + return ok && inv != nil && inv.GetRegime() == l10n.AE.Tax() +} diff --git a/addon/pint/scenarios_test.go b/addon/pint/scenarios_test.go new file mode 100644 index 0000000..88be581 --- /dev/null +++ b/addon/pint/scenarios_test.go @@ -0,0 +1,81 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/currency" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/num" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// scenarioInvoice is a minimal invoice for the given regime that can be +// calculated, so the regime and addon scenarios run on it. +func scenarioInvoice(regime l10n.TaxCountryCode, typ cbc.Key, tags ...cbc.Key) *bill.Invoice { + category, cur := tax.CategoryVAT, currency.AED + if regime == l10n.AU.Tax() { + category, cur = tax.CategoryGST, currency.AUD + } + return &bill.Invoice{ + Regime: tax.WithRegime(regime), + Addons: tax.WithAddons(pint.V1), + Tags: tax.WithTags(tags...), + Type: typ, + Currency: cur, + Series: "TEST", + Code: "0001", + IssueDate: cal.MakeDate(2026, 11, 10), + Supplier: &org.Party{Name: "Supplier"}, + Customer: &org.Party{Name: "Customer"}, + Lines: []*bill.Line{ + { + Quantity: num.MakeAmount(1, 0), + Item: &org.Item{Name: "Item", Price: num.NewAmount(10000, 2)}, + Taxes: tax.Set{{Category: category, Key: tax.KeyOutsideScope}}, + }, + }, + } +} + +func documentType(t *testing.T, inv *bill.Invoice) cbc.Code { + t.Helper() + require.NoError(t, inv.Calculate()) + require.NotNil(t, inv.Tax) + return inv.Tax.Ext.Get(untdid.ExtKeyDocumentType) +} + +func TestInvoiceScenarios(t *testing.T) { + ae := l10n.AE.Tax() + + t.Run("AE out-of-scope invoice is 480", func(t *testing.T) { + inv := scenarioInvoice(ae, bill.InvoiceTypeStandard, pint.TagOutsideTaxScope) + assert.Equal(t, cbc.Code("480"), documentType(t, inv)) + }) + + t.Run("AE out-of-scope credit note is 81", func(t *testing.T) { + inv := scenarioInvoice(ae, bill.InvoiceTypeCreditNote, pint.TagOutsideTaxScope) + assert.Equal(t, cbc.Code("81"), documentType(t, inv)) + }) + + t.Run("a hand-set code is replaced by the scenario", func(t *testing.T) { + inv := scenarioInvoice(ae, bill.InvoiceTypeStandard, pint.TagOutsideTaxScope) + inv.Tax = &bill.Tax{Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyDocumentType: "380"})} + assert.Equal(t, cbc.Code("480"), documentType(t, inv)) + }) + + t.Run("the tag has no effect outside AE", func(t *testing.T) { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard, pint.TagOutsideTaxScope) + assert.Equal(t, cbc.Code("380"), documentType(t, inv)) + + inv = scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeCreditNote, pint.TagOutsideTaxScope) + assert.Equal(t, cbc.Code("381"), documentType(t, inv)) + }) +} diff --git a/addon/pint/tax_combo.go b/addon/pint/tax_combo.go index 981bfc0..513aae1 100644 --- a/addon/pint/tax_combo.go +++ b/addon/pint/tax_combo.go @@ -2,15 +2,22 @@ package pint import ( "github.com/invopop/gobl/addons/eu/en16931" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/cef" "github.com/invopop/gobl/catalogues/untdid" "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/num" "github.com/invopop/gobl/rules" "github.com/invopop/gobl/rules/is" "github.com/invopop/gobl/tax" ) +// TaxCategoryMarginScheme is the PINT AE margin scheme VAT category. +const TaxCategoryMarginScheme cbc.Code = "N" + // taxCategoryMap maps GOBL tax keys to the UNTDID 5305 tax category codes that -// PINT recognises, mirroring EN 16931's VAT key mapping. +// PINT recognises, mirroring EN 16931's VAT key mapping. The PINT AE margin +// scheme category is not here, as it is only for UAE documents. var taxCategoryMap = tax.ExtensionsOf(cbc.CodeMap{ tax.KeyStandard: en16931.TaxCategoryStandard, tax.KeyZero: en16931.TaxCategoryZero, @@ -21,6 +28,14 @@ var taxCategoryMap = tax.ExtensionsOf(cbc.CodeMap{ tax.KeyOutsideScope: en16931.TaxCategoryOutsideScope, }) +// exemptionCodesAE are the UAE VAT exemptions of Article 46 of Federal Decree-Law No. 8 of 2017. +var exemptionCodesAE = []cbc.Code{ + "DL8.46.1", // certain financial services + "DL8.46.2", // residential buildings + "DL8.46.3", // bare land + "DL8.46.4", // local passenger transport +} + // taxCategoryCodesAUNZ lists the subset of UNTDID 5305 tax category codes // accepted by the A-NZ PINT specification. var taxCategoryCodesAUNZ = []cbc.Code{ @@ -31,6 +46,17 @@ var taxCategoryCodesAUNZ = []cbc.Code{ en16931.TaxCategoryOutsideScope, } +// taxCategoryCodesAE lists the subset of UNTDID 5305 tax category codes +// accepted by the AE PINT specification. +var taxCategoryCodesAE = []cbc.Code{ + en16931.TaxCategoryExempt, + en16931.TaxCategoryStandard, + en16931.TaxCategoryZero, + en16931.TaxCategoryOutsideScope, + en16931.TaxCategoryReverseCharge, + TaxCategoryMarginScheme, +} + // normalizeTaxCombo re-maps the UNTDID tax category code from the tax combo's // key using the EN 16931 key-to-code mapping. func normalizeTaxCombo(tc *tax.Combo) { @@ -42,6 +68,39 @@ func normalizeTaxCombo(tc *tax.Combo) { } } +// normalizeMarginSchemeAE gives N to the exempt VAT lines without a VATEX code of a UAE margin scheme +// invoice. Discounts, charges and lines with a reason keep E, so the rules reject them. +func normalizeMarginSchemeAE(inv *bill.Invoice) { + if inv == nil || !inv.HasTags(TagMarginScheme) { + return + } + for _, l := range inv.Lines { + if l == nil { + continue + } + for _, c := range l.Taxes { + if c != nil && c.Category == tax.CategoryVAT && c.Key == tax.KeyExempt && !c.Ext.Has(cef.ExtKeyVATEX) { + c.Ext = c.Ext.Set(untdid.ExtKeyTaxCategory, TaxCategoryMarginScheme) + } + } + } +} + +// normalizeMarginSchemeNoteAE ties the margin scheme note to N, and keys an imported one so the scenario +// doesn't add a second. It normalizes notes as the scenario adds the note after the invoice is normalized. +func normalizeMarginSchemeNoteAE(n *tax.Note) { + if n == nil || n.Category != tax.CategoryVAT { + return + } + if n.Key.IsEmpty() && n.Ext.Get(untdid.ExtKeyTaxCategory) == TaxCategoryMarginScheme { + n.Key = TagMarginScheme + } + if n.Key == TagMarginScheme { + n.Ext = n.Ext.Set(untdid.ExtKeyTaxCategory, TaxCategoryMarginScheme) + } +} + +// taxComboRules validates tax combos on PINT documents. func taxComboRules() *rules.Set { return rules.For(new(tax.Combo), // PINT recognises GST (and other non-VAT schemes) as standard, zero or @@ -62,5 +121,70 @@ func taxComboRules() *rules.Set { ), ), ), + + // TODO: A-NZ has the same zero rate rule (ALIGNED-IBRP-Z-05/06/07) and a positive standard rate (ALIGNED-IBRP-S-05/06/07). + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + // EN 16931's and PINT's category lists have no N; IBR-139-AE checks the PINT AE list instead. + rules.Ignore("GOBL-EU-EN16931-TAX-COMBO-02", "GOBL-PEPPOL-PINT-TAX-COMBO-01"), + rules.Field("ext", + rules.Assert("03", "tax category code must be an AE UNCL5305 code: E, S, Z, O, AE or N (IBR-139-AE)", + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, taxCategoryCodesAE...), + ), + ), + + rules.When( + is.Func("tax combo is standard rated", taxComboIsStandard), + rules.Field("percent", + rules.Assert("04", "tax percentage must be 5.00 (IBR-190-AE, ALIGNED-IBRP-S-05/06/07)", + num.Equals(num.MakePercentage(5, 2)), + ), + ), + ), + + rules.When( + is.Func("tax combo is zero rated", taxComboIsZero), + rules.Field("percent", + rules.Assert("05", "tax percentage must be 0.00 (ALIGNED-IBRP-Z-05/06/07, IBR-120-AE)", + num.Equals(num.MakePercentage(0, 2)), + ), + ), + ), + + rules.Field("ext", + rules.When( + is.AllOf( + tax.ExtensionsRequire(untdid.ExtKeyTaxCategory), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, en16931.TaxCategoryExempt), + ), + rules.Assert("06", "exempt VAT needs a VAT exemption reason (IBR-167-AE, IBR-168-AE, IBR-169-AE)", + tax.ExtensionsRequire(cef.ExtKeyVATEX), + ), + ), + ), + + // The Schematron doesn't check the code list, but UAE VAT law allows no other reasons. + rules.Field("ext", + rules.Assert("07", "VAT exemption reason must be a UAE one: DL8.46.1, DL8.46.2, DL8.46.3 or DL8.46.4", + tax.ExtensionsHasCodes(cef.ExtKeyVATEX, exemptionCodesAE...), + ), + ), + ), ) } + +func taxComboIsStandard(val any) bool { + tc, ok := val.(*tax.Combo) + return ok && tc != nil && tc.Key == tax.KeyStandard +} + +func taxComboIsZero(val any) bool { + tc, ok := val.(*tax.Combo) + return ok && tc != nil && tc.Key == tax.KeyZero +} + +// taxCategoryCodesOutsideScope are the VAT category codes allowed on outside scope documents. +var taxCategoryCodesOutsideScope = []cbc.Code{ + en16931.TaxCategoryExempt, + en16931.TaxCategoryOutsideScope, +} diff --git a/addon/pint/tax_combo_test.go b/addon/pint/tax_combo_test.go index a03877f..370540d 100644 --- a/addon/pint/tax_combo_test.go +++ b/addon/pint/tax_combo_test.go @@ -5,6 +5,8 @@ import ( "github.com/invopop/gobl.peppol/addon/pint" "github.com/invopop/gobl/addons/eu/en16931" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/cef" "github.com/invopop/gobl/catalogues/untdid" "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/l10n" @@ -61,6 +63,58 @@ func TestTaxComboNormalization(t *testing.T) { norm.Normalize(c, tax.AddonContext(en16931.V2017, pint.V1)) assert.Equal(t, "S", c.Ext.Get(untdid.ExtKeyTaxCategory).String()) }) + + t.Run("exempt lines map to N only on UAE margin scheme invoices", func(t *testing.T) { + normalized := func(regime l10n.TaxCountryCode) *bill.Invoice { + inv := &bill.Invoice{ + Tags: tax.WithTags(pint.TagMarginScheme), + Lines: []*bill.Line{{Taxes: tax.Set{{Category: tax.CategoryVAT, Key: tax.KeyExempt}}}}, + Tax: &bill.Tax{Notes: []*tax.Note{{ + Category: tax.CategoryVAT, + Key: pint.TagMarginScheme, + Text: "VAT charged under the Profit Margin Scheme", + }}}, + } + norm.Normalize(inv, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(regime)) + return inv + } + + inv := normalized(l10n.AE.Tax()) + assert.Equal(t, "N", inv.Lines[0].Taxes[0].Ext.Get(untdid.ExtKeyTaxCategory).String()) + assert.Equal(t, "N", inv.Tax.Notes[0].Ext.Get(untdid.ExtKeyTaxCategory).String()) + + inv = normalized(l10n.SG.Tax()) + assert.Equal(t, "E", inv.Lines[0].Taxes[0].Ext.Get(untdid.ExtKeyTaxCategory).String()) + assert.Empty(t, inv.Tax.Notes[0].Ext) + }) +} + +func TestMarginSchemeNoteNormalizationAE(t *testing.T) { + normalize := func(n *tax.Note) { + norm.Normalize(n, tax.AddonContext(en16931.V2017, pint.V1), tax.RegimeContext(l10n.AE.Tax())) + } + + t.Run("the statement gets the N category", func(t *testing.T) { + n := &tax.Note{Category: tax.CategoryVAT, Key: pint.TagMarginScheme, Text: "VAT charged under the Profit Margin Scheme"} + normalize(n) + assert.Equal(t, "N", n.Ext.Get(untdid.ExtKeyTaxCategory).String()) + }) + + t.Run("an N note without a key gets the margin scheme key", func(t *testing.T) { + n := &tax.Note{ + Category: tax.CategoryVAT, + Text: "VAT charged under the Profit Margin Scheme", + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyTaxCategory: "N"}), + } + normalize(n) + assert.Equal(t, pint.TagMarginScheme, n.Key) + }) + + t.Run("other notes are left alone", func(t *testing.T) { + n := &tax.Note{Category: tax.CategoryVAT, Key: tax.KeyReverseCharge, Text: "Reverse Charge"} + normalize(n) + assert.Equal(t, "AE", n.Ext.Get(untdid.ExtKeyTaxCategory).String()) + }) } func gstCombo(category string) *tax.Combo { @@ -94,3 +148,89 @@ func TestTaxComboRules(t *testing.T) { assert.NoError(t, err) }) } + +func vatCombo(key cbc.Key, category string, percent *num.Percentage) *tax.Combo { + return &tax.Combo{ + Category: tax.CategoryVAT, + Key: key, + Percent: percent, + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyTaxCategory: cbc.Code(category)}), + } +} + +func validateComboIn(tc *tax.Combo, regime l10n.TaxCountryCode) error { + return rules.Validate(tc, tax.AddonContext(pint.V1), tax.RegimeContext(regime)) +} + +func TestTaxComboRulesAE(t *testing.T) { + ae := l10n.AE.Tax() + + t.Run("AE subset categories are accepted (IBR-139-AE)", func(t *testing.T) { + for cat, key := range map[string]cbc.Key{ + "E": tax.KeyExempt, + "O": tax.KeyOutsideScope, + "AE": tax.KeyReverseCharge, + } { + c := vatCombo(key, cat, nil) + if cat == "E" { + c.Ext = c.Ext.Set(cef.ExtKeyVATEX, "DL8.46.1") + } + assert.NoError(t, validateComboIn(c, ae), "category %s", cat) + } + assert.NoError(t, validateComboIn(vatCombo(tax.KeyStandard, "S", num.NewPercentage(5, 2)), ae)) + assert.NoError(t, validateComboIn(vatCombo(tax.KeyZero, "Z", num.NewPercentage(0, 2)), ae)) + assert.NoError(t, validateComboIn(vatCombo(tax.KeyExempt, "N", nil), ae)) + }) + + t.Run("margin scheme category is rejected outside AE", func(t *testing.T) { + for _, regime := range []l10n.TaxCountryCode{l10n.SG.Tax(), l10n.AU.Tax()} { + err := validateComboIn(vatCombo(cbc.KeyEmpty, "N", nil), regime) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-TAX-COMBO-01", "regime %s", regime) + } + }) + + t.Run("categories outside the AE subset are rejected (IBR-139-AE)", func(t *testing.T) { + for _, cat := range []string{"G", "K", "L", "M"} { + err := validateComboIn(vatCombo(cbc.KeyEmpty, cat, nil), ae) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-TAX-COMBO-03", "category %s", cat) + } + }) + + t.Run("AE subset does not apply outside AE", func(t *testing.T) { + assert.NoError(t, validateComboIn(vatCombo(cbc.KeyEmpty, "K", nil), l10n.SG.Tax())) + }) + + t.Run("standard rate must be 5% (IBR-190-AE, ALIGNED-IBRP-S-05/06/07)", func(t *testing.T) { + for _, rate := range []int64{0, 10} { + err := validateComboIn(vatCombo(tax.KeyStandard, "S", num.NewPercentage(rate, 2)), ae) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-TAX-COMBO-04", "rate %d", rate) + } + }) + + t.Run("5% check compares numbers, not strings", func(t *testing.T) { + assert.NoError(t, validateComboIn(vatCombo(tax.KeyStandard, "S", num.NewPercentage(50, 3)), ae)) + }) + + t.Run("zero rate must be 0% (ALIGNED-IBRP-Z-05/06/07, IBR-120-AE)", func(t *testing.T) { + err := validateComboIn(vatCombo(tax.KeyZero, "Z", num.NewPercentage(5, 2)), ae) + assert.ErrorContains(t, err, "GOBL-PEPPOL-PINT-TAX-COMBO-05") + }) + + t.Run("exempt VAT needs an exemption reason (IBR-167-AE, IBR-168-AE, IBR-169-AE)", func(t *testing.T) { + const faultExemption = "GOBL-PEPPOL-PINT-TAX-COMBO-06" + assert.ErrorContains(t, validateComboIn(vatCombo(tax.KeyExempt, "E", nil), ae), faultExemption) + for _, code := range []cbc.Code{"DL8.46.1", "DL8.46.4"} { + c := vatCombo(tax.KeyExempt, "E", nil) + c.Ext = c.Ext.Set(cef.ExtKeyVATEX, code) + assert.NoError(t, validateComboIn(c, ae), code) + } + }) + + t.Run("rate rules do not apply outside AE", func(t *testing.T) { + for _, regime := range []l10n.TaxCountryCode{l10n.SG.Tax(), l10n.AU.Tax()} { + assert.NoError(t, validateComboIn(vatCombo(tax.KeyStandard, "S", num.NewPercentage(0, 2)), regime), regime) + assert.NoError(t, validateComboIn(vatCombo(tax.KeyStandard, "S", num.NewPercentage(10, 2)), regime), regime) + assert.NoError(t, validateComboIn(vatCombo(tax.KeyZero, "Z", num.NewPercentage(5, 2)), regime), regime) + } + }) +} diff --git a/addon/pint/tax_identity.go b/addon/pint/tax_identity.go new file mode 100644 index 0000000..6b60586 --- /dev/null +++ b/addon/pint/tax_identity.go @@ -0,0 +1,25 @@ +package pint + +import ( + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/rules/is" + "github.com/invopop/gobl/tax" +) + +// vatTRNSuffixPattern is the trailing 03 of a UAE TRN for VAT. +const vatTRNSuffixPattern = `03$` + +// taxIdentityRules validates tax identities on UAE documents. +func taxIdentityRules() *rules.Set { + return rules.For(new(tax.Identity), + rules.When( + is.InContext(tax.RegimeIn(regimesAE...)), + rules.When(tax.IdentityIn("AE"), + rules.Field("code", + rules.AssertIfPresent("01", "UAE TRN must end with 03 (IBR-132-AE)", + is.Matches(vatTRNSuffixPattern)), + ), + ), + ), + ) +} diff --git a/addon/pint/tax_identity_test.go b/addon/pint/tax_identity_test.go new file mode 100644 index 0000000..8b1b859 --- /dev/null +++ b/addon/pint/tax_identity_test.go @@ -0,0 +1,46 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/rules" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" +) + +func TestTaxIdentityRulesAE(t *testing.T) { + const faultTRN = "GOBL-PEPPOL-PINT-TAX-IDENTITY-01" + validateIn := func(id *tax.Identity, regime l10n.TaxCountryCode) error { + return rules.Validate(id, tax.AddonContext(pint.V1), tax.RegimeContext(regime)) + } + validate := func(id *tax.Identity) error { return validateIn(id, l10n.AE.Tax()) } + + t.Run("valid TRN is accepted (IBR-132-AE)", func(t *testing.T) { + assert.NoError(t, validate(&tax.Identity{Country: "AE", Code: "100000001600003"})) + }) + + t.Run("TRN not ending with 03 is rejected (IBR-132-AE)", func(t *testing.T) { + err := validate(&tax.Identity{Country: "AE", Code: "100000001600004"}) + assert.ErrorContains(t, err, faultTRN) + }) + + t.Run("identity without a code is accepted (IBR-132-AE)", func(t *testing.T) { + assert.NoError(t, validate(&tax.Identity{Country: "AE"})) + }) + + t.Run("non-UAE identities are not checked (IBR-132-AE)", func(t *testing.T) { + err := validate(&tax.Identity{Country: "DE", Code: "111111125"}) + if err != nil { + assert.NotContains(t, err.Error(), faultTRN) + } + }) + + t.Run("the rule does not apply outside AE", func(t *testing.T) { + err := validateIn(&tax.Identity{Country: "AE", Code: "100000001600004"}, l10n.AU.Tax()) + if err != nil { + assert.NotContains(t, err.Error(), faultTRN) + } + }) +} diff --git a/addon/pint/transaction_type.go b/addon/pint/transaction_type.go new file mode 100644 index 0000000..0b388d0 --- /dev/null +++ b/addon/pint/transaction_type.go @@ -0,0 +1,157 @@ +package pint + +import ( + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/i18n" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/tax" +) + +// Invoice tags for the PINT AE transaction type flags (BTAE-02). Exports use +// GOBL's own "export" tag. +const ( + TagFreeTradeZone cbc.Key = "free-trade-zone" + TagDeemedSupply cbc.Key = "deemed-supply" + TagMarginScheme = ae.TagMarginScheme + TagSummary cbc.Key = "summary" + TagContinuousSupply cbc.Key = "continuous-supply" + TagDisclosedAgent cbc.Key = "disclosed-agent" + TagECommerce cbc.Key = "e-commerce" +) + +// transactionTypePattern is the format of the transaction type: 8 flags of 0 or 1. +const transactionTypePattern = `^[01]{8}$` + +// TransactionType is a parsed PINT AE invoice transaction type (BTAE-02). +type TransactionType struct { + FreeTradeZone bool + DeemedSupply bool + MarginScheme bool + Summary bool + ContinuousSupply bool + DisclosedAgent bool + ECommerce bool + Export bool +} + +// transactionTypeFlags lists the flags in their order in the code, with the +// tag that sets each one. +var transactionTypeFlags = []struct { + tag cbc.Key + get func(*TransactionType) *bool +}{ + {TagFreeTradeZone, func(t *TransactionType) *bool { return &t.FreeTradeZone }}, + {TagDeemedSupply, func(t *TransactionType) *bool { return &t.DeemedSupply }}, + {TagMarginScheme, func(t *TransactionType) *bool { return &t.MarginScheme }}, + {TagSummary, func(t *TransactionType) *bool { return &t.Summary }}, + {TagContinuousSupply, func(t *TransactionType) *bool { return &t.ContinuousSupply }}, + {TagDisclosedAgent, func(t *TransactionType) *bool { return &t.DisclosedAgent }}, + {TagECommerce, func(t *TransactionType) *bool { return &t.ECommerce }}, + {tax.TagExport, func(t *TransactionType) *bool { return &t.Export }}, +} + +// ParseTransactionType reads the flags of a transaction type code: each position holding a 1 sets +// its flag. +func ParseTransactionType(code cbc.Code) TransactionType { + var t TransactionType + s := code.String() + for i, f := range transactionTypeFlags { + if len(s) > i && s[i] == '1' { + *f.get(&t) = true + } + } + return t +} + +// Code returns the 8-character transaction type code. +func (t TransactionType) Code() cbc.Code { + b := []byte("00000000") + for i, f := range transactionTypeFlags { + if *f.get(&t) { + b[i] = '1' + } + } + return cbc.Code(b) +} + +// Tags returns the invoice tags of the flags that are set. +func (t TransactionType) Tags() []cbc.Key { + var tags []cbc.Key + for _, f := range transactionTypeFlags { + if *f.get(&t) { + tags = append(tags, f.tag) + } + } + return tags +} + +// transactionTypeFromTags builds the transaction type from the invoice tags. +func transactionTypeFromTags(inv *bill.Invoice) TransactionType { + var t TransactionType + for _, f := range transactionTypeFlags { + if inv.HasTags(f.tag) { + *f.get(&t) = true + } + } + return t +} + +// normalizeTransactionType sets the transaction type from the flag tags only: a code from an earlier +// calculation can't be told apart from one set directly. +func normalizeTransactionType(inv *bill.Invoice) { + if inv == nil { + return + } + if inv.Tax == nil { + inv.Tax = new(bill.Tax) + } + inv.Tax.Ext = inv.Tax.Ext.Set(ExtKeyTransactionType, transactionTypeFromTags(inv).Code()) +} + +// transactionTypeTags are the invoice tags for the transaction type flags. +var transactionTypeTags = []*cbc.Definition{ + { + Key: TagFreeTradeZone, + Name: i18n.String{i18n.EN: "Free Trade Zone"}, + Desc: i18n.String{i18n.EN: "PINT AE: supply of goods or services in a free trade zone. Needs the beneficiary ID."}, + }, + { + Key: TagDeemedSupply, + Name: i18n.String{i18n.EN: "Deemed Supply"}, + Desc: i18n.String{i18n.EN: "PINT AE: supply of goods or services without consideration."}, + }, + { + Key: TagSummary, + Name: i18n.String{i18n.EN: "Summary Invoice"}, + Desc: i18n.String{i18n.EN: "PINT AE: more than one supply of goods or services to the same person in the same calendar month. Needs the invoicing period."}, + }, + { + Key: TagContinuousSupply, + Name: i18n.String{i18n.EN: "Continuous Supply"}, + Desc: i18n.String{i18n.EN: "PINT AE: supply of goods or services made on a recurrent basis."}, + }, + { + Key: TagDisclosedAgent, + Name: i18n.String{i18n.EN: "Disclosed Agent Billing"}, + Desc: i18n.String{i18n.EN: "PINT AE: an agent who is a registrant makes a supply on behalf of the principal. Needs the principal ID."}, + }, + { + Key: TagECommerce, + Name: i18n.String{i18n.EN: "E-commerce"}, + Desc: i18n.String{i18n.EN: "PINT AE: supply of goods or services through e-commerce. Needs a complete delivery address."}, + }, + { + Key: tax.TagExport, + Name: i18n.String{i18n.EN: "Export"}, + Desc: i18n.String{i18n.EN: "PINT AE: supply of goods or services outside the country. Needs a complete delivery address outside the UAE."}, + }, +} + +// invoiceHasTags returns a predicate that reports whether an invoice has all the tags. +func invoiceHasTags(keys ...cbc.Key) func(any) bool { + return func(val any) bool { + inv, ok := val.(*bill.Invoice) + return ok && inv != nil && inv.HasTags(keys...) + } +} diff --git a/addon/pint/transaction_type_test.go b/addon/pint/transaction_type_test.go new file mode 100644 index 0000000..5909fc0 --- /dev/null +++ b/addon/pint/transaction_type_test.go @@ -0,0 +1,84 @@ +package pint_test + +import ( + "testing" + + "github.com/invopop/gobl.peppol/addon/pint" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestTransactionType(t *testing.T) { + t.Run("each flag has its position", func(t *testing.T) { + tests := map[cbc.Code]pint.TransactionType{ + "10000000": {FreeTradeZone: true}, + "01000000": {DeemedSupply: true}, + "00100000": {MarginScheme: true}, + "00010000": {Summary: true}, + "00001000": {ContinuousSupply: true}, + "00000100": {DisclosedAgent: true}, + "00000010": {ECommerce: true}, + "00000001": {Export: true}, + "00000000": {}, + } + for code, want := range tests { + assert.Equal(t, want, pint.ParseTransactionType(code), code) + assert.Equal(t, code, want.Code(), code) + } + }) + + t.Run("several flags", func(t *testing.T) { + tt := pint.ParseTransactionType("10000101") + assert.Equal(t, pint.TransactionType{FreeTradeZone: true, DisclosedAgent: true, Export: true}, tt) + assert.Equal(t, []cbc.Key{pint.TagFreeTradeZone, pint.TagDisclosedAgent, tax.TagExport}, tt.Tags()) + }) + + t.Run("a missing or short code gives no flags beyond its length", func(t *testing.T) { + assert.Equal(t, pint.TransactionType{}, pint.ParseTransactionType("")) + assert.Equal(t, pint.TransactionType{FreeTradeZone: true}, pint.ParseTransactionType("1")) + }) +} + +func TestNormalizeTransactionType(t *testing.T) { + code := func(inv *bill.Invoice) cbc.Code { + t.Helper() + require.NoError(t, inv.Calculate()) + return inv.Tax.GetExt(pint.ExtKeyTransactionType) + } + + t.Run("no tags give 00000000", func(t *testing.T) { + assert.Equal(t, cbc.Code("00000000"), code(aeDocument(bill.InvoiceTypeStandard))) + }) + + t.Run("tags set their flags", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, pint.TagSummary, pint.TagECommerce, tax.TagExport) + assert.Equal(t, cbc.Code("00010011"), code(inv)) + }) + + t.Run("a code set directly is replaced by the tags", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard) + inv.Tax = &bill.Tax{Ext: tax.ExtensionsOf(cbc.CodeMap{pint.ExtKeyTransactionType: "00001000"})} + assert.Equal(t, cbc.Code("00000000"), code(inv), "without tags") + + inv = aeDocument(bill.InvoiceTypeStandard, pint.TagContinuousSupply) + inv.Tax = &bill.Tax{Ext: tax.ExtensionsOf(cbc.CodeMap{pint.ExtKeyTransactionType: "00000000"})} + assert.Equal(t, cbc.Code("00001000"), code(inv), "with tags") + }) + + t.Run("removing the last tag clears its flag", func(t *testing.T) { + inv := aeDocument(bill.InvoiceTypeStandard, tax.TagExport) + assert.Equal(t, cbc.Code("00000001"), code(inv)) + inv.Tags.List = nil + assert.Equal(t, cbc.Code("00000000"), code(inv)) + }) + + t.Run("only under the AE regime", func(t *testing.T) { + inv := scenarioInvoice(l10n.AU.Tax(), bill.InvoiceTypeStandard) + require.NoError(t, inv.Calculate()) + assert.Empty(t, inv.Tax.GetExt(pint.ExtKeyTransactionType)) + }) +} diff --git a/examples/invoice-ae.yaml b/examples/invoice-ae.yaml new file mode 100644 index 0000000..6e2a958 --- /dev/null +++ b/examples/invoice-ae.yaml @@ -0,0 +1,72 @@ +$schema: "https://gobl.org/draft-0/bill/invoice" +$regime: "AE" +$addons: + - "peppol-pint-v1" +uuid: "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2" +currency: "AED" +issue_date: "2025-01-30" +series: "AE" +code: "001" + +supplier: + name: "Supplier Legal Name" + tax_id: + country: "AE" + code: "135790246700003" + identities: + - type: "TL" + code: "112345678900003" + description: "Trade License issuing Authority" + inboxes: + - key: "peppol" + scheme: "0235" + code: "1357902467" + addresses: + - street: "Sheikh Zayed Road" + locality: "Dubai" + region: "DXB" + country: "AE" + +customer: + name: "Buyer Legal Name" + tax_id: + country: "AE" + code: "134567890600003" + identities: + - type: "TL" + code: "112345679000001" + description: "Trade License issuing Authority" + inboxes: + - key: "peppol" + scheme: "0235" + code: "1345678906" + addresses: + - street: "Corniche Road" + locality: "Abu Dhabi" + region: "AUH" + country: "AE" + +lines: + - quantity: "100" + item: + name: "Item Name" + description: "Item Description" + price: "10.00" + taxes: + - cat: VAT + key: standard + percent: "5%" + +payment: + terms: + key: "due-date" + due_dates: + - date: "2025-02-06" + percent: "100%" + instructions: + key: "credit-transfer" + ext: + untdid-payment-means: "30" + credit_transfer: + - iban: "AE070331234567890123456" + name: "Emirates NBD" diff --git a/examples/out/invoice-ae.json b/examples/out/invoice-ae.json new file mode 100644 index 0000000..0bd0fbd --- /dev/null +++ b/examples/out/invoice-ae.json @@ -0,0 +1,182 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "8a51fd30-2a27-11ee-be56-0242ac120002", + "dig": { + "alg": "sha256", + "val": "d924a491f980aeff6dd9b1d5f21f22f7bbc602574cef0080551546a052896f71" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "001", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "inboxes": [ + { + "key": "peppol", + "scheme": "0235", + "code": "1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "inboxes": [ + { + "key": "peppol", + "scheme": "0235", + "code": "1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "key": "due-date", + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/go.mod b/go.mod index 78d59dc..68ebb7a 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/invopop/gobl.peppol go 1.25.0 require ( - github.com/invopop/gobl v0.512.0 + github.com/invopop/gobl v0.512.1-0.20261119150448-a26856f0b5ff github.com/invopop/gobl.cii v0.85.0 - github.com/invopop/gobl.ubl v0.102.0 + github.com/invopop/gobl.ubl v0.103.1-0.20261119164756-14cbfffcf2c2 github.com/invopop/phorm v0.1.5 github.com/stretchr/testify v1.11.1 ) diff --git a/go.sum b/go.sum index 737220e..1620daf 100644 --- a/go.sum +++ b/go.sum @@ -22,12 +22,12 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/invopop/gobl v0.512.0 h1:qcZ4WvbgUqp8UFjjQ80VPHhdPAZzjexnBaKEJmcml3o= -github.com/invopop/gobl v0.512.0/go.mod h1:7xBxkslYmW2MdNvanWiVPUYIvR3Se+2dKLYA6Tg+A40= +github.com/invopop/gobl v0.512.1-0.20261119150448-a26856f0b5ff h1:eCXKA1mnojbc+8GkVgCJNIAzmH5EGhDw4RucCD84oIU= +github.com/invopop/gobl v0.512.1-0.20261119150448-a26856f0b5ff/go.mod h1:7xBxkslYmW2MdNvanWiVPUYIvR3Se+2dKLYA6Tg+A40= github.com/invopop/gobl.cii v0.85.0 h1:EbVISpzaBdOlnGxh/M0JMNUMMl0xbSRmi/DTez5YH+o= github.com/invopop/gobl.cii v0.85.0/go.mod h1:YQZ5XlHyEFPerP9TgCXAr1Bb7YIlkjssQIKY0P/2R50= -github.com/invopop/gobl.ubl v0.102.0 h1:zMeSVXNDFN1c+RcHwdtuhAm9gsM+hipO0AKho/IiEKY= -github.com/invopop/gobl.ubl v0.102.0/go.mod h1:11heZ+/Zl3EtK5JpjKZULu1Co2+aer9yw427qzHqukY= +github.com/invopop/gobl.ubl v0.103.1-0.20261119164756-14cbfffcf2c2 h1:Bg8ZOe2FIj0cAcoULSqanHOSWtLtQL8fncS2qO1bklc= +github.com/invopop/gobl.ubl v0.103.1-0.20261119164756-14cbfffcf2c2/go.mod h1:11heZ+/Zl3EtK5JpjKZULu1Co2+aer9yw427qzHqukY= github.com/invopop/jsonschema v0.14.0 h1:MHQqLhvpNUZfw+hM3AZDYK7jxO8FZoQeQM77g8iyZjg= github.com/invopop/jsonschema v0.14.0/go.mod h1:ygm6C2EaVNMBDPpaPlnOA2pFAxBnxGjFlMZABxm9n2I= github.com/invopop/phorm v0.1.5 h1:qzhDJgo1YaRFTRknD58cLbuTp5UAV/PhQTD9FFK0LIM= diff --git a/ubl/ae.go b/ubl/ae.go new file mode 100644 index 0000000..f9a2a1a --- /dev/null +++ b/ubl/ae.go @@ -0,0 +1,1076 @@ +package ubl + +import ( + "regexp" + "strings" + + "github.com/invopop/gobl" + "github.com/invopop/gobl.peppol/addon/pint" + goblubl "github.com/invopop/gobl.ubl" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/cef" + "github.com/invopop/gobl/catalogues/icc" + "github.com/invopop/gobl/catalogues/iso" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/currency" + "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/num" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pay" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/tax" + "github.com/invopop/gobl/uuid" +) + +// UNTDID 5305 VAT category codes the AE format writes rates and amounts for. +const ( + taxCategoryStandard = "S" + taxCategoryExempt = "E" + taxCategoryReverseCharge = "AE" + taxCategoryMarginScheme = "N" +) + +// aedTotalDocumentType is the document type code PINT AE gives the additional +// document reference that carries the total with VAT in AED (BTAE-20). +const aedTotalDocumentType = "aedtotal-incl-vat" + +// deliveryTermsSchemeIncoterms is the scheme of the Incoterms code (BTAE-22), +// which the syntax binding requires and the official examples write. +const deliveryTermsSchemeIncoterms = "Incoterms" + +// exportAE applies the Peppol PINT AE rules to an exported invoice. +func exportAE(_ *goblubl.Format, env *gobl.Envelope, doc goblubl.Document) error { + out, ok := doc.(*goblubl.Invoice) + inv, ok2 := env.Extract().(*bill.Invoice) + if !ok || !ok2 { + return nil + } + exportAEUUID(out, inv) + exportAEIssueTime(out, inv) + exportAETransactionType(out, inv) + exportAECreditNoteReason(out, inv) + exportAEIncoterms(out, inv) + exportAEDeliveryPartyID(out, inv) + exportAEContractValue(out, inv) + exportAEPayment(out, inv) + exportAEChargeRates(out, aeStandardRate(inv)) + exportAELines(out.InvoiceLines, inv) + exportAELines(out.CreditNoteLines, inv) + for _, p := range goblubl.InvoiceParties(inv, out) { + exportAEPartyTaxID(p.UBL, p.GOBL.TaxID) + } + exportAEPartyIdentities(out.AccountingSupplierParty.Party, inv.Supplier) + exportAEPartyIdentities(out.AccountingCustomerParty.Party, inv.Customer) + for i := range out.TaxTotal { + exportAETaxTotal(&out.TaxTotal[i], aeStandardRate(inv)) + } + exportAEExchangeRate(out, inv) + return nil +} + +// importAE applies the Peppol PINT AE rules to an imported invoice. +func importAE(_ *goblubl.Format, doc goblubl.Document, env *gobl.Envelope) error { + in, ok := doc.(*goblubl.Invoice) + inv, ok2 := env.Extract().(*bill.Invoice) + if !ok || !ok2 { + return nil + } + importAEUUID(in, inv) + importAEOutsideTaxScope(in, inv) + importAEMarginScheme(inv) + importAETransactionType(in, inv) + importAECreditNoteReason(in, inv) + importAEIncoterms(in, inv) + importAEDeliveryPartyID(in, inv) + importAEChargeExemptions(in, inv) + importAELineExemptions(in.InvoiceLines, inv) + importAELineExemptions(in.CreditNoteLines, inv) + importAELineGoods(in.InvoiceLines, inv) + importAELineGoods(in.CreditNoteLines, inv) + importAELineItems(in.InvoiceLines, inv) + importAELineItems(in.CreditNoteLines, inv) + importAEPartyIdentities(in.AccountingSupplierParty.Party, inv.Supplier, true) + importAEPartyIdentities(in.AccountingCustomerParty.Party, inv.Customer, false) + return nil +} + +// importAEOutsideTaxScope reads 480 and 81, which gobl.ubl imports as "other", as a standard invoice +// and a credit note with the outside-tax-scope tag. +func importAEOutsideTaxScope(in *goblubl.Invoice, inv *bill.Invoice) { + code := in.InvoiceTypeCode + if code == nil { + code = in.CreditNoteTypeCode + } + if code == nil { + return + } + switch code.Value { + case "480": + inv.Type = bill.InvoiceTypeStandard + case "81": + inv.Type = bill.InvoiceTypeCreditNote + default: + return + } + if !inv.HasTags(pint.TagOutsideTaxScope) { + inv.Tags.List = append(inv.Tags.List, pint.TagOutsideTaxScope) + } +} + +// importAEMarginScheme reads N VAT combos as exempt with the margin-scheme tag, as a user writes them; +// without a key EN 16931 would make them standard rated. +func importAEMarginScheme(inv *bill.Invoice) { + var sets []tax.Set + for _, l := range inv.Lines { + sets = append(sets, l.Taxes) + } + for _, d := range inv.Discounts { + sets = append(sets, d.Taxes) + } + for _, c := range inv.Charges { + sets = append(sets, c.Taxes) + } + found := false + for _, set := range sets { + for _, c := range set { + if c.Category == tax.CategoryVAT && c.Ext.Get(untdid.ExtKeyTaxCategory) == pint.TaxCategoryMarginScheme { + c.Key = tax.KeyExempt + c.Percent = nil + found = true + } + } + } + if found && !inv.HasTags(pint.TagMarginScheme) { + inv.Tags.List = append(inv.Tags.List, pint.TagMarginScheme) + } +} + +// exportAEUUID writes the invoice's UUID as cbc:UUID, the unique identifier +// number (BTAE-07). +func exportAEUUID(out *goblubl.Invoice, inv *bill.Invoice) { + if !inv.UUID.IsZero() { + out.UUID = inv.UUID.String() + } +} + +// exportAETransactionType writes the transaction type (BTAE-02), and the beneficiary (BTAE-01) and +// principal (BTAE-14) IDs as the buyer and seller party identifications. +func exportAETransactionType(out *goblubl.Invoice, inv *bill.Invoice) { + out.ProfileExecutionID = inv.Tax.GetExt(pint.ExtKeyTransactionType).String() + if id := inv.Tax.GetExt(pint.ExtKeyBeneficiaryID); id != "" { + out.BuyerCustomerParty = &goblubl.CustomerParty{Party: identifiedParty(id)} + } + if id := inv.Tax.GetExt(pint.ExtKeyPrincipalID); id != "" { + out.SellerSupplierParty = &goblubl.SupplierParty{Party: identifiedParty(id)} + } +} + +// importAEUUID reads the invoice's UUID back from cbc:UUID (BTAE-07). A value +// that is not a UUID is left out. +func importAEUUID(in *goblubl.Invoice, inv *bill.Invoice) { + if id, err := uuid.Parse(strings.TrimSpace(in.UUID)); err == nil { + inv.UUID = id + } +} + +// exportAEIssueTime writes the invoice's issue time as cbc:IssueTime +// (IBT-168), which gobl.ubl reads but doesn't write. +func exportAEIssueTime(out *goblubl.Invoice, inv *bill.Invoice) { + if inv.IssueTime != nil { + out.IssueTime = inv.IssueTime.String() + } +} + +// exportAEContractValue writes each contract's description, PINT AE's contract value (BTAE-05), as its +// cac:ContractDocumentReference/cbc:DocumentDescription. +func exportAEContractValue(out *goblubl.Invoice, inv *bill.Invoice) { + if inv.Ordering == nil || len(inv.Ordering.Contracts) != len(out.ContractDocumentReference) { + return + } + for i, c := range inv.Ordering.Contracts { + if c == nil { + continue + } + out.ContractDocumentReference[i].DocumentDescription = c.Description + } +} + +// exportAEPayment completes the payee account gobl.ubl writes from the first credit transfer. +func exportAEPayment(out *goblubl.Invoice, inv *bill.Invoice) { + if len(out.PaymentMeans) == 0 || inv.Payment == nil { + return + } + if instr := inv.Payment.Instructions; instr != nil && len(instr.CreditTransfer) > 0 { + exportAECreditTransfer(out.PaymentMeans[0].PayeeFinancialAccount, instr.CreditTransfer[0]) + } +} + +// exportAECreditTransfer writes the address of the payee account's branch (IBG-34), which gobl.ubl +// already reads back. +func exportAECreditTransfer(acc *goblubl.FinancialAccount, ct *pay.CreditTransfer) { + if acc == nil || ct == nil { + return + } + // TODO: FormatPINT should write the branch address too (IBG-34); gobl.ubl can't (UBL-CR-432). + if addr := aeAddress(ct.Branch); addr != nil { + if acc.FinancialInstitutionBranch == nil { + acc.FinancialInstitutionBranch = new(goblubl.Branch) + } + acc.FinancialInstitutionBranch.Address = addr + } +} + +// aeAddress provides the UBL address of a GOBL one, with the lines gobl.ubl +// writes for a party's address. +func aeAddress(a *org.Address) *goblubl.PostalAddress { + if a == nil { + return nil + } + addr := new(goblubl.PostalAddress) + set := func(field **string, v string) { + if v != "" { + *field = &v + } + } + set(&addr.StreetName, a.LineOne()) + set(&addr.AdditionalStreetName, a.LineTwo()) + set(&addr.CityName, a.Locality) + set(&addr.PostalZone, a.Code.String()) + set(&addr.CountrySubentity, a.Region) + if a.Country != "" { + addr.Country = &goblubl.Country{IdentificationCode: a.Country.String()} + } + return addr +} + +// exportAEChargeRates writes the standard rate on reverse charge allowances and charges, where gobl.ubl +// writes 0 and PINT AE wants one above 0. +func exportAEChargeRates(out *goblubl.Invoice, standard string) { + for _, ac := range out.AllowanceCharge { + for _, c := range ac.TaxCategory { + if c != nil && c.ID != nil && c.ID.Value == taxCategoryReverseCharge { + rate := standard + c.Percent = &rate + } + } + } +} + +// importAEChargeExemptions reads charge and discount exemption reasons from their own cac:TaxCategory; +// gobl.ubl takes them from the breakdown, which keeps only shared ones. +func importAEChargeExemptions(in *goblubl.Invoice, inv *bill.Invoice) { + if len(in.AllowanceCharge) != len(inv.Charges)+len(inv.Discounts) { + return + } + var charges, discounts int + for _, ac := range in.AllowanceCharge { + var set tax.Set + if ac.ChargeIndicator { + set = inv.Charges[charges].Taxes + charges++ + } else { + set = inv.Discounts[discounts].Taxes + discounts++ + } + c := set.Get(tax.CategoryVAT) + if c == nil { + continue + } + for _, cat := range ac.TaxCategory { + if cat == nil || cat.TaxExemptionReasonCode == nil { + continue + } + if code := cbc.Code(strings.TrimSpace(*cat.TaxExemptionReasonCode)); code != "" { + c.Ext = c.Ext.Set(cef.ExtKeyVATEX, code) + break + } + } + } +} + +// identifiedParty returns a party with only a cac:PartyIdentification. +func identifiedParty(id cbc.Code) *goblubl.Party { + return &goblubl.Party{PartyIdentification: []goblubl.Identification{ + {ID: &goblubl.IDType{Value: id.String()}}, + }} +} + +// importAETransactionType reads back what exportAETransactionType writes, and adds the tags of the +// transaction type's flags. +func importAETransactionType(in *goblubl.Invoice, inv *bill.Invoice) { + code := cbc.Code(strings.TrimSpace(in.ProfileExecutionID)) + if code != "" { + setAEExt(inv, pint.ExtKeyTransactionType, code) + for _, tag := range pint.ParseTransactionType(code).Tags() { + if !inv.HasTags(tag) { + inv.Tags.List = append(inv.Tags.List, tag) + } + } + } + if in.BuyerCustomerParty != nil { + setAEExt(inv, pint.ExtKeyBeneficiaryID, partyIdentificationID(in.BuyerCustomerParty.Party)) + } + if in.SellerSupplierParty != nil { + setAEExt(inv, pint.ExtKeyPrincipalID, partyIdentificationID(in.SellerSupplierParty.Party)) + } +} + +// partyIdentificationID returns the party's first cac:PartyIdentification ID. +func partyIdentificationID(p *goblubl.Party) cbc.Code { + if p == nil { + return "" + } + for _, pi := range p.PartyIdentification { + if pi.ID != nil && strings.TrimSpace(pi.ID.Value) != "" { + return cbc.Code(strings.TrimSpace(pi.ID.Value)) + } + } + return "" +} + +// setAEExt sets a tax extension on the invoice, when the value isn't empty. +func setAEExt(inv *bill.Invoice, key cbc.Key, code cbc.Code) { + if code == "" { + return + } + if inv.Tax == nil { + inv.Tax = new(bill.Tax) + } + inv.Tax.Ext = inv.Tax.Ext.Set(key, code) +} + +// exportAECreditNoteReason writes the credit note reason as +// cac:DiscrepancyResponse/cbc:ResponseCode (BTAE-03). UBL 2.1 only allows it +// on credit notes. +func exportAECreditNoteReason(out *goblubl.Invoice, inv *bill.Invoice) { + reason := inv.Tax.GetExt(pint.ExtKeyCreditNoteReason) + if reason == "" || out.CreditNoteTypeCode == nil { + return + } + out.DiscrepancyResponse = []goblubl.Response{ + {ResponseCode: &goblubl.IDType{Value: reason.String()}}, + } +} + +// importAECreditNoteReason reads the credit note reason back from the first +// cac:DiscrepancyResponse with a code, the only one PINT AE allows. +func importAECreditNoteReason(in *goblubl.Invoice, inv *bill.Invoice) { + for _, r := range in.DiscrepancyResponse { + if r.ResponseCode != nil && strings.TrimSpace(r.ResponseCode.Value) != "" { + setAEExt(inv, pint.ExtKeyCreditNoteReason, cbc.Code(strings.TrimSpace(r.ResponseCode.Value))) + return + } + } +} + +// exportAELineExemption writes the line's VATEX code (IBT-186) and, except on standard rated lines, +// its category's tax note as the reason (IBT-185). +func exportAELineExemption(line *goblubl.InvoiceLine, l *bill.Line, tx *bill.Tax) { + if l == nil || line.Item == nil || line.Item.ClassifiedTaxCategory == nil { + return + } + c := l.Taxes.Get(tax.CategoryVAT) + if c == nil { + return + } + ctc := line.Item.ClassifiedTaxCategory + if code := c.Ext.Get(cef.ExtKeyVATEX); code != "" { + v := code.String() + ctc.TaxExemptionReasonCode = &v + } + if tx == nil || c.Ext.Get(untdid.ExtKeyTaxCategory) == taxCategoryStandard { + return + } + if note := aeTaxNote(tx.Notes, c); note != nil { + ctc.TaxExemptionReason = ¬e.Text + } +} + +// aeTaxNote finds the tax note for a combo's category, the way gobl.ubl does +// for the VAT breakdowns: by tax category and UNTDID 5305 category code. +func aeTaxNote(notes []*tax.Note, c *tax.Combo) *tax.Note { + code := c.Ext.Get(untdid.ExtKeyTaxCategory) + if code == "" { + return nil + } + for _, n := range notes { + if n != nil && n.Category == c.Category && n.Ext.Get(untdid.ExtKeyTaxCategory) == code { + return n + } + } + return nil +} + +// importAELineExemptions reads the line VATEX codes back, and a reason text as the category's tax +// note when the breakdown gave none. +func importAELineExemptions(lines []goblubl.InvoiceLine, inv *bill.Invoice) { + if len(lines) == 0 || len(lines) != len(inv.Lines) { + return + } + for i, line := range lines { + c := inv.Lines[i].Taxes.Get(tax.CategoryVAT) + if line.Item == nil || line.Item.ClassifiedTaxCategory == nil || c == nil { + continue + } + ctc := line.Item.ClassifiedTaxCategory + if ctc.TaxExemptionReasonCode != nil { + if code := cbc.Code(strings.TrimSpace(*ctc.TaxExemptionReasonCode)); code != "" { + c.Ext = c.Ext.Set(cef.ExtKeyVATEX, code) + } + } + if ctc.TaxExemptionReason == nil || strings.TrimSpace(*ctc.TaxExemptionReason) == "" { + continue + } + code := c.Ext.Get(untdid.ExtKeyTaxCategory) + if code == "" || (inv.Tax != nil && aeTaxNote(inv.Tax.Notes, c) != nil) { + continue + } + inv.Tax = inv.Tax.MergeNotes(&tax.Note{ + Category: c.Category, + Text: strings.TrimSpace(*ctc.TaxExemptionReason), + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyTaxCategory: code}), + }) + } +} + +// exportAELineGoods writes the goods type (BTAE-09) as cbc:NatureCode and the GTIN as the standard +// identifier, where gobl.ubl may write another identity. +func exportAELineGoods(line *goblubl.InvoiceLine, l *bill.Line) { + if l == nil || l.Item == nil || line.Item == nil { + return + } + if code := l.Item.Ext.Get(pint.ExtKeyGoodsType); code != "" { + v := code.String() + aeCommodityClassification(line.Item).NatureCode = &v + } + if id := pint.GTINIdentity(l.Item.Identities); id != nil { + scheme := pint.IdentitySchemeGTIN.String() + line.Item.StandardItemIdentification = &goblubl.ItemIdentification{ + ID: &goblubl.IDType{SchemeID: &scheme, Value: id.Code.String()}, + } + } +} + +// aeCommodityClassification returns the item's first commodity classification, adding one if it has +// none. The PINT AE item codes go there with the item classification code, as in the official examples. +func aeCommodityClassification(it *goblubl.Item) *goblubl.CommodityClassification { + if it.CommodityClassification == nil || len(*it.CommodityClassification) == 0 { + it.CommodityClassification = &[]goblubl.CommodityClassification{{}} + } + return &(*it.CommodityClassification)[0] +} + +// exportAELineSAC moves the SAC item classifications gobl.ubl writes to cac:AdditionalItemIdentification +// with the SAC scheme (BTAE-17). +func exportAELineSAC(line *goblubl.InvoiceLine) { + if line.Item == nil || line.Item.CommodityClassification == nil { + return + } + var kept []goblubl.CommodityClassification + for _, cc := range *line.Item.CommodityClassification { + code := cc.ItemClassificationCode + if code == nil || code.ListID == nil || *code.ListID != pint.IdentityLabelSAC { + kept = append(kept, cc) + continue + } + scheme := pint.IdentityLabelSAC + line.Item.AdditionalItemIdentification = append(line.Item.AdditionalItemIdentification, + goblubl.ItemIdentification{ID: &goblubl.IDType{SchemeID: &scheme, Value: code.Value}}) + } + if len(kept) == 0 { + line.Item.CommodityClassification = nil + return + } + line.Item.CommodityClassification = &kept +} + +// exportAELineItemType writes the item type (BTAE-13) of the item's key as +// its cac:CommodityClassification/cbc:CommodityCode. +func exportAELineItemType(line *goblubl.InvoiceLine, l *bill.Line) { + if l == nil || l.Item == nil || line.Item == nil { + return + } + if typ := pint.ItemTypeAE(l.Item.Key); typ != "" { + v := typ.String() + aeCommodityClassification(line.Item).CommodityCode = &v + } +} + +// importAELineGoods reads the goods type back onto the line items. gobl.ubl already reads the GTIN. +func importAELineGoods(lines []goblubl.InvoiceLine, inv *bill.Invoice) { + if len(lines) == 0 || len(lines) != len(inv.Lines) { + return + } + for i, line := range lines { + if line.Item == nil || inv.Lines[i].Item == nil { + continue + } + if line.Item.CommodityClassification == nil { + continue + } + for _, cc := range *line.Item.CommodityClassification { + if cc.NatureCode == nil { + continue + } + if code := cbc.Code(strings.TrimSpace(*cc.NatureCode)); code != "" { + inv.Lines[i].Item.Ext = inv.Lines[i].Item.Ext.Set(pint.ExtKeyGoodsType, code) + break + } + } + } +} + +// importAELineItems reads back what exportAELineSAC and exportAELineItemType +// write: the service accounting codes as identities with their scheme as +// label, and the item type as the item's key. +func importAELineItems(lines []goblubl.InvoiceLine, inv *bill.Invoice) { + if len(lines) == 0 || len(lines) != len(inv.Lines) { + return + } + for i, line := range lines { + it := inv.Lines[i].Item + if line.Item == nil || it == nil { + continue + } + for _, ai := range line.Item.AdditionalItemIdentification { + if ai.ID == nil || strings.TrimSpace(ai.ID.Value) == "" { + continue + } + id := &org.Identity{Code: cbc.Code(strings.TrimSpace(ai.ID.Value))} + if ai.ID.SchemeID != nil { + id.Label = strings.TrimSpace(*ai.ID.SchemeID) + } + it.Identities = append(it.Identities, id) + } + if line.Item.CommodityClassification == nil { + continue + } + for _, cc := range *line.Item.CommodityClassification { + if cc.CommodityCode == nil { + continue + } + if key := pint.ItemKeyAE(cbc.Code(strings.TrimSpace(*cc.CommodityCode))); key != "" { + it.Key = key + break + } + } + } +} + +// exportAEIncoterms writes the delivery's Incoterms rule code, from the ICC +// Incoterms 2020 or 2010 extension, as cac:Delivery/cac:DeliveryTerms/cbc:ID +// (BTAE-22) under the Incoterms scheme. +func exportAEIncoterms(out *goblubl.Invoice, inv *bill.Invoice) { + if inv.Delivery == nil { + return + } + code := inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2020) + if code == "" { + code = inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2010) + } + if code == "" { + return + } + if len(out.Delivery) == 0 { + out.Delivery = []*goblubl.Delivery{{}} + } + scheme := deliveryTermsSchemeIncoterms + out.Delivery[0].DeliveryTerms = []goblubl.DeliveryTerms{ + {ID: goblubl.IDType{SchemeID: &scheme, Value: code.String()}}, + } +} + +// importAEIncoterms reads the delivery terms back as the ICC Incoterms 2020 +// extension, the current edition, as PINT AE doesn't say which one a code is +// from. A code only the 2010 edition has is read as that one. +func importAEIncoterms(in *goblubl.Invoice, inv *bill.Invoice) { + if len(in.Delivery) == 0 || in.Delivery[0] == nil || len(in.Delivery[0].DeliveryTerms) == 0 { + return + } + code := cbc.Code(strings.TrimSpace(in.Delivery[0].DeliveryTerms[0].ID.Value)) + if code == "" { + return + } + if inv.Delivery == nil { + inv.Delivery = new(bill.DeliveryDetails) + } + key := icc.ExtKeyIncoterms2020 + if !extensionHasCode(key, code) && extensionHasCode(icc.ExtKeyIncoterms2010, code) { + key = icc.ExtKeyIncoterms2010 + } + inv.Delivery.Ext = inv.Delivery.Ext.Set(key, code) +} + +// exportAEDeliveryPartyID writes the receiver's UAE TRN, or else TIN, as the Deliver to Party ID +// (BTAE-23, implementation guide 2.3.11). +func exportAEDeliveryPartyID(out *goblubl.Invoice, inv *bill.Invoice) { + if inv.Delivery == nil { + return + } + id := aeReceiverID(inv.Delivery.Receiver) + if id == "" { + return + } + if len(out.Delivery) == 0 { + out.Delivery = []*goblubl.Delivery{{}} + } + d := out.Delivery[0] + if d.DeliveryParty == nil { + d.DeliveryParty = new(goblubl.Party) + } + d.DeliveryParty.PartyIdentification = []goblubl.Identification{ + {ID: &goblubl.IDType{Value: id.String()}}, + } +} + +// aeReceiverID provides the receiver's UAE TRN, or else its TIN. +func aeReceiverID(p *org.Party) cbc.Code { + if p == nil { + return "" + } + if p.TaxID != nil && p.TaxID.Country.Code() == l10n.AE && p.TaxID.Code != "" { + return p.TaxID.Code + } + for _, id := range p.Identities { + if id != nil && id.Type == ae.IdentityTypeTIN && id.Code != "" { + return id.Code + } + } + return "" +} + +// importAEDeliveryPartyID reads back what exportAEDeliveryPartyID writes: a +// TRN, 15 digits starting with 1, as the receiver's UAE tax ID, and anything +// else as a TIN identity, the only other ID the implementation guide allows. +func importAEDeliveryPartyID(in *goblubl.Invoice, inv *bill.Invoice) { + if len(in.Delivery) == 0 || in.Delivery[0] == nil { + return + } + code := partyIdentificationID(in.Delivery[0].DeliveryParty) + if code == "" { + return + } + if inv.Delivery == nil { + inv.Delivery = new(bill.DeliveryDetails) + } + if inv.Delivery.Receiver == nil { + inv.Delivery.Receiver = new(org.Party) + } + r := inv.Delivery.Receiver + if trnRegexp.MatchString(code.String()) { + r.TaxID = &tax.Identity{Country: l10n.AE.Tax(), Code: code} + return + } + r.Identities = append(r.Identities, &org.Identity{Type: ae.IdentityTypeTIN, Code: code}) +} + +// trnRegexp matches a UAE TRN. +var trnRegexp = regexp.MustCompile(ae.TRNPattern) + +// extensionHasCode reports whether the extension lists the code. +func extensionHasCode(key cbc.Key, code cbc.Code) bool { + def := tax.ExtensionForKey(key) + return def != nil && def.HasCode(code) +} + +// exportAELines completes the UBL lines, which gobl.ubl writes in the same +// order as the invoice's lines. +func exportAELines(lines []goblubl.InvoiceLine, inv *bill.Invoice) { + var rate *currency.ExchangeRate + if inv.Currency != currency.AED { + rate = currency.MatchExchangeRate(inv.ExchangeRates, inv.Currency, currency.AED) + } + standard := aeStandardRate(inv) + for i := range lines { + exportAELine(&lines[i], standard) + if len(lines) == len(inv.Lines) { + exportAELineAmounts(&lines[i], inv.Lines[i], inv.Currency, rate) + exportAELineExemption(&lines[i], inv.Lines[i], inv.Tax) + exportAELineSAC(&lines[i]) + exportAELineGoods(&lines[i], inv.Lines[i]) + exportAELineItemType(&lines[i], inv.Lines[i]) + } + } +} + +// exportAELine completes a line's price details and VAT rate. +func exportAELine(line *goblubl.InvoiceLine, standard string) { + exportAEPrice(line) + if line.Item != nil && line.Item.ClassifiedTaxCategory != nil { + c := line.Item.ClassifiedTaxCategory + c.Percent = aeRate(c.ID, c.Percent, standard) + } +} + +// exportAELineAmounts writes the line amount payable (BTAE-10) and VAT (BTAE-08), in AED as the +// implementation guide (3.1.1) asks. GOBL keeps no VAT per line, so it is the line total at the line's rate. +func exportAELineAmounts(line *goblubl.InvoiceLine, l *bill.Line, cur currency.Code, rate *currency.ExchangeRate) { + if l == nil || l.Total == nil { + return + } + def := cur.Def() + if def == nil { + return + } + out := cur + convert := func(a num.Amount) num.Amount { return a } + if rate != nil { + out = currency.AED + convert = rate.Convert + } + total := convert(def.Rescale(*l.Total)) + ext := &goblubl.ItemPriceExtension{Amount: aeAmount(total, out)} + if vat, ok := aeLineVAT(line, l); ok { + vat = convert(def.Rescale(vat)) + ext.Amount = aeAmount(total.Add(vat), out) + ext.TaxTotal = []goblubl.TaxTotal{{TaxAmount: aeAmount(vat, out)}} + } + line.ItemPriceExtension = ext +} + +// aeLineVAT provides the VAT charged on a line, which only standard rated lines have, and false for +// exempt lines, which must not have one. +func aeLineVAT(line *goblubl.InvoiceLine, l *bill.Line) (num.Amount, bool) { + zero := num.MakeAmount(0, l.Total.Exp()) + if line.Item == nil || line.Item.ClassifiedTaxCategory == nil || line.Item.ClassifiedTaxCategory.ID == nil { + return zero, true + } + switch line.Item.ClassifiedTaxCategory.ID.Value { + case taxCategoryExempt: + return zero, false + case taxCategoryStandard: + if c := l.Taxes.Get(tax.CategoryVAT); c != nil && c.Percent != nil { + return c.Percent.Of(*l.Total), true + } + } + return zero, true +} + +// exportAEExchangeRate writes, for invoices not in AED, the rate to AED (BTAE-04) as cac:TaxExchangeRate +// and the total with VAT in AED (BTAE-20). +func exportAEExchangeRate(out *goblubl.Invoice, inv *bill.Invoice) { + if inv.Currency == currency.AED { + return + } + rate := currency.MatchExchangeRate(inv.ExchangeRates, inv.Currency, currency.AED) + if rate == nil { + return + } + source, target, calc := inv.Currency.String(), currency.AED.String(), rate.Amount.String() + out.TaxExchangeRate = &goblubl.ExchangeRate{ + SourceCurrencyCode: &source, + TargetCurrencyCode: &target, + CalculationRate: &calc, + } + if inv.Totals != nil { + total := rate.Convert(inv.Totals.TotalWithTax) + out.AdditionalDocumentReference = append(out.AdditionalDocumentReference, goblubl.Reference{ + ID: goblubl.IDType{Value: currency.AED.String()}, + DocumentTypeCode: aedTotalDocumentType, + DocumentDescription: total.String(), + }) + } +} + +// aeAmount provides a UBL amount in the currency. +func aeAmount(a num.Amount, cur currency.Code) goblubl.Amount { + code := cur.String() + return goblubl.Amount{CurrencyID: &code, Value: a.String()} +} + +// exportAEPrice adds the base quantity 1 and the gross price PINT AE requires on every line, +// with a zero price discount when gobl.ubl writes none. +func exportAEPrice(line *goblubl.InvoiceLine) { + price := line.Price + if price == nil { + return + } + if price.BaseQuantity == nil { + price.BaseQuantity = &goblubl.Quantity{UnitCode: lineUnitCode(line), Value: "1"} + } + if price.AllowanceCharge == nil { + gross := price.PriceAmount + net, _ := num.AmountFromString(gross.Value) + price.AllowanceCharge = &goblubl.AllowanceCharge{ + ChargeIndicator: false, + Amount: goblubl.Amount{CurrencyID: gross.CurrencyID, Value: num.AmountZero.MatchPrecision(net).String()}, + BaseAmount: &gross, + } + } +} + +// lineUnitCode provides the unit code of the line's invoiced or credited +// quantity. +func lineUnitCode(line *goblubl.InvoiceLine) string { + if line.InvoicedQuantity != nil { + return line.InvoicedQuantity.UnitCode + } + if line.CreditedQuantity != nil { + return line.CreditedQuantity.UnitCode + } + return "" +} + +// aeStandardRate provides the AE regime's standard VAT rate on the invoice's tax date, as UBL writes it. +func aeStandardRate(inv *bill.Invoice) string { + date := inv.IssueDate + if inv.ValueDate != nil { + date = *inv.ValueDate + } + rd := tax.RegimeDefFor(l10n.AE).CategoryDef(tax.CategoryVAT).RateDef(tax.KeyStandard, tax.RateGeneral) + if rd == nil { + return "" + } + if v := rd.Value(date, tax.Extensions{}); v != nil { + return v.Percent.StringWithoutSymbol() + } + return "" +} + +// aeRate provides the rate PINT AE expects for a VAT category where gobl.ubl writes 0: none for exempt, +// the standard rate for reverse charge and margin scheme. +func aeRate(id *goblubl.IDType, percent *string, standard string) *string { + if id == nil { + return percent + } + switch id.Value { + case taxCategoryExempt: + return nil + case taxCategoryReverseCharge, taxCategoryMarginScheme: + rate := standard + return &rate + } + return percent +} + +// exportAEPartyTaxID writes UAE TRNs without the AE prefix gobl.ubl adds. +func exportAEPartyTaxID(out *goblubl.Party, tID *tax.Identity) { + if out == nil || tID == nil || tID.Code == "" || tID.Country.Code() != l10n.AE { + return + } + prefixed := tID.String() + for i := range out.PartyTaxScheme { + id := out.PartyTaxScheme[i].CompanyID + if id != nil && id.Value == prefixed { + id.Value = tID.Code.String() + } + } +} + +// exportAEPartyIdentities writes the PINT AE details of the seller and buyer +// identities that gobl.ubl has no place for. +func exportAEPartyIdentities(out *goblubl.Party, p *org.Party) { + if out == nil || p == nil { + return + } + exportAELegalIdentity(out, p) + exportAETINIdentification(out) +} + +// exportAETINIdentification writes the scheme of a TIN identity in cac:PartyIdentification as its +// ISO 6523 ICD, 0235, where gobl.ubl writes its type, TIN, which is not an ICD. +func exportAETINIdentification(out *goblubl.Party) { + for i := range out.PartyIdentification { + id := out.PartyIdentification[i].ID + if id != nil && id.SchemeID != nil && *id.SchemeID == ae.IdentityTypeTIN.String() { + scheme := ae.TINScheme.String() + id.SchemeID = &scheme + } + } +} + +// exportAELegalIdentity writes the PINT AE type of the first legal identity as @schemeAgencyID (BTAE-15/16), +// and a passport's country or a trade licence's authority as @schemeAgencyName. +func exportAELegalIdentity(out *goblubl.Party, p *org.Party) { + if out.PartyLegalEntity == nil || out.PartyLegalEntity.CompanyID == nil { + return + } + var id *org.Identity + for _, i := range p.Identities { + if i != nil && i.Scope == org.IdentityScopeLegal { + id = i + break + } + } + if id == nil { + return + } + typ := pint.IdentityTypeAE(id) + if typ == "" { + return + } + cid := out.PartyLegalEntity.CompanyID + agencyID := typ.String() + cid.SchemeAgencyID = &agencyID + switch typ { + case pint.IdentityTypePassport: + if id.Country != "" { + name := id.Country.String() + cid.SchemeAgencyName = &name + } + case ae.IdentityTypeTradeLicense: + if id.Description != "" { + name := id.Description + cid.SchemeAgencyName = &name + } + } +} + +// importAEPartyIdentities reads back what exportAEPartyIdentities writes, and the supplier's non-VAT +// tax registration as its TIN (IBT-032). +// +// TODO: the seller TIN scheme has no code list (examples use TIN and TAX), so any scheme is read as TIN. +// TODO: gobl.ubl gives imported tax registrations the address's country; fix there. +func importAEPartyIdentities(in *goblubl.Party, p *org.Party, supplier bool) { + if in == nil || p == nil { + return + } + if le := in.PartyLegalEntity; le != nil && le.CompanyID != nil && le.CompanyID.SchemeAgencyID != nil { + cid := le.CompanyID + for _, id := range p.Identities { + if id == nil || id.Scope != org.IdentityScopeLegal || id.Code.String() != cid.Value { + continue + } + importAELegalIdentity(id, cid) + break + } + } + for _, id := range p.Identities { + if id != nil && id.Scope == "" && id.Ext.Get(iso.ExtKeySchemeID) == ae.TINScheme { + id.Type = ae.IdentityTypeTIN + id.Ext = id.Ext.Delete(iso.ExtKeySchemeID) + } + } + if !supplier { + return + } + for _, pts := range in.PartyTaxScheme { + if pts.CompanyID == nil || pts.TaxScheme == nil || + strings.EqualFold(strings.TrimSpace(pts.TaxScheme.ID.Value), goblubl.TaxSchemeVAT) { + continue + } + for _, id := range p.Identities { + if id != nil && id.Scope == org.IdentityScopeTax && id.Code.String() == pts.CompanyID.Value { + id.Type = ae.IdentityTypeTIN + break + } + } + } +} + +// importAELegalIdentity sets the identity's key or type and, from +// @schemeAgencyName, its issuing country or description. +func importAELegalIdentity(id *org.Identity, cid *goblubl.IDType) { + if !pint.SetIdentityTypeAE(id, cbc.Code(strings.TrimSpace(*cid.SchemeAgencyID))) { + return + } + if cid.SchemeAgencyName == nil { + return + } + name := strings.TrimSpace(*cid.SchemeAgencyName) + switch { + case id.Key == org.IdentityKeyPassport: + id.Country = l10n.ISOCountryCode(name) + case id.Type == ae.IdentityTypeTradeLicense: + id.Description = name + } +} + +// exportAETaxTotal fixes the breakdown rates, merges breakdowns left with the same category and rate, +// and says prices exclude VAT (IBT-200). +func exportAETaxTotal(tt *goblubl.TaxTotal, standard string) { + for i := range tt.TaxSubtotal { + c := &tt.TaxSubtotal[i].TaxCategory + c.Percent = aeRate(c.ID, c.Percent, standard) + } + tt.TaxSubtotal = mergeAETaxSubtotals(tt.TaxSubtotal) + if len(tt.TaxSubtotal) > 0 { + // gobl.ubl takes the taxes out of prices that include them. + included := false + tt.TaxIncludedIndicator = &included + } +} + +// mergeAETaxSubtotals merges breakdowns with the same category and rate: GOBL makes one per exemption +// code, PINT AE wants one per category. Codes and reasons that differ are dropped. +func mergeAETaxSubtotals(subtotals []goblubl.TaxSubtotal) []goblubl.TaxSubtotal { + var merged []goblubl.TaxSubtotal + for _, st := range subtotals { + i := indexAETaxSubtotal(merged, st.TaxCategory) + if i < 0 { + merged = append(merged, st) + continue + } + m := &merged[i] + m.TaxableAmount.Value = addAmounts(m.TaxableAmount.Value, st.TaxableAmount.Value) + m.TaxAmount.Value = addAmounts(m.TaxAmount.Value, st.TaxAmount.Value) + if !sameString(m.TaxCategory.TaxExemptionReasonCode, st.TaxCategory.TaxExemptionReasonCode) { + m.TaxCategory.TaxExemptionReasonCode = nil + } + if !sameString(m.TaxCategory.TaxExemptionReason, st.TaxCategory.TaxExemptionReason) { + m.TaxCategory.TaxExemptionReason = nil + } + } + return merged +} + +// indexAETaxSubtotal finds the breakdown with the same category ID, rate and +// tax scheme, or -1. +func indexAETaxSubtotal(list []goblubl.TaxSubtotal, c goblubl.TaxCategory) int { + for i, st := range list { + if sameID(st.TaxCategory.ID, c.ID) && + samePercent(st.TaxCategory.Percent, c.Percent) && + sameScheme(st.TaxCategory.TaxScheme, c.TaxScheme) { + return i + } + } + return -1 +} + +func sameID(a, b *goblubl.IDType) bool { + if a == nil || b == nil { + return a == b + } + return a.Value == b.Value +} + +// samePercent compares rates by value, so "0" and "0.0" match. +func samePercent(a, b *string) bool { + if a == nil || b == nil { + return a == b + } + x, errA := num.AmountFromString(*a) + y, errB := num.AmountFromString(*b) + if errA != nil || errB != nil { + return *a == *b + } + return x.Equals(y) +} + +func sameString(a, b *string) bool { + if a == nil || b == nil { + return a == b + } + return *a == *b +} + +func sameScheme(a, b *goblubl.TaxScheme) bool { + if a == nil || b == nil { + return a == b + } + return a.ID.Value == b.ID.Value +} + +// addAmounts adds two decimal amounts, keeping the larger number of decimals. +func addAmounts(a, b string) string { + x, err := num.AmountFromString(a) + if err != nil { + return a + } + y, err := num.AmountFromString(b) + if err != nil { + return a + } + return x.MatchPrecision(y).Add(y).String() +} diff --git a/ubl/ae_internal_test.go b/ubl/ae_internal_test.go new file mode 100644 index 0000000..0bf7f98 --- /dev/null +++ b/ubl/ae_internal_test.go @@ -0,0 +1,391 @@ +package ubl + +import ( + "testing" + + goblubl "github.com/invopop/gobl.ubl" + "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/catalogues/cef" + "github.com/invopop/gobl/catalogues/icc" + "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/currency" + "github.com/invopop/gobl/num" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/pay" + "github.com/invopop/gobl/regimes/ae" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func strPtr(s string) *string { return &s } + +func aeCategory(id string, percent *string) goblubl.TaxCategory { + return goblubl.TaxCategory{ + ID: &goblubl.IDType{Value: id}, + Percent: percent, + TaxScheme: &goblubl.TaxScheme{ID: goblubl.IDType{Value: "VAT"}}, + } +} + +func aedAmount(v string) goblubl.Amount { + return goblubl.Amount{CurrencyID: strPtr("AED"), Value: v} +} + +func TestExportAEPrice(t *testing.T) { + t.Run("writes the zero discount with the decimals of the price", func(t *testing.T) { + line := &goblubl.InvoiceLine{ + InvoicedQuantity: &goblubl.Quantity{UnitCode: "C62", Value: "1"}, + Price: &goblubl.Price{PriceAmount: aedAmount("10.1234")}, + } + exportAEPrice(line) + assert.Equal(t, "0.0000", line.Price.AllowanceCharge.Amount.Value) + }) + + t.Run("keeps a price discount gobl.ubl already wrote", func(t *testing.T) { + existing := &goblubl.AllowanceCharge{Amount: aedAmount("20.00"), BaseAmount: &goblubl.Amount{Value: "120.00"}} + line := &goblubl.InvoiceLine{ + InvoicedQuantity: &goblubl.Quantity{UnitCode: "C62", Value: "1"}, + Price: &goblubl.Price{PriceAmount: aedAmount("100.00"), AllowanceCharge: existing}, + } + exportAEPrice(line) + assert.Same(t, existing, line.Price.AllowanceCharge) + }) +} + +func TestAERate(t *testing.T) { + zero := strPtr("0") + assert.Nil(t, aeRate(&goblubl.IDType{Value: "E"}, zero, "5"), "exempt has no rate") + rc := aeRate(&goblubl.IDType{Value: "AE"}, zero, "5") + require.NotNil(t, rc) + assert.Equal(t, "5", *rc, "reverse charge is written at the standard rate") + ms := aeRate(&goblubl.IDType{Value: "N"}, zero, "5") + require.NotNil(t, ms) + assert.Equal(t, "5", *ms, "margin scheme is written at the standard rate") + assert.Equal(t, strPtr("5"), aeRate(&goblubl.IDType{Value: "S"}, strPtr("5"), "5"), "standard keeps its rate") + assert.Nil(t, aeRate(&goblubl.IDType{Value: "O"}, nil, "5"), "outside scope keeps no rate") + assert.Equal(t, zero, aeRate(nil, zero, "5"), "no category, no change") +} + +func TestMergeAETaxSubtotals(t *testing.T) { + exempt := func(base, code string) goblubl.TaxSubtotal { + c := aeCategory("E", nil) + c.TaxExemptionReasonCode = strPtr(code) + return goblubl.TaxSubtotal{TaxableAmount: aedAmount(base), TaxAmount: aedAmount("0.00"), TaxCategory: c} + } + standard := goblubl.TaxSubtotal{ + TaxableAmount: aedAmount("1000.00"), + TaxAmount: aedAmount("50.00"), + TaxCategory: aeCategory("S", strPtr("5")), + } + + t.Run("merges breakdowns of the same category and drops differing codes", func(t *testing.T) { + out := mergeAETaxSubtotals([]goblubl.TaxSubtotal{standard, exempt("200.00", "VATEX-1"), exempt("280.00", "VATEX-2")}) + require.Len(t, out, 2) + assert.Equal(t, "1000.00", out[0].TaxableAmount.Value) + assert.Equal(t, "480.00", out[1].TaxableAmount.Value) + assert.Equal(t, "0.00", out[1].TaxAmount.Value) + assert.Nil(t, out[1].TaxCategory.TaxExemptionReasonCode) + }) + + t.Run("keeps a code all merged breakdowns share", func(t *testing.T) { + out := mergeAETaxSubtotals([]goblubl.TaxSubtotal{exempt("200.00", "VATEX-1"), exempt("100.00", "VATEX-1")}) + require.Len(t, out, 1) + assert.Equal(t, "300.00", out[0].TaxableAmount.Value) + assert.Equal(t, strPtr("VATEX-1"), out[0].TaxCategory.TaxExemptionReasonCode) + }) + + t.Run("does not merge different rates", func(t *testing.T) { + zero := goblubl.TaxSubtotal{TaxableAmount: aedAmount("10.00"), TaxAmount: aedAmount("0.00"), TaxCategory: aeCategory("S", strPtr("0"))} + out := mergeAETaxSubtotals([]goblubl.TaxSubtotal{standard, zero}) + assert.Len(t, out, 2) + }) + + t.Run("merges rates written differently (ALIGNED-IBRP-Z-01)", func(t *testing.T) { + zero := func(base, pc string) goblubl.TaxSubtotal { + return goblubl.TaxSubtotal{TaxableAmount: aedAmount(base), TaxAmount: aedAmount("0.00"), TaxCategory: aeCategory("Z", strPtr(pc))} + } + out := mergeAETaxSubtotals([]goblubl.TaxSubtotal{zero("10.00", "0"), zero("20.00", "0.0")}) + require.Len(t, out, 1) + assert.Equal(t, "30.00", out[0].TaxableAmount.Value) + }) +} + +func TestImportAEPartyIdentities(t *testing.T) { + companyID := func(agencyID, agencyName string) *goblubl.Party { + cid := &goblubl.IDType{Value: "112345678900003"} + if agencyID != "" { + cid.SchemeAgencyID = &agencyID + } + if agencyName != "" { + cid.SchemeAgencyName = &agencyName + } + return &goblubl.Party{PartyLegalEntity: &goblubl.PartyLegalEntity{CompanyID: cid}} + } + // imported builds the GOBL party the way gobl.ubl imports it, then reads + // the AE details. + imported := func(in *goblubl.Party, supplier bool) *org.Party { + p := goblubl.ParseParty(in) + importAEPartyIdentities(in, p, supplier) + return p + } + + t.Run("supplier non-VAT tax registration is the TIN", func(t *testing.T) { + in := companyID("TL", "Authority") + in.PartyTaxScheme = []goblubl.PartyTaxScheme{ + {CompanyID: &goblubl.IDType{Value: "198765432200003"}, TaxScheme: &goblubl.TaxScheme{ID: goblubl.IDType{Value: "VAT"}}}, + {CompanyID: &goblubl.IDType{Value: "1234567897"}, TaxScheme: &goblubl.TaxScheme{ID: goblubl.IDType{Value: "TIN"}}}, + } + p := imported(in, true) + require.Len(t, p.Identities, 2) + assert.Equal(t, ae.IdentityTypeTIN, p.Identities[1].Type) + assert.Equal(t, cbc.Code("1234567897"), p.Identities[1].Code) + + p = imported(in, false) + assert.Empty(t, p.Identities[1].Type, "only the seller has a TIN") + + // Any scheme other than VAT, like the official example's TAX. + in.PartyTaxScheme[1].TaxScheme.ID.Value = "TAX" + p = imported(in, true) + assert.Equal(t, ae.IdentityTypeTIN, p.Identities[1].Type) + }) + + t.Run("unknown or missing types are left alone", func(t *testing.T) { + for _, typ := range []string{"XYZ", ""} { + id := imported(companyID(typ, "Some Authority"), false).Identities[0] + assert.Empty(t, id.Key, typ) + assert.Empty(t, id.Type, typ) + assert.Empty(t, id.Description, typ) + } + }) + + t.Run("nil parties are skipped", func(t *testing.T) { + assert.NotPanics(t, func() { + importAEPartyIdentities(nil, &org.Party{}, true) + importAEPartyIdentities(&goblubl.Party{}, nil, true) + }) + }) +} + +func TestExportAEPartyIdentities(t *testing.T) { + export := func(p *org.Party) *goblubl.Party { + out := goblubl.NewParty(p) + exportAEPartyIdentities(out, p) + return out + } + + t.Run("legal identity without a PINT AE type is left alone", func(t *testing.T) { + cid := export(&org.Party{Name: "Party", Identities: []*org.Identity{ + {Scope: org.IdentityScopeLegal, Code: "CN-1234567"}, + }}).PartyLegalEntity.CompanyID + assert.Nil(t, cid.SchemeAgencyID) + assert.Nil(t, cid.SchemeAgencyName) + }) + + t.Run("parties without a company ID are left alone", func(t *testing.T) { + out := export(&org.Party{Name: "Party"}) + require.NotNil(t, out.PartyLegalEntity) + assert.Nil(t, out.PartyLegalEntity.CompanyID) + }) + + t.Run("nil parties are skipped", func(t *testing.T) { + assert.NotPanics(t, func() { + exportAEPartyIdentities(nil, &org.Party{}) + exportAEPartyIdentities(&goblubl.Party{}, nil) + }) + }) +} + +func TestImportAETransactionType(t *testing.T) { + t.Run("existing tags are not repeated", func(t *testing.T) { + inv := &bill.Invoice{Tags: tax.WithTags(tax.TagExport)} + importAETransactionType(&goblubl.Invoice{ProfileExecutionID: "00000001"}, inv) + assert.Equal(t, []cbc.Key{tax.TagExport}, inv.Tags.List) + }) + + t.Run("nothing to read leaves the invoice alone", func(t *testing.T) { + inv := new(bill.Invoice) + importAETransactionType(&goblubl.Invoice{BuyerCustomerParty: &goblubl.CustomerParty{}}, inv) + assert.Nil(t, inv.Tax) + assert.Empty(t, inv.Tags.List) + }) +} + +func TestAEIncoterms(t *testing.T) { + t.Run("writes the Incoterms as the delivery terms", func(t *testing.T) { + out := new(goblubl.Invoice) + exportAEIncoterms(out, &bill.Invoice{Delivery: &bill.DeliveryDetails{ + Ext: tax.ExtensionsOf(cbc.CodeMap{icc.ExtKeyIncoterms2020: "CIF"}), + }}) + require.Len(t, out.Delivery, 1) + require.Len(t, out.Delivery[0].DeliveryTerms, 1) + id := out.Delivery[0].DeliveryTerms[0].ID + assert.Equal(t, "CIF", id.Value) + require.NotNil(t, id.SchemeID) + assert.Equal(t, "Incoterms", *id.SchemeID) + }) + + t.Run("reads the Incoterms back as the 2020 edition", func(t *testing.T) { + in := &goblubl.Invoice{Delivery: []*goblubl.Delivery{{DeliveryTerms: []goblubl.DeliveryTerms{{ID: goblubl.IDType{Value: " CIF "}}}}}} + inv := new(bill.Invoice) + importAEIncoterms(in, inv) + require.NotNil(t, inv.Delivery) + assert.Equal(t, cbc.Code("CIF"), inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2020)) + + // DAT is only in the 2010 edition. + in = &goblubl.Invoice{Delivery: []*goblubl.Delivery{{DeliveryTerms: []goblubl.DeliveryTerms{{ID: goblubl.IDType{Value: "DAT"}}}}}} + inv = new(bill.Invoice) + importAEIncoterms(in, inv) + assert.Equal(t, cbc.Code("DAT"), inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2010)) + assert.Empty(t, inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2020)) + + // A code in neither edition is kept under the current one. + in = &goblubl.Invoice{Delivery: []*goblubl.Delivery{{DeliveryTerms: []goblubl.DeliveryTerms{{ID: goblubl.IDType{Value: "XYZ"}}}}}} + inv = new(bill.Invoice) + importAEIncoterms(in, inv) + assert.Equal(t, cbc.Code("XYZ"), inv.Delivery.Ext.Get(icc.ExtKeyIncoterms2020)) + + inv = new(bill.Invoice) + importAEIncoterms(new(goblubl.Invoice), inv) + assert.Nil(t, inv.Delivery) + }) +} + +func TestExportAELineAmounts(t *testing.T) { + line := func(category string) *goblubl.InvoiceLine { + return &goblubl.InvoiceLine{Item: &goblubl.Item{ + ClassifiedTaxCategory: &goblubl.ClassifiedTaxCategory{ID: &goblubl.IDType{Value: category}}, + }} + } + goblLine := func(total string, key cbc.Key, percent *num.Percentage) *bill.Line { + a, err := num.AmountFromString(total) + require.NoError(t, err) + return &bill.Line{Total: &a, Taxes: tax.Set{{Category: tax.CategoryVAT, Key: key, Percent: percent}}} + } + + t.Run("line VAT is rounded to the currency", func(t *testing.T) { + out := line("S") + exportAELineAmounts(out, goblLine("99.99", tax.KeyStandard, num.NewPercentage(5, 2)), currency.USD, nil) + assert.Equal(t, "5.00", out.ItemPriceExtension.TaxTotal[0].TaxAmount.Value) + assert.Equal(t, "104.99", out.ItemPriceExtension.Amount.Value) + assert.Equal(t, "USD", *out.ItemPriceExtension.Amount.CurrencyID, "no rate, so the document currency") + }) + + t.Run("other currencies are converted to AED", func(t *testing.T) { + out := line("S") + rate := ¤cy.ExchangeRate{From: currency.USD, To: currency.AED, Amount: num.MakeAmount(367285, 5)} + exportAELineAmounts(out, goblLine("99.99", tax.KeyStandard, num.NewPercentage(5, 2)), currency.USD, rate) + ext := out.ItemPriceExtension + assert.Equal(t, "AED", *ext.Amount.CurrencyID) + assert.Equal(t, "AED", *ext.TaxTotal[0].TaxAmount.CurrencyID) + assert.Equal(t, "18.36", ext.TaxTotal[0].TaxAmount.Value, "5.00 USD") + assert.Equal(t, "385.61", ext.Amount.Value, "99.99 USD is 367.25 AED, plus the VAT") + }) +} + +func TestAELineExemptionReason(t *testing.T) { + ublLine := func(category string, reason *string) goblubl.InvoiceLine { + return goblubl.InvoiceLine{Item: &goblubl.Item{ClassifiedTaxCategory: &goblubl.ClassifiedTaxCategory{ + ID: &goblubl.IDType{Value: category}, TaxExemptionReason: reason, + }}} + } + goblLine := func(category cbc.Code) *bill.Line { + return &bill.Line{Taxes: tax.Set{{ + Category: tax.CategoryVAT, + Ext: tax.ExtensionsOf(cbc.CodeMap{untdid.ExtKeyTaxCategory: category}), + }}} + } + + t.Run("reads the text back as a tax note, once per category", func(t *testing.T) { + inv := &bill.Invoice{Lines: []*bill.Line{goblLine("E"), goblLine("E"), goblLine("O")}} + importAELineExemptions([]goblubl.InvoiceLine{ + ublLine("E", strPtr(" Exempt supply ")), + ublLine("E", strPtr("Another text")), + ublLine("O", strPtr(" ")), + }, inv) + require.Len(t, inv.Tax.Notes, 1) + assert.Equal(t, "Exempt supply", inv.Tax.Notes[0].Text) + assert.Equal(t, cbc.Code("E"), inv.Tax.Notes[0].Ext.Get(untdid.ExtKeyTaxCategory)) + }) +} + +func TestExportAELines(t *testing.T) { + t.Run("lines without an item, price or total are left alone", func(t *testing.T) { + lines := []goblubl.InvoiceLine{{}} + exportAELines(lines, &bill.Invoice{Currency: currency.AED, Lines: []*bill.Line{{}}}) + assert.Equal(t, goblubl.InvoiceLine{}, lines[0]) + }) +} + +func TestExportAEExchangeRate(t *testing.T) { + t.Run("invoices without a rate to AED are left to the PINT addon", func(t *testing.T) { + out := new(goblubl.Invoice) + exportAEExchangeRate(out, &bill.Invoice{ + Currency: currency.USD, + ExchangeRates: []*currency.ExchangeRate{{From: currency.USD, To: currency.EUR, Amount: num.MakeAmount(92, 2)}}, + }) + assert.Nil(t, out.TaxExchangeRate) + assert.Empty(t, out.AdditionalDocumentReference) + }) +} + +func TestExportAECreditTransfer(t *testing.T) { + t.Run("writes the branch address on a new branch", func(t *testing.T) { + acc := &goblubl.FinancialAccount{ID: strPtr("AE070331234567890123456")} + exportAECreditTransfer(acc, &pay.CreditTransfer{ + IBAN: "AE070331234567890123456", + Branch: &org.Address{Street: "Baniyas Road", Locality: "Dubai", Region: "DXB", Country: "AE"}, + }) + require.NotNil(t, acc.FinancialInstitutionBranch) + require.NotNil(t, acc.FinancialInstitutionBranch.Address) + assert.Equal(t, "Dubai", *acc.FinancialInstitutionBranch.Address.CityName) + }) +} + +func TestImportAEChargeExemptions(t *testing.T) { + t.Run("charges that don't match are skipped", func(t *testing.T) { + exempt := &tax.Combo{Category: tax.CategoryVAT, Key: tax.KeyExempt, Ext: tax.ExtensionsOf(cbc.CodeMap{cef.ExtKeyVATEX: "DL8.46.1"})} + inv := &bill.Invoice{Discounts: []*bill.Discount{{Taxes: tax.Set{exempt}}}} + category := []*goblubl.TaxCategory{{ID: &goblubl.IDType{Value: "E"}, TaxExemptionReasonCode: strPtr("DL8.46.2")}} + in := &goblubl.Invoice{AllowanceCharge: []goblubl.AllowanceCharge{{TaxCategory: category}, {TaxCategory: category}}} + importAEChargeExemptions(in, inv) + assert.Equal(t, cbc.Code("DL8.46.1"), inv.Discounts[0].Taxes[0].Ext.Get(cef.ExtKeyVATEX)) + }) +} + +func TestAEDeliveryPartyID(t *testing.T) { + delivery := func(r *org.Party) *bill.Invoice { + return &bill.Invoice{Delivery: &bill.DeliveryDetails{Receiver: r}} + } + + t.Run("writes the receiver's TIN without a TRN", func(t *testing.T) { + out := new(goblubl.Invoice) + exportAEDeliveryPartyID(out, delivery(&org.Party{ + Identities: []*org.Identity{{Type: ae.IdentityTypeTIN, Code: "1345678906"}}, + })) + require.Len(t, out.Delivery, 1) + require.NotNil(t, out.Delivery[0].DeliveryParty) + require.Len(t, out.Delivery[0].DeliveryParty.PartyIdentification, 1) + assert.Equal(t, "1345678906", out.Delivery[0].DeliveryParty.PartyIdentification[0].ID.Value) + }) + + t.Run("nothing without a receiver", func(t *testing.T) { + out := new(goblubl.Invoice) + exportAEDeliveryPartyID(out, delivery(nil)) + assert.Empty(t, out.Delivery) + }) + + t.Run("reads anything but a TRN as a TIN, on a new receiver", func(t *testing.T) { + in := &goblubl.Invoice{Delivery: []*goblubl.Delivery{{DeliveryParty: identifiedParty("1345678906")}}} + inv := new(bill.Invoice) + importAEDeliveryPartyID(in, inv) + require.NotNil(t, inv.Delivery) + r := inv.Delivery.Receiver + require.NotNil(t, r) + assert.Nil(t, r.TaxID) + require.Len(t, r.Identities, 1) + assert.Equal(t, ae.IdentityTypeTIN, r.Identities[0].Type) + assert.Equal(t, cbc.Code("1345678906"), r.Identities[0].Code) + }) +} diff --git a/ubl/examples_test.go b/ubl/examples_test.go index 6495718..a62033a 100644 --- a/ubl/examples_test.go +++ b/ubl/examples_test.go @@ -33,6 +33,7 @@ var exampleFormats = []struct { }{ {"bis", peppolubl.FormatBIS}, {"pint/aunz", peppolubl.FormatAUNZ}, + {"pint/ae", peppolubl.FormatAE}, {"pint", peppolubl.FormatPINT}, } diff --git a/ubl/testdata/convert/pint/ae/credit-note-ae-margin-scheme.json b/ubl/testdata/convert/pint/ae/credit-note-ae-margin-scheme.json new file mode 100644 index 0000000..d3f8d6f --- /dev/null +++ b/ubl/testdata/convert/pint/ae/credit-note-ae-margin-scheme.json @@ -0,0 +1,193 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "00584c9137b26e2f579e19ada5ee72e101098cbd47ce1dcc94fe1abd1082b157" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "margin-scheme" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "series": "AE", + "code": "MARGIN-CN-001", + "issue_date": "2025-02-10", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-01-30", + "series": "AE", + "code": "MARGIN-001" + } + ], + "tax": { + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00100000", + "untdid-document-type": "381" + }, + "notes": [ + { + "cat": "VAT", + "key": "margin-scheme", + "text": "VAT charged under the Profit Margin Scheme", + "ext": { + "untdid-tax-category": "N" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "key": "goods", + "name": "Second-hand watch", + "identities": [ + { + "label": "HS", + "code": "9102" + } + ], + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1000.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/credit-note-ae-outside-scope.json b/ubl/testdata/convert/pint/ae/credit-note-ae-outside-scope.json new file mode 100644 index 0000000..45f90fc --- /dev/null +++ b/ubl/testdata/convert/pint/ae/credit-note-ae-outside-scope.json @@ -0,0 +1,166 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "27a62f83d1631d564c74d24bd2573a6c73b1747ce8d0edea27e06df3f5c3f0a8" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "series": "AE", + "code": "CN-OS-001", + "issue_date": "2025-01-30", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-01-30", + "code": "AE-001" + } + ], + "tax": { + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "81" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/credit-note-ae-self-billed.json b/ubl/testdata/convert/pint/ae/credit-note-ae-self-billed.json new file mode 100644 index 0000000..b3202da --- /dev/null +++ b/ubl/testdata/convert/pint/ae/credit-note-ae-self-billed.json @@ -0,0 +1,168 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "3ce961ffec96d1ff9a093023168d48f5de4e2aa71fd35c6a61781587ad2f4160" + }, + "from": "iso6523-actorid-upis::0235:1345678906", + "to": "iso6523-actorid-upis::0235:1357902467" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "self-billed" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "series": "AE", + "code": "SB-CN-001", + "issue_date": "2025-01-30", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-01-30", + "code": "AE-001" + } + ], + "tax": { + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "261" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/credit-note-ae-volume-discount.json b/ubl/testdata/convert/pint/ae/credit-note-ae-volume-discount.json new file mode 100644 index 0000000..153bc02 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/credit-note-ae-volume-discount.json @@ -0,0 +1,159 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "f36963d07094d11b804e2de64955e93fcc9a6d5f1c97f265c2eb81c68aa7bc03" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "series": "AE", + "code": "CN-VD-001", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-credit-note-reason": "VD", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "381" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/credit-note-ae.json b/ubl/testdata/convert/pint/ae/credit-note-ae.json new file mode 100644 index 0000000..231f478 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/credit-note-ae.json @@ -0,0 +1,165 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "fa1ceef1d3dc511b27fd1718c626267c984915ffecc5f6e1826ed7a9c3452b95" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "series": "AE", + "code": "CN-001", + "issue_date": "2025-01-30", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-01-30", + "code": "AE-001" + } + ], + "tax": { + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "381" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-continuous-supply.json b/ubl/testdata/convert/pint/ae/invoice-ae-continuous-supply.json new file mode 100644 index 0000000..7564aa4 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-continuous-supply.json @@ -0,0 +1,181 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "c62d8f786fcc7b8d72ab8cd08b2623254b52db6184210d72ef731f68daad304f" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "continuous-supply" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "005", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00001000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "ordering": { + "period": { + "start": "2025-01-01", + "end": "2025-01-21" + } + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + }, + "notes": [ + { + "text": "Billed every 3 weeks" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-deemed-supply.json b/ubl/testdata/convert/pint/ae/invoice-ae-deemed-supply.json new file mode 100644 index 0000000..69f4cf6 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-deemed-supply.json @@ -0,0 +1,152 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "7ddabf80535664ff17da422ad80225ed31987ab147a1b452280149eaa394278e" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:9900000097" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "deemed-supply" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "004", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "01000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:9900000097" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "notes": "Deemed supply, no consideration due" + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-exempt.json b/ubl/testdata/convert/pint/ae/invoice-ae-exempt.json new file mode 100644 index 0000000..eb78d68 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-exempt.json @@ -0,0 +1,278 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "b2690fac7335f0a0f929d514770946f99cc3f2183ba7d5ce3d2ca023df13e0d0" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "003", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + }, + "notes": [ + { + "cat": "VAT", + "key": "exempt", + "text": "Exempt supplies under Article 46 of the VAT Decree-Law", + "ext": { + "untdid-tax-category": "E" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + }, + { + "i": 2, + "quantity": "1", + "item": { + "name": "Financial service", + "description": "Margin-free financial service", + "price": "200.00", + "unit": "one" + }, + "sum": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.1", + "untdid-tax-category": "E" + } + } + ], + "total": "200.00" + }, + { + "i": 3, + "quantity": "1", + "item": { + "name": "Residential rent", + "description": "Residential building lease", + "price": "300.00", + "unit": "one" + }, + "sum": "300.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.2", + "untdid-tax-category": "E" + } + } + ], + "total": "300.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Loyalty discount", + "amount": "20.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.1", + "untdid-tax-category": "E" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Delivery", + "amount": "30.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ] + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1561.50", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1500.00", + "discount": "20.00", + "charge": "30.00", + "total": "1510.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1030.00", + "percent": "5%", + "amount": "51.50" + }, + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.1", + "untdid-tax-category": "E" + }, + "base": "180.00", + "amount": "0.00" + }, + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.2", + "untdid-tax-category": "E" + }, + "base": "300.00", + "amount": "0.00" + } + ], + "amount": "51.50" + } + ], + "sum": "51.50" + }, + "tax": "51.50", + "total_with_tax": "1561.50", + "payable": "1561.50" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-export-summary.json b/ubl/testdata/convert/pint/ae/invoice-ae-export-summary.json new file mode 100644 index 0000000..7afc822 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-export-summary.json @@ -0,0 +1,195 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "fe8ab4f6a3d8de93ccb4e71fd3606138f133b8b38277f2ae19b15a41d69e2817" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "export", + "summary", + "e-commerce" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "003", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00010011", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "1000.00" + } + ], + "ordering": { + "period": { + "start": "2025-01-01", + "end": "2025-01-31" + } + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1000.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "delivery": { + "receiver": { + "name": "Buyer Warehouse", + "addresses": [ + { + "street": "Baker Street 221B", + "locality": "London", + "region": "Greater London", + "code": "NW1 6XE", + "country": "GB" + } + ] + }, + "ext": { + "icc-incoterms-2020": "CIF" + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "1000.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-free-trade-zone-agent.json b/ubl/testdata/convert/pint/ae/invoice-ae-free-trade-zone-agent.json new file mode 100644 index 0000000..b7775cd --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-free-trade-zone-agent.json @@ -0,0 +1,173 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "3adb895a945f2fdb132df86dae69957935674e3d70f66eb6846783f0a221b8bc" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "free-trade-zone", + "disclosed-agent" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "002", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-beneficiary-id": "189098765401003", + "peppol-pint-ae-principal-id": "155667745601003", + "peppol-pint-ae-transaction-type": "10000100", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-margin-scheme.json b/ubl/testdata/convert/pint/ae/invoice-ae-margin-scheme.json new file mode 100644 index 0000000..35e27e7 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-margin-scheme.json @@ -0,0 +1,185 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "e752ebb4294935c9d960e0f34bd0991f6557054c78584f6232c28aacaf9fd783" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "margin-scheme" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "MARGIN-001", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00100000", + "untdid-document-type": "380" + }, + "notes": [ + { + "cat": "VAT", + "key": "margin-scheme", + "text": "VAT charged under the Profit Margin Scheme", + "ext": { + "untdid-tax-category": "N" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "key": "goods", + "name": "Second-hand watch", + "identities": [ + { + "label": "HS", + "code": "9102" + } + ], + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1000.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-outside-scope.json b/ubl/testdata/convert/pint/ae/invoice-ae-outside-scope.json new file mode 100644 index 0000000..3ca496b --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-outside-scope.json @@ -0,0 +1,168 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "5a86a501ea11880882458513af95e640102bbca324bf859ad111529dc95f07f4" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "005", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1000.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge-allowance.json b/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge-allowance.json new file mode 100644 index 0000000..1fc3ac5 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge-allowance.json @@ -0,0 +1,210 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "f326588689945ac91791b0f06751fbd53575269d80153e6240f900d4a601f103" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "004", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "identities": [ + { + "code": "4006381333931", + "ext": { + "iso-scheme-id": "0160" + } + } + ], + "description": "Item Description", + "price": "10.00", + "unit": "one", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.8.1" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "1000.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Volume discount", + "amount": "50.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ] + } + ], + "charges": [ + { + "i": 1, + "reason": "Handling", + "amount": "25.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ] + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "975.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "discount": "50.00", + "charge": "25.00", + "total": "975.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "975.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "975.00", + "payable": "975.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge.json b/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge.json new file mode 100644 index 0000000..0e61641 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-reverse-charge.json @@ -0,0 +1,181 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "bac2c8d74e5afa7a689c1e76f0171d3ebef9b399c9413c84ad4df3005b99bcfa" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "002", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "2709" + }, + { + "code": "4006381333931", + "ext": { + "iso-scheme-id": "0160" + } + } + ], + "description": "Item Description", + "price": "10.00", + "unit": "one", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1000.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-self-billed.json b/ubl/testdata/convert/pint/ae/invoice-ae-self-billed.json new file mode 100644 index 0000000..49cb6a6 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-self-billed.json @@ -0,0 +1,170 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "372f4f2209fca02e9f663e61f5bb38a3c8bce0d6bfbf1c9252131362863fe4ef" + }, + "from": "iso6523-actorid-upis::0235:1345678906", + "to": "iso6523-actorid-upis::0235:1357902467" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "self-billed" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "SB-001", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "389" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-shared-fields.json b/ubl/testdata/convert/pint/ae/invoice-ae-shared-fields.json new file mode 100644 index 0000000..ef0fc60 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-shared-fields.json @@ -0,0 +1,330 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "b14834d8d3931ec9c554408a2f4fe3839b37158ebc0d2725abd6eac142e4f5ea" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "e-commerce" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "SF-001", + "issue_date": "2025-01-30", + "issue_time": "17:31:00", + "value_date": "2025-01-28", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000010", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "street_extra": "Trade Centre", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + }, + { + "type": "TIN", + "code": "1345678906" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "street_extra": "Al Bateen", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Office Chair", + "description": "Ergonomic office chair", + "price": "200.00", + "unit": "one" + }, + "sum": "2000.00", + "discounts": [ + { + "reason": "Loyalty discount", + "percent": "10%", + "amount": "200.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Assembly", + "percent": "5%", + "amount": "100.00", + "ext": { + "untdid-charge": "ABL" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1900.00", + "notes": [ + { + "key": "general", + "text": "Delivered in two batches.", + "ext": { + "untdid-text-subject": "AAI" + } + } + ] + }, + { + "i": 2, + "quantity": "4", + "item": { + "name": "Desk Lamp", + "description": "LED desk lamp", + "price": "50.00", + "unit": "one" + }, + "sum": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "200.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Early order discount", + "base": "2100.00", + "percent": "2%", + "amount": "42.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Handling", + "base": "2100.00", + "percent": "1%", + "amount": "21.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "ABL" + } + } + ], + "ordering": { + "seller": { + "name": "Tax Representative LLC", + "tax_id": { + "country": "AE", + "code": "124681357800003" + }, + "addresses": [ + { + "street": "Al Maktoum Road", + "street_extra": "Deira", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + } + }, + "payment": { + "payee": { + "name": "Payee Collections LLC", + "identities": [ + { + "scope": "legal", + "code": "112345679100002" + } + ] + }, + "terms": { + "due_dates": [ + { + "date": "2025-02-28", + "amount": "2182.95", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Payee Collections LLC" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "delivery": { + "receiver": { + "name": "Buyer Warehouse", + "tax_id": { + "country": "AE", + "code": "155667745601003" + }, + "addresses": [ + { + "street": "Industrial Area 4", + "street_extra": "Musaffah", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "date": "2025-01-27" + }, + "totals": { + "sum": "2100.00", + "discount": "42.00", + "charge": "21.00", + "total": "2079.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "2079.00", + "percent": "5%", + "amount": "103.95" + } + ], + "amount": "103.95" + } + ], + "sum": "103.95" + }, + "tax": "103.95", + "total_with_tax": "2182.95", + "payable": "2182.95" + }, + "notes": [ + { + "key": "general", + "text": "Goods remain the property of the seller until paid in full.", + "ext": { + "untdid-text-subject": "AAI" + } + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-tin-passport.json b/ubl/testdata/convert/pint/ae/invoice-ae-tin-passport.json new file mode 100644 index 0000000..df3f1f4 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-tin-passport.json @@ -0,0 +1,167 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "7508525c45d0ef33f1e4bac693d7dfa3c5fce959cbab9c9277ea87ace10f66a0" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "AE-TIN-PAS-01", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "tax", + "type": "TIN", + "code": "1234567897" + }, + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "country": "IN", + "key": "passport", + "code": "P1234567890" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae-usd.json b/ubl/testdata/convert/pint/ae/invoice-ae-usd.json new file mode 100644 index 0000000..2339cba --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae-usd.json @@ -0,0 +1,306 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "6f2ebc6db3e9e054a4ada49b60eecf64275d2395c63e2903f8747bb67d8a72c7" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "006", + "issue_date": "2025-01-30", + "currency": "USD", + "exchange_rates": [ + { + "from": "USD", + "to": "AED", + "amount": "3.67285" + } + ], + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "key": "goods-services", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "8471" + }, + { + "label": "SAC", + "code": "998713" + } + ], + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + }, + { + "i": 2, + "quantity": "2", + "item": { + "key": "goods", + "name": "Export goods", + "identities": [ + { + "label": "HS", + "code": "8471" + } + ], + "description": "Zero rated supply", + "price": "250.00", + "unit": "one" + }, + "sum": "500.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "500.00" + }, + { + "i": 3, + "quantity": "1", + "item": { + "key": "services", + "name": "Financial service", + "identities": [ + { + "label": "SAC", + "code": "997113" + } + ], + "description": "Exempt supply", + "price": "120.00", + "unit": "one" + }, + "sum": "120.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.3", + "untdid-tax-category": "E" + } + } + ], + "total": "120.00" + }, + { + "i": 4, + "quantity": "3", + "item": { + "key": "goods", + "name": "Electronic devices", + "identities": [ + { + "label": "HS", + "code": "8517" + }, + { + "code": "4006381333931", + "ext": { + "iso-scheme-id": "0160" + } + } + ], + "description": "Reverse charge supply", + "price": "33.33", + "unit": "one", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.8.2" + } + }, + "sum": "99.99", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "99.99" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1769.99", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "name": "Emirates NBD" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1719.99", + "total": "1719.99", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + }, + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "500.00", + "percent": "0%", + "amount": "0.00" + }, + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.3", + "untdid-tax-category": "E" + }, + "base": "120.00", + "amount": "0.00" + }, + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "99.99", + "amount": "0.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1769.99", + "payable": "1769.99" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/invoice-ae.json b/ubl/testdata/convert/pint/ae/invoice-ae.json new file mode 100644 index 0000000..20b6d00 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/invoice-ae.json @@ -0,0 +1,188 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "f8a6c4f1aa1a55b796e919a076c07452d3ceddae5d374d863b998e1ad48cdd6a" + }, + "from": "iso6523-actorid-upis::0235:1357902467", + "to": "iso6523-actorid-upis::0235:1345678906" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "series": "AE", + "code": "001", + "issue_date": "2025-01-30", + "issue_time": "17:31:00", + "currency": "AED", + "tax": { + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246700003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "type": "TIN", + "code": "1357902467" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902467" + } + ], + "addresses": [ + { + "street": "Sheikh Zayed Road", + "street_extra": "Trade Centre", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890600003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678906" + } + ], + "addresses": [ + { + "street": "Corniche Road", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "cost": "CS-024", + "item": { + "name": "Item Name", + "description": "Item Description", + "price": "10.00", + "unit": "one" + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "ordering": { + "contracts": [ + { + "code": "CT-2025-014", + "description": "AED 200000" + } + ] + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "credit-transfer", + "ref": "INV-REM-0042", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "EBILAEAD", + "name": "Emirates NBD", + "branch": { + "street": "Baniyas Road", + "street_extra": "Deira", + "locality": "Dubai", + "region": "DXB", + "code": "777", + "country": "AE" + } + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/credit-note-ae-margin-scheme.xml b/ubl/testdata/convert/pint/ae/out/credit-note-ae-margin-scheme.xml new file mode 100644 index 0000000..aa01b8a --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/credit-note-ae-margin-scheme.xml @@ -0,0 +1,147 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00100000 + AE-MARGIN-CN-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-02-10 + 381 + AED + + DL8.61.1.E + + + NA + + + + AE-MARGIN-001 + 2025-01-30 + + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + 2025-02-06 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + N + 5 + VAT charged under the Profit Margin Scheme + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Second-hand watch + + G + 9102 + + + N + 5 + VAT charged under the Profit Margin Scheme + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/credit-note-ae-outside-scope.xml b/ubl/testdata/convert/pint/ae/out/credit-note-ae-outside-scope.xml new file mode 100644 index 0000000..7223372 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/credit-note-ae-outside-scope.xml @@ -0,0 +1,138 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CN-OS-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 81 + AED + + DL8.61.1.E + + + NA + + + + AE-001 + 2025-01-30 + + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + O + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + O + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/credit-note-ae-self-billed.xml b/ubl/testdata/convert/pint/ae/out/credit-note-ae-self-billed.xml new file mode 100644 index 0000000..288f397 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/credit-note-ae-self-billed.xml @@ -0,0 +1,140 @@ + + + urn:peppol:pint:selfbilling-1@ae-1 + urn:peppol:bis:selfbilling + 00000000 + AE-SB-CN-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 261 + AED + + DL8.61.1.E + + + NA + + + + AE-001 + 2025-01-30 + + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/credit-note-ae-volume-discount.xml b/ubl/testdata/convert/pint/ae/out/credit-note-ae-volume-discount.xml new file mode 100644 index 0000000..c4468cf --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/credit-note-ae-volume-discount.xml @@ -0,0 +1,134 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CN-VD-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 381 + AED + + VD + + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/credit-note-ae.xml b/ubl/testdata/convert/pint/ae/out/credit-note-ae.xml new file mode 100644 index 0000000..8dfc2c8 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/credit-note-ae.xml @@ -0,0 +1,140 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CN-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 381 + AED + + DL8.61.1.E + + + NA + + + + AE-001 + 2025-01-30 + + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-continuous-supply.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-continuous-supply.xml new file mode 100644 index 0000000..ae03699 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-continuous-supply.xml @@ -0,0 +1,137 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00001000 + AE-005 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + Billed every 3 weeks + AED + + 2025-01-01 + 2025-01-21 + + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-deemed-supply.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-deemed-supply.xml new file mode 100644 index 0000000..b5e1465 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-deemed-supply.xml @@ -0,0 +1,127 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 01000000 + AE-004 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 9900000097 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + Deemed supply, no consideration due + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-exempt.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-exempt.xml new file mode 100644 index 0000000..961ae56 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-exempt.xml @@ -0,0 +1,230 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-003 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + true + Delivery + 30.00 + + S + 5 + + VAT + + + + + false + 95 + Loyalty discount + 20.00 + + E + 0 + DL8.46.1 + Exempt supplies under Article 46 of the VAT Decree-Law + + VAT + + + + + 51.50 + false + + 1030.00 + 51.50 + + S + 5 + + VAT + + + + + 480.00 + 0.00 + + E + Exempt supplies under Article 46 of the VAT Decree-Law + + VAT + + + + + + 1500.00 + 1510.00 + 1561.50 + 20.00 + 30.00 + 1561.50 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + + 2 + 1 + 200.00 + + Margin-free financial service + Financial service + + E + DL8.46.1 + Exempt supplies under Article 46 of the VAT Decree-Law + + VAT + + + + + 200.00 + 1 + + false + 0.00 + 200.00 + + + + 200.00 + + + + 3 + 1 + 300.00 + + Residential building lease + Residential rent + + E + DL8.46.2 + Exempt supplies under Article 46 of the VAT Decree-Law + + VAT + + + + + 300.00 + 1 + + false + 0.00 + 300.00 + + + + 300.00 + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-export-summary.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-export-summary.xml new file mode 100644 index 0000000..f00ab55 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-export-summary.xml @@ -0,0 +1,160 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00010011 + AE-003 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + 2025-01-01 + 2025-01-31 + + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + + + Baker Street 221B + London + NW1 6XE + Greater London + + GB + + + + + + Buyer Warehouse + + + Buyer Warehouse + + + + CIF + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + Z + 0 + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + Z + 0 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-free-trade-zone-agent.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-free-trade-zone-agent.xml new file mode 100644 index 0000000..a57411b --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-free-trade-zone-agent.xml @@ -0,0 +1,146 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 10000100 + AE-002 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + + + 189098765401003 + + + + + + + 155667745601003 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-margin-scheme.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-margin-scheme.xml new file mode 100644 index 0000000..d4f2c0c --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-margin-scheme.xml @@ -0,0 +1,138 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00100000 + AE-MARGIN-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + N + 5 + VAT charged under the Profit Margin Scheme + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Second-hand watch + + G + 9102 + + + N + 5 + VAT charged under the Profit Margin Scheme + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-outside-scope.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-outside-scope.xml new file mode 100644 index 0000000..5da7023 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-outside-scope.xml @@ -0,0 +1,130 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-005 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 480 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + O + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + O + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge-allowance.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge-allowance.xml new file mode 100644 index 0000000..012f90f --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge-allowance.xml @@ -0,0 +1,164 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-004 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + true + Handling + 25.00 + + AE + 5 + + VAT + + + + + false + Volume discount + 50.00 + + AE + 5 + + VAT + + + + + 0.00 + false + + 975.00 + 0.00 + + AE + 5 + + VAT + + + + + + 1000.00 + 975.00 + 975.00 + 50.00 + 25.00 + 975.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + 4006381333931 + + + DL8.48.8.1 + + + AE + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge.xml new file mode 100644 index 0000000..856082f --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-reverse-charge.xml @@ -0,0 +1,140 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-002 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 0.00 + false + + 1000.00 + 0.00 + + AE + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1000.00 + 1000.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + 4006381333931 + + + DL8.48.3.1 + G + 2709 + + + AE + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1000.00 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-self-billed.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-self-billed.xml new file mode 100644 index 0000000..cf1ac3a --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-self-billed.xml @@ -0,0 +1,132 @@ + + + urn:peppol:pint:selfbilling-1@ae-1 + urn:peppol:bis:selfbilling + 00000000 + AE-SB-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 389 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-shared-fields.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-shared-fields.xml new file mode 100644 index 0000000..7328af5 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-shared-fields.xml @@ -0,0 +1,276 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000010 + AE-SF-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 17:31:00 + 2025-02-28 + 380 + #AAI#Goods remain the property of the seller until paid in full. + 2025-01-28 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Trade Centre + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + 1345678906 + + + Buyer Legal Name + + + Corniche Road + Al Bateen + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + + Payee Collections LLC + + + 112345679100002 + + + + + Tax Representative LLC + + + Al Maktoum Road + Deira + Dubai + DXB + + AE + + + + 124681357800003 + + VAT + + + + Tax Representative LLC + + + + 2025-01-27 + + + Industrial Area 4 + Musaffah + Abu Dhabi + AUH + + AE + + + + + + 155667745601003 + + + Buyer Warehouse + + + Buyer Warehouse + + + + + 30 + + AE070331234567890123456 + Payee Collections LLC + + + + true + ABL + Handling + 1 + 21.00 + 2100.00 + + S + 5 + + VAT + + + + + false + 95 + Early order discount + 2 + 42.00 + 2100.00 + + S + 5 + + VAT + + + + + 103.95 + false + + 2079.00 + 103.95 + + S + 5 + + VAT + + + + + + 2100.00 + 2079.00 + 2182.95 + 42.00 + 21.00 + 2182.95 + + + 1 + #AAI#Delivered in two batches. + 10 + 1900.00 + + true + ABL + Assembly + 5 + 100.00 + 2000.00 + + + false + 95 + Loyalty discount + 10 + 200.00 + 2000.00 + + + Ergonomic office chair + Office Chair + + S + 5 + + VAT + + + + + 200.00 + 1 + + false + 0.00 + 200.00 + + + + 1995.00 + + 95.00 + + + + + 2 + 4 + 200.00 + + LED desk lamp + Desk Lamp + + S + 5 + + VAT + + + + + 50.00 + 1 + + false + 0.00 + 50.00 + + + + 210.00 + + 10.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-tin-passport.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-tin-passport.xml new file mode 100644 index 0000000..4d60928 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-tin-passport.xml @@ -0,0 +1,132 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-AE-TIN-PAS-01 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + AED + + NA + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1234567897 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + P1234567890 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae-usd.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae-usd.xml new file mode 100644 index 0000000..0e10400 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae-usd.xml @@ -0,0 +1,294 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-006 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 2025-02-06 + 380 + USD + AED + + NA + + + AED + aedtotal-incl-vat + 6500.91 + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + + AE070331234567890123456 + Emirates NBD + + + + USD + AED + 3.67285 + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + 500.00 + 0.00 + + Z + 0 + + VAT + + + + + 120.00 + 0.00 + + E + DL8.46.3 + + VAT + + + + + 99.99 + 0.00 + + AE + 5 + + VAT + + + + + + 183.64 + + + 1719.99 + 1719.99 + 1769.99 + 1769.99 + + + 1 + 100 + 1000.00 + + Item Description + Item Name + + 998713 + + + B + 8471 + + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 3856.49 + + 183.64 + + + + + 2 + 2 + 500.00 + + Zero rated supply + Export goods + + G + 8471 + + + Z + 0 + + VAT + + + + + 250.00 + 1 + + false + 0.00 + 250.00 + + + + 1836.43 + + 0.00 + + + + + 3 + 1 + 120.00 + + Exempt supply + Financial service + + 997113 + + + S + + + E + DL8.46.3 + + VAT + + + + + 120.00 + 1 + + false + 0.00 + 120.00 + + + + 440.74 + + + + 4 + 3 + 99.99 + + Reverse charge supply + Electronic devices + + 4006381333931 + + + DL8.48.8.2 + G + 8517 + + + AE + 5 + + VAT + + + + + 33.33 + 1 + + false + 0.00 + 33.33 + + + + 367.25 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/convert/pint/ae/out/invoice-ae.xml b/ubl/testdata/convert/pint/ae/out/invoice-ae.xml new file mode 100644 index 0000000..793eb39 --- /dev/null +++ b/ubl/testdata/convert/pint/ae/out/invoice-ae.xml @@ -0,0 +1,153 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-001 + 0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2 + 2025-01-30 + 17:31:00 + 2025-02-06 + 380 + AED + + NA + + + CT-2025-014 + AED 200000 + + + + 1357902467 + + Supplier Legal Name + + + Sheikh Zayed Road + Trade Centre + Dubai + DXB + + AE + + + + 135790246700003 + + VAT + + + + 1357902467 + + TIN + + + + Supplier Legal Name + 112345678900003 + + + + + + 1345678906 + + Buyer Legal Name + + + Corniche Road + Abu Dhabi + AUH + + AE + + + + 134567890600003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 30 + INV-REM-0042 + + AE070331234567890123456 + Emirates NBD + + EBILAEAD + + Baniyas Road + Deira + Dubai + 777 + DXB + + AE + + + + + + + 50.00 + false + + 1000.00 + 50.00 + + S + 5 + + VAT + + + + + + 1000.00 + 1000.00 + 1050.00 + 1050.00 + + + 1 + 100 + 1000.00 + CS-024 + + Item Description + Item Name + + S + 5 + + VAT + + + + + 10.00 + 1 + + false + 0.00 + 10.00 + + + + 1050.00 + + 50.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/allowance-exempt.xml b/ubl/testdata/parse/pint/ae/allowance-exempt.xml new file mode 100644 index 0000000..64ca77d --- /dev/null +++ b/ubl/testdata/parse/pint/ae/allowance-exempt.xml @@ -0,0 +1,156 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-ALLOW-E-01 + a1b2c3d4-e5f6-7890-abcd-300000000003 + 2025-03-15 + 2025-03-30 + 480 + Exempt supply invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + false + 100 + Special Rebate + 100 + + E + 0 + DL8.46.4 + + VAT + + + + + 0 + false + + 900 + 0 + + E + + VAT + + + + + + 1000 + 900 + 900 + 100 + 900 + + + 1 + 10 + 1000 + + Local passenger transport services exempt from VAT + Local Passenger Transport + + E + DL8.46.4 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/allowance-outside-scope.xml b/ubl/testdata/parse/pint/ae/allowance-outside-scope.xml new file mode 100644 index 0000000..cf32dca --- /dev/null +++ b/ubl/testdata/parse/pint/ae/allowance-outside-scope.xml @@ -0,0 +1,156 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-ALLOW-O-01 + a1b2c3d4-e5f6-7890-abcd-500000000005 + 2025-03-15 + 2025-03-30 + 480 + Not subject to VAT invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + false + 95 + Discount + 100 + + O + + VAT + + + + + 0 + false + + 900 + 0 + + O + + VAT + + + + + + 1000 + 900 + 900 + 100 + 900 + + + 1 + 10 + 1000 + + Services not subject to VAT + Out of Scope Services + + O + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/allowance-reverse-charge.xml b/ubl/testdata/parse/pint/ae/allowance-reverse-charge.xml new file mode 100644 index 0000000..373ba0b --- /dev/null +++ b/ubl/testdata/parse/pint/ae/allowance-reverse-charge.xml @@ -0,0 +1,165 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-ALLOW-AE-01 + a1b2c3d4-e5f6-7890-abcd-100000000001 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + false + 95 + Discount + 100 + + AE + 5 + + VAT + + + + + 0 + false + + 900 + 0 + + AE + 5 + + VAT + + + + + + 1000 + 900 + 900 + 100 + 900 + + + 1 + 10 + 1000 + + Consulting services subject to reverse charge + Consulting Services + + 9876543210 + + + DL8.48.3.1 + + + AE + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/allowance-zero-rated.xml b/ubl/testdata/parse/pint/ae/allowance-zero-rated.xml new file mode 100644 index 0000000..1d61d26 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/allowance-zero-rated.xml @@ -0,0 +1,159 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-ALLOW-Z-01 + a1b2c3d4-e5f6-7890-abcd-700000000007 + 2025-03-15 + 2025-03-30 + 380 + Zero rated supply invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + false + 95 + Discount + 100 + + Z + 0 + + VAT + + + + + 0 + false + + 900 + 0 + + Z + 0 + + VAT + + + + + + 1000 + 900 + 900 + 100 + 900 + + + 1 + 10 + 1000 + + Zero rated goods for export + Zero Rated Goods + + Z + 0 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/buyer-pas-identifier.xml b/ubl/testdata/parse/pint/ae/buyer-pas-identifier.xml new file mode 100644 index 0000000..867e1c5 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/buyer-pas-identifier.xml @@ -0,0 +1,145 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-BUYER-PAS-01 + a1b2c3d4-e5f6-7890-abcd-900000000009 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + P1234567890 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + 50 + false + + 1000 + 50 + + S + 5 + + VAT + + + + + + 1000 + 1000 + 1050 + 1050 + + + 1 + 10 + 1000 + + Standard rated goods + Electronic Components + + S + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1050 + + 50 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/charge-exempt.xml b/ubl/testdata/parse/pint/ae/charge-exempt.xml new file mode 100644 index 0000000..9a6e7f1 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/charge-exempt.xml @@ -0,0 +1,156 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CHARGE-E-01 + a1b2c3d4-e5f6-7890-abcd-400000000004 + 2025-03-15 + 2025-03-30 + 480 + Exempt supply invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + true + AAT + Handling fee + 200 + + E + 0 + DL8.46.4 + + VAT + + + + + 0 + false + + 1200 + 0 + + E + + VAT + + + + + + 1000 + 1200 + 1200 + 200 + 1200 + + + 1 + 10 + 1000 + + Local passenger transport services exempt from VAT + Local Passenger Transport + + E + DL8.46.4 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/charge-outside-scope.xml b/ubl/testdata/parse/pint/ae/charge-outside-scope.xml new file mode 100644 index 0000000..a2f102a --- /dev/null +++ b/ubl/testdata/parse/pint/ae/charge-outside-scope.xml @@ -0,0 +1,156 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CHARGE-O-01 + a1b2c3d4-e5f6-7890-abcd-600000000006 + 2025-03-15 + 2025-03-30 + 480 + Not subject to VAT invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + true + AAT + Handling fee + 200 + + O + + VAT + + + + + 0 + false + + 1200 + 0 + + O + + VAT + + + + + + 1000 + 1200 + 1200 + 200 + 1200 + + + 1 + 10 + 1000 + + Services not subject to VAT + Out of Scope Services + + O + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0.00 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/charge-reverse-charge.xml b/ubl/testdata/parse/pint/ae/charge-reverse-charge.xml new file mode 100644 index 0000000..29e9d42 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/charge-reverse-charge.xml @@ -0,0 +1,165 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CHARGE-AE-01 + a1b2c3d4-e5f6-7890-abcd-200000000002 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + true + AAT + Rush Delivery + 200 + + AE + 5 + + VAT + + + + + 0 + false + + 1200 + 0 + + AE + 5 + + VAT + + + + + + 1000 + 1200 + 1200 + 200 + 1200 + + + 1 + 10 + 1000 + + Consulting services subject to reverse charge + Consulting Services + + 9876543210 + + + DL8.48.3.1 + + + AE + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/charge-zero-rated.xml b/ubl/testdata/parse/pint/ae/charge-zero-rated.xml new file mode 100644 index 0000000..ffb0c3c --- /dev/null +++ b/ubl/testdata/parse/pint/ae/charge-zero-rated.xml @@ -0,0 +1,159 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CHARGE-Z-01 + a1b2c3d4-e5f6-7890-abcd-800000000008 + 2025-03-15 + 2025-03-30 + 380 + Zero rated supply invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + true + AAT + Rush Delivery + 200 + + Z + 0 + + VAT + + + + + 0 + false + + 1200 + 0 + + Z + 0 + + VAT + + + + + + 1000 + 1200 + 1200 + 200 + 1200 + + + 1 + 10 + 1000 + + Zero rated goods for export + Zero Rated Goods + + Z + 0 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/commercial-invoice.xml b/ubl/testdata/parse/pint/ae/commercial-invoice.xml new file mode 100644 index 0000000..b642330 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/commercial-invoice.xml @@ -0,0 +1,140 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-CI-001Test + 19e2c9a3-b000-4fb0-9bd5-a9c4ebda2358 + 2025-02-07 + 17:38:00+04:00 + 2025-02-07 + 480 + AED + + + 1987654321 + + Seller Trade Name + + + Street Name + Sharjah + SHJ + + AE + + + + 198765432112303 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email address + + + + + + 1345678901 + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email Address + + + + + + Payee Ltd. + + + CN12389045678121 + + + + 10 + + + Cash payment + + + 0 + false + + 150000 + 0 + + O + + VAT + + + + + + 150000 + 150000 + 150000 + 150000 + + + 1 + 1000 + 150000 + + Item Description + Item Name + + O + + VAT + + + + + 150 + 1 + + false + 1 + 151 + + + + 150000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/continuous-supplies.xml b/ubl/testdata/parse/pint/ae/continuous-supplies.xml new file mode 100644 index 0000000..cd30bda --- /dev/null +++ b/ubl/testdata/parse/pint/ae/continuous-supplies.xml @@ -0,0 +1,239 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00001000 + AE-001CS-TEST + 2175fae7-7dc2-4aea-b78b-d358f8863919 + 2025-02-07 + 2025-03-07 + 380 + Tax invoice + 2025-01-30 + AED + + 2025-01-31 + 2025-02-07 + MTH + + + ZXC-CS-03 + AED 1000000 + + + Cabbills + + + https://www.site.ae/cabbills.pdf + + + + + All signed cab bills + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + + 1987654321 + + Supplier Trade Name + + + Street Name + Dubai + DXB + + AE + + + + 132654987101003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email Address + + + + + + 1456789456 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 145678945601003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email Address + + + + + 30 + + AE0000000001 + current account + + 236000 + + + + + 1 month + + + true + ABU + Polyethylene wrap packing + 1.5 + 75 + 5000 + + S + 5 + + VAT + + + + + 253.75 + false + + 5075 + 253.75 + + S + 5 + + VAT + + + + + 727.5 + 0 + + E + + VAT + + + + + + 5727.50 + 5802.5 + 6056.25 + 75 + 0.75 + 6057 + + + 1 + 10 + 5000 + + 2025-01-31 + 2025-02-07 + + + 250 + + + Item Description + Item Name + + G + 23424 + + + S + 5 + + VAT + + + + + 500 + 1 + + false + 0 + 500 + + + + 5250 + + 250 + + + + + 2 + 1455 + 727.5 + + 2025-01-31 + 2025-02-07 + + + Item Description + Item Name + + E + DL8.46.4 + Local passenger transport + + VAT + + + + + 0.5 + 1 + + false + 0 + 0.5 + + + + 727.5 + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/credit-note-disclosed-agent.xml b/ubl/testdata/parse/pint/ae/credit-note-disclosed-agent.xml new file mode 100644 index 0000000..6ac2625 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/credit-note-disclosed-agent.xml @@ -0,0 +1,256 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000100 + AE001-CN-TEST + 9330196c-74e7-4da2-bb72-b290e3b86556 + 2025-02-07 + 15:55:00+04:00 + 381 + Tax Credit invoice + AED + Regular sales + PO-AE-220 + + 2025-01-31 + 2025-02-07 + + + DL8.61.1.E + + + PO-AE-220 + Salesorder-2122 + + + + Sample-02 + 2025-02-07 + + + + Memo-1000 + + + PO-AE-220 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + PO-AE-220 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Sarjah + SHJ + + AE + + + + 198765432102003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email address + + + + + + 1345678901 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email address + + + + + + Payee Party Name + + + 1122334455 + + + + + + 155667745601003 + + + + + Will be adjusted against next invoice + + + false + 100 + Special Rebate + 2.5 + 262.15 + 10486 + + S + 5 + + VAT + + + + + true + AAT + Rush Delivery + 4 + 419.44 + 10486 + + S + 5 + + VAT + + + + + 532.16 + false + + 10643.29 + 532.1645 + + S + 5 + + VAT + + + + + + 10486 + 10643.29 + 11175.45 + 262.15 + 419.44 + 0.05 + 11175.5 + + + 1 + All items + 2000 + 10486 + + 2025-01-31 + 2025-01-31 + + + 1 + + PO-AE-220 + + + + false + 95 + Discount + 3 + 294 + 9800 + + + true + AAC + Technical Modification + 10 + 980 + 9800 + + + Item Description + Item Name + + Buyer Item Identification + + + Seller Item Identification + + + AE + + + G + 11223355 + + + S + 5 + + VAT + + + + Additional Item Property Name + Additional Item Property Value + + + + 4.9 + 1 + + false + 0.1 + 5 + + + + 11010.3 + + 524.3 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/credit-note-standard.xml b/ubl/testdata/parse/pint/ae/credit-note-standard.xml new file mode 100644 index 0000000..fdcfe5b --- /dev/null +++ b/ubl/testdata/parse/pint/ae/credit-note-standard.xml @@ -0,0 +1,249 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE001-CN-TEST + f1c9d83d-e31f-43fc-919f-10b961f599e7 + 2025-02-07 + 15:55:00+04:00 + 381 + Tax Credit invoice + AED + Regular sales + PO-AE-220 + + 2025-01-31 + 2025-02-07 + + + DL8.61.1.E + + + PO-AE-220 + Salesorder-2122 + + + + Sample-02 + 2025-02-07 + + + + Memo-1000 + + + PO-AE-220 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + PO-AE-220 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Sarjah + SHJ + + AE + + + + 198765432102003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email address + + + + + + 1345678901 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email address + + + + + + Payee Party Name + + + 1122334455 + + + + Will be adjusted against next invoice + + + false + 100 + Special Rebate + 2.5 + 262.15 + 10486 + + S + 5 + + VAT + + + + + true + AAT + Rush Delivery + 4 + 419.44 + 10486 + + S + 5 + + VAT + + + + + 532.16 + false + + 10643.29 + 532.1645 + + S + 5 + + VAT + + + + + + 10486 + 10643.29 + 11175.45 + 262.15 + 419.44 + 0.05 + 11175.5 + + + 1 + All items + 2000 + 10486 + + 2025-01-31 + 2025-01-31 + + + 1 + + PO-AE-220 + + + + false + 95 + Discount + 3 + 294 + 9800 + + + true + AAC + Technical Modification + 10 + 980 + 9800 + + + Item Description + Item Name + + Buyer Item Identification + + + Seller Item Identification + + + AE + + + G + 11223355 + + + S + 5 + + VAT + + + + Additional Item Property Name + Additional Item Property Value + + + + 4.9 + 1 + + false + 0.1 + 5 + + + + 11010.3 + + 524.3 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/credit-note-volume-discount.xml b/ubl/testdata/parse/pint/ae/credit-note-volume-discount.xml new file mode 100644 index 0000000..47503ef --- /dev/null +++ b/ubl/testdata/parse/pint/ae/credit-note-volume-discount.xml @@ -0,0 +1,248 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE001-CN-VD + a2b3c4d5-e6f7-8901-abcd-ef1234567890 + 2025-02-07 + 15:55:00+04:00 + 381 + Volume discount credit note - VD reason, no BillingReference required per ibr-055-ae + AED + Regular sales + PO-AE-220 + + 2025-01-31 + 2025-02-07 + + + VD + Volume discount + + + PO-AE-220 + Salesorder-2122 + + + Memo-1000 + + + PO-AE-220 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + PO-AE-220 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Sarjah + SHJ + + AE + + + + 198765432102003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email address + + + + + + 1345678901 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email address + + + + + + Payee Party Name + + + 1122334455 + + + + Will be adjusted against next invoice + + + false + 100 + Special Rebate + 2.5 + 262.15 + 10486 + + S + 5 + + VAT + + + + + true + AAT + Rush Delivery + 4 + 419.44 + 10486 + + S + 5 + + VAT + + + + + 532.16 + false + + 10643.29 + 532.1645 + + S + 5 + + VAT + + + + + + 10486 + 10643.29 + 11175.45 + 262.15 + 419.44 + 0.05 + 11175.5 + + + 1 + All items + 2000 + 10486 + + 2025-01-31 + 2025-01-31 + + + 1 + + PO-AE-220 + + + + VD + Volume discount + + + false + 95 + Discount + 3 + 294 + 9800 + + + true + AAC + Technical Modification + 10 + 980 + 9800 + + + Item Description + Item Name + + Buyer Item Identification + + + Seller Item Identification + + + AE + + + G + 11223355 + + + S + 5 + + VAT + + + + Additional Item Property Name + Additional Item Property Value + + + + 4.9 + 1 + + false + 0.1 + 5 + + + + 11010.3 + + 524.3 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/deemed-supply.xml b/ubl/testdata/parse/pint/ae/deemed-supply.xml new file mode 100644 index 0000000..333189a --- /dev/null +++ b/ubl/testdata/parse/pint/ae/deemed-supply.xml @@ -0,0 +1,182 @@ + + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 01000000 + AE-001DS-Test + 08b06931-4698-4ff9-9862-2ebd2901a00c + 2025-02-07 + 380 + Tax invoice + AED + + Sample-05 + + + https://www.site.ae/Sample-05.pdf + + + + + Sample-05 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + + 1246801357 + + Street Name + Sharjah + SHJ + + AE + + + + 124680135701003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email address + + + + + + 9900000097 + + Street Name + Dubai + DXB + + AE + + + + 178901234501003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email Address + + + + + 1 + + + false + 100 + Special Rebate + 5 + 14 + 280 + + S + 5 + + VAT + + + + + 13.3 + false + + 266 + 13.3 + + S + 5 + + VAT + + + + + + 280 + 266 + 279.3 + 14 + 279.3 + + + 1 + 2 + 280 + + Item Description + Item Name + + Service + + + G + 88098432 + + + S + 5 + + VAT + + + + + + 140 + 1 + + false + 10 + 150 + + + + 294 + + 14 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/disclosed-agent-billing.xml b/ubl/testdata/parse/pint/ae/disclosed-agent-billing.xml new file mode 100644 index 0000000..7a6e941 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/disclosed-agent-billing.xml @@ -0,0 +1,178 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000100 + AE-01DAB-TEST + 01506abf-d824-4548-af5e-539b284b4203 + 2025-02-07 + 15:08:00+04:00 + 2025-02-07 + 380 + Tax invoice + AED + + + 1239874562 + + Street Name + Sharjah + SHJ + + AE + + + + 124680135701003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Telephone Number + Email Address + + + + + + 1456789456 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 145678945601003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact number + email address + + + + + + + 155667745601003 + + + + + 30 + + AE0000000001 + current account + + 236000 + + + + + cash payment + + + false + 100 + Special Rebate + 5 + 49.97 + 999.375 + + S + 5 + + VAT + + + + + 47.47 + false + + 949.405 + 47.47025 + + S + 5 + + VAT + + + + + + 999.38 + 949.41 + 996.88 + 49.97 + 996.88 + + + 1 + Inspect the goods + 50 + 999.375 + + true + AAC + Technical Modification + 2.5 + 24.375 + 975 + + + Item Description + Item Name + + G + 889900 + + + S + 5 + + VAT + + + + + 19.5 + 1 + + false + 0.5 + 20 + + + + 1049.3438 + + 49.9688 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/e-commerce.xml b/ubl/testdata/parse/pint/ae/e-commerce.xml new file mode 100644 index 0000000..3d6baff --- /dev/null +++ b/ubl/testdata/parse/pint/ae/e-commerce.xml @@ -0,0 +1,258 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000010 + AE-001-E-Commerce-TEST + 0401431a-3b05-442e-95bd-2d12c2cb2296 + 2025-02-11 + 11:35:10+04:00 + 2025-02-11 + 380 + Tax invoice + AED + + DR-INV-001 + + + https://www.site.ae/invoices.pdf + + + + + DR-INV-02 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + + 112345678900003 + + Supplier Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address line + + + AE + + + + 112345678900003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Contact Email address + + + + + + 112345679000003 + + Buyer Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address Line + + + AE + + + + 112345679000003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Contact Email address + + + + + + 132345679670003 + + + Payee Party Name + + + 112345679350001 + + + + 2025-02-11 + + 112345679000003 + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Address line 3 + + + AE + + + + + + Delivery Party Name + + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + Instant Payment + + + false + 95 + Discount + 5 + 5 + 100 + + S + 5 + + VAT + + + + + true + AAC + Technical Modification + 2.5 + 2.5 + 100 + + S + 5 + + VAT + + + + + 5 + false + + 100 + 5 + + S + 5 + + VAT + + + + + + 102.5 + 100 + 105 + 5 + 2.5 + 0 + 0 + 105 + + + 1 + Please check the invoice + 1 + 102.5 + + false + 95 + Discount + 2.5 + 2.5 + 100 + + + true + AAC + Technical Modification + 5 + 5 + 100 + + + Item Description + Item Name + + G + 11223355 + + + S + 5 + 100 + + VAT + + + + + 100 + 1 + + false + 1 + 101 + + + + 107.625 + + 5.125 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/exports-predefined-endpoint.xml b/ubl/testdata/parse/pint/ae/exports-predefined-endpoint.xml new file mode 100644 index 0000000..368ac7b --- /dev/null +++ b/ubl/testdata/parse/pint/ae/exports-predefined-endpoint.xml @@ -0,0 +1,199 @@ + + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000001 + AE-001-Exports-TEST + 42fd81e6-27cd-422e-b93e-760f6c47c82d + 2025-02-07 + 17:31:00+04:00 + 2025-02-22 + 380 + Tax invoice + 2025-01-31 + USD + AED + + EXP-09 + EC-24-25-1001 + + + EXP010101234 + + + AED + aedtotal-incl-vat + 913621.44 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Dubai + DXB + + AE + + + + 132654987101003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email Address + + + + + + 9900000099 + + Buyer Legal Name + + + Street Name + Additional Street Name + Perth + Postal code + WA + + AU + + + + Export Traders + CN0102000001123 + + + Contact Name + Email Address + + + + + + + mm + 333 + 333 + + US + + + + + CIF + + + + 1 + + + within 1 month + + + USD + AED + 3.67285 + + + 0 + false + + 248750 + 0 + + Z + 0 + + VAT + + + + + + 0 + + + 248750 + 248750 + 248750 + 248750 + + + 1 + 5000 + 248750 + + 0 + + + Item Description + Item Name + + G + 22334455 + + + Z + 0 + + VAT + + + + + Lot 1 + + + + + 49.75 + 1 + + false + 0.25 + 50 + + + + 913621.44 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/exports.xml b/ubl/testdata/parse/pint/ae/exports.xml new file mode 100644 index 0000000..2458b5d --- /dev/null +++ b/ubl/testdata/parse/pint/ae/exports.xml @@ -0,0 +1,199 @@ + + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000001 + AE-001-Exports-TEST + 42fd81e6-27cd-422e-b93e-760f6c47c82d + 2025-02-07 + 17:31:00+04:00 + 2025-02-22 + 380 + Tax invoice + 2025-01-31 + USD + AED + + EXP-09 + EC-24-25-1001 + + + EXP010101234 + + + AED + aedtotal-incl-vat + 913621.44 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Dubai + DXB + + AE + + + + 132654987101003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email Address + + + + + + 51824753556 + + Buyer Legal Name + + + Street Name + Additional Street Name + Perth + Postal code + WA + + AU + + + + Export company + CN0102000001123 + + + Contact Name + Email Address + + + + + + + mm + 333 + 333 + + US + + + + + CIF + + + + 1 + + + within 1 month + + + USD + AED + 3.67285 + + + 0 + false + + 248750 + 0 + + Z + 0 + + VAT + + + + + + 0 + + + 248750 + 248750 + 248750 + 248750 + + + 1 + 5000 + 248750 + + 0 + + + Item Description + Item Name + + G + 22334455 + + + Z + 0 + + VAT + + + + + Lot 1 + + + + + 49.75 + 1 + + false + 0.25 + 50 + + + + 913621.44 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/margin-scheme-credit-note.xml b/ubl/testdata/parse/pint/ae/margin-scheme-credit-note.xml new file mode 100644 index 0000000..93ed02b --- /dev/null +++ b/ubl/testdata/parse/pint/ae/margin-scheme-credit-note.xml @@ -0,0 +1,162 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00100000 + AE-001-Marginscheme-CN-TEST + e59f130c-eb13-4476-bc18-2202915f48d0 + 2025-02-11 + 381 + Tax invoice + AED + + DL8.61.1.E + + + + AE-001-Marginscheme-TEST + 2025-02-11 + + + + + 112345678900003 + + Supplier Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address line + + + AE + + + + 112345678900003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Contact Email address + + + + + + 112345679000003 + + Buyer Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address Line + + + AE + + + + 112345679000003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Contact Email address + + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + Instant Payment + + + 0 + false + + 1000 + 0 + + N + 5 + + VAT + + + + + + 1000 + 1000 + 1000 + 1000 + + + 1 + Margin scheme goods + 1 + 1000 + + Item Description + Item Name + + N + 5 + 1000 + + VAT + + + + + 1000 + 1 + + false + 0 + 1000 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/margin-scheme.xml b/ubl/testdata/parse/pint/ae/margin-scheme.xml new file mode 100644 index 0000000..5123196 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/margin-scheme.xml @@ -0,0 +1,154 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00100000 + AE-001-Marginscheme-TEST + e59f130c-eb13-4476-bc18-2202915f48cf + 2025-02-11 + 2025-02-11 + 380 + Tax invoice + AED + + + 112345678900003 + + Supplier Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address line + + + AE + + + + 112345678900003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Contact Email address + + + + + + 112345679000003 + + Buyer Trade Name + + + Street Name + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address Line + + + AE + + + + 112345679000003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Contact Email address + + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + Instant Payment + + + 0 + false + + 1000 + 0 + + N + 5 + + VAT + + + + + + 1000 + 1000 + 1000 + 1000 + + + 1 + Margin scheme goods + 1 + 1000 + + Item Description + Item Name + + N + 5 + 1000 + + VAT + + + + + 1000 + 1 + + false + 0 + 1000 + + + + 1000 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/allowance-exempt.json b/ubl/testdata/parse/pint/ae/out/allowance-exempt.json new file mode 100644 index 0000000..eb64084 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/allowance-exempt.json @@ -0,0 +1,250 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "673bc22ae78d3b44150df6acd4b1afa5f2ed4810bdd4bc0a3c4fce5a53ec9fc0" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-ALLOW-E-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Local Passenger Transport", + "description": "Local passenger transport services exempt from VAT", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + } + } + ], + "total": "1000.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "100.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "900.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "discount": "100.00", + "total": "900.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + }, + "base": "900.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "900.00", + "payable": "900.00" + }, + "notes": [ + { + "text": "Exempt supply invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/allowance-outside-scope.json b/ubl/testdata/parse/pint/ae/out/allowance-outside-scope.json new file mode 100644 index 0000000..e6b27d1 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/allowance-outside-scope.json @@ -0,0 +1,247 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "cd397fe17b94104ac1a366be43bcad2ea6d2e499c06f7082419ef769a4ba8a2e" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-ALLOW-O-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Out of Scope Services", + "description": "Services not subject to VAT", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "1000.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Discount", + "amount": "100.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "900.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "discount": "100.00", + "total": "900.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "900.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "900.00", + "payable": "900.00" + }, + "notes": [ + { + "text": "Not subject to VAT invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/allowance-reverse-charge.json b/ubl/testdata/parse/pint/ae/out/allowance-reverse-charge.json new file mode 100644 index 0000000..f67d316 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/allowance-reverse-charge.json @@ -0,0 +1,253 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "869618c64d041c34958b76b03d8647fd374d8fcfcb376b15462b8cf50ffa8190" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-ALLOW-AE-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Consulting Services", + "identities": [ + { + "code": "9876543210", + "ext": { + "iso-scheme-id": "0160" + } + } + ], + "description": "Consulting services subject to reverse charge", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1", + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "1000.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Discount", + "amount": "100.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "900.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "discount": "100.00", + "total": "900.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "900.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "900.00", + "payable": "900.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/allowance-zero-rated.json b/ubl/testdata/parse/pint/ae/out/allowance-zero-rated.json new file mode 100644 index 0000000..8f4f5d2 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/allowance-zero-rated.json @@ -0,0 +1,247 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "d8a710af97e31ce240532a5212976bad855710317b1a198a2a04dd09ca779dca" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-ALLOW-Z-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Zero Rated Goods", + "description": "Zero rated goods for export", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "1000.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Discount", + "amount": "100.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "900.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "discount": "100.00", + "total": "900.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "900.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "900.00", + "payable": "900.00" + }, + "notes": [ + { + "text": "Zero rated supply invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/buyer-pas-identifier.json b/ubl/testdata/parse/pint/ae/out/buyer-pas-identifier.json new file mode 100644 index 0000000..811285e --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/buyer-pas-identifier.json @@ -0,0 +1,226 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "0f11b7af4b8dbd1776a91b5f8dafed226104322a4a6fc8c53603aa3cd941a39d" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-BUYER-PAS-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "country": "IN", + "key": "passport", + "code": "P1234567890" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Electronic Components", + "description": "Standard rated goods", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1050.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/charge-exempt.json b/ubl/testdata/parse/pint/ae/out/charge-exempt.json new file mode 100644 index 0000000..58791eb --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/charge-exempt.json @@ -0,0 +1,250 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "3a4b2089f13b033d2e412a698f6307c0f3b3af59f9910b65f6e83e408aa25284" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-CHARGE-E-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Local Passenger Transport", + "description": "Local passenger transport services exempt from VAT", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + } + } + ], + "total": "1000.00" + } + ], + "charges": [ + { + "i": 1, + "reason": "Handling fee", + "amount": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1200.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "charge": "200.00", + "total": "1200.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + }, + "base": "1200.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1200.00", + "payable": "1200.00" + }, + "notes": [ + { + "text": "Exempt supply invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/charge-outside-scope.json b/ubl/testdata/parse/pint/ae/out/charge-outside-scope.json new file mode 100644 index 0000000..96d0632 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/charge-outside-scope.json @@ -0,0 +1,247 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "254e32977d29359a0af08bcb5d4895c1c04b8b16327d1e3d508b473691052585" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-CHARGE-O-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Out of Scope Services", + "description": "Services not subject to VAT", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "1000.00" + } + ], + "charges": [ + { + "i": 1, + "reason": "Handling fee", + "amount": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1200.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "charge": "200.00", + "total": "1200.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "1200.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1200.00", + "payable": "1200.00" + }, + "notes": [ + { + "text": "Not subject to VAT invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/charge-reverse-charge.json b/ubl/testdata/parse/pint/ae/out/charge-reverse-charge.json new file mode 100644 index 0000000..5ea1709 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/charge-reverse-charge.json @@ -0,0 +1,253 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "7a5747643d912a1839bcb4bc085a40fb28cd3b149671d442f45849ef93fd5930" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-CHARGE-AE-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Consulting Services", + "identities": [ + { + "code": "9876543210", + "ext": { + "iso-scheme-id": "0160" + } + } + ], + "description": "Consulting services subject to reverse charge", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1", + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "1000.00" + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1200.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "charge": "200.00", + "total": "1200.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "1200.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1200.00", + "payable": "1200.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/charge-zero-rated.json b/ubl/testdata/parse/pint/ae/out/charge-zero-rated.json new file mode 100644 index 0000000..8ca5820 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/charge-zero-rated.json @@ -0,0 +1,247 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "240c9b62483cc6edefe4dfde65b14e826655c321ec8dce030c370397d000ce62" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-CHARGE-Z-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Zero Rated Goods", + "description": "Zero rated goods for export", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "1000.00" + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "200.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1200.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "charge": "200.00", + "total": "1200.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "1200.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1200.00", + "payable": "1200.00" + }, + "notes": [ + { + "text": "Zero rated supply invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/commercial-invoice.json b/ubl/testdata/parse/pint/ae/out/commercial-invoice.json new file mode 100644 index 0000000..3818273 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/commercial-invoice.json @@ -0,0 +1,224 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "2392799f45b29fb36053d68ee66e7fcacdc57be7870d31e0eb953f768ff89c46" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "outside-tax-scope" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-CI-001Test", + "issue_date": "2025-02-07", + "issue_time": "17:38:00", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "480" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432112303" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1000", + "item": { + "name": "Item Name", + "description": "Item Description", + "list": "151", + "discount": "1", + "price": "150.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "150000.00", + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "150000.00" + } + ], + "payment": { + "payee": { + "name": "Payee Ltd.", + "identities": [ + { + "scope": "legal", + "code": "CN12389045678121" + } + ] + }, + "terms": { + "due_dates": [ + { + "date": "2025-02-07", + "amount": "150000.00", + "percent": "100%" + } + ], + "notes": "Cash payment" + }, + "instructions": { + "key": "cash", + "detail": "In cash", + "ext": { + "untdid-payment-means": "10" + } + } + }, + "totals": { + "sum": "150000.00", + "total": "150000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "150000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "150000.00", + "payable": "150000.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/continuous-supplies.json b/ubl/testdata/parse/pint/ae/out/continuous-supplies.json new file mode 100644 index 0000000..dbb954d --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/continuous-supplies.json @@ -0,0 +1,329 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "18ae894b9ae4571e0fec36d6d642627716b5246cc12427d22178c49f12b3eec2" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1456789456" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "continuous-supply" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001CS-TEST", + "issue_date": "2025-02-07", + "value_date": "2025-01-30", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00001000", + "untdid-document-type": "380" + }, + "notes": [ + { + "cat": "VAT", + "key": "exempt", + "text": "Local passenger transport", + "ext": { + "untdid-tax-category": "E" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "132654987101003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "145678945601003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1456789456" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1456789456" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "23424" + } + ], + "description": "Item Description", + "list": "500", + "price": "500.00", + "ext": { + "untdid-unit": "TIP" + } + }, + "sum": "5000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "5000.00" + }, + { + "i": 2, + "quantity": "1455", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "item": { + "name": "Item Name", + "description": "Item Description", + "list": "0.5", + "price": "0.50", + "ext": { + "untdid-unit": "LN" + } + }, + "sum": "727.50", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + } + } + ], + "total": "727.50" + } + ], + "charges": [ + { + "i": 1, + "reason": "Polyethylene wrap packing", + "base": "5000", + "percent": "1.5%", + "amount": "75", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "ABU" + } + } + ], + "ordering": { + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "contracts": [ + { + "code": "ZXC-CS-03", + "description": "AED 1000000" + } + ] + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-07", + "amount": "6057.00", + "percent": "100%" + } + ], + "notes": "1 month" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "5727.50", + "charge": "75.00", + "total": "5802.50", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "5075.00", + "percent": "5%", + "amount": "253.75" + }, + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.4", + "untdid-tax-category": "E" + }, + "base": "727.50", + "amount": "0.00" + } + ], + "amount": "253.75" + } + ], + "sum": "253.75" + }, + "tax": "253.75", + "total_with_tax": "6056.25", + "rounding": "0.75", + "payable": "6057.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "Cabbills", + "url": "https://www.site.ae/cabbills.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/credit-note-disclosed-agent.json b/ubl/testdata/parse/pint/ae/out/credit-note-disclosed-agent.json new file mode 100644 index 0000000..6017439 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/credit-note-disclosed-agent.json @@ -0,0 +1,347 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "4a9f733ae204bb7102065c952458b4015cf2ef728c1ee46799b7af3c464cd67e" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "disclosed-agent" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "code": "AE001-CN-TEST", + "issue_date": "2025-02-07", + "issue_time": "15:55:00", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-02-07", + "code": "Sample-02" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-principal-id": "155667745601003", + "peppol-pint-ae-transaction-type": "00000100", + "untdid-document-type": "381" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sarjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2000", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "order": "1", + "item": { + "ref": "Seller Item Identification", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "Buyer Item Identification" + }, + { + "label": "HS", + "code": "11223355" + } + ], + "attributes": [ + { + "label": "Additional Item Property Name", + "text": "Additional Item Property Value" + } + ], + "description": "Item Description", + "list": "5", + "discount": "0.1", + "price": "4.90", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "9800.00", + "discounts": [ + { + "reason": "Discount", + "base": "9800.00", + "percent": "3%", + "amount": "294.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "9800.00", + "percent": "10%", + "amount": "980.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "10486.00", + "notes": [ + { + "text": "All items" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "262.15", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "419.44", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "ordering": { + "code": "PO-AE-220", + "cost": "Regular sales", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "purchases": [ + { + "code": "PO-AE-220" + } + ], + "sales": [ + { + "code": "Salesorder-2122" + } + ], + "despatch": [ + { + "code": "Memo-1000" + } + ], + "tender": [ + { + "code": "PO-AE-220" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Party Name", + "identities": [ + { + "scope": "legal", + "code": "1122334455" + } + ] + }, + "terms": { + "notes": "Will be adjusted against next invoice" + } + }, + "totals": { + "sum": "10486.00", + "discount": "262.15", + "charge": "419.44", + "total": "10643.29", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10643.29", + "percent": "5%", + "amount": "532.16" + } + ], + "amount": "532.16" + } + ], + "sum": "532.16" + }, + "tax": "532.16", + "total_with_tax": "11175.45", + "rounding": "0.05", + "payable": "11175.50" + }, + "notes": [ + { + "text": "Tax Credit invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/credit-note-standard.json b/ubl/testdata/parse/pint/ae/out/credit-note-standard.json new file mode 100644 index 0000000..24fe7b7 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/credit-note-standard.json @@ -0,0 +1,343 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "fc66967c942a5fbb70adf5b67dcf6cb4356062a97590c19cb176000ac1c056a3" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "code": "AE001-CN-TEST", + "issue_date": "2025-02-07", + "issue_time": "15:55:00", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-02-07", + "code": "Sample-02" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "381" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sarjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2000", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "order": "1", + "item": { + "ref": "Seller Item Identification", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "Buyer Item Identification" + }, + { + "label": "HS", + "code": "11223355" + } + ], + "attributes": [ + { + "label": "Additional Item Property Name", + "text": "Additional Item Property Value" + } + ], + "description": "Item Description", + "list": "5", + "discount": "0.1", + "price": "4.90", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "9800.00", + "discounts": [ + { + "reason": "Discount", + "base": "9800.00", + "percent": "3%", + "amount": "294.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "9800.00", + "percent": "10%", + "amount": "980.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "10486.00", + "notes": [ + { + "text": "All items" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "262.15", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "419.44", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "ordering": { + "code": "PO-AE-220", + "cost": "Regular sales", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "purchases": [ + { + "code": "PO-AE-220" + } + ], + "sales": [ + { + "code": "Salesorder-2122" + } + ], + "despatch": [ + { + "code": "Memo-1000" + } + ], + "tender": [ + { + "code": "PO-AE-220" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Party Name", + "identities": [ + { + "scope": "legal", + "code": "1122334455" + } + ] + }, + "terms": { + "notes": "Will be adjusted against next invoice" + } + }, + "totals": { + "sum": "10486.00", + "discount": "262.15", + "charge": "419.44", + "total": "10643.29", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10643.29", + "percent": "5%", + "amount": "532.16" + } + ], + "amount": "532.16" + } + ], + "sum": "532.16" + }, + "tax": "532.16", + "total_with_tax": "11175.45", + "rounding": "0.05", + "payable": "11175.50" + }, + "notes": [ + { + "text": "Tax Credit invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/credit-note-volume-discount.json b/ubl/testdata/parse/pint/ae/out/credit-note-volume-discount.json new file mode 100644 index 0000000..9d3de03 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/credit-note-volume-discount.json @@ -0,0 +1,337 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "9b3ac2b9ada6a768dcc49bd2da94154cc86a98c5f5670e2c241e5d448315b888" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "code": "AE001-CN-VD", + "issue_date": "2025-02-07", + "issue_time": "15:55:00", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-credit-note-reason": "VD", + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "381" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sarjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2000", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "order": "1", + "item": { + "ref": "Seller Item Identification", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "Buyer Item Identification" + }, + { + "label": "HS", + "code": "11223355" + } + ], + "attributes": [ + { + "label": "Additional Item Property Name", + "text": "Additional Item Property Value" + } + ], + "description": "Item Description", + "list": "5", + "discount": "0.1", + "price": "4.90", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "9800.00", + "discounts": [ + { + "reason": "Discount", + "base": "9800.00", + "percent": "3%", + "amount": "294.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "9800.00", + "percent": "10%", + "amount": "980.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "10486.00", + "notes": [ + { + "text": "All items" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "262.15", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "419.44", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "ordering": { + "code": "PO-AE-220", + "cost": "Regular sales", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "purchases": [ + { + "code": "PO-AE-220" + } + ], + "sales": [ + { + "code": "Salesorder-2122" + } + ], + "despatch": [ + { + "code": "Memo-1000" + } + ], + "tender": [ + { + "code": "PO-AE-220" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Party Name", + "identities": [ + { + "scope": "legal", + "code": "1122334455" + } + ] + }, + "terms": { + "notes": "Will be adjusted against next invoice" + } + }, + "totals": { + "sum": "10486.00", + "discount": "262.15", + "charge": "419.44", + "total": "10643.29", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10643.29", + "percent": "5%", + "amount": "532.16" + } + ], + "amount": "532.16" + } + ], + "sum": "532.16" + }, + "tax": "532.16", + "total_with_tax": "11175.45", + "rounding": "0.05", + "payable": "11175.50" + }, + "notes": [ + { + "text": "Volume discount credit note - VD reason, no BillingReference required per ibr-055-ae" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/deemed-supply.json b/ubl/testdata/parse/pint/ae/out/deemed-supply.json new file mode 100644 index 0000000..27c25b9 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/deemed-supply.json @@ -0,0 +1,250 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "7989551e884c34ff7ee65fe3c1786ba4abb06bc5731963a0dccd0e937d3a8af5" + }, + "from": "iso6523-actorid-upis::0235:1246801357", + "to": "iso6523-actorid-upis::0235:9900000097" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "deemed-supply" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001DS-Test", + "issue_date": "2025-02-07", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "01000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "124680135701003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1246801357" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1246801357" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "178901234501003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:9900000097" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "9900000097" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "88098432" + }, + { + "label": "SAC", + "code": "Service" + } + ], + "description": "Item Description", + "list": "150", + "discount": "10", + "price": "140.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "280.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "280.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "base": "280", + "percent": "5%", + "amount": "14", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "payment": { + "instructions": { + "key": "any", + "detail": "Instrument Not Defined", + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "280.00", + "discount": "14.00", + "total": "266.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "266.00", + "percent": "5%", + "amount": "13.30" + } + ], + "amount": "13.30" + } + ], + "sum": "13.30" + }, + "tax": "13.30", + "total_with_tax": "279.30", + "payable": "279.30" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "Sample-05", + "url": "https://www.site.ae/Sample-05.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/disclosed-agent-billing.json b/ubl/testdata/parse/pint/ae/out/disclosed-agent-billing.json new file mode 100644 index 0000000..370cf1f --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/disclosed-agent-billing.json @@ -0,0 +1,274 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "a12b3f0f36099606ff5bab463e55d90ca9aa8c6dcffb12ec3ee6559bd12c64ba" + }, + "from": "iso6523-actorid-upis::0235:1239874562", + "to": "iso6523-actorid-upis::0235:1456789456" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "disclosed-agent", + "bypass" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-01DAB-TEST", + "issue_date": "2025-02-07", + "issue_time": "15:08:00", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-principal-id": "155667745601003", + "peppol-pint-ae-transaction-type": "00000100", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "124680135701003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1239874562" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1239874562" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Telephone Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "145678945601003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1456789456" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1456789456" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "email address" + } + ], + "telephones": [ + { + "num": "Contact number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "50", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "889900" + } + ], + "description": "Item Description", + "list": "20", + "discount": "0.5", + "price": "19.50", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "975.00", + "charges": [ + { + "reason": "Technical Modification", + "amount": "24.38", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "999.375", + "notes": [ + { + "text": "Inspect the goods" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "base": "999.375", + "percent": "5%", + "amount": "49.97", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-07", + "amount": "996.88", + "percent": "100%" + } + ], + "notes": "cash payment" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "999.38", + "discount": "49.97", + "total": "949.41", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "ext": { + "untdid-tax-category": "S" + }, + "base": "949.405", + "percent": "5%", + "amount": "47.47025" + } + ], + "amount": "47.47025" + } + ], + "sum": "47.47025" + }, + "tax": "47.47", + "total_with_tax": "996.88", + "payable": "996.88" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/e-commerce.json b/ubl/testdata/parse/pint/ae/out/e-commerce.json new file mode 100644 index 0000000..8e1db29 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/e-commerce.json @@ -0,0 +1,360 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "b0523c01e5d7bdceaca8bfac980a250585e86e8340bf1d95bea22a6b94d257f3" + }, + "from": "iso6523-actorid-upis::0235:112345678900003", + "to": "iso6523-actorid-upis::0235:112345679000003" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "e-commerce" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001-E-Commerce-TEST", + "issue_date": "2025-02-11", + "issue_time": "11:35:10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000010", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "112345678900003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345678900003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345678900003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "112345679000003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345679000003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345679000003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "11223355" + } + ], + "description": "Item Description", + "list": "101", + "discount": "1", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "100.00", + "discounts": [ + { + "reason": "Discount", + "amount": "2.50", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "100.00", + "percent": "5%", + "amount": "5.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "102.50", + "notes": [ + { + "text": "Please check the invoice" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Discount", + "base": "100", + "percent": "5%", + "amount": "5", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Technical Modification", + "amount": "2.50", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAC" + } + } + ], + "payment": { + "payee": { + "name": "Payee Party Name", + "identities": [ + { + "scope": "legal", + "code": "112345679350001" + }, + { + "code": "132345679670003", + "ext": { + "iso-scheme-id": "0066" + } + } + ] + }, + "advances": [ + { + "description": "Prepaid Amount", + "amount": "0.00" + } + ], + "terms": { + "due_dates": [ + { + "date": "2025-02-11", + "amount": "105.00", + "percent": "100%" + } + ], + "notes": "Instant Payment" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "delivery": { + "receiver": { + "name": "Delivery Party Name", + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ] + }, + "identities": [ + { + "code": "112345679000003", + "ext": { + "iso-scheme-id": "0066" + } + } + ], + "date": "2025-02-11" + }, + "totals": { + "sum": "102.50", + "discount": "5.00", + "charge": "2.50", + "total": "100.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "100.00", + "percent": "5%", + "amount": "5.00" + } + ], + "amount": "5.00" + } + ], + "sum": "5.00" + }, + "tax": "5.00", + "total_with_tax": "105.00", + "payable": "105.00", + "advance": "0.00", + "due": "105.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "DR-INV-001", + "url": "https://www.site.ae/invoices.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/exports-predefined-endpoint.json b/ubl/testdata/parse/pint/ae/out/exports-predefined-endpoint.json new file mode 100644 index 0000000..b22bd03 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/exports-predefined-endpoint.json @@ -0,0 +1,258 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "84651eddb0685a11952e2b2f47f135e0ab7d74f81212dee15c4ff7a1341cefcc" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:9900000099" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "export" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001-Exports-TEST", + "issue_date": "2025-02-07", + "issue_time": "17:31:00", + "value_date": "2025-01-31", + "currency": "USD", + "exchange_rates": [ + { + "from": "USD", + "to": "AED", + "amount": "3.67285" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000001", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "132654987101003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Export Traders", + "alias": "Buyer Legal Name", + "identities": [ + { + "scope": "legal", + "country": "AU", + "key": "passport", + "code": "CN0102000001123" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:9900000099" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "9900000099" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Perth", + "region": "WA", + "code": "Postal code", + "country": "AU" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "5000", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "22334455" + } + ], + "description": "Item Description", + "list": "50", + "discount": "0.25", + "price": "49.75", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "248750.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "248750.00" + } + ], + "ordering": { + "purchases": [ + { + "code": "EXP-09" + } + ], + "sales": [ + { + "code": "EC-24-25-1001" + } + ] + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-22", + "amount": "248750.00", + "percent": "100%" + } + ], + "notes": "within 1 month" + }, + "instructions": { + "key": "any", + "detail": "Instrument Not Defined", + "ext": { + "untdid-payment-means": "1" + } + } + }, + "delivery": { + "receiver": { + "addresses": [ + { + "street": "mm", + "locality": "333", + "region": "333", + "country": "US" + } + ] + }, + "ext": { + "icc-incoterms-2020": "CIF" + } + }, + "totals": { + "sum": "248750.00", + "total": "248750.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "248750.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "248750.00", + "payable": "248750.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/exports.json b/ubl/testdata/parse/pint/ae/out/exports.json new file mode 100644 index 0000000..44579df --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/exports.json @@ -0,0 +1,256 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "a96d36e1938fca0986fde4eb332a99f27f739237b4d5d58f936788170d1244f4" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0151:51824753556" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "export" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001-Exports-TEST", + "issue_date": "2025-02-07", + "issue_time": "17:31:00", + "value_date": "2025-01-31", + "currency": "USD", + "exchange_rates": [ + { + "from": "USD", + "to": "AED", + "amount": "3.67285" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000001", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "132654987101003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Export company", + "alias": "Buyer Legal Name", + "identities": [ + { + "scope": "legal", + "code": "CN0102000001123" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0151:51824753556" + } + ], + "inboxes": [ + { + "scheme": "0151", + "code": "51824753556" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Perth", + "region": "WA", + "code": "Postal code", + "country": "AU" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "5000", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "22334455" + } + ], + "description": "Item Description", + "list": "50", + "discount": "0.25", + "price": "49.75", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "248750.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "248750.00" + } + ], + "ordering": { + "purchases": [ + { + "code": "EXP-09" + } + ], + "sales": [ + { + "code": "EC-24-25-1001" + } + ] + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-22", + "amount": "248750.00", + "percent": "100%" + } + ], + "notes": "within 1 month" + }, + "instructions": { + "key": "any", + "detail": "Instrument Not Defined", + "ext": { + "untdid-payment-means": "1" + } + } + }, + "delivery": { + "receiver": { + "addresses": [ + { + "street": "mm", + "locality": "333", + "region": "333", + "country": "US" + } + ] + }, + "ext": { + "icc-incoterms-2020": "CIF" + } + }, + "totals": { + "sum": "248750.00", + "total": "248750.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "248750.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "248750.00", + "payable": "248750.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/margin-scheme-credit-note.json b/ubl/testdata/parse/pint/ae/out/margin-scheme-credit-note.json new file mode 100644 index 0000000..fe156eb --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/margin-scheme-credit-note.json @@ -0,0 +1,242 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "9ea1f11f478d3b88d27b6f8f1a7c962f5fa73217e3085583dc4db1ac6961f2a2" + }, + "from": "iso6523-actorid-upis::0235:112345678900003", + "to": "iso6523-actorid-upis::0235:112345679000003" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "margin-scheme" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "credit-note", + "code": "AE-001-Marginscheme-CN-TEST", + "issue_date": "2025-02-11", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-02-11", + "code": "AE-001-Marginscheme-TEST" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-credit-note-reason": "DL8.61.1.E", + "peppol-pint-ae-transaction-type": "00100000", + "untdid-document-type": "381" + }, + "notes": [ + { + "cat": "VAT", + "key": "margin-scheme", + "text": "VAT charged under the Profit Margin Scheme", + "ext": { + "untdid-tax-category": "N" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "112345678900003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345678900003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345678900003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "112345679000003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345679000003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345679000003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "name": "Item Name", + "description": "Item Description", + "list": "1000", + "price": "1000.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + } + } + ], + "total": "1000.00", + "notes": [ + { + "text": "Margin scheme goods" + } + ] + } + ], + "payment": { + "terms": { + "notes": "Instant Payment" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/margin-scheme.json b/ubl/testdata/parse/pint/ae/out/margin-scheme.json new file mode 100644 index 0000000..7c2995b --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/margin-scheme.json @@ -0,0 +1,242 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "29157f4ff0650ba375633a21a878177b60c2561e511fa438dbcf27871ee8ec69" + }, + "from": "iso6523-actorid-upis::0235:112345678900003", + "to": "iso6523-actorid-upis::0235:112345679000003" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "margin-scheme" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001-Marginscheme-TEST", + "issue_date": "2025-02-11", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00100000", + "untdid-document-type": "380" + }, + "notes": [ + { + "cat": "VAT", + "key": "margin-scheme", + "text": "VAT charged under the Profit Margin Scheme", + "ext": { + "untdid-tax-category": "N" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "112345678900003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345678900003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345678900003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "112345679000003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345679000003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345679000003" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Contact Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "1", + "item": { + "name": "Item Name", + "description": "Item Description", + "list": "1000", + "price": "1000.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + } + } + ], + "total": "1000.00", + "notes": [ + { + "text": "Margin scheme goods" + } + ] + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-11", + "amount": "1000.00", + "percent": "100%" + } + ], + "notes": "Instant Payment" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "exempt", + "ext": { + "untdid-tax-category": "N" + }, + "base": "1000.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "1000.00", + "payable": "1000.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/reverse-charge.json b/ubl/testdata/parse/pint/ae/out/reverse-charge.json new file mode 100644 index 0000000..0eb1eb8 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/reverse-charge.json @@ -0,0 +1,242 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "00d656e3354bb011406df5b52dd1dd95827b3141d1a470f85b97f97d7cb27782" + }, + "from": "iso6523-actorid-upis::0235:1278906543", + "to": "iso6523-actorid-upis::0235:1347809543" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-01RCTEST", + "issue_date": "2025-02-07", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "127890654301003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1278906543" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1278906543" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "emailAddress" + } + ], + "telephones": [ + { + "num": "Contact number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134780954301003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1347809543" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1347809543" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Emailaddress" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "30", + "item": { + "name": "Item Name", + "identities": [ + { + "code": "324243424", + "ext": { + "iso-scheme-id": "0160" + } + }, + { + "label": "HS", + "code": "88098432324" + } + ], + "description": "Item Description", + "list": "100", + "discount": "1", + "price": "99.00", + "unit": "kl", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1", + "untdid-unit": "K6" + } + }, + "sum": "2970.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "2970.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-21", + "amount": "2970.00", + "percent": "100%" + } + ], + "notes": "Within 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "2970.00", + "total": "2970.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "2970.00", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "2970.00", + "payable": "2970.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "DC", + "url": "https://www.site.ae/deliverychallans.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/seller-pas-identifier.json b/ubl/testdata/parse/pint/ae/out/seller-pas-identifier.json new file mode 100644 index 0000000..f692869 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/seller-pas-identifier.json @@ -0,0 +1,226 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "478bc168ea771d750d62cc0bd7ee23f43d21823442b420cf6e40b83f4f3a23d8" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-SELLER-PAS-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "country": "GB", + "key": "passport", + "code": "P9876543210" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Electronic Components", + "description": "Standard rated goods", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1050.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/seller-tin-identifier.json b/ubl/testdata/parse/pint/ae/out/seller-tin-identifier.json new file mode 100644 index 0000000..75f815c --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/seller-tin-identifier.json @@ -0,0 +1,232 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "9fff00e71174fd1145229246a5523a8768b900380865a6ed8d18cb77623f0ed9" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-SELLER-TIN-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "country": "AE", + "type": "TIN", + "code": "1234567890" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Electronic Components", + "description": "Standard rated goods", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1050.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/seller-trn-tin-identifiers.json b/ubl/testdata/parse/pint/ae/out/seller-trn-tin-identifiers.json new file mode 100644 index 0000000..69b676f --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/seller-trn-tin-identifiers.json @@ -0,0 +1,232 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "8e4e4cb345325d46a6b3c13a7d0a356869d30ed49a10ea836588113560ca2ed4" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-SELLER-TRN-TIN-01", + "issue_date": "2025-03-15", + "value_date": "2025-03-10", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Seller Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + }, + { + "scope": "tax", + "country": "AE", + "type": "TIN", + "code": "1234567892" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Al Maktoum Road", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "seller@example.ae" + } + ], + "telephones": [ + { + "num": "+971501234567" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Buyer Contact" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Khalifa Street", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "buyer@example.ae" + } + ], + "telephones": [ + { + "num": "+971502345678" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "10", + "item": { + "name": "Electronic Components", + "description": "Standard rated goods", + "list": "100", + "price": "100.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-30", + "amount": "1050.00", + "percent": "100%" + } + ], + "notes": "Net 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE070331234567890123456", + "bic": "ABORAEADXXX", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + }, + "notes": [ + { + "text": "Tax invoice - Seller carrying both a VAT registration (TRN) and a non-VAT tax registration (TIN)" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/standard-invoice-extensive.json b/ubl/testdata/parse/pint/ae/out/standard-invoice-extensive.json new file mode 100644 index 0000000..b3dbd94 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/standard-invoice-extensive.json @@ -0,0 +1,812 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "ba4aa4653e5217dee968b65a60673e18e2d14243b866772a83703d748c03c531" + }, + "from": "iso6523-actorid-upis::0235:112345678900003", + "to": "iso6523-actorid-upis::0235:112345679000003" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "free-trade-zone", + "continuous-supply", + "e-commerce" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "INV-001/2025", + "issue_date": "2025-01-30", + "issue_time": "18:24:10", + "value_date": "2025-01-29", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-01-30", + "code": "INV-1001/2022" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-beneficiary-id": "189098765401003", + "peppol-pint-ae-transaction-type": "10001010", + "untdid-document-type": "380" + }, + "notes": [ + { + "cat": "VAT", + "key": "exempt", + "text": "Supply of residential units (lease or sale)", + "ext": { + "untdid-tax-category": "E" + } + } + ] + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "112345678900003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contct Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345678900003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345678900003" + } + ], + "addresses": [ + { + "street": "Al Bateen Street", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "112345679000003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:112345679000003" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "112345679000003" + } + ], + "addresses": [ + { + "street": "Khalifa street", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "5", + "period": { + "start": "2025-01-30", + "end": "2025-01-30" + }, + "order": "st-nar-1", + "cost": "ABC-001", + "item": { + "ref": "art-p-001", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "art-to-001" + }, + { + "code": "04012345123456", + "ext": { + "iso-scheme-id": "0160" + } + }, + { + "label": "HS", + "code": "88098432324" + } + ], + "attributes": [ + { + "label": "colour", + "text": "red" + } + ], + "description": "Item Description", + "list": "1000", + "price": "1000.00", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "5000.00", + "discounts": [ + { + "reason": "Discount", + "base": "5000.00", + "percent": "1%", + "amount": "50.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "amount": "10.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "4960.00", + "notes": [ + { + "text": "Please check the invoice" + } + ] + }, + { + "i": 2, + "quantity": "10", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "1101" + } + ], + "description": "Item Description", + "list": "2000", + "discount": "20", + "price": "1980.00", + "per": "5", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "3960.00", + "discounts": [ + { + "reason": "Discount", + "base": "4000.00", + "percent": "2%", + "amount": "80.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Special Construction", + "amount": "20.00", + "ext": { + "untdid-charge": "AAV" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.2", + "untdid-tax-category": "E" + } + } + ], + "total": "3900.00" + }, + { + "i": 3, + "quantity": "15", + "period": { + "start": "2025-01-30", + "end": "2025-01-30" + }, + "order": "st-nar-1", + "cost": "CS-024", + "item": { + "ref": "art-p-001", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "art-to-001" + }, + { + "label": "HS", + "code": "3450" + } + ], + "attributes": [ + { + "label": "Item Additional Name", + "text": "Item Additional Value" + } + ], + "description": "Item Description", + "list": "3000", + "discount": "30", + "price": "2970.00", + "per": "10", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "4455.00", + "discounts": [ + { + "reason": "Discount", + "amount": "135.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "amount": "112.50", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + } + } + ], + "total": "4432.50", + "notes": [ + { + "text": "Please check the invoice" + } + ] + }, + { + "i": 4, + "quantity": "20", + "period": { + "start": "2025-01-30", + "end": "2025-01-30" + }, + "order": "st-nar-1", + "cost": "CS-024", + "item": { + "ref": "art-p-001", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "art-to-001" + }, + { + "code": "04012345123456", + "ext": { + "iso-scheme-id": "0160" + } + }, + { + "label": "HS", + "code": "5000" + } + ], + "attributes": [ + { + "label": "Item Additional Name", + "text": "Item Additional Value" + } + ], + "description": "Item Description", + "list": "158.4", + "price": "158.40", + "unit": "piece", + "origin": "AE", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1", + "untdid-unit": "H87" + } + }, + "sum": "3168.00", + "discounts": [ + { + "reason": "Discount", + "base": "3200.00", + "percent": "4%", + "amount": "128.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "3040.00", + "notes": [ + { + "text": "Please check the invoice" + } + ] + }, + { + "i": 5, + "quantity": "25", + "period": { + "start": "2025-01-30", + "end": "2025-01-30" + }, + "order": "st-nar-1", + "cost": "CS-024", + "item": { + "ref": "art-p-001", + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "art-to-001" + }, + { + "code": "04012345123456", + "ext": { + "iso-scheme-id": "0160" + } + }, + { + "label": "HS", + "code": "8680" + } + ], + "attributes": [ + { + "label": "Item Additional Name", + "text": "Item Additional Value" + } + ], + "description": "Item Description", + "list": "5000", + "discount": "50", + "price": "4950.00", + "per": "50", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "2475.00", + "discounts": [ + { + "reason": "Discount", + "amount": "625.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "2500.00", + "percent": "5%", + "amount": "125.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "1975.00", + "notes": [ + { + "text": "Please check the invoice" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Discount", + "amount": "273.75", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + }, + { + "i": 2, + "reason": "Discount", + "amount": "2451.25", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Technical Modification", + "base": "1975", + "percent": "4%", + "amount": "79", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAC" + } + } + ], + "ordering": { + "code": "BR-001/23", + "cost": "4025:123:4343", + "period": { + "start": "2025-01-30", + "end": "2025-01-30" + }, + "seller": { + "name": "Seller Tax Representative Party Name", + "tax_id": { + "country": "AE", + "code": "123349792700003" + }, + "addresses": [ + { + "street": "Al Bateen Street", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zonw", + "country": "AE" + } + ] + }, + "projects": [ + { + "code": "BR-001/23" + } + ], + "contracts": [ + { + "code": "BR-001/23", + "description": "AED200000" + } + ], + "purchases": [ + { + "code": "PO-001/23" + } + ], + "sales": [ + { + "code": "SO-001/23" + } + ], + "receiving": [ + { + "code": "RAR-001/23" + } + ], + "despatch": [ + { + "code": "DAR-001/23" + } + ], + "tender": [ + { + "code": "LR-001/23" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Party Name", + "identities": [ + { + "scope": "legal", + "code": "112345679350001" + }, + { + "code": "132345679670003", + "ext": { + "iso-scheme-id": "0060" + } + } + ] + }, + "advances": [ + { + "description": "Prepaid Amount", + "amount": "10000.00" + } + ], + "terms": { + "due_dates": [ + { + "date": "2025-02-13", + "amount": "5777.50", + "percent": "100%" + } + ], + "notes": "15 days" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "direct_debit": { + "ref": "2025-01-30" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "delivery": { + "receiver": { + "name": "Delivery Party Name", + "addresses": [ + { + "street": "Khalifa street", + "street_extra": "Additional Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "code": "Postal Zone", + "country": "AE" + } + ] + }, + "identities": [ + { + "code": "112345679000003", + "ext": { + "iso-scheme-id": "0060" + } + } + ], + "date": "2025-01-30" + }, + "totals": { + "sum": "18307.50", + "discount": "2725.00", + "charge": "79.00", + "total": "15661.50", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "2314.00", + "percent": "5%", + "amount": "115.70" + }, + { + "key": "exempt", + "ext": { + "cef-vatex": "DL8.46.2", + "untdid-tax-category": "E" + }, + "base": "3900.00", + "amount": "0.00" + }, + { + "key": "outside-scope", + "ext": { + "untdid-tax-category": "O" + }, + "base": "4432.50", + "amount": "0.00" + }, + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "3040.00", + "amount": "0.00" + }, + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "1975.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "115.70" + } + ], + "sum": "115.70" + }, + "tax": "115.70", + "total_with_tax": "15777.20", + "rounding": "0.30", + "payable": "15777.50", + "advance": "10000.00", + "due": "5777.50" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "DR-INV-001", + "description": "Invoice is enclosed", + "url": "https://www.site.ae/invoices.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/standard-invoice-predefined-endpoint.json b/ubl/testdata/parse/pint/ae/out/standard-invoice-predefined-endpoint.json new file mode 100644 index 0000000..2923c04 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/standard-invoice-predefined-endpoint.json @@ -0,0 +1,367 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "b4e2414132dad1ac1db0607b2e83887dc61d75e69e44f43c2bd20cd4c6def416" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:9900000098" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-01TEST", + "issue_date": "2025-02-06", + "issue_time": "07:54:00", + "value_date": "2025-01-30", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-02-06", + "code": "INV-234-2025" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Party Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Telephone number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Noor Electronics", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:9900000098" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "9900000098" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Telephone number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2000", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "order": "1", + "item": { + "ref": "Sales Goods", + "name": "Item Name", + "identities": [ + { + "code": "Purchase goods" + } + ], + "attributes": [ + { + "label": "Item details", + "text": "Item Value" + } + ], + "description": "Item Description", + "list": "5", + "discount": "0.1", + "price": "4.90", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "9800.00", + "discounts": [ + { + "reason": "Discount", + "base": "9800.00", + "percent": "3%", + "amount": "294.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "9800.00", + "percent": "10%", + "amount": "980.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "10486.00", + "notes": [ + { + "text": "All items" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "262.15", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "419.44", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "ordering": { + "code": "PO-AE-220", + "cost": "Regular sales", + "period": { + "start": "2025-01-31", + "end": "2025-02-06" + }, + "projects": [ + { + "code": "Regular work" + } + ], + "purchases": [ + { + "code": "PO-AE-220" + } + ], + "sales": [ + { + "code": "Salesorder-2122" + } + ], + "despatch": [ + { + "code": "Memo-1000" + } + ], + "tender": [ + { + "code": "PO-AE-220" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Name", + "identities": [ + { + "scope": "legal", + "code": "1122334455" + } + ] + }, + "terms": { + "due_dates": [ + { + "date": "2025-02-13", + "amount": "11175.50", + "percent": "100%" + } + ], + "notes": "Within a week" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "10486.00", + "discount": "262.15", + "charge": "419.44", + "total": "10643.29", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10643.29", + "percent": "5%", + "amount": "532.16" + } + ], + "amount": "532.16" + } + ], + "sum": "532.16" + }, + "tax": "532.16", + "total_with_tax": "11175.45", + "rounding": "0.05", + "payable": "11175.50" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "PO-AE-220", + "url": "https://www.site.ae/PO-AE-220.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/standard-invoice.json b/ubl/testdata/parse/pint/ae/out/standard-invoice.json new file mode 100644 index 0000000..ac76e16 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/standard-invoice.json @@ -0,0 +1,184 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "37366cc846f8e944d592108c598d3d47cc47e2e77c04604703ec8069d83e91e6" + }, + "from": "iso6523-actorid-upis::0235:1357902468", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE001-Test", + "issue_date": "2025-01-30", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "135790246801003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1357902468" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1357902468" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "City Name", + "region": "DXB", + "country": "AE" + } + ] + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "CityName", + "region": "AUH", + "country": "AE" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "aaa" + } + ], + "description": "Item Description", + "list": "10", + "price": "10.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1000.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1000.00" + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-06", + "amount": "1050.00", + "percent": "100%" + } + ] + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "1000.00", + "total": "1000.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "1000.00", + "percent": "5%", + "amount": "50.00" + } + ], + "amount": "50.00" + } + ], + "sum": "50.00" + }, + "tax": "50.00", + "total_with_tax": "1050.00", + "payable": "1050.00" + } + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/standard-tax-invoice.json b/ubl/testdata/parse/pint/ae/out/standard-tax-invoice.json new file mode 100644 index 0000000..02490d9 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/standard-tax-invoice.json @@ -0,0 +1,367 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "952e40c78cd37443b101d808906a144cb6947959fd74b212384bdcf58eb85bf4" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1345678901" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-01TEST", + "issue_date": "2025-02-06", + "issue_time": "07:54:00", + "value_date": "2025-01-30", + "currency": "AED", + "preceding": [ + { + "issue_date": "2025-02-06", + "code": "INV-234-2025" + } + ], + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Party Trade Name", + "tax_id": { + "country": "AE", + "code": "198765432102003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Telephone number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Noor Electronics", + "alias": "Buyer Trade Name", + "tax_id": { + "country": "AE", + "code": "134567890123003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1345678901" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1345678901" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Telephone number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "2000", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "order": "1", + "item": { + "ref": "Sales Goods", + "name": "Item Name", + "identities": [ + { + "code": "Purchase goods" + } + ], + "attributes": [ + { + "label": "Item details", + "text": "Item Value" + } + ], + "description": "Item Description", + "list": "5", + "discount": "0.1", + "price": "4.90", + "unit": "piece", + "origin": "AE", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "9800.00", + "discounts": [ + { + "reason": "Discount", + "base": "9800.00", + "percent": "3%", + "amount": "294.00", + "ext": { + "untdid-allowance": "95" + } + } + ], + "charges": [ + { + "reason": "Technical Modification", + "base": "9800.00", + "percent": "10%", + "amount": "980.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "10486.00", + "notes": [ + { + "text": "All items" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "amount": "262.15", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "charges": [ + { + "i": 1, + "reason": "Rush Delivery", + "amount": "419.44", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-charge": "AAT" + } + } + ], + "ordering": { + "code": "PO-AE-220", + "cost": "Regular sales", + "period": { + "start": "2025-01-31", + "end": "2025-02-06" + }, + "projects": [ + { + "code": "Regular work" + } + ], + "purchases": [ + { + "code": "PO-AE-220" + } + ], + "sales": [ + { + "code": "Salesorder-2122" + } + ], + "despatch": [ + { + "code": "Memo-1000" + } + ], + "tender": [ + { + "code": "PO-AE-220" + } + ] + }, + "payment": { + "payee": { + "name": "Payee Name", + "identities": [ + { + "scope": "legal", + "code": "1122334455" + } + ] + }, + "terms": { + "due_dates": [ + { + "date": "2025-02-13", + "amount": "11175.50", + "percent": "100%" + } + ], + "notes": "Within a week" + }, + "instructions": { + "key": "any", + "detail": "Debit Card", + "card": { + "last4": "1234", + "holder": "Card Holder Name" + }, + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "10486.00", + "discount": "262.15", + "charge": "419.44", + "total": "10643.29", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10643.29", + "percent": "5%", + "amount": "532.16" + } + ], + "amount": "532.16" + } + ], + "sum": "532.16" + }, + "tax": "532.16", + "total_with_tax": "11175.45", + "rounding": "0.05", + "payable": "11175.50" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "PO-AE-220", + "url": "https://www.site.ae/PO-AE-220.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/summary-invoice.json b/ubl/testdata/parse/pint/ae/out/summary-invoice.json new file mode 100644 index 0000000..108725f --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/summary-invoice.json @@ -0,0 +1,401 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "99dd606346f0374228082b5337f66b552acb6412d281fe9abae98c8bac8c3712" + }, + "from": "iso6523-actorid-upis::0235:1278906543", + "to": "iso6523-actorid-upis::0235:1347809543" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "summary" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-010TEST", + "issue_date": "2025-02-07", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00010000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Supplier Trade Name", + "tax_id": { + "country": "AE", + "code": "127890654301003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1278906543" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1278906543" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Abu Dhabi", + "region": "AUH", + "country": "AE" + } + ], + "emails": [ + { + "addr": "emailAddress" + } + ], + "telephones": [ + { + "num": "Contact number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Noor Electronics", + "tax_id": { + "country": "AE", + "code": "134780954301003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1347809543" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1347809543" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Emailaddress" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "100", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "11223344" + } + ], + "description": "Item Description", + "list": "15", + "discount": "0.75", + "price": "14.25", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "1425.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "1425.00" + }, + { + "i": 2, + "quantity": "150", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "224455" + } + ], + "description": "Item Description", + "list": "25", + "discount": "1.25", + "price": "23.75", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "3562.50", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "3562.50" + }, + { + "i": 3, + "quantity": "200", + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + }, + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "123456" + } + ], + "description": "Item Description", + "list": "30", + "discount": "1.5", + "price": "28.50", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "5700.00", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "5700.00" + }, + { + "i": 4, + "quantity": "30", + "period": { + "start": "2025-01-31", + "end": "2025-01-31" + }, + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "code": "34092834029", + "ext": { + "iso-scheme-id": "0160" + } + }, + { + "label": "HS", + "code": "88098432324" + } + ], + "description": "Item Description", + "list": "100", + "discount": "1", + "price": "99.00", + "unit": "kl", + "ext": { + "peppol-pint-ae-goods-type": "DL8.48.3.1", + "untdid-unit": "K6" + } + }, + "sum": "2970.00", + "taxes": [ + { + "cat": "VAT", + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + } + } + ], + "total": "2970.00" + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special rebate", + "amount": "80.16", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "ordering": { + "period": { + "start": "2025-01-31", + "end": "2025-02-07" + } + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-21", + "amount": "14108.00", + "percent": "100%" + } + ], + "notes": "Within 15 days" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "13657.50", + "discount": "80.16", + "total": "13577.34", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "10607.34", + "percent": "5%", + "amount": "530.37" + }, + { + "key": "reverse-charge", + "ext": { + "untdid-tax-category": "AE" + }, + "base": "2970.00", + "amount": "0.00" + } + ], + "amount": "530.37" + } + ], + "sum": "530.37" + }, + "tax": "530.37", + "total_with_tax": "14107.71", + "rounding": "0.29", + "payable": "14108.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "DC", + "url": "https://www.site.ae/deliverychallans.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/supply-free-trade-zone.json b/ubl/testdata/parse/pint/ae/out/supply-free-trade-zone.json new file mode 100644 index 0000000..7d624ea --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/supply-free-trade-zone.json @@ -0,0 +1,280 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "6bbf139c3a941859cf76a3891038641f7649c08ad5fd57b963b7b5152dd135d1" + }, + "from": "iso6523-actorid-upis::0235:1246801357", + "to": "iso6523-actorid-upis::0235:1789012345" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "$tags": [ + "free-trade-zone" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001FTZ-TEST", + "issue_date": "2025-02-07", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-beneficiary-id": "189098765401003", + "peppol-pint-ae-transaction-type": "10000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "tax_id": { + "country": "AE", + "code": "124680135701003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1246801357" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1246801357" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Sharjah", + "region": "SHJ", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer Legal Name", + "tax_id": { + "country": "AE", + "code": "178901234501003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1789012345" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1789012345" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "500", + "item": { + "key": "goods", + "name": "Item Name", + "identities": [ + { + "label": "HS", + "code": "112233" + } + ], + "description": "Item Description", + "list": "150", + "discount": "10", + "price": "140.00", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "70000.00", + "charges": [ + { + "reason": "Technical Modification", + "base": "70000.00", + "percent": "1%", + "amount": "700.00", + "ext": { + "untdid-charge": "AAC" + } + } + ], + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "total": "70700.00", + "notes": [ + { + "text": "Invoice line note" + } + ] + } + ], + "discounts": [ + { + "i": 1, + "reason": "Special Rebate", + "base": "70700", + "percent": "5%", + "amount": "3535", + "taxes": [ + { + "cat": "VAT", + "key": "standard", + "percent": "5%", + "ext": { + "untdid-tax-category": "S" + } + } + ], + "ext": { + "untdid-allowance": "100" + } + } + ], + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-03-07", + "amount": "70523.25", + "percent": "100%" + } + ], + "notes": "1 month" + }, + "instructions": { + "key": "credit-transfer", + "detail": "Credit transfer", + "credit_transfer": [ + { + "iban": "AE0000000001", + "bic": "236000", + "name": "current account" + } + ], + "ext": { + "untdid-payment-means": "30" + } + } + }, + "totals": { + "sum": "70700.00", + "discount": "3535.00", + "total": "67165.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "standard", + "ext": { + "untdid-tax-category": "S" + }, + "base": "67165.00", + "percent": "5%", + "amount": "3358.25" + } + ], + "amount": "3358.25" + } + ], + "sum": "3358.25" + }, + "tax": "3358.25", + "total_with_tax": "70523.25", + "payable": "70523.25" + }, + "notes": [ + { + "text": "Tax invoice" + } + ], + "attachments": [ + { + "code": "Sample-04", + "url": "https://www.site.ae/Sample-04.pdf" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/out/zero-rated.json b/ubl/testdata/parse/pint/ae/out/zero-rated.json new file mode 100644 index 0000000..e0c8d1f --- /dev/null +++ b/ubl/testdata/parse/pint/ae/out/zero-rated.json @@ -0,0 +1,226 @@ +{ + "$schema": "https://gobl.org/draft-0/envelope", + "head": { + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "dig": { + "alg": "sha256", + "val": "62f2c887df133158832a40fbaea30939c121caac7f0365a23e75485007efaace" + }, + "from": "iso6523-actorid-upis::0235:1987654321", + "to": "iso6523-actorid-upis::0235:1347809543" + }, + "doc": { + "$schema": "https://gobl.org/draft-0/bill/invoice", + "$regime": "AE", + "$addons": [ + "eu-en16931-v2017", + "peppol-pint-v1" + ], + "uuid": "0195ce71-dc9c-72c8-bf2c-9890a4a9f0a2", + "type": "standard", + "code": "AE-001-ZeroRated-TEST", + "issue_date": "2025-02-07", + "issue_time": "17:31:00", + "value_date": "2025-01-31", + "currency": "AED", + "tax": { + "rounding": "currency", + "ext": { + "peppol-pint-ae-transaction-type": "00000000", + "untdid-document-type": "380" + } + }, + "supplier": { + "name": "Supplier Legal Name", + "alias": "Seller Trade Name", + "tax_id": { + "country": "AE", + "code": "132654987101003" + }, + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345678900003", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1987654321" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1987654321" + } + ], + "addresses": [ + { + "street": "Street Name", + "locality": "Dubai", + "region": "DXB", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ], + "telephones": [ + { + "num": "Contact Number" + } + ], + "registration": { + "other": "Merchant" + } + }, + "customer": { + "name": "Buyer legal Name", + "alias": "Buyer Legal Name", + "identities": [ + { + "scope": "legal", + "type": "TL", + "code": "112345679000001", + "description": "Trade License issuing Authority" + } + ], + "people": [ + { + "name": { + "given": "Contact Name" + } + } + ], + "endpoints": [ + { + "uri": "iso6523-actorid-upis::0235:1347809543" + } + ], + "inboxes": [ + { + "scheme": "0235", + "code": "1347809543" + } + ], + "addresses": [ + { + "street": "Street Name", + "street_extra": "Additional Street Name", + "locality": "Dubai", + "region": "DXB", + "code": "Postal code", + "country": "AE" + } + ], + "emails": [ + { + "addr": "Email Address" + } + ] + }, + "lines": [ + { + "i": 1, + "quantity": "5000", + "item": { + "name": "Item Name", + "description": "Item Description", + "list": "50", + "discount": "0.25", + "price": "49.75", + "unit": "piece", + "ext": { + "untdid-unit": "H87" + } + }, + "sum": "248750.00", + "taxes": [ + { + "cat": "VAT", + "key": "zero", + "percent": "0%", + "ext": { + "untdid-tax-category": "Z" + } + } + ], + "total": "248750.00" + } + ], + "ordering": { + "purchases": [ + { + "code": "EXP-09" + } + ], + "sales": [ + { + "code": "EC-24-25-1001" + } + ] + }, + "payment": { + "terms": { + "due_dates": [ + { + "date": "2025-02-22", + "amount": "248750.00", + "percent": "100%" + } + ], + "notes": "within 15 days" + }, + "instructions": { + "key": "any", + "detail": "Instrument Not Defined", + "ext": { + "untdid-payment-means": "1" + } + } + }, + "totals": { + "sum": "248750.00", + "total": "248750.00", + "taxes": { + "categories": [ + { + "code": "VAT", + "rates": [ + { + "key": "zero", + "ext": { + "untdid-tax-category": "Z" + }, + "base": "248750.00", + "percent": "0%", + "amount": "0.00" + } + ], + "amount": "0.00" + } + ], + "sum": "0.00" + }, + "tax": "0.00", + "total_with_tax": "248750.00", + "payable": "248750.00" + }, + "notes": [ + { + "text": "Tax invoice" + } + ] + } +} \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/reverse-charge.xml b/ubl/testdata/parse/pint/ae/reverse-charge.xml new file mode 100644 index 0000000..0cec993 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/reverse-charge.xml @@ -0,0 +1,162 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-01RCTEST + 9281afd3-613b-44ef-96aa-37a46e42a88e + 2025-02-07 + 2025-02-21 + 380 + Tax invoice + AED + + DC + + + https://www.site.ae/deliverychallans.pdf + + + + + Delivery Challans + + PmFzZTY0IKNvbnRlbnQgZXhhbXBsZQ== + + + + + 1278906543 + + Supplier Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 127890654301003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact number + emailAddress + + + + + + 1347809543 + + Street Name + Sharjah + SHJ + + AE + + + + 134780954301003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Emailaddress + + + + + 30 + + AE0000000001 + current account + + 236000 + + + + + Within 15 days + + + 0 + false + + 2970 + 0 + + AE + 5 + + VAT + + + + + + 2970 + 2970 + 2970 + 2970 + + + 1 + 30 + 2970 + + Item Description + Item Name + + 324243424 + + + DL8.48.3.1 + 88098432324 + + + AE + 5 + + VAT + + + + + 99 + 1 + + false + 1 + 100 + + + + 2970 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/seller-pas-identifier.xml b/ubl/testdata/parse/pint/ae/seller-pas-identifier.xml new file mode 100644 index 0000000..54836c1 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/seller-pas-identifier.xml @@ -0,0 +1,145 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-SELLER-PAS-01 + a1b2c3d4-e5f6-7890-abcd-110000000011 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + Seller Legal Name + P9876543210 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + 50 + false + + 1000 + 50 + + S + 5 + + VAT + + + + + + 1000 + 1000 + 1050 + 1050 + + + 1 + 10 + 1000 + + Standard rated goods + Electronic Components + + S + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1050 + + 50 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/seller-tin-identifier.xml b/ubl/testdata/parse/pint/ae/seller-tin-identifier.xml new file mode 100644 index 0000000..dbb6c59 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/seller-tin-identifier.xml @@ -0,0 +1,151 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-SELLER-TIN-01 + a1b2c3d4-e5f6-7890-abcd-100000000010 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + 198765432102003 + + VAT + + + + 1234567890 + + TIN + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + 50 + false + + 1000 + 50 + + S + 5 + + VAT + + + + + + 1000 + 1000 + 1050 + 1050 + + + 1 + 10 + 1000 + + Standard rated goods + Electronic Components + + S + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1050 + + 50 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/seller-trn-tin-identifiers.xml b/ubl/testdata/parse/pint/ae/seller-trn-tin-identifiers.xml new file mode 100644 index 0000000..751cba7 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/seller-trn-tin-identifiers.xml @@ -0,0 +1,155 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-SELLER-TRN-TIN-01 + a1b2c3d4-e5f6-7890-abcd-100000000014 + 2025-03-15 + 2025-03-30 + 380 + Tax invoice - Seller carrying both a VAT registration (TRN) and a non-VAT tax registration (TIN) + 2025-03-10 + AED + + + 1987654321 + + Seller Trade Name + + + Al Maktoum Road + Dubai + DXB + + AE + + + + + 198765432102003 + + VAT + + + + + 1234567892 + + TAX + + + + Seller Legal Name + 112345678900003 + Merchant + + + Contact Name + +971501234567 + seller@example.ae + + + + + + 1345678901 + + Buyer Trade Name + + + Khalifa Street + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Buyer Contact + +971502345678 + buyer@example.ae + + + + + 30 + + AE070331234567890123456 + current account + + ABORAEADXXX + + + + + Net 15 days + + + 50 + false + + 1000 + 50 + + S + 5 + + VAT + + + + + + 1000 + 1000 + 1050 + 1050 + + + 1 + 10 + 1000 + + Standard rated goods + Electronic Components + + S + 5 + + VAT + + + + + 100 + 1 + + false + 0 + 100 + + + + 1050 + + 50 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/standard-invoice-extensive.xml b/ubl/testdata/parse/pint/ae/standard-invoice-extensive.xml new file mode 100644 index 0000000..83d4017 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/standard-invoice-extensive.xml @@ -0,0 +1,687 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 10001010 + INV-001/2025 + 4b6000ca-0128-4bdc-99a6-406f2909247f + 2025-01-30 + 18:24:10+04:00 + 2025-02-13 + 380 + Tax invoice + 2025-01-29 + AED + 4025:123:4343 + BR-001/23 + + 2025-01-30 + 2025-01-30 + OTH + + + PO-001/23 + SO-001/23 + + + + INV-1001/2022 + 2025-01-30 + + + + DAR-001/23 + + + RAR-001/23 + + + LR-001/23 + + + BR-001/23 + AED200000 + + + DR-INV-001 + Invoice is enclosed + + + https://www.site.ae/invoices.pdf + + + + + DR-INV-02 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + BR-001/23 + + + + 112345678900003 + + Supplier Trade Name + + + Al Bateen Street + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address line + + + AE + + + + 112345678900003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contct Name + Contact Number + Email Address + + + + + + 112345679000003 + + Buyer Trade Name + + + Khalifa street + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Additional Address Line + + + AE + + + + 112345679000003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email Address + + + + + + 132345679670003 + + + Payee Party Name + + + 112345679350001 + + + + + + 189098765401003 + + + + + + Seller Tax Representative Party Name + + + Al Bateen Street + Additional Street Name + Abu Dhabi + Postal Zonw + AUH + + Address line + + + AE + + + + 123349792700003 + + VAT + + + + + 2025-01-30 + + 112345679000003 + + Khalifa street + Additional Street Name + Abu Dhabi + Postal Zone + AUH + + Text + + + AE + + + + + + Delivery Party Name + + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + AE0000000001 + current account + + 236000 + + + + 2025-01-30 + + + + 15 days + + + false + 95 + Discount + 1.5 + 273.75 + 18250 + + S + 5 + + VAT + + + + + false + 95 + Discount + 50 + 2451.25 + 4902.5 + + S + 5 + + VAT + + + + + true + AAC + Technical Modification + 4 + 79 + 1975 + + S + 5 + + VAT + + + + + 115.70 + false + + 2314 + 115.70 + + S + 5 + + VAT + + + + + 3900 + 0 + + E + + VAT + + + + + 4432.50 + 0 + + O + + VAT + + + + + 3040 + 0 + + AE + 5 + + VAT + + + + + 1975 + 0 + + Z + 0 + + VAT + + + + + + 18307.50 + 15661.50 + 15777.20 + 2725 + 79 + 10000 + 0.30 + 5777.50 + + + 1 + Please check the invoice + 5 + 4960 + ABC-001 + + 2025-01-30 + 2025-01-30 + + + st-nar-1 + + PO-001/23 + + + + false + 95 + Discount + 1 + 50 + 5000 + + + true + AAC + Technical Modification + 10 + + + Item Description + Item Name + + art-to-001 + + + art-p-001 + + + 04012345123456 + + + AE + + + G + 88098432324 + + + S + 5 + + VAT + + + + colour + red + + + + 1000 + 1 + + false + 0 + 1000 + + + + 5208 + + 248 + + + + + 2 + 10 + 3900 + + false + 95 + Discount + 2 + 80 + 4000 + + + true + AAV + Special Construction + 20 + + + Item Description + Item Name + + AE + + + G + 1101 + + + E + DL8.46.2 + Supply of residential units (lease or sale) + + VAT + + + + + 1980 + 5 + + false + 20 + 2000 + + + + 3900 + + + + 3 + Please check the invoice + 15 + 4432.50 + CS-024 + + 2025-01-30 + 2025-01-30 + + + st-nar-1 + + PO-001/23 + + + + false + 95 + Discount + 135 + + + true + AAC + Technical Modification + 2.5 + 112.5 + 4500 + + + Item Description + Item Name + + art-to-001 + + + art-p-001 + + + AE + + + G + 3450 + + + O + + VAT + + + + Item Additional Name + Item Additional Value + + + + 2970 + 10 + + false + 30 + 3000 + + + + 4432.50 + + 0 + + + + + 4 + Please check the invoice + 20 + 3040 + CS-024 + + 2025-01-30 + 2025-01-30 + + + st-nar-1 + + PO-001/23 + + + + false + 95 + Discount + 4 + 128 + 3200 + + + Item Description + Item Name + + art-to-001 + + + art-p-001 + + + 04012345123456 + + + AE + + + DL8.48.3.1 + G + 5000 + + + AE + 5 + + VAT + + + + Item Additional Name + Item Additional Value + + + + 158.4 + 1 + + false + 0 + 158.4 + + + + 3040 + + 0 + + + + + 5 + Please check the invoice + 25 + 1975 + CS-024 + + 2025-01-30 + 2025-01-30 + + + st-nar-1 + + PO-001/23 + + + + false + 95 + Discount + 625 + + + true + AAC + Technical Modification + 5 + 125 + 2500 + + + Item Description + Item Name + + art-to-001 + + + art-p-001 + + + 04012345123456 + + + AE + + + G + 8680 + + + Z + 0 + + VAT + + + + Item Additional Name + Item Additional Value + + + + 4950 + 50 + + false + 50 + 5000 + + + + 1975 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/standard-invoice-predefined-endpoint.xml b/ubl/testdata/parse/pint/ae/standard-invoice-predefined-endpoint.xml new file mode 100644 index 0000000..7b45fb8 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/standard-invoice-predefined-endpoint.xml @@ -0,0 +1,264 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-01TEST + f12f329f-6430-4399-b661-7c5cd9c3a9e6 + 2025-02-06 + 07:54:00+04:00 + 2025-02-13 + 380 + Tax invoice + 2025-01-30 + AED + Regular sales + PO-AE-220 + + 2025-01-31 + 2025-02-06 + + + PO-AE-220 + Salesorder-2122 + + + + INV-234-2025 + 2025-02-06 + + + + Memo-1000 + + + PO-AE-220 + + + PO-AE-220 + + + https://www.site.ae/PO-AE-220.pdf + + + + + PO-AE-220 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + Regular work + + + + 1987654321 + + Party Trade Name + + + Street Name + Sharjah + SHJ + + AE + + + + 198765432102003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Telephone number + Email address + + + + + + 9900000098 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Noor Electronics + 112345679000001 + + + Contact Name + Telephone number + Email address + + + + + + Payee Name + + + 1122334455 + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + Within a week + + + false + 100 + Special Rebate + 2.5 + 262.15 + 10486 + + S + 5 + + VAT + + + + + true + AAT + Rush Delivery + 4 + 419.44 + 10486 + + S + 5 + + VAT + + + + + 532.16 + false + + 10643.29 + 532.1645 + + S + 5 + + VAT + + + + + + 10486 + 10643.29 + 11175.45 + 262.15 + 419.44 + 0.05 + 11175.5 + + + 1 + All items + 2000 + 10486 + + 2025-01-31 + 2025-01-31 + + + 1 + + PO-AE-220 + + + + false + 95 + Discount + 3 + 294 + 9800 + + + true + AAC + Technical Modification + 10 + 980 + 9800 + + + Item Description + Item Name + + Purchase goods + + + Sales Goods + + + AE + + + S + 5 + + VAT + + + + Item details + Item Value + + + + 4.9 + 1 + + false + 0.1 + 5 + + + + 11010.3 + + 524.3 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/standard-invoice.xml b/ubl/testdata/parse/pint/ae/standard-invoice.xml new file mode 100644 index 0000000..07e027a --- /dev/null +++ b/ubl/testdata/parse/pint/ae/standard-invoice.xml @@ -0,0 +1,124 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE001-Test + 4b6000ca-0128-4bdc-99a6-406f2909247f + 2025-01-30 + 2025-02-06 + 380 + AED + + + 1357902468 + + Street Name + City Name + DXB + + AE + + + + 135790246801003 + + VAT + + + + Supplier Legal Name + 112345678900003 + + + + + 1345678901 + + Street Name + CityName + AUH + + AE + + + + 134567890123003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + 50 + false + + 1000 + 50 + + S + 5 + + VAT + + + + + + 1000 + 1000 + 1050 + 1050 + + + 1 + 100 + 1000 + + Item Description + Item Name + + G + aaa + + + S + 5 + + VAT + + + + + 10 + 1 + + false + 0 + 10 + + + + 1050 + + 50 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/standard-tax-invoice.xml b/ubl/testdata/parse/pint/ae/standard-tax-invoice.xml new file mode 100644 index 0000000..0d850bf --- /dev/null +++ b/ubl/testdata/parse/pint/ae/standard-tax-invoice.xml @@ -0,0 +1,264 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-01TEST + f12f329f-6430-4399-b661-7c5cd9c3a9e6 + 2025-02-06 + 07:54:00+04:00 + 2025-02-13 + 380 + Tax invoice + 2025-01-30 + AED + Regular sales + PO-AE-220 + + 2025-01-31 + 2025-02-06 + + + PO-AE-220 + Salesorder-2122 + + + + INV-234-2025 + 2025-02-06 + + + + Memo-1000 + + + PO-AE-220 + + + PO-AE-220 + + + https://www.site.ae/PO-AE-220.pdf + + + + + PO-AE-220 + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + Regular work + + + + 1987654321 + + Party Trade Name + + + Street Name + Sharjah + SHJ + + AE + + + + 198765432102003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Telephone number + Email address + + + + + + 1345678901 + + Buyer Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 134567890123003 + + VAT + + + + Noor Electronics + 112345679000001 + + + Contact Name + Telephone number + Email address + + + + + + Payee Name + + + 1122334455 + + + + 55 + + XXXXXXXXXXXX1234 + VISA + Card Holder Name + + + + Within a week + + + false + 100 + Special Rebate + 2.5 + 262.15 + 10486 + + S + 5 + + VAT + + + + + true + AAT + Rush Delivery + 4 + 419.44 + 10486 + + S + 5 + + VAT + + + + + 532.16 + false + + 10643.29 + 532.1645 + + S + 5 + + VAT + + + + + + 10486 + 10643.29 + 11175.45 + 262.15 + 419.44 + 0.05 + 11175.5 + + + 1 + All items + 2000 + 10486 + + 2025-01-31 + 2025-01-31 + + + 1 + + PO-AE-220 + + + + false + 95 + Discount + 3 + 294 + 9800 + + + true + AAC + Technical Modification + 10 + 980 + 9800 + + + Item Description + Item Name + + Purchase goods + + + Sales Goods + + + AE + + + S + 5 + + VAT + + + + Item details + Item Value + + + + 4.9 + 1 + + false + 0.1 + 5 + + + + 11010.3 + + 524.3 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/summary-invoice.xml b/ubl/testdata/parse/pint/ae/summary-invoice.xml new file mode 100644 index 0000000..bf6353d --- /dev/null +++ b/ubl/testdata/parse/pint/ae/summary-invoice.xml @@ -0,0 +1,316 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00010000 + AE-010TEST + 108f8b54-9d31-461f-b9be-1de67837f4d4 + 2025-02-07 + 2025-02-21 + 380 + Tax invoice + AED + + 2025-01-31 + 2025-02-07 + + + DC + + + https://www.site.ae/deliverychallans.pdf + + + + + Delivery Challans + + JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA1OTUgODQyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA1IDAgUiA+PiA+PiAvQ29udGVudHMgNCAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCA0OCA+PgpzdHJlYW0KQlQgL0YxIDE0IFRmIDcyIDc3MCBUZCAoU2FtcGxlIGF0dGFjaG1lbnQpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzM5IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1NpemUgNiAvUm9vdCAxIDAgUiA+PgpzdGFydHhyZWYKNDA5CiUlRU9GCg== + + + + + 1278906543 + + Supplier Trade Name + + + Street Name + Abu Dhabi + AUH + + AE + + + + 127890654301003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact number + emailAddress + + + + + + 1347809543 + + Street Name + Sharjah + SHJ + + AE + + + + 134780954301003 + + VAT + + + + Noor Electronics + 112345679000001 + + + Contact Name + Contact Number + Emailaddress + + + + + 30 + + AE0000000001 + current account + + 236000 + + + + + Within 15 days + + + false + 100 + Special rebate + 0.75 + 80.16 + 10687.5 + + S + 5 + + VAT + + + + + 530.37 + false + + 10607.34 + 530.367 + + S + 5 + + VAT + + + + + 2970 + 0 + + AE + 5 + + VAT + + + + + + 13657.5 + 13577.34 + 14107.71 + 80.16 + 0.29 + 14108 + + + 1 + 100 + 1425 + + 2025-01-31 + 2025-02-07 + + + Item Description + Item Name + + G + 11223344 + + + S + 5 + + VAT + + + + + 14.25 + 1 + + false + 0.75 + 15 + + + + 1496.25 + + 71.25 + + + + + 2 + 150 + 3562.5 + + 2025-01-31 + 2025-02-07 + + + Item Description + Item Name + + G + 224455 + + + S + 5 + + VAT + + + + + 23.75 + 1 + + false + 1.25 + 25 + + + + 3740.625 + + 178.125 + + + + + 3 + 200 + 5700 + + 2025-01-31 + 2025-02-07 + + + Item Description + Item Name + + G + 123456 + + + S + 5 + + VAT + + + + + 28.5 + 1 + + false + 1.5 + 30 + + + + 5985 + + 285 + + + + + 4 + 30 + 2970 + + 2025-01-31 + 2025-01-31 + + + Item Description + Item Name + + 34092834029 + + + DL8.48.3.1 + G + 88098432324 + + + AE + 5 + + VAT + + + + + 99 + 1 + + false + 1 + 100 + + + + 2970 + + 0 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/supply-free-trade-zone.xml b/ubl/testdata/parse/pint/ae/supply-free-trade-zone.xml new file mode 100644 index 0000000..4d19232 --- /dev/null +++ b/ubl/testdata/parse/pint/ae/supply-free-trade-zone.xml @@ -0,0 +1,188 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 10000000 + AE-001FTZ-TEST + 3666341e-86b7-4f4d-a14f-dd56d59b7606 + 2025-02-07 + 2025-03-07 + 380 + Tax invoice + AED + + Sample-04 + + + https://www.site.ae/Sample-04.pdf + + + + + Sample-04 + + JmFzZTY0IKNvbnRlbnQgZXhhbXBsZQ== + + + + + 1246801357 + + Street Name + Sharjah + SHJ + + AE + + + + 124680135701003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email Address + + + + + + 1789012345 + + Street Name + Dubai + DXB + + AE + + + + 178901234501003 + + VAT + + + + Buyer Legal Name + 112345679000001 + + + Contact Name + Contact Number + Email address + + + + + + + 189098765401003 + + + + + 30 + + AE0000000001 + current account + + 236000 + + + + + 1 month + + + false + 100 + Special Rebate + 5 + 3535 + 70700 + + S + 5 + + VAT + + + + + 3358.25 + false + + 67165 + 3358.25 + + S + 5 + + VAT + + + + + + 70700 + 67165 + 70523.25 + 3535 + 70523.25 + + + 1 + Invoice line note + 500 + 70700 + + true + AAC + Technical Modification + 1 + 700 + 70000 + + + Item Description + Item Name + + G + 112233 + + + S + 5 + + VAT + + + + + 140 + 1 + + false + 10 + 150 + + + + 74235 + + 3535 + + + + \ No newline at end of file diff --git a/ubl/testdata/parse/pint/ae/zero-rated.xml b/ubl/testdata/parse/pint/ae/zero-rated.xml new file mode 100644 index 0000000..daf4dfb --- /dev/null +++ b/ubl/testdata/parse/pint/ae/zero-rated.xml @@ -0,0 +1,138 @@ + + + urn:peppol:pint:billing-1@ae-1 + urn:peppol:bis:billing + 00000000 + AE-001-ZeroRated-TEST + 65a5426a-b9ee-4190-9db7-1ada969b3eb2 + 2025-02-07 + 17:31:00+04:00 + 2025-02-22 + 380 + Tax invoice + 2025-01-31 + AED + + EXP-09 + EC-24-25-1001 + + + + 1987654321 + + Seller Trade Name + + + Street Name + Dubai + DXB + + AE + + + + 132654987101003 + + VAT + + + + Supplier Legal Name + 112345678900003 + Merchant + + + Contact Name + Contact Number + Email Address + + + + + + 1347809543 + + Buyer Legal Name + + + Street Name + Additional Street Name + Dubai + Postal code + DXB + + AE + + + + Buyer legal Name + 112345679000001 + + + Contact Name + Email Address + + + + + 1 + + + within 15 days + + + 0 + false + + 248750 + 0 + + Z + 0 + + VAT + + + + + + 248750 + 248750 + 248750 + 248750 + + + 1 + 5000 + 248750 + + Item Description + Item Name + + Z + 0 + + VAT + + + + + 49.75 + 1 + + false + 0.25 + 50 + + + + 248750 + + 0 + + + + \ No newline at end of file diff --git a/ubl/ubl.go b/ubl/ubl.go index c9cb07f..f220e52 100644 --- a/ubl/ubl.go +++ b/ubl/ubl.go @@ -26,6 +26,8 @@ const ( KeyPINT cbc.Key = "ubl+peppol+pint-v1" // KeyAUNZ identifies the Peppol PINT A-NZ format. KeyAUNZ cbc.Key = "ubl+peppol+pint+aunz-v1" + // KeyAE identifies the Peppol PINT AE format. + KeyAE cbc.Key = "ubl+peppol+pint+ae-v1" ) var ( @@ -92,8 +94,8 @@ var FormatPINT = goblubl.Format{ ProfileID: "urn:peppol:bis:billing", Addons: []cbc.Key{pint.V1}, VESIDs: goblubl.VESIDMapping{ - Invoice: "org.peppol.pint:invoice:1.1.2", - CreditNote: "org.peppol.pint:credit-note:1.1.2", + Invoice: "org.peppol.pint:invoice:1.1.3", + CreditNote: "org.peppol.pint:credit-note:1.1.3", }, ImportFuncs: []goblubl.ImportFunc{importPINT, importEndpoints}, // A jurisdiction specialization no dedicated format claimed still follows @@ -113,8 +115,8 @@ var FormatAUNZ = goblubl.Format{ ProfileID: "urn:peppol:bis:billing", Addons: []cbc.Key{pint.V1}, VESIDs: goblubl.VESIDMapping{ - Invoice: "org.peppol.pint.aunz:invoice:1.1.2", - CreditNote: "org.peppol.pint.aunz:creditnote:1.1.2", + Invoice: "org.peppol.pint.aunz:invoice:1.1.3", + CreditNote: "org.peppol.pint.aunz:creditnote:1.1.3", }, Specifications: []goblubl.Specification{ SpecificationAUNZSelfBilling, @@ -130,8 +132,45 @@ var SpecificationAUNZSelfBilling = goblubl.Specification{ ProfileID: "urn:peppol:bis:selfbilling", Addons: []cbc.Key{pint.V1}, VESIDs: goblubl.VESIDMapping{ - Invoice: "org.peppol.pint.aunz:invoice-self-billing:1.1.2", - CreditNote: "org.peppol.pint.aunz:creditnote-self-billing:1.1.2", + Invoice: "org.peppol.pint.aunz:invoice-self-billing:1.1.3", + CreditNote: "org.peppol.pint.aunz:creditnote-self-billing:1.1.3", + }, + Applies: isSelfBilled, +} + +// FormatAE defines the Peppol PINT AE format. Invoices are written with +// PINT AE Billing, and self-billed invoices with PINT AE Self-Billing. +var FormatAE = goblubl.Format{ + Key: KeyAE, + Name: i18n.NewString("UBL Peppol PINT AE 1"), + Countries: []l10n.Code{l10n.AE}, + Import: []schema.ID{invoiceSchema}, + Export: []schema.ID{invoiceSchema}, + CustomizationID: "urn:peppol:pint:billing-1@ae-1", + ProfileID: "urn:peppol:bis:billing", + Addons: []cbc.Key{pint.V1}, + VESIDs: goblubl.VESIDMapping{ + Invoice: "org.peppol.pint.ae:invoice:2026.11", + CreditNote: "org.peppol.pint.ae:creditnote:2026.11", + }, + Specifications: []goblubl.Specification{ + SpecificationAESelfBilling, + }, + ExportFuncs: []goblubl.ExportFunc{exportAE}, + // No importPINT: it reads a non-VAT tax registration as the tax ID, which in PINT AE is the seller's TIN. + ImportFuncs: []goblubl.ImportFunc{importAE, importEndpoints}, + Match: matchCustomization("urn:peppol:pint:billing-1@ae-1", "urn:peppol:pint:selfbilling-1@ae-1"), +} + +// SpecificationAESelfBilling is Peppol PINT AE Self-Billing, used for +// self-billed invoices. +var SpecificationAESelfBilling = goblubl.Specification{ + CustomizationID: "urn:peppol:pint:selfbilling-1@ae-1", + ProfileID: "urn:peppol:bis:selfbilling", + Addons: []cbc.Key{pint.V1}, + VESIDs: goblubl.VESIDMapping{ + Invoice: "org.peppol.pint.ae:invoice-self-billing:2026.11", + CreditNote: "org.peppol.pint.ae:creditnote-self-billing:2026.11", }, Applies: isSelfBilled, } @@ -157,5 +196,5 @@ func isSelfBilled(doc any) bool { } func init() { - goblubl.RegisterFormats(FormatBIS, FormatPINT, FormatAUNZ) + goblubl.RegisterFormats(FormatBIS, FormatPINT, FormatAUNZ, FormatAE) } diff --git a/ubl/ubl_test.go b/ubl/ubl_test.go index 82c179e..acd778a 100644 --- a/ubl/ubl_test.go +++ b/ubl/ubl_test.go @@ -1,6 +1,8 @@ package ubl_test import ( + "path/filepath" + "regexp" "testing" "github.com/invopop/gobl.peppol/addon/pint" @@ -10,6 +12,8 @@ import ( "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/convert" "github.com/invopop/gobl/l10n" + "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/ae" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -64,7 +68,7 @@ func TestExport(t *testing.T) { } // TestDetectPINTFallback checks that a PINT jurisdiction with no dedicated -// format falls back to the base billing one, while A-NZ keeps its own. +// format falls back to the base billing one, while A-NZ and AE keep their own. func TestDetectPINTFallback(t *testing.T) { f := ubl.FindFormat(peppolubl.FormatPINT.CustomizationID+"@jp-1", peppolubl.FormatPINT.ProfileID) require.NotNil(t, f) @@ -77,6 +81,10 @@ func TestDetectPINTFallback(t *testing.T) { f = ubl.FindFormat(peppolubl.SpecificationAUNZSelfBilling.CustomizationID, peppolubl.SpecificationAUNZSelfBilling.ProfileID) require.NotNil(t, f) assert.Equal(t, peppolubl.KeyAUNZ, f.Key) + // AE has its own format, so the fallback doesn't claim it. + f = ubl.FindFormat(peppolubl.FormatPINT.CustomizationID+"@ae-1", peppolubl.FormatPINT.ProfileID) + require.NotNil(t, f) + assert.Equal(t, peppolubl.KeyAE, f.Key) } // TestSpecificationAUNZSelfBilling checks that self-billed invoices are @@ -97,3 +105,205 @@ func TestSpecificationAUNZSelfBilling(t *testing.T) { assert.Equal(t, peppolubl.SpecificationAUNZSelfBilling.CustomizationID, s.CustomizationID) assert.Equal(t, peppolubl.SpecificationAUNZSelfBilling.ProfileID, s.ProfileID) } + +// TestFormatAE checks that the PINT AE format is registered for the UAE and +// claims its own documents, both billing and self-billing. +func TestFormatAE(t *testing.T) { + f := convert.FormatFor(peppolubl.KeyAE) + require.NotNil(t, f) + assert.Equal(t, []l10n.Code{l10n.AE}, f.Countries) + + keys := make([]cbc.Key, 0) + for _, c := range convert.FormatsFor(l10n.AE) { + keys = append(keys, c.Key) + } + assert.Contains(t, keys, peppolubl.KeyAE) + + for _, id := range []string{peppolubl.FormatAE.CustomizationID, peppolubl.SpecificationAESelfBilling.CustomizationID} { + found := ubl.FindFormat(id, "") + require.NotNil(t, found, id) + assert.Equal(t, peppolubl.KeyAE, found.Key, id) + } +} + +// TestDetectAndImportAE checks that an official PINT AE example is detected +// as PINT AE and imported with the PINT addon. +func TestDetectAndImportAE(t *testing.T) { + data, err := testLoadXML("pint/ae/standard-invoice.xml") + require.NoError(t, err) + + f, err := convert.Detect(data) + require.NoError(t, err) + assert.Equal(t, peppolubl.KeyAE, f.Key) + + res, err := convert.Import(data) + require.NoError(t, err) + inv, ok := res.Envelope.Extract().(*bill.Invoice) + require.True(t, ok) + assert.Contains(t, inv.GetAddons(), pint.V1) + assert.Equal(t, l10n.TaxCountryCode("AE"), inv.GetRegime()) +} + +// importFaultsAE are the faults the official PINT AE examples give once +// imported. They pass the PINT AE Schematron, but their data is made up: the +// TRNs and TINs fail the check digit the Federal Tax Authority defines (the +// supplier gets no TIN from such a TRN), and some email addresses are +// placeholders. Any other fault is a defect in the +// import. margin-scheme-credit-note.xml is the official margin scheme +// example turned into a credit note, as there is no official one. +var importFaultsAE = map[string][]string{ + "allowance-exempt.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "allowance-outside-scope.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "allowance-reverse-charge.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "allowance-zero-rated.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "buyer-pas-identifier.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "charge-exempt.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "charge-outside-scope.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "charge-reverse-charge.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "charge-zero-rated.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "commercial-invoice.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "continuous-supplies.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "credit-note-disclosed-agent.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "credit-note-standard.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "credit-note-volume-discount.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "deemed-supply.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "disclosed-agent-billing.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "e-commerce.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "exports-predefined-endpoint.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "exports.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "margin-scheme-credit-note.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "margin-scheme.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "reverse-charge.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "seller-pas-identifier.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "seller-tin-identifier.xml": {"GOBL-AE-ORG-IDENTITY-02", "GOBL-AE-TAX-IDENTITY-02"}, + "seller-trn-tin-identifiers.xml": {"GOBL-AE-ORG-IDENTITY-02", "GOBL-AE-TAX-IDENTITY-02"}, + "standard-invoice-extensive.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "standard-invoice-predefined-endpoint.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "standard-invoice.xml": {"GOBL-AE-TAX-IDENTITY-02"}, + "standard-tax-invoice.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "summary-invoice.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "supply-free-trade-zone.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, + "zero-rated.xml": {"GOBL-AE-TAX-IDENTITY-02", "GOBL-ORG-EMAIL-02"}, +} + +// faultCodePattern matches the fault codes in a validation error. +var faultCodePattern = regexp.MustCompile(`\[(GOBL-[A-Z0-9-]+)\]`) + +// TestImportAEFaults checks that the official PINT AE examples import with +// no faults beyond the ones their made-up data gives. +func TestImportAEFaults(t *testing.T) { + examples, err := filepath.Glob(filepath.Join("testdata", "parse", "pint", "ae", "*.xml")) + require.NoError(t, err) + require.Len(t, examples, len(importFaultsAE)) + for _, example := range examples { + name := filepath.Base(example) + t.Run(name, func(t *testing.T) { + env := parseXMLInvoice(t, filepath.Join("pint", "ae", name)) + require.NoError(t, env.Calculate()) + err := env.Validate() + require.Error(t, err) + var got []string + for _, m := range faultCodePattern.FindAllStringSubmatch(err.Error(), -1) { + got = append(got, m[1]) + } + assert.ElementsMatch(t, importFaultsAE[name], got) + }) + } +} + +// TestRoundTripAE checks that each AE convert example gives the same XML +// after an import and a second export, so whatever FormatAE writes it also +// reads back. +func TestRoundTripAE(t *testing.T) { + examples, err := filepath.Glob(filepath.Join("testdata", "convert", "pint", "ae", "*.json")) + require.NoError(t, err) + require.NotEmpty(t, examples) + for _, example := range examples { + name := filepath.Base(example) + t.Run(name, func(t *testing.T) { + env := loadTestEnvelope(t, filepath.Join("pint", "ae", name)) + doc, err := ubl.ExportInvoice(env, ubl.WithFormat(peppolubl.FormatAE)) + require.NoError(t, err) + first, err := ubl.Encode(doc) + require.NoError(t, err) + + in, err := ubl.Decode(first) + require.NoError(t, err) + out, err := ubl.Import(in) + require.NoError(t, err) + require.NoError(t, out.Calculate()) + require.NoError(t, out.Validate()) + doc, err = ubl.ExportInvoice(out, ubl.WithFormat(peppolubl.FormatAE)) + require.NoError(t, err) + second, err := ubl.Encode(doc) + require.NoError(t, err) + + assert.Equal(t, string(first), string(second)) + }) + } +} + +// TestImportAESellerTIN checks that a seller with a TIN and no TRN, as out of +// scope documents allow, keeps the TIN as a tax registration when imported, +// instead of getting it as its tax ID. +func TestImportAESellerTIN(t *testing.T) { + env := loadTestEnvelope(t, "pint/ae/invoice-ae-outside-scope.json") + inv, ok := env.Extract().(*bill.Invoice) + require.True(t, ok) + // The fixture's supplier has its TIN as a tax identity; without the TRN, + // the TIN is its only tax registration. + inv.Supplier.TaxID = &tax.Identity{Country: "AE"} + require.NoError(t, env.Calculate()) + require.NoError(t, env.Validate()) + + doc, err := ubl.ExportInvoice(env, ubl.WithFormat(peppolubl.FormatAE)) + require.NoError(t, err) + out, err := ubl.Import(doc) + require.NoError(t, err) + supplier := out.Extract().(*bill.Invoice).Supplier + assert.Nil(t, supplier.TaxID) + var tin *org.Identity + for _, id := range supplier.Identities { + if id.Type == ae.IdentityTypeTIN { + tin = id + } + } + require.NotNil(t, tin) + assert.Equal(t, org.IdentityScopeTax, tin.Scope) + assert.Equal(t, cbc.Code("1357902467"), tin.Code) +} + +// TestExportAE checks that a UAE invoice is exported with the PINT AE +// identifiers and detected as PINT AE again. +func TestExportAE(t *testing.T) { + env := loadTestEnvelope(t, "pint/ae/invoice-ae.json") + out, err := convert.Export(env, peppolubl.KeyAE) + require.NoError(t, err) + assert.Equal(t, peppolubl.KeyAE, out.Format.Key) + assert.Contains(t, string(out.Data), ""+peppolubl.FormatAE.CustomizationID) + + f, err := convert.Detect(out.Data) + require.NoError(t, err) + assert.Equal(t, peppolubl.KeyAE, f.Key, "detected again") +} + +// TestSpecificationAESelfBilling checks that self-billed invoices are written +// with the AE self-billing identifiers and validated against its rule set. +func TestSpecificationAESelfBilling(t *testing.T) { + env := loadTestEnvelope(t, "pint/ae/invoice-ae.json") + inv, ok := env.Extract().(*bill.Invoice) + require.True(t, ok) + + f := peppolubl.FormatAE + assert.Equal(t, peppolubl.FormatAE.VESIDs.Invoice, f.VESID(inv)) + + inv.SetTags(tax.TagSelfBilled) + assert.Equal(t, peppolubl.SpecificationAESelfBilling.VESIDs.Invoice, f.VESID(inv)) + s := f.SpecificationFor(inv) + require.NotNil(t, s) + assert.Equal(t, peppolubl.SpecificationAESelfBilling.CustomizationID, s.CustomizationID) + assert.Equal(t, peppolubl.SpecificationAESelfBilling.ProfileID, s.ProfileID) + + inv.Type = bill.InvoiceTypeCreditNote + assert.Equal(t, peppolubl.SpecificationAESelfBilling.VESIDs.CreditNote, f.VESID(inv)) +}