From a3748a2a6a4a0d1817b5a240046fb594ed0a56cd Mon Sep 17 00:00:00 2001 From: Julien Van Roy Date: Mon, 13 Mar 2023 15:24:49 +0000 Subject: [PATCH] [IMP] account_edi_ubl_cii: add Singapore Bis 3 format Add a new edi_format "SG BIS Billing 3.0" available for SG companies. This format is based on BIS Billing 3.0. task-3180983 closes odoo/odoo#115147 Signed-off-by: Laurent Smet --- addons/account_edi_ubl_cii/models/__init__.py | 1 + .../models/account_edi_xml_ubl_sg.py | 75 +++++++++++++++++++ .../models/account_journal.py | 2 + 3 files changed, 78 insertions(+) create mode 100644 addons/account_edi_ubl_cii/models/account_edi_xml_ubl_sg.py diff --git a/addons/account_edi_ubl_cii/models/__init__.py b/addons/account_edi_ubl_cii/models/__init__.py index 4d9a1fdf8d7..f154d6612ca 100644 --- a/addons/account_edi_ubl_cii/models/__init__.py +++ b/addons/account_edi_ubl_cii/models/__init__.py @@ -9,6 +9,7 @@ from . import account_edi_xml_ubl_xrechnung from . import account_edi_xml_ubl_nlcius from . import account_edi_xml_ubl_efff from . import account_edi_xml_ubl_a_nz +from . import account_edi_xml_ubl_sg from . import account_move_send from . import account_move from . import account_journal diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_sg.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_sg.py new file mode 100644 index 00000000000..c4493e0d9b2 --- /dev/null +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_sg.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +from odoo import models + + +class AccountEdiXmlUBLSG(models.AbstractModel): + _inherit = "account.edi.xml.ubl_bis3" + _name = "account.edi.xml.ubl_sg" + _description = "SG BIS Billing 3.0" + + """ + Documentation: https://www.peppolguide.sg/billing/bis/ + """ + + # ------------------------------------------------------------------------- + # EXPORT + # ------------------------------------------------------------------------- + + def _export_invoice_filename(self, invoice): + return f"{invoice.name.replace('/', '_')}_sg.xml" + + def _export_invoice_ecosio_schematrons(self): + return { + 'invoice': 'eu.peppol.bis3.sg.ubl:invoice:1.0.3', + 'credit_note': 'eu.peppol.bis3.sg.ubl:creditnote:1.0.3', + } + + def _get_partner_party_vals(self, partner, role): + # EXTENDS account.edi.xml.ubl_bis3 + vals = super()._get_partner_party_vals(partner, role) + + for party_tax_scheme in vals['party_tax_scheme_vals']: + party_tax_scheme['tax_scheme_id'] = 'GST' + + return vals + + def _get_invoice_payment_means_vals_list(self, invoice): + """ https://www.peppolguide.sg/billing/bis/#_payment_means_information + """ + vals_list = super()._get_invoice_payment_means_vals_list(invoice) + for vals in vals_list: + vals.update({ + 'payment_means_code': 54, + 'payment_means_code_attrs': {'name': 'Credit Card'}, + }) + + return vals_list + + def _get_tax_sg_codes(self, invoice, tax): + """ https://www.peppolguide.sg/billing/bis/#_gst_category_codes + """ + tax_category_code = 'SR' + if tax.amount == 0: + tax_category_code = 'ZR' + return tax_category_code + + def _get_tax_category_list(self, invoice, taxes): + # OVERRIDE + res = [] + for tax in taxes: + res.append({ + 'id': self._get_tax_sg_codes(invoice, tax), + 'percent': tax.amount if tax.amount_type == 'percent' else False, + 'tax_scheme_id': 'GST', + }) + return res + + def _export_invoice_vals(self, invoice): + # EXTENDS account.edi.xml.ubl_bis3 + vals = super()._export_invoice_vals(invoice) + + vals['vals'].update({ + 'customization_id': 'urn:cen.eu:en16931:2017#conformant#urn:fdc:peppol.eu:2017:poacc:billing:international:sg:3.0', + }) + + return vals diff --git a/addons/account_edi_ubl_cii/models/account_journal.py b/addons/account_edi_ubl_cii/models/account_journal.py index 25735afefdc..62bcdfe08b4 100644 --- a/addons/account_edi_ubl_cii/models/account_journal.py +++ b/addons/account_edi_ubl_cii/models/account_journal.py @@ -39,5 +39,7 @@ class AccountJournal(models.Model): return self.env['account.edi.xml.ubl_a_nz'], {} if self.country_code == 'NL': return self.env['account.edi.xml.ubl_nl'], {} + if self.country_code == 'SG': + return self.env['account.edi.xml.ubl_sg'], {} if self.country_code in COUNTRY_EAS: return self.env['account.edi.xml.ubl_bis3'], {}