mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-22 13:42:07 +00:00
[IMP] account_banking_pain_base: add needed QRR information to generate correct XML file structure
This commit is contained in:
parent
b22e10a9ca
commit
994823f5b4
@ -3,7 +3,7 @@
|
||||
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
|
||||
# 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):
|
||||
@ -175,8 +175,17 @@ class AccountPaymentLine(models.Model):
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _get_payment_line_grouping_fields(self):
|
||||
"""Add specific PAIN fields to the grouping criteria."""
|
||||
res = super()._get_payment_line_grouping_fields()
|
||||
res += ["priority", "local_instrument", "category_purpose", "purpose"]
|
||||
return res
|
||||
def create(self, vals):
|
||||
if vals.get("name", "New") == "New":
|
||||
vals["name"] = (
|
||||
self.env["ir.sequence"].next_by_code("account.payment.line") or "New"
|
||||
)
|
||||
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
|
||||
|
@ -12,6 +12,7 @@ from lxml import etree
|
||||
from flectra import _, api, fields, models, tools
|
||||
from flectra.exceptions import UserError
|
||||
from flectra.tools.safe_eval import safe_eval
|
||||
import flectra.release
|
||||
|
||||
try:
|
||||
from unidecode import unidecode
|
||||
@ -399,6 +400,11 @@ class AccountPaymentOrder(models.Model):
|
||||
initiating_party = etree.SubElement(parent_node, "InitgPty")
|
||||
initiating_party_name = etree.SubElement(initiating_party, "Nm")
|
||||
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 = (
|
||||
self.payment_mode_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"
|
||||
)
|
||||
else:
|
||||
if gen_args.get("structured_remittance_issuer", True):
|
||||
if line.communication_type == 'QRR':
|
||||
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, "CdOrPrtry"
|
||||
)
|
||||
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_or, 'Prtry')
|
||||
creditor_ref_info_type_code.text = 'QRR'
|
||||
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, "Issr"
|
||||
)
|
||||
creditor_ref_info_type_issuer.text = communication_type
|
||||
creditor_ref_info_type, 'Issr')
|
||||
creditor_ref_info_type_issuer.text = \
|
||||
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 Structured Reference",
|
||||
"line.payment_reference",
|
||||
{"line": line},
|
||||
35,
|
||||
gen_args=gen_args,
|
||||
)
|
||||
creditor_reference.text = \
|
||||
self._prepare_field(
|
||||
'Creditor Structured Reference',
|
||||
'line.communication', {'line': line}, 35,
|
||||
gen_args=gen_args)
|
||||
return True
|
||||
|
||||
@api.model
|
||||
|
Loading…
Reference in New Issue
Block a user