Skip to content

Commit

Permalink
Merge pull request #70 from lucadela96/14.0-pain-direct-debit
Browse files Browse the repository at this point in the history
Changes of pre-commit.
  • Loading branch information
davidwul authored May 31, 2024
2 parents 58ad874 + 901a73c commit 4cb7d58
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions l10n_ch_pain_direct_debit/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from lxml import etree
import re

from lxml import etree

from odoo import api, fields, models
from odoo.exceptions import UserError
from odoo.tools import float_round,mod10r
from odoo.tools import float_round, mod10r

ACCEPTED_PAIN_FLAVOURS = ("pain.008.001.02.ch.03",)

Expand Down Expand Up @@ -421,7 +423,8 @@ def generate_remittance_info_block(self, parent_node, line, gen_args):
remittance_info_unstructured = etree.SubElement(remittance_info, "Ustrd")
remittance_info_unstructured.text = self._prepare_field(
"Remittance Unstructured Information",
"line.payment_line_ids[0].move_line_id.move_id.ref or line.payment_line_ids[0].move_line_id.move_id.name",
"line.payment_line_ids[0].move_line_id.move_id.ref or "
"line.payment_line_ids[0].move_line_id.move_id.name",
{"line": line},
140,
gen_args=gen_args,
Expand All @@ -440,13 +443,13 @@ def generate_remittance_info_block(self, parent_node, line, gen_args):
creditor_ref_info_type_code.text = "ESR"
creditor_reference = etree.SubElement(creditor_ref_information, "Ref")
ref = line.payment_line_ids[0].communication
if re.match(r'^(\d{2,27})$', ref):
if re.match(r"^(\d{2,27})$", ref):
if ref == mod10r(ref[:-1]):
creditor_reference.text = ref
else:
raise UserError(ref + ': control digit failed (QRR or ESR)')
raise UserError(ref + ": control digit failed (QRR or ESR)")
else:
raise UserError(ref + ' is not QRR or ESR ref')
raise UserError(ref + " is not QRR or ESR ref")
else:
super().generate_remittance_info_block(parent_node, line, gen_args)

Expand Down

0 comments on commit 4cb7d58

Please sign in to comment.