mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[REF] account_banking_sepa_credit_transfer: Adapt module to native payment refactoring
Notables changes: - InstrId and EndToEndId tags are now filled with the journal entry ID, as there's no bank payment line identifier.
This commit is contained in:
committed by
Dũng (Trần Đình)
parent
6cff6176a3
commit
1875265dee
@@ -1,5 +1,6 @@
|
||||
# Copyright 2010-2020 Akretion (www.akretion.com)
|
||||
# Copyright 2016-2020 Tecnativa - Antonio Espinosa and Pedro M. Baeza
|
||||
# Copyright 2016 Tecnativa - Antonio Espinosa
|
||||
# Copyright 2016-2022 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
{
|
||||
@@ -7,7 +8,7 @@
|
||||
"summary": "Create SEPA XML files for Credit Transfers",
|
||||
"version": "15.0.1.0.3",
|
||||
"license": "AGPL-3",
|
||||
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/bank-payment",
|
||||
"category": "Banking addons",
|
||||
"conflicts": ["account_sepa"],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright 2010-2020 Akretion (www.akretion.com)
|
||||
# Copyright 2014-2020 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from lxml import etree
|
||||
@@ -78,10 +78,11 @@ class AccountPaymentOrder(models.Model):
|
||||
lines_per_group = {}
|
||||
# key = (requested_date, priority, local_instrument, categ_purpose)
|
||||
# values = list of lines as object
|
||||
for line in self.bank_line_ids:
|
||||
priority = line.priority
|
||||
local_instrument = line.local_instrument
|
||||
categ_purpose = line.category_purpose
|
||||
for line in self.payment_ids:
|
||||
payment_line = line.payment_line_ids[:1]
|
||||
priority = payment_line.priority
|
||||
local_instrument = payment_line.local_instrument
|
||||
categ_purpose = payment_line.category_purpose
|
||||
# The field line.date is the requested payment date
|
||||
# taking into account the 'date_prefered' setting
|
||||
# cf account_banking_payment_export/models/account_payment.py
|
||||
@@ -145,7 +146,7 @@ class AccountPaymentOrder(models.Model):
|
||||
)
|
||||
instruction_identification.text = self._prepare_field(
|
||||
"Instruction Identification",
|
||||
"line.name",
|
||||
"str(line.move_id.id)",
|
||||
{"line": line},
|
||||
35,
|
||||
gen_args=gen_args,
|
||||
@@ -155,7 +156,7 @@ class AccountPaymentOrder(models.Model):
|
||||
)
|
||||
end2end_identification.text = self._prepare_field(
|
||||
"End to End Identification",
|
||||
"line.name",
|
||||
"str(line.move_id.id)",
|
||||
{"line": line},
|
||||
35,
|
||||
gen_args=gen_args,
|
||||
@@ -171,9 +172,9 @@ class AccountPaymentOrder(models.Model):
|
||||
instructed_amount = etree.SubElement(
|
||||
amount, "InstdAmt", Ccy=currency_name
|
||||
)
|
||||
instructed_amount.text = "%.2f" % line.amount_currency
|
||||
amount_control_sum_a += line.amount_currency
|
||||
amount_control_sum_b += line.amount_currency
|
||||
instructed_amount.text = "%.2f" % line.amount
|
||||
amount_control_sum_a += line.amount
|
||||
amount_control_sum_b += line.amount
|
||||
if not line.partner_bank_id:
|
||||
raise UserError(
|
||||
_(
|
||||
@@ -190,9 +191,10 @@ class AccountPaymentOrder(models.Model):
|
||||
gen_args,
|
||||
line,
|
||||
)
|
||||
if line.purpose:
|
||||
line_purpose = line.payment_line_ids[:1].purpose
|
||||
if line_purpose:
|
||||
purpose = etree.SubElement(credit_transfer_transaction_info, "Purp")
|
||||
etree.SubElement(purpose, "Cd").text = line.purpose
|
||||
etree.SubElement(purpose, "Cd").text = line_purpose
|
||||
self.generate_remittance_info_block(
|
||||
credit_transfer_transaction_info, line, gen_args
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2018 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2020 Sygel Technology - Valentin Vinagre
|
||||
# Copyright 2018-2022 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
import base64
|
||||
@@ -21,7 +21,6 @@ class TestSCT(TransactionCase):
|
||||
cls.journal_model = cls.env["account.journal"]
|
||||
cls.payment_order_model = cls.env["account.payment.order"]
|
||||
cls.payment_line_model = cls.env["account.payment.line"]
|
||||
cls.bank_line_model = cls.env["bank.payment.line"]
|
||||
cls.partner_bank_model = cls.env["res.partner.bank"]
|
||||
cls.attachment_model = cls.env["ir.attachment"]
|
||||
cls.invoice_model = cls.env["account.move"]
|
||||
@@ -104,7 +103,7 @@ class TestSCT(TransactionCase):
|
||||
"payment_method_id": cls.env.ref(
|
||||
"account_banking_sepa_credit_transfer.sepa_credit_transfer"
|
||||
).id,
|
||||
"payment_account_id": cls.account_payable.id,
|
||||
"payment_account_id": cls.account_expense.id,
|
||||
},
|
||||
)
|
||||
],
|
||||
@@ -207,20 +206,16 @@ class TestSCT(TransactionCase):
|
||||
self.payment_order.draft2open()
|
||||
self.assertEqual(self.payment_order.state, "open")
|
||||
self.assertEqual(self.payment_order.sepa, True)
|
||||
bank_lines = self.bank_line_model.search(
|
||||
[("partner_id", "=", self.partner_agrolait.id)]
|
||||
)
|
||||
self.assertEqual(len(bank_lines), 1)
|
||||
agrolait_bank_line = bank_lines[0]
|
||||
self.assertTrue(self.payment_order.payment_ids)
|
||||
agrolait_bank_line = self.payment_order.payment_ids[0]
|
||||
self.assertEqual(agrolait_bank_line.currency_id, self.eur_currency)
|
||||
self.assertEqual(
|
||||
agrolait_bank_line.currency_id.compare_amounts(
|
||||
agrolait_bank_line.amount_currency, 49.0
|
||||
agrolait_bank_line.amount, 49.0
|
||||
),
|
||||
0,
|
||||
)
|
||||
self.assertEqual(agrolait_bank_line.communication_type, "normal")
|
||||
self.assertEqual(agrolait_bank_line.communication, "F1341-F1342-A1301")
|
||||
self.assertEqual(agrolait_bank_line.payment_reference, "F1341-F1342-A1301")
|
||||
self.assertEqual(agrolait_bank_line.partner_bank_id, invoice1.partner_bank_id)
|
||||
|
||||
action = self.payment_order.open2generated()
|
||||
@@ -299,20 +294,14 @@ class TestSCT(TransactionCase):
|
||||
self.payment_order.draft2open()
|
||||
self.assertEqual(self.payment_order.state, "open")
|
||||
self.assertEqual(self.payment_order.sepa, False)
|
||||
bank_lines = self.bank_line_model.search(
|
||||
[("partner_id", "=", self.partner_asus.id)]
|
||||
)
|
||||
self.assertEqual(len(bank_lines), 1)
|
||||
asus_bank_line = bank_lines[0]
|
||||
self.assertEqual(self.payment_order.payment_count, 1)
|
||||
asus_bank_line = self.payment_order.payment_ids[0]
|
||||
self.assertEqual(asus_bank_line.currency_id, self.usd_currency)
|
||||
self.assertEqual(
|
||||
asus_bank_line.currency_id.compare_amounts(
|
||||
asus_bank_line.amount_currency, 3054.0
|
||||
),
|
||||
asus_bank_line.currency_id.compare_amounts(asus_bank_line.amount, 3054.0),
|
||||
0,
|
||||
)
|
||||
self.assertEqual(asus_bank_line.communication_type, "normal")
|
||||
self.assertEqual(asus_bank_line.communication, "Inv9032-Inv9033")
|
||||
self.assertEqual(asus_bank_line.payment_reference, "Inv9032-Inv9033")
|
||||
self.assertEqual(asus_bank_line.partner_bank_id, invoice1.partner_bank_id)
|
||||
|
||||
action = self.payment_order.open2generated()
|
||||
|
||||
Reference in New Issue
Block a user