2022-08-28 20:16:34 +00:00
|
|
|
# -*- 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.
|
|
|
|
|
2022-09-01 12:48:04 +00:00
|
|
|
from datetime import date
|
|
|
|
from decimal import Decimal
|
2023-06-06 13:22:57 +00:00
|
|
|
from trytond.tests.test_tryton import with_transaction
|
2022-08-28 20:16:34 +00:00
|
|
|
from trytond.pool import Pool
|
|
|
|
from trytond.transaction import Transaction
|
2023-06-06 13:22:57 +00:00
|
|
|
from .qifdata import qif_types
|
2022-08-28 20:16:34 +00:00
|
|
|
|
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
class CategoryTestCase(object):
|
2022-08-28 20:16:34 +00:00
|
|
|
'Test cashbook categoy module'
|
2022-09-02 12:33:12 +00:00
|
|
|
module = 'cashbook_dataexchange'
|
2022-08-28 20:16:34 +00:00
|
|
|
|
2022-08-30 20:49:52 +00:00
|
|
|
@with_transaction()
|
|
|
|
def test_wiz_import_category(self):
|
|
|
|
""" create categories by run wizard
|
|
|
|
"""
|
|
|
|
pool = Pool()
|
|
|
|
Category = pool.get('cashbook.category')
|
|
|
|
ImportWiz = pool.get('cashbook_dataexchange.qif_imp_wiz', type='wizard')
|
|
|
|
|
|
|
|
company = self.prep_company()
|
|
|
|
with Transaction().set_context({
|
2023-06-06 13:22:57 +00:00
|
|
|
'company': company.id,
|
|
|
|
'active_model': 'cashbook.category'}):
|
2022-08-30 20:49:52 +00:00
|
|
|
(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)
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
result['view']['defaults']['info'],
|
|
|
|
"""The following categories are now imported:\n
|
2022-08-30 20:49:52 +00:00
|
|
|
Gehalt (in)
|
|
|
|
Gehalt/Zulagen (in)
|
|
|
|
|
|
|
|
Telekommunikation (out)
|
|
|
|
Telekommunikation/Online-Dienste (out)
|
|
|
|
Telekommunikation/Telefon (out)
|
|
|
|
Telekommunikation/Telefon/Test1 (out)
|
|
|
|
Telekommunikation/Fernsehen (out)
|
|
|
|
Telefon (out)
|
|
|
|
Telefon/Telco1-Tablett (out)
|
|
|
|
Telefon/Telco2-Handy (out)
|
|
|
|
Telefon/Telco3 (out)
|
|
|
|
Fernsehen (out)
|
|
|
|
Fernsehen/TV-Company (out)
|
|
|
|
Fernsehen/GEZ (out)
|
|
|
|
Lebensmittel (out)""")
|
|
|
|
|
2022-08-31 08:29:24 +00:00
|
|
|
r1 = {'company': company.id}
|
|
|
|
result = ImportWiz.execute(sess_id, {'showinfo': r1}, 'importf')
|
|
|
|
self.assertEqual(list(result.keys()), [])
|
|
|
|
|
2022-08-30 20:49:52 +00:00
|
|
|
ImportWiz.delete(sess_id)
|
|
|
|
|
2022-08-31 08:29:24 +00:00
|
|
|
records = Category.search([], order=[('rec_name', 'ASC')])
|
|
|
|
self.assertEqual(len(records), 15)
|
|
|
|
|
|
|
|
self.assertEqual(records[0].rec_name, 'Fernsehen')
|
|
|
|
self.assertEqual(records[1].rec_name, 'Fernsehen/GEZ')
|
|
|
|
self.assertEqual(records[2].rec_name, 'Fernsehen/TV-Company')
|
|
|
|
self.assertEqual(records[3].rec_name, 'Gehalt')
|
|
|
|
self.assertEqual(records[4].rec_name, 'Gehalt/Zulagen')
|
|
|
|
self.assertEqual(records[5].rec_name, 'Lebensmittel')
|
|
|
|
self.assertEqual(records[6].rec_name, 'Telefon')
|
|
|
|
self.assertEqual(records[7].rec_name, 'Telefon/Telco1-Tablett')
|
|
|
|
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
|
|
|
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
|
|
|
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
records[11].rec_name, 'Telekommunikation/Fernsehen')
|
|
|
|
self.assertEqual(
|
|
|
|
records[12].rec_name, 'Telekommunikation/Online-Dienste')
|
|
|
|
self.assertEqual(
|
|
|
|
records[13].rec_name, 'Telekommunikation/Telefon')
|
|
|
|
self.assertEqual(
|
|
|
|
records[14].rec_name, 'Telekommunikation/Telefon/Test1')
|
2022-08-30 20:49:52 +00:00
|
|
|
|
2022-08-28 20:16:34 +00:00
|
|
|
@with_transaction()
|
|
|
|
def test_category_create_by_qif_emptydb(self):
|
|
|
|
""" create categories by import a qif-file
|
|
|
|
"""
|
|
|
|
pool = Pool()
|
|
|
|
Category = pool.get('cashbook.category')
|
|
|
|
|
|
|
|
company = self.prep_company()
|
|
|
|
with Transaction().set_context({
|
2023-06-06 13:22:57 +00:00
|
|
|
'company': company.id}):
|
2022-08-28 20:16:34 +00:00
|
|
|
records = Category.create_from_qif(qif_types)
|
|
|
|
|
2022-08-30 20:49:52 +00:00
|
|
|
records = Category.search([], order=[('rec_name', 'ASC')])
|
2022-08-28 20:16:34 +00:00
|
|
|
self.assertEqual(len(records), 15)
|
2022-08-30 20:49:52 +00:00
|
|
|
|
2022-08-28 20:16:34 +00:00
|
|
|
self.assertEqual(records[0].rec_name, 'Fernsehen')
|
2022-08-30 20:49:52 +00:00
|
|
|
self.assertEqual(records[1].rec_name, 'Fernsehen/GEZ')
|
|
|
|
self.assertEqual(records[2].rec_name, 'Fernsehen/TV-Company')
|
|
|
|
self.assertEqual(records[3].rec_name, 'Gehalt')
|
|
|
|
self.assertEqual(records[4].rec_name, 'Gehalt/Zulagen')
|
|
|
|
self.assertEqual(records[5].rec_name, 'Lebensmittel')
|
|
|
|
self.assertEqual(records[6].rec_name, 'Telefon')
|
|
|
|
self.assertEqual(records[7].rec_name, 'Telefon/Telco1-Tablett')
|
|
|
|
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
|
|
|
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
|
|
|
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
records[11].rec_name, 'Telekommunikation/Fernsehen')
|
|
|
|
self.assertEqual(
|
|
|
|
records[12].rec_name, 'Telekommunikation/Online-Dienste')
|
|
|
|
self.assertEqual(
|
|
|
|
records[13].rec_name, 'Telekommunikation/Telefon')
|
|
|
|
self.assertEqual(
|
|
|
|
records[14].rec_name, 'Telekommunikation/Telefon/Test1')
|
2022-08-28 20:16:34 +00:00
|
|
|
|
2022-08-31 15:32:01 +00:00
|
|
|
result = Category.export_as_qif()
|
|
|
|
self.assertEqual(result, """!Type:Cat
|
|
|
|
NFernsehen
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NFernsehen:GEZ
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NFernsehen:TV-Company
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NLebensmittel
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelefon
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelefon:Telco1-Tablett
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelefon:Telco2-Handy
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelefon:Telco3
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelekommunikation
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelekommunikation:Fernsehen
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelekommunikation:Online-Dienste
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelekommunikation:Telefon
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NTelekommunikation:Telefon:Test1
|
|
|
|
E
|
|
|
|
^
|
|
|
|
NGehalt
|
|
|
|
I
|
|
|
|
^
|
|
|
|
NGehalt:Zulagen
|
|
|
|
I
|
|
|
|
^""")
|
|
|
|
|
2022-08-28 20:16:34 +00:00
|
|
|
@with_transaction()
|
|
|
|
def test_category_create_by_qif_existing_categories(self):
|
|
|
|
""" create categories by import a qif-file,
|
|
|
|
some categories exists already
|
|
|
|
"""
|
|
|
|
pool = Pool()
|
|
|
|
Category = pool.get('cashbook.category')
|
|
|
|
|
|
|
|
company = self.prep_company()
|
|
|
|
with Transaction().set_context({
|
2023-06-06 13:22:57 +00:00
|
|
|
'company': company.id}):
|
2022-08-28 20:16:34 +00:00
|
|
|
cat1, = Category.create([{
|
|
|
|
'name': 'Telekommunikation',
|
|
|
|
'cattype': 'out',
|
|
|
|
'childs': [('create', [{
|
|
|
|
'cattype': 'out',
|
|
|
|
'name': 'Telefon',
|
|
|
|
}])],
|
|
|
|
}])
|
|
|
|
|
|
|
|
records = Category.search([])
|
|
|
|
self.assertEqual(len(records), 2)
|
2022-08-30 20:49:52 +00:00
|
|
|
self.assertEqual(records[0].rec_name, 'Telekommunikation')
|
|
|
|
self.assertEqual(records[1].rec_name, 'Telekommunikation/Telefon')
|
2022-08-28 20:16:34 +00:00
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
Category.create_from_qif(qif_types)
|
2022-08-28 20:16:34 +00:00
|
|
|
|
2022-08-30 20:49:52 +00:00
|
|
|
records = Category.search([], order=[('rec_name', 'ASC')])
|
2022-08-28 20:16:34 +00:00
|
|
|
self.assertEqual(len(records), 15)
|
|
|
|
|
2022-08-30 20:49:52 +00:00
|
|
|
self.assertEqual(records[0].rec_name, 'Fernsehen')
|
|
|
|
self.assertEqual(records[1].rec_name, 'Fernsehen/GEZ')
|
|
|
|
self.assertEqual(records[2].rec_name, 'Fernsehen/TV-Company')
|
|
|
|
self.assertEqual(records[3].rec_name, 'Gehalt')
|
|
|
|
self.assertEqual(records[4].rec_name, 'Gehalt/Zulagen')
|
|
|
|
self.assertEqual(records[5].rec_name, 'Lebensmittel')
|
|
|
|
self.assertEqual(records[6].rec_name, 'Telefon')
|
|
|
|
self.assertEqual(records[7].rec_name, 'Telefon/Telco1-Tablett')
|
|
|
|
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
|
|
|
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
|
|
|
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
records[11].rec_name, 'Telekommunikation/Fernsehen')
|
|
|
|
self.assertEqual(
|
|
|
|
records[12].rec_name, 'Telekommunikation/Online-Dienste')
|
|
|
|
self.assertEqual(
|
|
|
|
records[13].rec_name, 'Telekommunikation/Telefon')
|
|
|
|
self.assertEqual(
|
|
|
|
records[14].rec_name, 'Telekommunikation/Telefon/Test1')
|
2022-08-28 20:16:34 +00:00
|
|
|
|
|
|
|
@with_transaction()
|
|
|
|
def test_qiftool_split_types(self):
|
|
|
|
""" split file-content by types
|
|
|
|
"""
|
|
|
|
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
|
|
|
|
|
|
|
result = QifTool.split_by_type(qif_types)
|
|
|
|
self.assertEqual(len(result.keys()), 2)
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
result['Cat'],
|
|
|
|
'NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^\nNTelekommunikation' +
|
|
|
|
'\nE\n^\nNTelekommunikation:Online-Dienste\n' +
|
|
|
|
'E\n^\nNTelekommunikation:Telefon\nE\n^\nN' +
|
|
|
|
'Telekommunikation:Telefon:Test1\n' +
|
|
|
|
'E\n^\nNTelefon:Telco1-Tablett\n' +
|
|
|
|
'E\n^\nNTelefon:Telco2-Handy\nE\n^\nNTelefon:Telco3\nE\n^\n' +
|
|
|
|
'NTelekommunikation:Fernsehen\nE\n^\nNFernsehen:TV-Company\nE\n' +
|
2022-08-28 20:16:34 +00:00
|
|
|
'^\nNFernsehen:GEZ\nE\n^\nNLebensmittel\nE\n^')
|
2023-06-06 13:22:57 +00:00
|
|
|
self.assertEqual(
|
|
|
|
result['Bank'],
|
|
|
|
'D04.12.2013\nT7,12\nCX\n' +
|
|
|
|
'POpening Balance\nL[Bargeld]\n^\nD05.12.2013\nCX\nM05.12/' +
|
|
|
|
'06.42UHR TT TELTOW\nT-29,00\n' +
|
|
|
|
'PGA NR00002168 BLZ10000000 0\nL[S-Giro]\n^\nD05.12.2013' +
|
|
|
|
'\nCX\nMsome food\nT-56,37\nPFoodshop Zehlendorf\n' +
|
|
|
|
'LLebensmittel\n^\nD06.12.2013\nCX\nMreturn of bottles\n' +
|
|
|
|
'T1,45\nPFoodshop Zehlendorf\nLLebensmittel\n^\n')
|
2022-08-28 20:16:34 +00:00
|
|
|
|
2022-09-01 12:48:04 +00:00
|
|
|
@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')
|
2022-09-02 12:33:12 +00:00
|
|
|
Party = pool.get('party.party')
|
2022-09-01 12:48:04 +00:00
|
|
|
Book = pool.get('cashbook.book')
|
|
|
|
|
|
|
|
company = self.prep_company()
|
|
|
|
with Transaction().set_context({
|
2023-06-06 13:22:57 +00:00
|
|
|
'company': company.id}):
|
2022-09-01 12:48:04 +00:00
|
|
|
types = self.prep_type()
|
2022-09-08 15:29:10 +00:00
|
|
|
books = Book.create([{
|
2022-09-01 12:48:04 +00:00
|
|
|
'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),
|
2022-09-08 15:29:10 +00:00
|
|
|
}, {
|
|
|
|
'name': 'S-Giro',
|
|
|
|
'btype': types.id,
|
|
|
|
'company': company.id,
|
|
|
|
'currency': company.currency.id,
|
|
|
|
'number_sequ': self.prep_sequence().id,
|
|
|
|
'start_date': date(2010, 1, 1),
|
|
|
|
}, {
|
|
|
|
'name': 'Bargeld',
|
|
|
|
'btype': types.id,
|
|
|
|
'company': company.id,
|
|
|
|
'currency': company.currency.id,
|
|
|
|
'number_sequ': self.prep_sequence().id,
|
|
|
|
'start_date': date(2010, 1, 1),
|
2022-09-01 12:48:04 +00:00
|
|
|
}])
|
2022-09-08 15:29:10 +00:00
|
|
|
self.assertEqual(books[0].name, 'Cash Book')
|
|
|
|
self.assertEqual(books[1].name, 'S-Giro')
|
|
|
|
self.assertEqual(books[2].name, 'Bargeld')
|
|
|
|
self.assertEqual(books[0].btype.rec_name, 'CAS - Cash')
|
|
|
|
self.assertEqual(books[1].btype.rec_name, 'CAS - Cash')
|
|
|
|
self.assertEqual(books[2].btype.rec_name, 'CAS - Cash')
|
2022-09-01 12:48:04 +00:00
|
|
|
|
2022-09-02 12:33:12 +00:00
|
|
|
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([{
|
2022-09-01 12:48:04 +00:00
|
|
|
'name': 'Lebensmittel',
|
|
|
|
'cattype': 'out',
|
|
|
|
'company': company.id,
|
|
|
|
}, {
|
|
|
|
'name': 'Haushaltschemie',
|
|
|
|
'cattype': 'out',
|
|
|
|
'company': company.id,
|
|
|
|
}, {
|
|
|
|
'name': 'Kosmetik',
|
|
|
|
'cattype': 'out',
|
|
|
|
'company': company.id,
|
2022-09-08 15:29:10 +00:00
|
|
|
}])
|
2022-09-01 12:48:04 +00:00
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
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\nT-29,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\n' +
|
|
|
|
'EKlopapier\n' +
|
|
|
|
'$-2,99\nSHaushaltschemie\nESagrotan\n$-3,49\n' +
|
2022-09-13 16:14:06 +00:00
|
|
|
'S[S-Giro]\nEtransfer out\n$-3,49\n^\n')
|
2022-09-01 12:48:04 +00:00
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
(to_create, msg_txt, fail_cnt) = \
|
|
|
|
QifTool.convert_transactions_to_create(books[0], tr_list)
|
2022-09-01 12:48:04 +00:00
|
|
|
self.assertEqual(msg_txt, [])
|
|
|
|
self.assertEqual(to_create, [{
|
|
|
|
'date': date(2013, 12, 4),
|
|
|
|
'amount': Decimal('7.12'),
|
2022-09-08 15:29:10 +00:00
|
|
|
'state': 'edit',
|
|
|
|
'bookingtype': 'mvin',
|
|
|
|
'booktransf': books[2].id,
|
|
|
|
'description': 'Opening Balance',
|
2022-09-01 12:48:04 +00:00
|
|
|
}, {
|
|
|
|
'date': date(2013, 12, 5),
|
2022-09-08 15:29:10 +00:00
|
|
|
'amount': Decimal('29.00'),
|
|
|
|
'state': 'edit',
|
|
|
|
'bookingtype': 'mvout',
|
|
|
|
'booktransf': books[1].id,
|
2023-06-06 13:22:57 +00:00
|
|
|
'description':
|
|
|
|
'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW',
|
2022-09-01 12:48:04 +00:00
|
|
|
}, {
|
|
|
|
'date': date(2013, 12, 5),
|
|
|
|
'amount': Decimal('56.37'),
|
|
|
|
'description': 'some food',
|
|
|
|
'state': 'check',
|
|
|
|
'bookingtype': 'out',
|
2022-09-02 12:33:12 +00:00
|
|
|
'party': parties[2].id,
|
|
|
|
'category': categories[0].id,
|
2022-09-01 12:48:04 +00:00
|
|
|
}, {
|
|
|
|
'date': date(2020, 10, 22),
|
|
|
|
'amount': Decimal('55.84'),
|
|
|
|
'description': 'Lebensmittel',
|
|
|
|
'state': 'edit',
|
|
|
|
'bookingtype': 'spout',
|
2022-09-02 12:33:12 +00:00
|
|
|
'category': categories[0].id,
|
|
|
|
'party': parties[3].id,
|
2022-09-01 12:48:04 +00:00
|
|
|
'splitlines': [
|
|
|
|
('create', [{
|
2022-09-13 16:14:06 +00:00
|
|
|
'splittype': 'cat',
|
2022-09-01 12:48:04 +00:00
|
|
|
'amount': Decimal('49.36'),
|
|
|
|
'description': 'Lebensmittel',
|
2022-09-02 12:33:12 +00:00
|
|
|
'category': categories[0].id,
|
2022-09-01 12:48:04 +00:00
|
|
|
}, {
|
2022-09-13 16:14:06 +00:00
|
|
|
'splittype': 'cat',
|
2022-09-01 12:48:04 +00:00
|
|
|
'amount': Decimal('2.99'),
|
|
|
|
'description': 'Klopapier',
|
2022-09-02 12:33:12 +00:00
|
|
|
'category': categories[2].id,
|
2022-09-01 12:48:04 +00:00
|
|
|
}, {
|
2022-09-13 16:14:06 +00:00
|
|
|
'splittype': 'cat',
|
2022-09-01 12:48:04 +00:00
|
|
|
'amount': Decimal('3.49'),
|
|
|
|
'description': 'Sagrotan',
|
2022-09-02 12:33:12 +00:00
|
|
|
'category': categories[1].id,
|
2022-09-13 16:14:06 +00:00
|
|
|
}, {
|
|
|
|
'splittype': 'tr',
|
|
|
|
'amount': Decimal('3.49'),
|
|
|
|
'description': 'transfer out',
|
|
|
|
'booktransf': books[1].id,
|
2023-06-06 13:22:57 +00:00
|
|
|
}])],
|
2022-09-01 12:48:04 +00:00
|
|
|
}])
|
|
|
|
Book.write(*[
|
2022-09-08 15:29:10 +00:00
|
|
|
[books[0]],
|
2022-09-01 12:48:04 +00:00
|
|
|
{
|
|
|
|
'lines': [('create', to_create)],
|
|
|
|
}])
|
2022-09-08 15:29:10 +00:00
|
|
|
self.assertEqual(len(books[0].lines), 4)
|
2022-09-13 16:14:06 +00:00
|
|
|
self.assertEqual(books[0].balance, Decimal('-137.58'))
|
2022-09-01 12:48:04 +00:00
|
|
|
|
|
|
|
@with_transaction()
|
|
|
|
def test_qiftool_read_transactions(self):
|
|
|
|
""" read transaction data from text
|
|
|
|
"""
|
|
|
|
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
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' +
|
2022-09-01 12:48:04 +00:00
|
|
|
'$-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',
|
|
|
|
}])
|
|
|
|
|
2022-08-28 20:16:34 +00:00
|
|
|
@with_transaction()
|
|
|
|
def test_qiftool_read_categories(self):
|
|
|
|
""" read category-data from text
|
|
|
|
"""
|
|
|
|
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
|
|
|
|
2023-06-06 13:22:57 +00:00
|
|
|
result = QifTool.qif_read_categories(
|
|
|
|
'NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^' +
|
2022-08-28 20:16:34 +00:00
|
|
|
'NTelekommunikation\nE\n^\nNTelekommunikation:Online-Dienste\nE\n^')
|
|
|
|
self.assertEqual(result, {
|
|
|
|
'in': {
|
|
|
|
'Gehalt': {
|
|
|
|
'type': 'in',
|
|
|
|
'childs': {
|
|
|
|
'Zulagen': {
|
|
|
|
'type': 'in',
|
|
|
|
'childs': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'out': {
|
|
|
|
'Telekommunikation': {
|
|
|
|
'type': 'out',
|
|
|
|
'childs': {
|
|
|
|
'Online-Dienste': {
|
|
|
|
'type': 'out',
|
|
|
|
'childs': {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
# end CategoryTestCase
|