Skip to content

Commit

Permalink
[FIX] l10n_sa_edi: fix scheme ID for foreign customers
Browse files Browse the repository at this point in the history
Steps to reproduce:
- Install Contacts, Accounting and l10n_sa_edi
- Switch to a Saudi Arabian company (e.g. SA Company)
- Create a contact who is not in Saudi Arabia:
  * Address: [Complete address in United Arab Emirates]
  * VAT: [any]
- Create an invoice:
  * Customer: [The created contact]
  * Product: [any]
- Confirm the invoice
- Process by ZATCA

Issue:
The following warning is returned:
"The other Buyer ID (BT-46) must present in the tax invoice and associated
debit notes and credit notes (KSA-2, position 1 and 2 = 01), where the buyer
VAT registration number or buyer group VAT registration number (BT-48) is
not provided."

Cause:
"PartyIdentification" element is not set in the electronic invoice for customer
because he doesn't have "l10n_sa_additional_identification_number" field set.
This field is only available for contacts living in Saudi Arabia.
For contacts who don't live in Saudi Arabia, "PartyIdentification" should be
populate with their VAT number.

opw-3845645

closes odoo#163652

X-original-commit: 3500c5f
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
  • Loading branch information
kitan191 committed Apr 27, 2024
1 parent 704c0be commit 2a2c76a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 5 additions & 1 deletion addons/l10n_sa_edi/models/account_edi_xml_ubl_21_zatca.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def _get_partner_party_identification_vals_list(self, partner):
""" Override to include/update values specific to ZATCA's UBL 2.1 specs """
return [{
'id_attrs': {'schemeID': partner.l10n_sa_additional_identification_scheme},
'id': partner.l10n_sa_additional_identification_number if partner.l10n_sa_additional_identification_scheme != 'TIN' else partner.vat
'id': (
partner.l10n_sa_additional_identification_number
if partner.l10n_sa_additional_identification_scheme != 'TIN' and partner.country_code == 'SA'
else partner.vat
),
}]

def _l10n_sa_get_payment_means_code(self, invoice):
Expand Down
3 changes: 0 additions & 3 deletions addons/l10n_sa_edi/tests/compliance/standard/credit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="CRN">353535353535353</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>Chichi Lboukla</cbc:Name>
</cac:PartyName>
Expand Down
3 changes: 0 additions & 3 deletions addons/l10n_sa_edi/tests/compliance/standard/debit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="CRN">353535353535353</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>Chichi Lboukla</cbc:Name>
</cac:PartyName>
Expand Down
3 changes: 2 additions & 1 deletion addons/l10n_sa_edi/tests/compliance/standard/invoice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<cac:AccountingCustomerParty>
<cac:Party>
<cac:PartyIdentification>
<cbc:ID schemeID="CRN">353535353535353</cbc:ID>
<cbc:ID schemeID="CRN">US12345677</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>Chichi Lboukla</cbc:Name>
Expand All @@ -118,6 +118,7 @@
</cac:PostalAddress>
<cac:PartyLegalEntity>
<cbc:RegistrationName>Chichi Lboukla</cbc:RegistrationName>
<cbc:CompanyID>US12345677</cbc:CompanyID>
<cac:RegistrationAddress>
<cbc:StreetName>4557 De Silva St</cbc:StreetName>
<cbc:BuildingNumber>12300</cbc:BuildingNumber>
Expand Down
1 change: 1 addition & 0 deletions addons/l10n_sa_edi/tests/test_edi_zatca.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def testInvoiceStandard(self):
expected_tree = self.get_xml_tree_from_string(standard_invoice)
expected_tree = self.with_applied_xpath(expected_tree, self.invoice_applied_xpath)

self.partner_us.vat = 'US12345677'
move = self._create_invoice(name='INV/2022/00014', date='2022-09-05', date_due='2022-09-22', partner_id=self.partner_us,
product_id=self.product_a, price=320.0)
move._l10n_sa_generate_unsigned_data()
Expand Down

0 comments on commit 2a2c76a

Please sign in to comment.