mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[FIX] Fix same eror in camt54 module
This commit is contained in:
@@ -25,11 +25,10 @@ class AccountStatementImport(models.TransientModel):
|
|||||||
amount = -amount
|
amount = -amount
|
||||||
statement.line_ids.create(
|
statement.line_ids.create(
|
||||||
{
|
{
|
||||||
"name": statement.name,
|
|
||||||
"amount": amount,
|
"amount": amount,
|
||||||
"statement_id": statement.id,
|
"statement_id": statement.id,
|
||||||
"date": statement.date,
|
"date": statement.date,
|
||||||
"payment_ref": "/",
|
"payment_ref": statement.name,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
statement.balance_end_real = statement.balance_start
|
statement.balance_end_real = statement.balance_start
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CamtParser(models.AbstractModel):
|
|||||||
"./ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref", namespaces={"ns": ns}
|
"./ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref", namespaces={"ns": ns}
|
||||||
)
|
)
|
||||||
if len(isr_number):
|
if len(isr_number):
|
||||||
transaction["name"] = isr_number[0].text
|
transaction["payment_ref"] = isr_number[0].text
|
||||||
partner_ref = self._get_partner_ref(isr_number[0].text)
|
partner_ref = self._get_partner_ref(isr_number[0].text)
|
||||||
if partner_ref:
|
if partner_ref:
|
||||||
transaction["partner_ref"] = partner_ref
|
transaction["partner_ref"] = partner_ref
|
||||||
@@ -68,11 +68,11 @@ class CamtParser(models.AbstractModel):
|
|||||||
"./ns:AddtlNtryInf",
|
"./ns:AddtlNtryInf",
|
||||||
"/ns:Refs/ns:InstrId",
|
"/ns:Refs/ns:InstrId",
|
||||||
]
|
]
|
||||||
name = transaction["name"]
|
payment_ref = transaction["payment_ref"]
|
||||||
for xpath_expr in xpath_exprs:
|
for xpath_expr in xpath_exprs:
|
||||||
found_node = node.xpath(xpath_expr, namespaces={"ns": ns})
|
found_node = node.xpath(xpath_expr, namespaces={"ns": ns})
|
||||||
if found_node:
|
if found_node:
|
||||||
name = found_node[0].text
|
payment_ref = found_node[0].text
|
||||||
break
|
break
|
||||||
trans_id_node = (
|
trans_id_node = (
|
||||||
node.getparent()
|
node.getparent()
|
||||||
@@ -80,9 +80,9 @@ class CamtParser(models.AbstractModel):
|
|||||||
.xpath("./ns:AcctSvcrRef", namespaces={"ns": ns})
|
.xpath("./ns:AcctSvcrRef", namespaces={"ns": ns})
|
||||||
)
|
)
|
||||||
if trans_id_node:
|
if trans_id_node:
|
||||||
name = "{} ({})".format(name, trans_id_node[0].text)
|
payment_ref = "{} ({})".format(payment_ref, trans_id_node[0].text)
|
||||||
if name:
|
if payment_ref:
|
||||||
transaction["name"] = name
|
transaction["payment_ref"] = payment_ref
|
||||||
# End add esr to the label.
|
# End add esr to the label.
|
||||||
|
|
||||||
# add transaction id to ref
|
# add transaction id to ref
|
||||||
|
|||||||
@@ -27,21 +27,21 @@ class TestGetPartnerRef(common.TransactionCase):
|
|||||||
self.ICP.set_param("isr_partner_ref", "12")
|
self.ICP.set_param("isr_partner_ref", "12")
|
||||||
ref = "11 11111 11112 34567 11111 11111".replace(" ", "")
|
ref = "11 11111 11112 34567 11111 11111".replace(" ", "")
|
||||||
partner_ref = self.Parser._get_partner_ref(ref)
|
partner_ref = self.Parser._get_partner_ref(ref)
|
||||||
self.assertEquals(partner_ref, "234567")
|
self.assertEqual(partner_ref, "234567")
|
||||||
|
|
||||||
def test_ICP_full(self):
|
def test_ICP_full(self):
|
||||||
"""Test full format of partner ref definition"""
|
"""Test full format of partner ref definition"""
|
||||||
self.ICP.set_param("isr_partner_ref", "12,6")
|
self.ICP.set_param("isr_partner_ref", "12,6")
|
||||||
ref = "11 11111 11112 34567 11111 11111".replace(" ", "")
|
ref = "11 11111 11112 34567 11111 11111".replace(" ", "")
|
||||||
partner_ref = self.Parser._get_partner_ref(ref)
|
partner_ref = self.Parser._get_partner_ref(ref)
|
||||||
self.assertEquals(partner_ref, "234567")
|
self.assertEqual(partner_ref, "234567")
|
||||||
|
|
||||||
def test_zero_stripped(self):
|
def test_zero_stripped(self):
|
||||||
"""Test full format of partner ref definition"""
|
"""Test full format of partner ref definition"""
|
||||||
self.ICP.set_param("isr_partner_ref", "12,6")
|
self.ICP.set_param("isr_partner_ref", "12,6")
|
||||||
ref = "11 11111 11110 00560 11111 11111".replace(" ", "")
|
ref = "11 11111 11110 00560 11111 11111".replace(" ", "")
|
||||||
partner_ref = self.Parser._get_partner_ref(ref)
|
partner_ref = self.Parser._get_partner_ref(ref)
|
||||||
self.assertEquals(partner_ref, "560")
|
self.assertEqual(partner_ref, "560")
|
||||||
|
|
||||||
def test_bad_ICP(self):
|
def test_bad_ICP(self):
|
||||||
"""Test ir config parameter validation"""
|
"""Test ir config parameter validation"""
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
from odoo.modules.module import get_module_resource
|
from odoo.modules.module import get_module_resource
|
||||||
from odoo.tests.common import SavepointCase
|
from odoo.tests.common import SavepointCase
|
||||||
|
|
||||||
@@ -39,12 +37,7 @@ class TestGenerateBankStatement(SavepointCase):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@mock.patch(
|
def _load_statement(self):
|
||||||
"odoo.addons.account.models.sequence_mixin."
|
|
||||||
"SequenceMixin._constrains_date_sequence",
|
|
||||||
side_effect=False,
|
|
||||||
)
|
|
||||||
def _load_statement(self, constraint):
|
|
||||||
testfile = get_module_resource(
|
testfile = get_module_resource(
|
||||||
"account_statement_import_camt", "test_files", "test-camt053"
|
"account_statement_import_camt", "test_files", "test-camt053"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user