[FIX] account_edi_ubl_cii: fix Bis 3 support for Australia and Singapore

Add Australia and Singapore codes in the EAS list, enabling
the UBL Bis 3 format on the journals of these companies.

Also map the EAS codes to the correct Odoo fields:
* Australia uses the ABN, corresponding to the Odoo vat field
* Singapore uses the UEN, which has a custom Odoo field 'l10n_sg_unique_entity_number'

Fix the missing tax category codes for suppliers not in the european
economic area (e.g. Australian company invoicing a Singaporian one)

closes odoo/odoo#98073

X-original-commit: 8c6ed9386f2c1d29c903fd45d7d716b45eb9d47b
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2022-08-12 23:37:45 +02:00
parent 15eda2d7cf
commit a25490a4aa
2 changed files with 18 additions and 2 deletions
@@ -74,7 +74,9 @@ COUNTRY_EAS = {
'VA': 9953,
'SE': 9955,
'FR': 9957,
'NO':'0192',
'NO': '0192',
'SG': '0195',
'AU': '0151',
}
@@ -172,7 +174,11 @@ class AccountEdiCommon(models.AbstractModel):
tax_exemption_reason_code='VATEX-EU-IC',
tax_exemption_reason=_('Intra-Community supply'),
)
return create_dict()
if tax.amount != 0:
return create_dict(tax_category_code='S')
else:
return create_dict(tax_category_code='E', tax_exemption_reason=_('Articles 226 items 11 to 15 Directive 2006/112/EN'))
def _get_tax_category_list(self, invoice, taxes):
""" Full list: https://unece.org/fileadmin/DAM/trade/untdid/d16b/tred/tred5305.htm
@@ -54,6 +54,11 @@ 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
# sources:
# https://anskaffelser.dev/postaward/g3/spec/current/billing-3.0/norway/#_applying_foretaksregisteret
# https://docs.peppol.eu/poacc/billing/3.0/bis/#national_rules (NO-R-002 (warning))
@@ -117,6 +122,11 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel):
'endpoint_id': partner.l10n_nl_kvk,
'endpoint_id_attrs': {'schemeID': '0106'},
})
if partner.country_id.code == 'SG' and 'l10n_sg_unique_entity_number' in partner._fields:
vals.update({
'endpoint_id': partner.l10n_sg_unique_entity_number,
'endpoint_id_attrs': {'schemeID': '0195'},
})
return vals