[FIX] account_edi_ubl_cii: PartyTaxScheme should begin with country code
In Peppol Bis 3, the value on PartyTaxScheme/CompanyID should be prefixed with a 2 letters code representing the country of the partner. Currently, filling a VAT without this country code will lead to the error: "[BR-CO-09]-The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1 alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’." On the other hand, some extra-european countries use Peppol Bis 3 but do not prepend their VAT with the country code (i.e. Australia). To allow such cases, we automatically add the country code when it's missing. To prevent regression, we also add a contraint mimicking the schematron: we check that the final value of the PartyTaxScheme/CompanyID is prefixed with a 2 letters code. This way, the constraint is independant from the code. X-original-commit: b1ab100046db4ee65bed482c1abbf951190f8921 Part-of: odoo/odoo#154233
This commit is contained in:
@@ -785,6 +785,13 @@ msgid ""
|
||||
"the form: NO179728982MVA."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py:0
|
||||
#, python-format
|
||||
msgid "The VAT of the %s should be prefixed with its country code."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_edi_ubl_cii
|
||||
#. odoo-python
|
||||
#: code:addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py:0
|
||||
|
||||
@@ -59,10 +59,14 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel):
|
||||
vals.pop('registration_name', None)
|
||||
vals.pop('registration_address_vals', None)
|
||||
|
||||
# /!\ For Australian companies, the ABN is encoded on the VAT field, but doesn't have the 2 digits prefix,
|
||||
# causing a validation error
|
||||
if partner.country_id.code == "AU" and partner.vat and not partner.vat.upper().startswith("AU"):
|
||||
vals['company_id'] = "AU" + partner.vat
|
||||
# Some extra european countries use Bis 3 but do not prepend their VAT with the country code (i.e.
|
||||
# Australia). Allow them to use Bis 3 without raising BR-CO-09.
|
||||
if (
|
||||
partner.country_id
|
||||
and partner.country_id not in self.env.ref('base.europe').country_ids
|
||||
and not partner.vat[:2].isalpha()
|
||||
):
|
||||
vals['company_id'] = partner.country_id.code + partner.vat
|
||||
|
||||
# sources:
|
||||
# https://anskaffelser.dev/postaward/g3/spec/current/billing-3.0/norway/#_applying_foretaksregisteret
|
||||
@@ -327,6 +331,19 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel):
|
||||
# /!\ exception: possible to have any number of ecotaxes (fixed tax) with a regular percentage tax
|
||||
constraints.update({'cen_en16931_tax_line': _("Each invoice line shall have one and only one tax.")})
|
||||
|
||||
for role in ('supplier', 'customer'):
|
||||
scheme_vals = vals['vals'][f'accounting_{role}_party_vals']['party_vals']['party_tax_scheme_vals'][-1:]
|
||||
if (
|
||||
not (scheme_vals and scheme_vals[0]['company_id'] and scheme_vals[0]['company_id'][:2].isalpha())
|
||||
and (scheme_vals and scheme_vals[0]['tax_scheme_vals'].get('id') == 'VAT')
|
||||
and self._name in ('account.edi.xml.ubl_bis3', 'account.edi.xml.ubl_nl', 'account.edi.xml.ubl_de')
|
||||
):
|
||||
# [BR-CO-09]-The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63)
|
||||
# and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1
|
||||
# alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’.
|
||||
constraints.update({f'cen_en16931_{role}_vat_country_code': _(
|
||||
"The VAT of the %s should be prefixed with its country code.", role)})
|
||||
|
||||
return constraints
|
||||
|
||||
def _invoice_constraints_peppol_en16931_ubl(self, invoice, vals):
|
||||
|
||||
Reference in New Issue
Block a user