Debian Codegraph @

addons/l10n_jp_ubl_pint/models/account_edi_xml_pint_jp.py

raw symbols SCIP
1 from odoo import models
2
3
4 class AccountEdiXmlPint_Jp(models.AbstractModel):
5 _name = 'account.edi.xml.pint_jp'
6 _inherit = ["account.edi.xml.ubl_bis3"]
7 _description = "Japanese implementation of Peppol International (PINT) model for Billing"
8 """
9 Pint is a standard for International Billing from Peppol. It is based on Peppol BIS Billing 3.
10 It serves as a base for per-country specialization, while keeping a standard core for data being used
11 across countries. This is not meant to be used directly, but rather to be extended by country-specific modules.
12
13 The JP PINT format is the Japanese implementation of PINT.
14
15 * PINT Official documentation: https://docs.peppol.eu/poac/pint/pint/
16 * PINT JP Official documentation: https://docs.peppol.eu/poac/jp/pint-jp
17 """
18
19 # -------------------------------------------------------------------------
20 # EXPORT
21 # -------------------------------------------------------------------------
22
23 def _export_invoice_filename(self, invoice):
24 # EXTENDS account_edi_ubl_cii
25 return f"{invoice.name.replace('/', '_')}_pint_jp.xml"
26
27 def _get_customization_id(self, process_type='billing'):
28 if process_type == 'billing':
29 return 'urn:peppol:pint:billing-1@jp-1'
30
31 def _ubl_default_tax_subtotal_grouping_key(self, tax_category_grouping_key, vals):
32 # EXTENDS account.edi.xml.ubl_bis3
33 tax_subtotal_grouping_key = super()._ubl_default_tax_subtotal_grouping_key(tax_category_grouping_key, vals)
34
35 # If there is a TaxTotal section in company currency,
36 # its TaxSubtotals nodes should contain a 'Percent' node.
37 currency = vals['currency_id']
38 company = vals['company']
39 if (
40 currency != company.currency_id
41 and tax_subtotal_grouping_key['currency'] == company.currency_id
42 ):
43 tax_subtotal_grouping_key['percent'] = tax_category_grouping_key['percent']
44
45 return tax_subtotal_grouping_key
46
47 def _ubl_get_tax_subtotal_node(self, vals, tax_subtotal):
48 # EXTENDS account.edi.xml.ubl_bis3
49 tax_subtotal_node = super()._ubl_get_tax_subtotal_node(vals, tax_subtotal)
50
51 # If there is a TaxTotal section in company currency,
52 # its TaxSubtotals nodes should contain a 'Percent' node.
53 currency = vals['currency_id']
54 company = vals['company']
55 if (
56 currency != company.currency_id
57 and tax_subtotal['currency'] == company.currency_id
58 ):
59 tax_subtotal_node['cbc:Percent'] = {'_text': tax_subtotal['percent']}
60
61 return tax_subtotal_node
62
63 def _ubl_tax_totals_node_grouping_key(self, base_line, tax_data, vals, currency):
64 # OVERRIDE
65 return self.env['account.edi.ubl']._ubl_tax_totals_node_grouping_key(base_line, tax_data, vals, currency)
66
67 def _add_invoice_header_nodes(self, document_node, vals):
68 invoice = vals['invoice']
69 super()._add_invoice_header_nodes(document_node, vals)
70
71 # see https://docs.peppol.eu/poac/jp/pint-jp/bis/#profiles
72 document_node['cbc:ProfileID'] = {'_text': 'urn:peppol:bis:billing'}
73
74 # [aligned-ibrp-052] An Invoice MUST have an invoice period (ibg-14) or an Invoice line period (ibg-26).
75 document_node['cac:InvoicePeriod'] = {
76 'cbc:StartDate': {'_text': invoice.invoice_date},
77 'cbc:EndDate': {'_text': invoice.invoice_date},
78 }
79
80 def _get_address_node(self, vals):
81 address_node = super()._get_address_node(vals)
82 address_node['cbc:CountrySubentityCode'] = None
83 return address_node
84
85 def _get_party_node(self, vals):
86 party_node = super()._get_party_node(vals)
87 # optional, if set: scheme_id should be taken from ISO/IEC 6523 list
88 party_node['cac:PartyLegalEntity']['cbc:CompanyID'] = None
89 return party_node