import der transaktionen begonnen
This commit is contained in:
parent
b50927753b
commit
0287452fe8
11 changed files with 637 additions and 15 deletions
|
@ -3,6 +3,8 @@
|
|||
# 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
|
||||
|
@ -48,7 +50,7 @@ class CategoryTestCase(CashbookTestCase):
|
|||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
"""The following categories are now imported:\\n
|
||||
"""The following categories are now imported:\n
|
||||
Gehalt (in)
|
||||
Gehalt/Zulagen (in)
|
||||
|
||||
|
@ -238,6 +240,175 @@ I
|
|||
'PGA NR00002168 BLZ10000000 0\nL[S-Giro]\n^\nD05.12.2013\nCX\nMsome food\n'+
|
||||
'T-56,37\nPFoodshop Zehlendorf\nLLebensmittel\n^\n')
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_convert_transactions(self):
|
||||
""" convert_transactions_to_create
|
||||
"""
|
||||
pool = Pool()
|
||||
QifTool = pool.get('cashbook_dataexchange.qiftool')
|
||||
Category = pool.get('cashbook.category')
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
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'),
|
||||
}])
|
||||
self.assertEqual(book.name, 'Cash Book')
|
||||
self.assertEqual(book.btype.rec_name, 'CAS - Cash')
|
||||
|
||||
Category.create([{
|
||||
'name': 'Lebensmittel',
|
||||
'cattype': 'out',
|
||||
'company': company.id,
|
||||
}, {
|
||||
'name': 'Haushaltschemie',
|
||||
'cattype': 'out',
|
||||
'company': company.id,
|
||||
}, {
|
||||
'name': 'Kosmetik',
|
||||
'cattype': 'out',
|
||||
'company': company.id,
|
||||
}, {
|
||||
'name': 'S-Giro',
|
||||
'cattype': 'in',
|
||||
'company': company.id,
|
||||
}, {
|
||||
'name': 'Bargeld',
|
||||
'cattype': 'in',
|
||||
'company': company.id,
|
||||
}, ])
|
||||
|
||||
tr_list = QifTool.qif_read_transactions('D04.12.2013\nT7,12\nCX\n'+
|
||||
'POpening Balance\nL[Bargeld]\n^\nD05.12.2013\nCX\n'+
|
||||
'M05.12/06.42UHR TT TELTOW\nT290,00\nPGA NR00002168 BLZ10000000 0\n'+
|
||||
'L[S-Giro]\n^\nD05.12.2013\nCX\nMsome food\nT-56,37\n'+
|
||||
'PFoodshop Zehlendorf\nLLebensmittel\n^\nD22.10.2020\n'+
|
||||
'CX\nMLebensmittel\nT-55,84\nPreal,- Teltow\nLLebensmittel\n'+
|
||||
'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)
|
||||
self.assertEqual(msg_txt, [])
|
||||
self.assertEqual(to_create, [{
|
||||
'date': date(2013, 12, 4),
|
||||
'amount': Decimal('7.12'),
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'category': 74,
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('290.00'),
|
||||
'description': '05.12/06.42UHR TT TELTOW',
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'category': 73,
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('56.37'),
|
||||
'description': 'some food',
|
||||
'state': 'check',
|
||||
'bookingtype': 'out',
|
||||
'category': 70,
|
||||
}, {
|
||||
'date': date(2020, 10, 22),
|
||||
'amount': Decimal('55.84'),
|
||||
'description': 'Lebensmittel',
|
||||
'state': 'edit',
|
||||
'bookingtype': 'spout',
|
||||
'category': 70,
|
||||
'splitlines': [
|
||||
('create', [{
|
||||
'amount': Decimal('49.36'),
|
||||
'description': 'Lebensmittel',
|
||||
'category': 70,
|
||||
}, {
|
||||
'amount': Decimal('2.99'),
|
||||
'description': 'Klopapier',
|
||||
'category': 72,
|
||||
}, {
|
||||
'amount': Decimal('3.49'),
|
||||
'description': 'Sagrotan',
|
||||
'category': 71,
|
||||
}],
|
||||
)],
|
||||
}])
|
||||
Book.write(*[
|
||||
[book],
|
||||
{
|
||||
'lines': [('create', to_create)],
|
||||
}])
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(book.balance, Decimal('184.91'))
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_read_transactions(self):
|
||||
""" read transaction data from text
|
||||
"""
|
||||
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
||||
|
||||
result = QifTool.qif_read_transactions('D04.12.2013\nT7,12\nCX\n'+
|
||||
'POpening Balance\nL[Bargeld]\n^\nD05.12.2013\nCX\n'+
|
||||
'M05.12/06.42UHR TT TELTOW\nT290,00\nPGA NR00002168 BLZ10000000 0\n'+
|
||||
'L[S-Giro]\n^\nD05.12.2013\nCX\nMsome food\nT-56,37\n'+
|
||||
'PFoodshop Zehlendorf\nLLebensmittel\n^\nD22.10.2020\n'+
|
||||
'CX\nMLebensmittel\nT-55,84\nPreal,- Teltow\nLLebensmittel\n'+
|
||||
'SLebensmittel\nELebensmittel\n$-49,36\nSKosmetik\nEKlopapier\n'+
|
||||
'$-2,99\nSHaushaltschemie\nESagrotan\n$-3,49\n^\n')
|
||||
self.assertEqual(result, [{
|
||||
'split': [],
|
||||
'date': date(2013, 12, 4),
|
||||
'amount': Decimal('7.12'),
|
||||
'state': 'check',
|
||||
'party': 'Opening Balance',
|
||||
'account': 'Bargeld',
|
||||
}, {
|
||||
'split': [],
|
||||
'date': date(2013, 12, 5),
|
||||
'state': 'check',
|
||||
'description': '05.12/06.42UHR TT TELTOW',
|
||||
'amount': Decimal('290.00'),
|
||||
'party': 'GA NR00002168 BLZ10000000 0',
|
||||
'account': 'S-Giro',
|
||||
}, {
|
||||
'split': [],
|
||||
'date': date(2013, 12, 5),
|
||||
'state': 'check',
|
||||
'description': 'some food',
|
||||
'amount': Decimal('-56.37'),
|
||||
'party': 'Foodshop Zehlendorf',
|
||||
'category': 'Lebensmittel',
|
||||
}, {
|
||||
'split': [{
|
||||
'category': 'Lebensmittel',
|
||||
'description': 'Lebensmittel',
|
||||
'amount': Decimal('-49.36'),
|
||||
}, {
|
||||
'category': 'Kosmetik',
|
||||
'description': 'Klopapier',
|
||||
'amount': Decimal('-2.99'),
|
||||
}, {
|
||||
'category': 'Haushaltschemie',
|
||||
'description': 'Sagrotan',
|
||||
'amount': Decimal('-3.49'),
|
||||
}],
|
||||
'date': date(2020, 10, 22),
|
||||
'state': 'check',
|
||||
'description': 'Lebensmittel',
|
||||
'amount': Decimal('-55.84'),
|
||||
'party': 'real,- Teltow',
|
||||
'category': 'Lebensmittel',
|
||||
}])
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_read_categories(self):
|
||||
""" read category-data from text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue