[IMP] account_banking_pain_base: add needed QRR information to generate correct XML file structure

This commit is contained in:
Thomas Winteler 2023-05-09 11:34:04 +02:00 committed by Renzo Meister
parent b22e10a9ca
commit 994823f5b4
2 changed files with 52 additions and 25 deletions

View File

@ -3,7 +3,7 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza # Copyright 2014-2022 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from flectra import api, fields, models from flectra import fields, models, api, _
class AccountPaymentLine(models.Model): class AccountPaymentLine(models.Model):
@ -175,8 +175,17 @@ class AccountPaymentLine(models.Model):
) )
@api.model @api.model
def _get_payment_line_grouping_fields(self): def create(self, vals):
"""Add specific PAIN fields to the grouping criteria.""" if vals.get("name", "New") == "New":
res = super()._get_payment_line_grouping_fields() vals["name"] = (
res += ["priority", "local_instrument", "category_purpose", "purpose"] self.env["ir.sequence"].next_by_code("account.payment.line") or "New"
return res )
result = super(AccountPaymentLine, self).create(vals)
# set proper communication type
if result.communication.startswith('RF'):
result.communication_type = 'SCOR'
elif result.partner_bank_id._is_qr_iban():
result.communication_type = 'QRR'
return result

View File

@ -12,6 +12,7 @@ from lxml import etree
from flectra import _, api, fields, models, tools from flectra import _, api, fields, models, tools
from flectra.exceptions import UserError from flectra.exceptions import UserError
from flectra.tools.safe_eval import safe_eval from flectra.tools.safe_eval import safe_eval
import flectra.release
try: try:
from unidecode import unidecode from unidecode import unidecode
@ -399,6 +400,11 @@ class AccountPaymentOrder(models.Model):
initiating_party = etree.SubElement(parent_node, "InitgPty") initiating_party = etree.SubElement(parent_node, "InitgPty")
initiating_party_name = etree.SubElement(initiating_party, "Nm") initiating_party_name = etree.SubElement(initiating_party, "Nm")
initiating_party_name.text = my_company_name initiating_party_name.text = my_company_name
initiating_party_software = etree.SubElement(initiating_party, 'CtctDtls')
initiating_party_software_name = etree.SubElement(initiating_party_software, 'Nm')
initiating_party_software_name.text = 'Flectra Open Source ERP and CRM'
initiating_party_software_version = etree.SubElement(initiating_party_software, 'Othr')
initiating_party_software_version.text = 'Version ' + flectra.release.version
initiating_party_identifier = ( initiating_party_identifier = (
self.payment_mode_id.initiating_party_identifier self.payment_mode_id.initiating_party_identifier
or self.payment_mode_id.company_id.initiating_party_identifier or self.payment_mode_id.company_id.initiating_party_identifier
@ -643,31 +649,43 @@ class AccountPaymentOrder(models.Model):
creditor_ref_information, "CdtrRef" creditor_ref_information, "CdtrRef"
) )
else: else:
if gen_args.get("structured_remittance_issuer", True): if line.communication_type == 'QRR':
creditor_ref_info_type = etree.SubElement( creditor_ref_info_type = etree.SubElement(
creditor_ref_information, "Tp" creditor_ref_information, 'Tp')
)
creditor_ref_info_type_or = etree.SubElement( creditor_ref_info_type_or = etree.SubElement(
creditor_ref_info_type, "CdOrPrtry" creditor_ref_info_type, 'CdOrPrtry')
)
creditor_ref_info_type_code = etree.SubElement( creditor_ref_info_type_code = etree.SubElement(
creditor_ref_info_type_or, "Cd" creditor_ref_info_type_or, 'Prtry')
) creditor_ref_info_type_code.text = 'QRR'
creditor_ref_info_type_code.text = "SCOR" elif line.communication_type == 'SCOR':
creditor_ref_info_type = etree.SubElement(
creditor_ref_information, 'Tp')
creditor_ref_info_type_or = etree.SubElement(
creditor_ref_info_type, 'CdOrPrtry')
creditor_ref_info_type_code = etree.SubElement(
creditor_ref_info_type_or, 'Cd')
creditor_ref_info_type_code.text = 'SCOR'
elif gen_args.get('structured_remittance_issuer', True):
creditor_ref_info_type = etree.SubElement(
creditor_ref_information, 'Tp')
creditor_ref_info_type_or = etree.SubElement(
creditor_ref_info_type, 'CdOrPrtry')
creditor_ref_info_type_code = etree.SubElement(
creditor_ref_info_type_or, 'Cd')
creditor_ref_info_type_code.text = 'SCOR'
creditor_ref_info_type_issuer = etree.SubElement( creditor_ref_info_type_issuer = etree.SubElement(
creditor_ref_info_type, "Issr" creditor_ref_info_type, 'Issr')
) creditor_ref_info_type_issuer.text = \
creditor_ref_info_type_issuer.text = communication_type line.communication_type
creditor_reference = etree.SubElement(creditor_ref_information, "Ref") creditor_reference = etree.SubElement(
creditor_ref_information, 'Ref')
creditor_reference.text = self._prepare_field( creditor_reference.text = \
"Creditor Structured Reference", self._prepare_field(
"line.payment_reference", 'Creditor Structured Reference',
{"line": line}, 'line.communication', {'line': line}, 35,
35, gen_args=gen_args)
gen_args=gen_args,
)
return True return True
@api.model @api.model