import: party, transaction
übersetzung korrigiert
This commit is contained in:
parent
50cbb2cc37
commit
833f49c9a6
11 changed files with 383 additions and 86 deletions
|
@ -5,12 +5,16 @@ import trytond.tests.test_tryton
|
|||
import unittest
|
||||
|
||||
from trytond.modules.cashbook_dataexchange.tests.test_category import CategoryTestCase
|
||||
from trytond.modules.cashbook_dataexchange.tests.test_party import PartyTestCase
|
||||
from trytond.modules.cashbook_dataexchange.tests.test_transaction import TransactionTestCase
|
||||
|
||||
__all__ = ['suite']
|
||||
|
||||
|
||||
class CashbookExchangeTestCase(\
|
||||
CategoryTestCase,\
|
||||
PartyTestCase,\
|
||||
TransactionTestCase,\
|
||||
):
|
||||
'Test cashbook exchange module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
|
|
@ -14,7 +14,7 @@ from .qifdata import qif_category, qif_types
|
|||
|
||||
class CategoryTestCase(CashbookTestCase):
|
||||
'Test cashbook categoy module'
|
||||
module = 'CashbookExchangeTestCase'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
@with_transaction()
|
||||
def test_wiz_import_category(self):
|
||||
|
@ -247,6 +247,7 @@ I
|
|||
pool = Pool()
|
||||
QifTool = pool.get('cashbook_dataexchange.qiftool')
|
||||
Category = pool.get('cashbook.category')
|
||||
Party = pool.get('party.party')
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
company = self.prep_company()
|
||||
|
@ -266,7 +267,21 @@ I
|
|||
self.assertEqual(book.name, 'Cash Book')
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
|
||||
Category.create([{
|
||||
parties = Party.create([{
|
||||
'name': 'Opening Balance',
|
||||
'addresses': [('create', [{}])],
|
||||
}, {
|
||||
'name': 'GA NR00002168 BLZ10000000 0',
|
||||
'addresses': [('create', [{}])],
|
||||
}, {
|
||||
'name': 'Foodshop Zehlendorf',
|
||||
'addresses': [('create', [{}])],
|
||||
}, {
|
||||
'name': 'real,- Teltow',
|
||||
'addresses': [('create', [{}])],
|
||||
}])
|
||||
|
||||
categories = Category.create([{
|
||||
'name': 'Lebensmittel',
|
||||
'cattype': 'out',
|
||||
'company': company.id,
|
||||
|
@ -297,48 +312,52 @@ I
|
|||
'SLebensmittel\nELebensmittel\n$-49,36\nSKosmetik\nEKlopapier\n'+
|
||||
'$-2,99\nSHaushaltschemie\nESagrotan\n$-3,49\n^\n')
|
||||
|
||||
(to_create, msg_txt) = QifTool.convert_transactions_to_create(tr_list)
|
||||
(to_create, msg_txt, fail_cnt) = QifTool.convert_transactions_to_create(tr_list)
|
||||
self.assertEqual(msg_txt, [])
|
||||
self.assertEqual(to_create, [{
|
||||
'date': date(2013, 12, 4),
|
||||
'amount': Decimal('7.12'),
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'category': 74,
|
||||
'party': parties[0].id,
|
||||
'category': categories[4].id,
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('290.00'),
|
||||
'description': '05.12/06.42UHR TT TELTOW',
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'category': 73,
|
||||
'party': parties[1].id,
|
||||
'category': categories[3].id,
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('56.37'),
|
||||
'description': 'some food',
|
||||
'state': 'check',
|
||||
'bookingtype': 'out',
|
||||
'category': 70,
|
||||
'party': parties[2].id,
|
||||
'category': categories[0].id,
|
||||
}, {
|
||||
'date': date(2020, 10, 22),
|
||||
'amount': Decimal('55.84'),
|
||||
'description': 'Lebensmittel',
|
||||
'state': 'edit',
|
||||
'bookingtype': 'spout',
|
||||
'category': 70,
|
||||
'category': categories[0].id,
|
||||
'party': parties[3].id,
|
||||
'splitlines': [
|
||||
('create', [{
|
||||
'amount': Decimal('49.36'),
|
||||
'description': 'Lebensmittel',
|
||||
'category': 70,
|
||||
'category': categories[0].id,
|
||||
}, {
|
||||
'amount': Decimal('2.99'),
|
||||
'description': 'Klopapier',
|
||||
'category': 72,
|
||||
'category': categories[2].id,
|
||||
}, {
|
||||
'amount': Decimal('3.49'),
|
||||
'description': 'Sagrotan',
|
||||
'category': 71,
|
||||
'category': categories[1].id,
|
||||
}],
|
||||
)],
|
||||
}])
|
||||
|
|
71
tests/test_party.py
Normal file
71
tests/test_party.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from .qifdata import qif_types
|
||||
|
||||
|
||||
class PartyTestCase(ModuleTestCase):
|
||||
'Test cashbook party module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
@with_transaction()
|
||||
def test_wiz_import_party(self):
|
||||
""" create parties by run wizard
|
||||
"""
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'party.party',
|
||||
}):
|
||||
(sess_id, start_state, end_state) = ImportWiz.create()
|
||||
w_obj = ImportWiz(sess_id)
|
||||
self.assertEqual(start_state, 'start')
|
||||
self.assertEqual(end_state, 'end')
|
||||
|
||||
# run start
|
||||
result = ImportWiz.execute(sess_id, {}, start_state)
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
|
||||
r1 = {}
|
||||
r1['file_'] = qif_types.encode('utf8')
|
||||
r1['company'] = company.id
|
||||
w_obj.start.file_ = r1['file_']
|
||||
w_obj.start.company = company.id
|
||||
|
||||
result = ImportWiz.execute(sess_id, {'start': r1}, 'readf')
|
||||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
"""The following 3 parties are now imported:\n
|
||||
Opening Balance
|
||||
GA NR00002168 BLZ10000000 0
|
||||
Foodshop Zehlendorf""")
|
||||
|
||||
r1 = {'company': company.id}
|
||||
result = ImportWiz.execute(sess_id, {'showinfo': r1}, 'importf')
|
||||
self.assertEqual(list(result.keys()), [])
|
||||
|
||||
ImportWiz.delete(sess_id)
|
||||
|
||||
records = Party.search([], order=[('name', 'ASC')])
|
||||
self.assertEqual(len(records), 4)
|
||||
|
||||
self.assertEqual(records[0].rec_name, 'Foodshop Zehlendorf')
|
||||
self.assertEqual(records[1].rec_name, 'GA NR00002168 BLZ10000000 0')
|
||||
self.assertEqual(records[2].rec_name, 'm-ds')
|
||||
self.assertEqual(records[3].rec_name, 'Opening Balance')
|
||||
|
||||
# end PartyTestCase
|
108
tests/test_transaction.py
Normal file
108
tests/test_transaction.py
Normal file
|
@ -0,0 +1,108 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from .qifdata import qif_types
|
||||
|
||||
|
||||
class TransactionTestCase(ModuleTestCase):
|
||||
'Test cashbook transaction module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
@with_transaction()
|
||||
def test_wiz_import_transactions(self):
|
||||
""" create transactions by run wizard
|
||||
"""
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
Category = pool.get('cashbook.category')
|
||||
Book = pool.get('cashbook.book')
|
||||
ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'cashbook.book',
|
||||
}):
|
||||
types = self.prep_type()
|
||||
book, = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2010, 1, 1),
|
||||
'start_balance': Decimal('0.0'),
|
||||
}])
|
||||
|
||||
Party.create([{
|
||||
'name': 'GA NR00002168 BLZ10000000 0',
|
||||
'addresses':[('create', [{}])],
|
||||
}, {
|
||||
'name': 'Foodshop Zehlendorf',
|
||||
'addresses':[('create', [{}])],
|
||||
}, {
|
||||
'name': 'Opening Balance',
|
||||
'addresses':[('create', [{}])],
|
||||
}])
|
||||
|
||||
Category.create([{
|
||||
'name':'Bargeld',
|
||||
'cattype': 'in',
|
||||
}, {
|
||||
'name': 'S-Giro',
|
||||
'cattype': 'in',
|
||||
}, {
|
||||
'name': 'Lebensmittel',
|
||||
'cattype': 'out',
|
||||
}])
|
||||
|
||||
(sess_id, start_state, end_state) = ImportWiz.create()
|
||||
w_obj = ImportWiz(sess_id)
|
||||
self.assertEqual(start_state, 'start')
|
||||
self.assertEqual(end_state, 'end')
|
||||
|
||||
# run start
|
||||
result = ImportWiz.execute(sess_id, {}, start_state)
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
|
||||
r1 = {}
|
||||
r1['file_'] = qif_types.encode('utf8')
|
||||
r1['company'] = company.id
|
||||
r1['book'] = book.id
|
||||
w_obj.start.file_ = r1['file_']
|
||||
w_obj.start.company = company.id
|
||||
w_obj.start.book = book.id
|
||||
|
||||
result = ImportWiz.execute(sess_id, {'start': r1}, 'readf')
|
||||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
"""The following transactionen are now imported:
|
||||
Balance: usd240.75
|
||||
Number of transactions: 3""")
|
||||
|
||||
r1 = {
|
||||
'company': company.id,
|
||||
'book': book.id,
|
||||
}
|
||||
result = ImportWiz.execute(sess_id, {'showinfo': r1}, 'importf')
|
||||
self.assertEqual(list(result.keys()), [])
|
||||
|
||||
ImportWiz.delete(sess_id)
|
||||
|
||||
self.assertEqual(len(book.lines), 3)
|
||||
|
||||
self.assertEqual(book.lines[0].rec_name, '12/04/2013|Rev|7.12 usd|- [Bargeld]')
|
||||
self.assertEqual(book.lines[1].rec_name, '12/05/2013|Rev|290.00 usd|05.12/06.42UHR TT TELTOW [S-Giro]')
|
||||
self.assertEqual(book.lines[2].rec_name, '12/05/2013|Exp|-56.37 usd|some food [Lebensmittel]')
|
||||
|
||||
# end PartyTestCase
|
Loading…
Add table
Add a link
Reference in a new issue