Browse Source

Merge pull request #133 from eLBati/10.0-camt054

[10.0] allow camt054 to be parsed
pull/147/head
Alexis de Lattre 7 years ago
committed by GitHub
parent
commit
e8ea38d911
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      account_bank_statement_import_camt/README.rst
  2. 2
      account_bank_statement_import_camt/__manifest__.py
  3. 10
      account_bank_statement_import_camt/models/parser.py

2
account_bank_statement_import_camt/README.rst

@ -4,7 +4,7 @@
Bank Statement Parse Camt Bank Statement Parse Camt
========================= =========================
Module to import SEPA CAMT.053 Format bank statement files.
Module to import SEPA CAMT.053 and CAMT.054 Format bank statement files.
Based on the Banking addons framework. Based on the Banking addons framework.

2
account_bank_statement_import_camt/__manifest__.py

@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
'name': 'CAMT Format Bank Statements Import', 'name': 'CAMT Format Bank Statements Import',
'version': '10.0.1.1.0',
'version': '10.0.1.1.1',
'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',

10
account_bank_statement_import_camt/models/parser.py

@ -222,22 +222,24 @@ class CamtParser(models.AbstractModel):
) )
if not re_camt.search(ns): if not re_camt.search(ns):
raise ValueError('no camt: ' + ns) raise ValueError('no camt: ' + ns)
# Check wether version 052 or 053:
# Check wether version 052 ,053 or 054:
re_camt_version = re.compile( re_camt_version = re.compile(
r'(^urn:iso:std:iso:20022:tech:xsd:camt.053.'
r'(^urn:iso:std:iso:20022:tech:xsd:camt.054.'
r'|^urn:iso:std:iso:20022:tech:xsd:camt.053.'
r'|^urn:iso:std:iso:20022:tech:xsd:camt.052.' r'|^urn:iso:std:iso:20022:tech:xsd:camt.052.'
r'|^ISO:camt.054.'
r'|^ISO:camt.053.' r'|^ISO:camt.053.'
r'|^ISO:camt.052.)' r'|^ISO:camt.052.)'
) )
if not re_camt_version.search(ns): if not re_camt_version.search(ns):
raise ValueError('no camt 052 or 053: ' + ns)
raise ValueError('no camt 052 or 053 or 054: ' + ns)
# Check GrpHdr element: # Check GrpHdr element:
root_0_0 = root[0][0].tag[len(ns) + 2:] # strip namespace root_0_0 = root[0][0].tag[len(ns) + 2:] # strip namespace
if root_0_0 != 'GrpHdr': if root_0_0 != 'GrpHdr':
raise ValueError('expected GrpHdr, got: ' + root_0_0) raise ValueError('expected GrpHdr, got: ' + root_0_0)
def parse(self, data): def parse(self, data):
"""Parse a camt.052 or camt.053 file."""
"""Parse a camt.052 or camt.053 or camt.054 file."""
try: try:
root = etree.fromstring( root = etree.fromstring(
data, parser=etree.XMLParser(recover=True)) data, parser=etree.XMLParser(recover=True))

Loading…
Cancel
Save