[8.0][FIX] account_bank_statement_import_mt940_base. No eref in message. (#159)

This commit is contained in:
Ronald Portier
2018-08-08 08:16:39 +02:00
committed by Pedro M. Baeza
parent 436bf35252
commit c6968ace1c
4 changed files with 59 additions and 40 deletions

View File

@@ -1,23 +1,7 @@
# -*- coding: utf-8 -*-
"""Generic parser for MT940 files, base for customized versions per bank."""
##############################################################################
#
# Copyright (C) 2014-2015 Therp BV <http://therp.nl>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# Copyright 2014-2018 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import re
import logging
from datetime import datetime
@@ -78,7 +62,12 @@ def get_counterpart(transaction, subfield):
def handle_common_subfields(transaction, subfields):
"""Deal with common functionality for tag 86 subfields."""
"""Deal with common functionality for tag 86 subfields.
transaction.eref is filled from 61 record with information on subfield
that contains the actual reference in 86 record. So transaction.eref
is used for a dual purpose!
"""
# Get counterpart from CNTP, BENM or ORDP subfields:
for counterpart_field in ['CNTP', 'BENM', 'ORDP']:
if counterpart_field in subfields:
@@ -100,9 +89,8 @@ def handle_common_subfields(transaction, subfields):
'/'.join(x for x in subfields['REMI'] if x)
)
# EREF: End-to-end reference
if 'EREF' in subfields:
transaction.message += '/'.join(filter(bool, subfields['EREF']))
# Get transaction reference subfield (might vary):
transaction.eref = transaction.eref or 'EREF'
if transaction.eref in subfields:
transaction.eref = ''.join(subfields[transaction.eref])