Browse Source

[IMP] account_bank_statement_import_paypal: DE mapping; use account number

12.0
Alexey Pelykh 5 years ago
parent
commit
5450ff2121
  1. 45
      account_bank_statement_import_paypal/data/maps.xml
  2. 8
      account_bank_statement_import_paypal/models/account_bank_statement_import_paypal_parser.py
  3. 26
      account_bank_statement_import_paypal/tests/test_account_bank_statement_import_paypal.py

45
account_bank_statement_import_paypal/data/maps.xml

@ -96,4 +96,49 @@
<field name="note_column">Nota</field> <field name="note_column">Nota</field>
</record> </record>
<record id="paypal_statement_map_de" model="account.bank.statement.import.paypal.mapping">
<field name="name">PayPal Statement (DE)</field>
<field name="float_thousands_sep">dot</field>
<field name="float_decimal_sep">comma</field>
<field name="date_format">%d.%m.%Y</field>
<field name="time_format">%H:%M:%S</field>
<field name="date_column">Datum</field>
<field name="time_column">Uhrzeit</field>
<field name="tz_column">Zeitzone</field>
<field name="name_column">Name</field>
<field name="currency_column">Währung</field>
<field name="gross_column">Brutto</field>
<field name="fee_column">Gebühr</field>
<field name="balance_column">Guthaben</field>
<field name="transaction_id_column">Transaktionscode</field>
<field name="description_column">Beschreibung</field>
<field name="from_email_address_column">Absender E-Mail-Adresse</field>
<field name="invoice_id_column">Rechnungsnummer</field>
<field name="bank_name_column">Name der Bank</field>
<field name="bank_account_column">Bankkonto</field>
</record>
<record id="paypal_activity_map_de" model="account.bank.statement.import.paypal.mapping">
<field name="name">PayPal Activity (DE)</field>
<field name="float_thousands_sep">dot</field>
<field name="float_decimal_sep">comma</field>
<field name="date_format">%d.%m.%Y</field>
<field name="time_format">%H:%M:%S</field>
<field name="date_column">Datum</field>
<field name="time_column">Uhrzeit</field>
<field name="tz_column">Zeitzone</field>
<field name="name_column">Name</field>
<field name="currency_column">Währung</field>
<field name="gross_column">Brutto</field>
<field name="fee_column">Gebühr</field>
<field name="balance_column">Guthaben</field>
<field name="transaction_id_column">Transaktionscode</field>
<field name="type_column">Typ</field>
<field name="from_email_address_column">Absender E-Mail-Adresse</field>
<field name="to_email_address_column">Empfänger E-Mail-Adresse</field>
<field name="invoice_id_column">Rechnungsnummer</field>
<field name="subject_column">Betreff</field>
<field name="note_column">Hinweis</field>
</record>
</odoo> </odoo>

8
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, 'balance_amount': balance_amount,
'payer_name': name_value, 'payer_name': name_value,
'payer_email': payer_email, 'payer_email': payer_email,
'partner_bank_name': bank_name_value,
'partner_bank_account': bank_account_value,
}) })
return lines return lines
@ -211,6 +213,8 @@ class AccountBankStatementImportPayPalParser(models.TransientModel):
fee_amount = line['fee_amount'] fee_amount = line['fee_amount']
payer_name = line['payer_name'] payer_name = line['payer_name']
payer_email = line['payer_email'] payer_email = line['payer_email']
partner_bank_account = line['partner_bank_account']
if invoice: if invoice:
invoice = _('Invoice %s') % invoice invoice = _('Invoice %s') % invoice
note = '%s %s' % ( note = '%s %s' % (
@ -238,6 +242,10 @@ class AccountBankStatementImportPayPalParser(models.TransientModel):
line.update({ line.update({
'partner_name': payer_name, 'partner_name': payer_name,
}) })
if partner_bank_account:
line.update({
'account_number': partner_bank_account,
})
transactions.append(transaction) transactions.append(transaction)
if fee_amount: if fee_amount:

26
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: with open(path.join(path.dirname(__file__), filename)) as file:
return b64encode(file.read().encode('utf-8')) return b64encode(file.read().encode('utf-8'))
def test_import_statement_en(self):
def test_import_statement_en_usd(self):
journal = self.AccountJournal.create({ journal = self.AccountJournal.create({
'name': 'PayPal', 'name': 'PayPal',
'type': 'bank', 'type': 'bank',
@ -66,6 +66,30 @@ class TestAccountBankStatementImportPayPal(common.TransactionCase):
self.assertEqual(len(statement), 1) self.assertEqual(len(statement), 1)
self.assertEqual(len(statement.line_ids), 18) 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): def test_import_statement_es(self):
journal = self.AccountJournal.create({ journal = self.AccountJournal.create({
'name': 'PayPal', 'name': 'PayPal',

Loading…
Cancel
Save