From 5450ff2121597aaca76cd306a6c7e7fb4bcdecb8 Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Sat, 11 Apr 2020 08:14:07 +0200 Subject: [PATCH] [IMP] account_bank_statement_import_paypal: DE mapping; use account number --- .../data/maps.xml | 45 +++++++++++++++++++ ...unt_bank_statement_import_paypal_parser.py | 8 ++++ ...st_account_bank_statement_import_paypal.py | 26 ++++++++++- 3 files changed, 78 insertions(+), 1 deletion(-) diff --git a/account_bank_statement_import_paypal/data/maps.xml b/account_bank_statement_import_paypal/data/maps.xml index 1f72754..d583b9e 100644 --- a/account_bank_statement_import_paypal/data/maps.xml +++ b/account_bank_statement_import_paypal/data/maps.xml @@ -96,4 +96,49 @@ Nota + + PayPal Statement (DE) + dot + comma + %d.%m.%Y + %H:%M:%S + Datum + Uhrzeit + Zeitzone + Name + Währung + Brutto + Gebühr + Guthaben + Transaktionscode + Beschreibung + Absender E-Mail-Adresse + Rechnungsnummer + Name der Bank + Bankkonto + + + + PayPal Activity (DE) + dot + comma + %d.%m.%Y + %H:%M:%S + Datum + Uhrzeit + Zeitzone + Name + Währung + Brutto + Gebühr + Guthaben + Transaktionscode + Typ + Absender E-Mail-Adresse + Empfänger E-Mail-Adresse + Rechnungsnummer + Betreff + Hinweis + + diff --git a/account_bank_statement_import_paypal/models/account_bank_statement_import_paypal_parser.py b/account_bank_statement_import_paypal/models/account_bank_statement_import_paypal_parser.py index cdc9bcc..7f9edbf 100644 --- a/account_bank_statement_import_paypal/models/account_bank_statement_import_paypal_parser.py +++ b/account_bank_statement_import_paypal/models/account_bank_statement_import_paypal_parser.py @@ -195,6 +195,8 @@ class AccountBankStatementImportPayPalParser(models.TransientModel): 'balance_amount': balance_amount, 'payer_name': name_value, 'payer_email': payer_email, + 'partner_bank_name': bank_name_value, + 'partner_bank_account': bank_account_value, }) return lines @@ -211,6 +213,8 @@ class AccountBankStatementImportPayPalParser(models.TransientModel): fee_amount = line['fee_amount'] payer_name = line['payer_name'] payer_email = line['payer_email'] + partner_bank_account = line['partner_bank_account'] + if invoice: invoice = _('Invoice %s') % invoice note = '%s %s' % ( @@ -238,6 +242,10 @@ class AccountBankStatementImportPayPalParser(models.TransientModel): line.update({ 'partner_name': payer_name, }) + if partner_bank_account: + line.update({ + 'account_number': partner_bank_account, + }) transactions.append(transaction) if fee_amount: diff --git a/account_bank_statement_import_paypal/tests/test_account_bank_statement_import_paypal.py b/account_bank_statement_import_paypal/tests/test_account_bank_statement_import_paypal.py index afb78b9..983396d 100644 --- a/account_bank_statement_import_paypal/tests/test_account_bank_statement_import_paypal.py +++ b/account_bank_statement_import_paypal/tests/test_account_bank_statement_import_paypal.py @@ -42,7 +42,7 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase): with open(path.join(path.dirname(__file__), filename)) as file: return b64encode(file.read().encode('utf-8')) - def test_import_statement_en(self): + def test_import_statement_en_usd(self): journal = self.AccountJournal.create({ 'name': 'PayPal', 'type': 'bank', @@ -66,6 +66,30 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase): self.assertEqual(len(statement), 1) self.assertEqual(len(statement.line_ids), 18) + def test_import_statement_en_eur(self): + journal = self.AccountJournal.create({ + 'name': 'PayPal', + 'type': 'bank', + 'code': 'PP', + 'currency_id': self.currency_eur.id, + }) + wizard = self.AccountBankStatementImport.with_context({ + 'journal_id': journal.id, + }).create({ + 'filename': 'fixtures/statement_en.csv', + 'data_file': self._data_file('fixtures/statement_en.csv'), + 'paypal_mapping_id': self.paypal_statement_map_en.id, + }) + wizard.with_context({ + 'journal_id': journal.id, + 'account_bank_statement_import_paypal_test': True, + }).import_file() + statement = self.AccountBankStatement.search([ + ('journal_id', '=', journal.id), + ]) + self.assertEqual(len(statement), 1) + self.assertEqual(len(statement.line_ids), 8) + def test_import_statement_es(self): journal = self.AccountJournal.create({ 'name': 'PayPal',