mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[IMP] account_bank_statement_import_paypal: create paypal maps
This commit is contained in:
1
account_statement_import_paypal/tests/__init__.py
Normal file
1
account_statement_import_paypal/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_paypal_statement_import
|
||||
3
account_statement_import_paypal/tests/paypal_en.csv
Normal file
3
account_statement_import_paypal/tests/paypal_en.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
"Date","Time","Time Zone","Description","Currency","Gross","Fee ","Net","Balance","Transaction ID","From Email Address","Name","Bank Name","Bank Account","Shipping and Handling Amount","Sales Tax","Invoice ID","Reference Txn ID"
|
||||
"12/15/2018","20:07:53","CET","Your best supplier","USD","-33,50","-2,3","-31,2","-31,2","53820712527632627","","John Doe","Bank of America","123456789","0","0","INV25","23"
|
||||
"12/15/2018","22:07:53","CET","Your payment","USD","525","0","525","493,80","34731322767782103","","Agrolait","","","0","0","INV/2019/0003","24"
|
||||
|
@@ -0,0 +1,54 @@
|
||||
# Copyright 2019 Tecnativa - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import os
|
||||
import base64
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestPaypalFile(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestPaypalFile, cls).setUpClass()
|
||||
|
||||
cls.map = cls.env['account.bank.statement.import.paypal.map'].create({
|
||||
'name': 'Paypal Map Test',
|
||||
})
|
||||
cls.journal = cls.env['account.journal'].create({
|
||||
'name': 'Paypal Bank',
|
||||
'type': 'bank',
|
||||
'code': 'PYPAL',
|
||||
})
|
||||
|
||||
def _do_import(self, file_name):
|
||||
file_name = os.path.join(os.path.dirname(__file__), file_name)
|
||||
return open(file_name).read()
|
||||
|
||||
def test_import_header(self):
|
||||
file = self._do_import('paypal_en.csv')
|
||||
file = base64.b64encode(file.encode("utf-8"))
|
||||
wizard = self.env['wizard.paypal.map.create'].with_context({
|
||||
'journal_id': self.journal.id,
|
||||
'active_ids': [self.map.id],
|
||||
}).create({'data_file': file})
|
||||
wizard.create_map_lines()
|
||||
self.assertEqual(len(self.map.map_line_ids.ids), 18)
|
||||
|
||||
def test_import_paypal_file(self):
|
||||
# Current statements before to run the wizard
|
||||
old_statements = self.env['account.bank.statement'].search([])
|
||||
# This journal is for Paypal statements
|
||||
map = self.env.ref('account_bank_statement_import_paypal.paypal_map')
|
||||
self.journal.paypal_map_id = map.id
|
||||
file = self._do_import('paypal_en.csv')
|
||||
file = base64.b64encode(file.encode("utf-8"))
|
||||
wizard = self.env['account.bank.statement.import'].with_context({
|
||||
'journal_id': self.journal.id,
|
||||
}).create({'data_file': file})
|
||||
wizard.import_file()
|
||||
staments_now = self.env['account.bank.statement'].search([])
|
||||
statement = staments_now - old_statements
|
||||
self.assertEqual(len(statement.line_ids), 3)
|
||||
self.assertEqual(len(statement.mapped('line_ids').filtered(
|
||||
lambda x: x.partner_id and x.account_id)), 1)
|
||||
self.assertAlmostEqual(sum(statement.mapped('line_ids.amount')), 489.2)
|
||||
Reference in New Issue
Block a user