Browse Source

[11.0][FIX] account_bank_statement_import_camt: payment amounts (#168)

pull/152/merge
Andrea Stirpe 6 years ago
committed by Pedro M. Baeza
parent
commit
64f26f3a6b
  1. 2
      account_bank_statement_import_camt_oca/__manifest__.py
  2. 6
      account_bank_statement_import_camt_oca/models/parser.py
  3. 9
      account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata
  4. 50
      account_bank_statement_import_camt_oca/test_files/test-camt053
  5. 18
      account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py

2
account_bank_statement_import_camt_oca/__manifest__.py

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'CAMT Format Bank Statements Import',
'version': '11.0.1.0.1',
'version': '11.0.1.0.2',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import',

6
account_bank_statement_import_camt_oca/models/parser.py

@ -19,9 +19,15 @@ class CamtParser(models.AbstractModel):
sign = 1
amount = 0.0
sign_node = node.xpath('ns:CdtDbtInd', namespaces={'ns': ns})
if not sign_node:
sign_node = node.xpath(
'../../ns:CdtDbtInd', namespaces={'ns': ns})
if sign_node and sign_node[0].text == 'DBIT':
sign = -1
amount_node = node.xpath('ns:Amt', namespaces={'ns': ns})
if not amount_node:
amount_node = node.xpath(
'./ns:AmtDtls/ns:TxAmt/ns:Amt', namespaces={'ns': ns})
if amount_node:
amount = sign * float(amount_node[0].text)
return amount

9
account_bank_statement_import_camt_oca/test_files/golden-camt053.pydata

@ -12,12 +12,19 @@
'partner_name': 'INSURANCE COMPANY TESTX',
'ref': '435005714488-ABNO33052620'},
{'account_number': 'NL46ABNA0499998748',
'amount': -594.05,
'amount': -564.05,
'date': '2014-01-05',
'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408',
'note': 'Direct Debit S14 0410',
'partner_name': 'Test Customer',
'ref': 'TESTBANK/NL/20141229/01206408'},
{'account_number': 'NL46ABNA0499998748',
'amount': -100.0,
'date': '2014-01-05',
'name': 'Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408',
'note': 'Direct Debit S14 0410',
'partner_name': 'Test Customer',
'ref': 'TESTBANK/NL/20141229/01206407'},
{'account_number': 'NL69ABNA0522123643',
'amount': 1405.31,
'date': '2014-01-05',

50
account_bank_statement_import_camt_oca/test_files/test-camt053

@ -111,7 +111,7 @@
</NtryDtls>
</Ntry>
<Ntry>
<Amt Ccy="EUR">594.05</Amt>
<Amt Ccy="EUR">664.05</Amt>
<CdtDbtInd>DBIT</CdtDbtInd>
<RvslInd>true</RvslInd>
<Sts>BOOK</Sts>
@ -134,6 +134,13 @@
</Prtry>
</BkTxCd>
<NtryDtls>
<Btch>
<MsgId>2014/125</MsgId>
<PmtInfId>2018/125-20141229-NORM</PmtInfId>
<NbOfTxs>2</NbOfTxs>
<TtlAmt Ccy="EUR">664.05</TtlAmt>
<CdtDbtInd>DBIT</CdtDbtInd>
</Btch>
<TxDtls>
<Refs>
<InstrId>TESTBANK/NL/20141229/01206408</InstrId>
@ -175,6 +182,47 @@
</RtrInf>
<AddtlTxInf>Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408</AddtlTxInf>
</TxDtls>
<TxDtls>
<Refs>
<InstrId>TESTBANK/NL/20141229/01206407</InstrId>
<EndToEndId>TESTBANK/NL/20141229/01206407</EndToEndId>
<MndtId>NL22ZZZ524885430000-C0125.2</MndtId>
</Refs>
<AmtDtls>
<TxAmt>
<Amt Ccy="EUR">100.00</Amt>
</TxAmt>
</AmtDtls>
<RltdPties>
<Cdtr>
<Nm>Test Customer</Nm>
<PstlAdr>
<Ctry>NL</Ctry>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>NL46ABNA0499998748</IBAN>
</Id>
</CdtrAcct>
</RltdPties>
<RltdAgts>
<CdtrAgt>
<FinInstnId>
<BIC>ABNANL2A</BIC>
</FinInstnId>
</CdtrAgt>
</RltdAgts>
<RmtInf>
<Ustrd>Direct Debit S14 0410</Ustrd>
</RmtInf>
<RtrInf>
<Rsn>
<Cd>AC06</Cd>
</Rsn>
</RtrInf>
<AddtlTxInf>Direct debit S14 0410 AC07 Rek.nummer blokkade TESTBANK/NL/20141229/01206408</AddtlTxInf>
</TxDtls>
</NtryDtls>
</Ntry>
<Ntry>

18
account_bank_statement_import_camt_oca/tests/test_import_bank_statement.py

@ -72,6 +72,24 @@ class TestImport(TransactionCase):
'date': '2014-01-05',
'ref': '435005714488-ABNO33052620',
},
{
'remote_account': 'NL46ABNA0499998748',
'transferred_amount': -564.05,
'value_date': '2014-01-05',
'ref': 'TESTBANK/NL/20141229/01206408',
},
{
'remote_account': 'NL46ABNA0499998748',
'transferred_amount': -100.0,
'value_date': '2014-01-05',
'ref': 'TESTBANK/NL/20141229/01206407',
},
{
'remote_account': 'NL69ABNA0522123643',
'transferred_amount': 1405.31,
'value_date': '2014-01-05',
'ref': '115',
},
]
def setUp(self):

Loading…
Cancel
Save