[IMP] l10n_dk_oioubl: Handle payment terms in oioubl xml file

The aim of this commit is handling the invoice payment terms
in the oioubl xml file.

closes odoo/odoo#142501

Task-id: 3422407
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
This commit is contained in:
Florian(flg)
2023-11-24 16:22:02 +00:00
parent 671640cf59
commit 362ef0042a
6 changed files with 87 additions and 4 deletions
+3
View File
@@ -12,6 +12,9 @@ E-invoice implementation for the Denmark
'account_edi_ubl_cii',
'l10n_dk',
],
'data': [
'data/oioubl_templates.xml',
],
'installable': True,
'auto_install': True,
'license': 'LGPL-3',
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="oioubl_PaymentTermsType" inherit_id="account_edi_ubl_cii.ubl_20_PaymentTermsType" primary="True">
<xpath expr="//*[local-name()='Amount']" position="after">
<t xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
<t t-set="settlement_period" t-value="vals['settlement_period']"/>
<cac:SettlementPeriod>
<cbc:StartDate><t t-out="settlement_period['start_date']"/></cbc:StartDate>
<cbc:EndDate><t t-out="settlement_period['end_date']"/></cbc:EndDate>
</cac:SettlementPeriod>
</t>
</xpath>
</template>
</odoo>
@@ -1,4 +1,5 @@
from odoo import _, models, tools
from odoo.tools import html2plaintext
DANISH_NATIONAL_IT_AND_TELECOM_AGENCY_ID = '320'
@@ -61,9 +62,9 @@ class AccountEdiXmlOIOUBL201(models.AbstractModel):
def _export_invoice_vals(self, invoice):
# EXTENDS account.edi.xml.ubl_20
vals = super()._export_invoice_vals(invoice)
vals['PaymentTermsType_template'] = 'l10n_dk_oioubl.oioubl_PaymentTermsType'
vals['vals'].update({
'customization_id': 'OIOUBL-2.01',
'AddressType_template': 'l10n_dk_oioubl.oioubl_201_AddressType',
# ProfileID is the property that define which documents the company can send and receive
# 'Procurement-BilSim-1.0' is the simplest one: invoice and bill
# https://www.oioubl.info/documents/en/en/Guidelines/OIOUBL_GUIDE_PROFILES.pdf
@@ -211,9 +212,25 @@ class AccountEdiXmlOIOUBL201(models.AbstractModel):
return vals
def _get_invoice_payment_terms_vals_list(self, invoice):
# cleaned atm because it's not mandatory and the standard payment terms gets the document rejected for validation
# https://www.oioubl.info/Classes/en/PaymentTerms.html
return []
# OVERRIDES 'account_edi_ubl_cii'
if not invoice.invoice_payment_term_id:
return []
sign = 1 if invoice.is_inbound(include_receipts=True) else -1
return [
{
'id': line.id,
'amount': sign * line.amount_currency,
'currency_name': line.currency_id.name,
'currency_dp': self._get_currency_decimal_places(line.currency_id),
'note_vals': [{'note_vals': [{'note': html2plaintext(invoice.invoice_payment_term_id.note)}]}],
'settlement_period': {
'start_date': invoice.invoice_date,
'end_date': line.date_maturity,
}
}
for line in invoice.line_ids.filtered(lambda line: line.display_type == 'payment_term').sorted('date_maturity')
]
def _get_tax_category_list(self, invoice, taxes):
# EXTENDS account.edi.common
@@ -168,6 +168,22 @@
<cbc:ID>DK5000400440116243</cbc:ID>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">450.00</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-01-01</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">1050.00</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-02-28</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">0.00</cbc:TaxAmount>
<cac:TaxSubtotal>
@@ -167,6 +167,22 @@
<cbc:ID>DK5000400440116243</cbc:ID>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">450.00</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-01-01</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">1050.00</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-02-28</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">0.00</cbc:TaxAmount>
<cac:TaxSubtotal>
@@ -168,6 +168,22 @@
<cbc:ID>DK5000400440116243</cbc:ID>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">562.50</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-01-01</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:PaymentTerms>
<cbc:ID>___ignore___</cbc:ID>
<cbc:Amount currencyID="DKK">1312.50</cbc:Amount>
<cac:SettlementPeriod>
<cbc:StartDate>2017-01-01</cbc:StartDate>
<cbc:EndDate>2017-02-28</cbc:EndDate>
</cac:SettlementPeriod>
</cac:PaymentTerms>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="DKK">375.00</cbc:TaxAmount>
<cac:TaxSubtotal>