-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.0][FIX] account_bank_statement_import_mt940_base. No eref in messa…
…ge. (#159)
- Loading branch information
1 parent
436bf35
commit c6968ac
Showing
4 changed files
with
59 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from . import test_mt940_parser |
45 changes: 45 additions & 0 deletions
45
account_bank_statement_import_mt940_base/tests/test_mt940_parser.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2018 Therp BV <https://therp.nl>. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openerp.tests.common import TransactionCase | ||
|
||
from openerp.addons.account_bank_statement_import.parserlib import \ | ||
BankTransaction | ||
|
||
from ..mt940 import str2amount, get_subfields, handle_common_subfields | ||
|
||
|
||
RECORD86 = ( | ||
":86:/EREF/ZZ12T32FYCIO7YPXC//CNTP/FR7630239881239147035594069/BNP" | ||
"AFRPP/JOHN WHO PAID///REMI/USTD//virt AD 934637/") | ||
CODEWORDS = [ | ||
'RTRN', 'BENM', 'ORDP', 'CSID', 'BUSP', 'MARF', 'EREF', | ||
'PREF', 'REMI', 'ID', 'PURP', 'ULTB', 'ULTD', | ||
'CREF', 'IREF', 'CNTP', 'ULTC', 'EXCH', 'CHGS'] | ||
|
||
|
||
class TestMT940Parser(TransactionCase): | ||
"""Test common methods in mt940 parser.""" | ||
|
||
def test_str2amount(self): | ||
"""Test conversion of string to amount.""" | ||
amount = str2amount('C', '16,16') | ||
self.assertEqual(amount, 16.16) | ||
amount = str2amount('D', '25,25') | ||
self.assertEqual(amount, -25.25) | ||
|
||
def test_get_subfields(self): | ||
"""Test get subfields.""" | ||
subfields = get_subfields(RECORD86, CODEWORDS) | ||
self.assertIn('EREF', subfields) | ||
self.assertEqual('ZZ12T32FYCIO7YPXC', subfields['EREF'][0]) | ||
self.assertIn('REMI', subfields) | ||
self.assertEqual('virt AD 934637', subfields['REMI'][2]) | ||
|
||
def test_handle_common_subfields(self): | ||
"""test handle_common_subfields""" | ||
transaction = BankTransaction() | ||
subfields = get_subfields(RECORD86, CODEWORDS) | ||
handle_common_subfields(transaction, subfields) | ||
self.assertEqual('virt AD 934637', transaction.message) | ||
self.assertEqual('ZZ12T32FYCIO7YPXC', transaction.eref) |