Tom
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
69 additions and
0 deletions
-
account_bank_statement_import_camt/models/parser.py
-
account_bank_statement_import_camt/test_files/golden-camt053-no-ntry.pydata
-
account_bank_statement_import_camt/test_files/golden-camt053-txdtls.pydata
-
account_bank_statement_import_camt/test_files/golden-camt053.pydata
-
account_bank_statement_import_camt/test_files/test-camt053-no-ntry
-
account_bank_statement_import_camt/tests/test_import_bank_statement.py
|
|
@ -65,6 +65,7 @@ class CamtParser(models.AbstractModel): |
|
|
|
ns, node, [ |
|
|
|
'./ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', |
|
|
|
'./ns:Refs/ns:EndToEndId', |
|
|
|
'./ns:Ntry/ns:AcctSvcrRef' |
|
|
|
], |
|
|
|
transaction, 'ref' |
|
|
|
) |
|
|
@ -135,6 +136,7 @@ class CamtParser(models.AbstractModel): |
|
|
|
ns, node, [ |
|
|
|
'./ns:NtryDtls/ns:RmtInf/ns:Strd/ns:CdtrRefInf/ns:Ref', |
|
|
|
'./ns:NtryDtls/ns:Btch/ns:PmtInfId', |
|
|
|
'./ns:NtryDtls/ns:TxDtls/ns:Refs/ns:AcctSvcrRef' |
|
|
|
], |
|
|
|
transaction, 'ref' |
|
|
|
) |
|
|
@ -205,6 +207,12 @@ class CamtParser(models.AbstractModel): |
|
|
|
for entry_node in entry_nodes: |
|
|
|
transactions.extend(self.parse_entry(ns, entry_node)) |
|
|
|
result['transactions'] = transactions |
|
|
|
result['date'] = None |
|
|
|
if transactions: |
|
|
|
result['date'] = sorted(transactions, |
|
|
|
key=lambda x: x['date'], |
|
|
|
reverse=True |
|
|
|
)[0]['date'] |
|
|
|
return result |
|
|
|
|
|
|
|
def check_version(self, ns, root): |
|
|
|
|
|
@ -0,0 +1 @@ |
|
|
|
(None, None, []) |
|
|
@ -2,6 +2,7 @@ |
|
|
|
'CH1111000000123456789', |
|
|
|
[{'balance_end_real': 79443.15, |
|
|
|
'balance_start': 75960.15, |
|
|
|
'date': '2017-03-22', |
|
|
|
'name': '20170323123456789012345', |
|
|
|
'transactions': [{'account_number': 'CH2222000000123456789', |
|
|
|
'amount': 2187.0, |
|
|
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
'NL77ABNA0574908765', |
|
|
|
[{'balance_end_real': 15121.12, |
|
|
|
'balance_start': 15568.27, |
|
|
|
'date': '2014-01-05', |
|
|
|
'name': '1234Test/1', |
|
|
|
'transactions': [{'account_bic': 'ABNANL2A', |
|
|
|
'account_number': 'NL46ABNA0499998748', |
|
|
|
|
|
@ -0,0 +1,52 @@ |
|
|
|
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.04"> |
|
|
|
<BkToCstmrStmt> |
|
|
|
<GrpHdr> |
|
|
|
<MsgId>TESTBANK/NL/1420561226673</MsgId> |
|
|
|
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm> |
|
|
|
</GrpHdr> |
|
|
|
<Stmt> |
|
|
|
<Id>1234Test/1</Id> |
|
|
|
<LglSeqNb>2</LglSeqNb> |
|
|
|
<CreDtTm>2014-01-06T16:20:26.673Z</CreDtTm> |
|
|
|
<FrToDt> |
|
|
|
<FrDtTm>2014-01-05T00:00:00.000Z</FrDtTm> |
|
|
|
<ToDtTm>2014-01-05T23:59:59.999Z</ToDtTm> |
|
|
|
</FrToDt> |
|
|
|
<Acct> |
|
|
|
<Id> |
|
|
|
<IBAN>NL77ABNA0574908765</IBAN> |
|
|
|
</Id> |
|
|
|
<Nm>Example company</Nm> |
|
|
|
<Svcr> |
|
|
|
<FinInstnId> |
|
|
|
<BIC>ABNANL2A</BIC> |
|
|
|
</FinInstnId> |
|
|
|
</Svcr> |
|
|
|
</Acct> |
|
|
|
<Bal> |
|
|
|
<Tp> |
|
|
|
<CdOrPrtry> |
|
|
|
<Cd>OPBD</Cd> |
|
|
|
</CdOrPrtry> |
|
|
|
</Tp> |
|
|
|
<Amt Ccy="CHF">1520.76</Amt> |
|
|
|
<CdtDbtInd>CRDT</CdtDbtInd> |
|
|
|
<Dt> |
|
|
|
<Dt>2014-01-05</Dt> |
|
|
|
</Dt> |
|
|
|
</Bal> |
|
|
|
<Bal> |
|
|
|
<Tp> |
|
|
|
<CdOrPrtry> |
|
|
|
<Cd>CLBD</Cd> |
|
|
|
</CdOrPrtry> |
|
|
|
</Tp> |
|
|
|
<Amt Ccy="CHF">1520.76</Amt> |
|
|
|
<CdtDbtInd>CRDT</CdtDbtInd> |
|
|
|
<Dt> |
|
|
|
<Dt>2014-01-05</Dt> |
|
|
|
</Dt> |
|
|
|
</Bal> |
|
|
|
</Stmt> |
|
|
|
</BkToCstmrStmt> |
|
|
|
</Document> |
|
|
@ -46,6 +46,12 @@ class TestParser(TransactionCase): |
|
|
|
DATA_DIR + 'test-camt053-txdtls', |
|
|
|
DATA_DIR + 'golden-camt053-txdtls.pydata') |
|
|
|
|
|
|
|
def test_parse_no_ntry(self): |
|
|
|
self._do_parse_test( |
|
|
|
DATA_DIR + 'test-camt053-no-ntry', |
|
|
|
DATA_DIR + 'golden-camt053-no-ntry.pydata', |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
class TestImport(TransactionCase): |
|
|
|
"""Run test to import camt import.""" |
|
|
|