Browse Source

Support zip files.

pull/134/head
Ronald Portier (Therp BV) 10 years ago
committed by Andrea
parent
commit
c53c5423f0
  1. 2
      account_bank_statement_import_camt/__manifest__.py
  2. 9
      account_bank_statement_import_camt/camt.py
  3. 30
      account_bank_statement_import_camt/test_files/test-camt053.xml
  4. BIN
      account_bank_statement_import_camt/test_files/test-camt053.zip
  5. 11
      account_bank_statement_import_camt/tests/test_import_bank_statement.py

2
account_bank_statement_import_camt/__manifest__.py

@ -19,7 +19,7 @@
############################################################################## ##############################################################################
{ {
'name': 'CAMT Format Bank Statements Import', 'name': 'CAMT Format Bank Statements Import',
'version': '8.0.0.3.0',
'version': '8.0.0.4.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA), Therp BV', 'author': 'Odoo Community Association (OCA), Therp BV',
'website': 'https://github.com/OCA/bank-statement-import', 'website': 'https://github.com/OCA/bank-statement-import',

9
account_bank_statement_import_camt/camt.py

@ -69,7 +69,7 @@ class CamtParser(object):
'./ns:RmtInf/ns:Ustrd', './ns:RmtInf/ns:Ustrd',
'./ns:AddtlTxInf', './ns:AddtlTxInf',
'./ns:AddtlNtryInf', './ns:AddtlNtryInf',
], transaction, 'message')
], transaction, 'message', join_str='\n')
# eref # eref
self.add_value_from_node( self.add_value_from_node(
ns, node, [ ns, node, [
@ -137,6 +137,13 @@ class CamtParser(object):
if not transaction.message: if not transaction.message:
self.add_value_from_node( self.add_value_from_node(
ns, node, './ns:AddtlNtryInf', transaction, 'message') ns, node, './ns:AddtlNtryInf', transaction, 'message')
if not transaction.eref:
self.add_value_from_node(
ns, node, [
'./ns:NtryDtls/ns:Btch/ns:PmtInfId',
],
transaction, 'eref'
)
transaction.data = etree.tostring(node) transaction.data = etree.tostring(node)
return transaction return transaction

30
account_bank_statement_import_camt/test_files/test-camt053.xml

@ -2,15 +2,15 @@
<BkToCstmrStmt> <BkToCstmrStmt>
<GrpHdr> <GrpHdr>
<MsgId>TESTBANK/NL/1420561226673</MsgId> <MsgId>TESTBANK/NL/1420561226673</MsgId>
<CreDtTm>2013-01-06T16:20:26.673Z</CreDtTm>
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm>
</GrpHdr> </GrpHdr>
<Stmt> <Stmt>
<Id>1234Test/1</Id> <Id>1234Test/1</Id>
<LglSeqNb>2</LglSeqNb> <LglSeqNb>2</LglSeqNb>
<CreDtTm>2013-01-06T16:20:26.673Z</CreDtTm>
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm>
<FrToDt> <FrToDt>
<FrDtTm>2013-01-05T00:00:00.000Z</FrDtTm>
<ToDtTm>2013-01-05T23:59:59.999Z</ToDtTm>
<FrDtTm>2014-01-05T00:00:00.000Z</FrDtTm>
<ToDtTm>2014-01-05T23:59:59.999Z</ToDtTm>
</FrToDt> </FrToDt>
<Acct> <Acct>
<Id> <Id>
@ -32,7 +32,7 @@
<Amt Ccy="EUR">15568.27</Amt> <Amt Ccy="EUR">15568.27</Amt>
<CdtDbtInd>CRDT</CdtDbtInd> <CdtDbtInd>CRDT</CdtDbtInd>
<Dt> <Dt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</Dt> </Dt>
</Bal> </Bal>
<Bal> <Bal>
@ -44,7 +44,7 @@
<Amt Ccy="EUR">15121.12</Amt> <Amt Ccy="EUR">15121.12</Amt>
<CdtDbtInd>CRDT</CdtDbtInd> <CdtDbtInd>CRDT</CdtDbtInd>
<Dt> <Dt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</Dt> </Dt>
</Bal> </Bal>
<Ntry> <Ntry>
@ -52,10 +52,10 @@
<CdtDbtInd>DBIT</CdtDbtInd> <CdtDbtInd>DBIT</CdtDbtInd>
<Sts>BOOK</Sts> <Sts>BOOK</Sts>
<BookgDt> <BookgDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</BookgDt> </BookgDt>
<ValDt> <ValDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</ValDt> </ValDt>
<BkTxCd> <BkTxCd>
<Domn> <Domn>
@ -104,9 +104,9 @@
</CdtrAgt> </CdtrAgt>
</RltdAgts> </RltdAgts>
<RmtInf> <RmtInf>
<Ustrd>Insurance policy 857239PERIOD 01.01.2013 - 31.12.2013</Ustrd>
<Ustrd>Insurance policy 857239PERIOD 01.01.2014 - 31.12.2014</Ustrd>
</RmtInf> </RmtInf>
<AddtlTxInf>MKB Insurance 859239PERIOD 01.01.2013 - 31.12.2013</AddtlTxInf>
<AddtlTxInf>MKB Insurance 859239PERIOD 01.01.2014 - 31.12.2014</AddtlTxInf>
</TxDtls> </TxDtls>
</NtryDtls> </NtryDtls>
</Ntry> </Ntry>
@ -116,10 +116,10 @@
<RvslInd>true</RvslInd> <RvslInd>true</RvslInd>
<Sts>BOOK</Sts> <Sts>BOOK</Sts>
<BookgDt> <BookgDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</BookgDt> </BookgDt>
<ValDt> <ValDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</ValDt> </ValDt>
<BkTxCd> <BkTxCd>
<Domn> <Domn>
@ -182,10 +182,10 @@
<CdtDbtInd>CRDT</CdtDbtInd> <CdtDbtInd>CRDT</CdtDbtInd>
<Sts>BOOK</Sts> <Sts>BOOK</Sts>
<BookgDt> <BookgDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</BookgDt> </BookgDt>
<ValDt> <ValDt>
<Dt>2013-01-05</Dt>
<Dt>2014-01-05</Dt>
</ValDt> </ValDt>
<BkTxCd> <BkTxCd>
<Domn> <Domn>
@ -202,7 +202,7 @@
<NtryDtls> <NtryDtls>
<TxDtls> <TxDtls>
<Refs> <Refs>
<InstrId>INNDNL2U20130105000217200000708</InstrId>
<InstrId>INNDNL2U20140105000217200000708</InstrId>
<EndToEndId>115</EndToEndId> <EndToEndId>115</EndToEndId>
</Refs> </Refs>
<AmtDtls> <AmtDtls>

BIN
account_bank_statement_import_camt/test_files/test-camt053.zip

11
account_bank_statement_import_camt/tests/test_import_bank_statement.py

@ -31,11 +31,10 @@ class TestImport(TestStatementFile):
{ {
'remote_account': 'NL46ABNA0499998748', 'remote_account': 'NL46ABNA0499998748',
'transferred_amount': -754.25, 'transferred_amount': -754.25,
'value_date': '2013-01-05',
'value_date': '2014-01-05',
'ref': '435005714488-ABNO33052620', 'ref': '435005714488-ABNO33052620',
}, },
] ]
# statement name is account number + '-' + date of last 62F line:
self._test_statement_import( self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.xml', 'account_bank_statement_import_camt', 'test-camt053.xml',
'1234Test/1', '1234Test/1',
@ -43,3 +42,11 @@ class TestImport(TestStatementFile):
start_balance=15568.27, end_balance=15121.12, start_balance=15568.27, end_balance=15121.12,
transactions=transactions transactions=transactions
) )
def test_zip_import(self):
"""Test import of multiple statements from zip file."""
self._test_statement_import(
'account_bank_statement_import_camt', 'test-camt053.zip',
'1234Test/2', # Only name of first statement
local_account='NL77ABNA0574908765',
)
Loading…
Cancel
Save