formatting, optimize code
This commit is contained in:
parent
6cf6584f92
commit
d0e2c8bc52
10 changed files with 362 additions and 253 deletions
9
book.py
9
book.py
|
@ -3,7 +3,6 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
|
@ -28,13 +27,13 @@ class Book(metaclass=PoolMeta):
|
|||
Book2 = pool.get('cashbook.book')
|
||||
|
||||
qif_content = QifTool.split_by_type(qifdata)
|
||||
if not 'Bank' in qif_content.keys():
|
||||
if 'Bank' not in qif_content.keys():
|
||||
return None
|
||||
|
||||
(to_create, msg_list, fail_cnt) = QifTool.convert_transactions_to_create(
|
||||
(to_create, msg_list, fail_cnt) = \
|
||||
QifTool.convert_transactions_to_create(
|
||||
book,
|
||||
QifTool.qif_read_transactions(qif_content['Bank'])
|
||||
)
|
||||
QifTool.qif_read_transactions(qif_content['Bank']))
|
||||
if fail_cnt == 0:
|
||||
Book2.write(*[
|
||||
[book],
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
|
||||
|
||||
|
@ -18,7 +17,8 @@ class Category(metaclass=PoolMeta):
|
|||
Category2 = pool.get('cashbook.category')
|
||||
QifTool = pool.get('cashbook_dataexchange.qiftool')
|
||||
|
||||
categories = Category2.search([],
|
||||
categories = Category2.search(
|
||||
[],
|
||||
order=[('cattype', 'ASC'), ('rec_name', 'ASC')])
|
||||
|
||||
export = ['!Type:Cat']
|
||||
|
@ -34,7 +34,7 @@ class Category(metaclass=PoolMeta):
|
|||
Category2 = pool.get('cashbook.category')
|
||||
|
||||
type_data = QifTool.split_by_type(qifdata)
|
||||
if not 'Cat' in type_data.keys():
|
||||
if 'Cat' not in type_data.keys():
|
||||
return None
|
||||
|
||||
to_create = QifTool.convert_categories_to_create(
|
||||
|
|
|
@ -8,7 +8,6 @@ from trytond.pool import Pool
|
|||
from slugify import slugify
|
||||
|
||||
|
||||
|
||||
class QifCategoryExport(Report):
|
||||
__name__ = 'cashbook_dataexchange.rep_category'
|
||||
|
||||
|
|
|
@ -7,26 +7,27 @@ from trytond.transaction import Transaction
|
|||
from trytond.pool import Pool
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.wizard import Wizard, StateTransition, StateView, Button
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.i18n import gettext
|
||||
from trytond.pyson import Eval, Bool
|
||||
from trytond.report import Report
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class ImportQifWizardStart(ModelView):
|
||||
'Import QIF-File'
|
||||
__name__ = 'cashbook_dataexchange.qif_imp_wiz.start'
|
||||
|
||||
company = fields.Many2One(model_name='company.company',
|
||||
company = fields.Many2One(
|
||||
model_name='company.company',
|
||||
string="Company", required=True,
|
||||
states={'invisible': True})
|
||||
book = fields.Many2One(string='Cashbook', readonly=True,
|
||||
book = fields.Many2One(
|
||||
string='Cashbook', readonly=True,
|
||||
model_name='cashbook.book',
|
||||
states={
|
||||
'invisible': ~Bool(Eval('book')),
|
||||
})
|
||||
file_ = fields.Binary(string="QIF-File", required=True,
|
||||
file_ = fields.Binary(
|
||||
string="QIF-File", required=True,
|
||||
help='Quicken Interchange Format')
|
||||
|
||||
@classmethod
|
||||
|
@ -40,15 +41,16 @@ class ImportQifWizardInfo(ModelView):
|
|||
'Import QIF-File'
|
||||
__name__ = 'cashbook_dataexchange.qif_imp_wiz.info'
|
||||
|
||||
company = fields.Many2One(model_name='company.company',
|
||||
string="Company", required=True,
|
||||
states={'invisible': True})
|
||||
book = fields.Many2One(string='Cash Book', readonly=True,
|
||||
model_name='cashbook.book',
|
||||
company = fields.Many2One(
|
||||
model_name='company.company', string="Company",
|
||||
required=True, states={'invisible': True})
|
||||
book = fields.Many2One(
|
||||
string='Cash Book', readonly=True, model_name='cashbook.book',
|
||||
states={
|
||||
'invisible': ~Bool(Eval('book')),
|
||||
})
|
||||
allowimport = fields.Boolean(string='Import Enabled',
|
||||
allowimport = fields.Boolean(
|
||||
string='Import Enabled',
|
||||
states={'invisible': True})
|
||||
info = fields.Text(string='Information', readonly=True)
|
||||
|
||||
|
@ -60,17 +62,23 @@ class ImportQifWizard(Wizard):
|
|||
__name__ = 'cashbook_dataexchange.qif_imp_wiz'
|
||||
|
||||
start_state = 'start'
|
||||
start = StateView(model_name='cashbook_dataexchange.qif_imp_wiz.start', \
|
||||
view='cashbook_dataexchange.qif_imp_wiz_start_form', \
|
||||
start = StateView(
|
||||
model_name='cashbook_dataexchange.qif_imp_wiz.start',
|
||||
view='cashbook_dataexchange.qif_imp_wiz_start_form',
|
||||
buttons=[
|
||||
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||
Button(string='Read File', state='readf', icon='tryton-forward', default=True),
|
||||
Button(
|
||||
string='Read File', state='readf',
|
||||
icon='tryton-forward', default=True),
|
||||
])
|
||||
showinfo = StateView(model_name='cashbook_dataexchange.qif_imp_wiz.info', \
|
||||
view='cashbook_dataexchange.qif_imp_wiz_info_form', \
|
||||
showinfo = StateView(
|
||||
model_name='cashbook_dataexchange.qif_imp_wiz.info',
|
||||
view='cashbook_dataexchange.qif_imp_wiz_info_form',
|
||||
buttons=[
|
||||
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||
Button(string='Import Data', state='importf', icon='tryton-import', default=True,
|
||||
Button(
|
||||
string='Import Data', state='importf',
|
||||
icon='tryton-import', default=True,
|
||||
states={
|
||||
'readonly': Eval('allowimport', False) == False,
|
||||
}),
|
||||
|
@ -146,7 +154,8 @@ class ImportQifWizard(Wizard):
|
|||
# read file content, extract categories
|
||||
qif_content = QifTool.split_by_type(file_content)
|
||||
if 'Cat' in qif_content.keys():
|
||||
to_create = QifTool.convert_categories_to_create(QifTool.qif_read_categories(qif_content['Cat']))
|
||||
to_create = QifTool.convert_categories_to_create(
|
||||
QifTool.qif_read_categories(qif_content['Cat']))
|
||||
|
||||
in_categories = []
|
||||
out_categories = []
|
||||
|
@ -166,7 +175,8 @@ class ImportQifWizard(Wizard):
|
|||
if len(to_create) > 0:
|
||||
self.showinfo.allowimport = True
|
||||
else:
|
||||
self.showinfo.info = gettext('cashbook_dataexchange.msg_wiz_no_categories')
|
||||
self.showinfo.info = gettext(
|
||||
'cashbook_dataexchange.msg_wiz_no_categories')
|
||||
elif model == 'party.party':
|
||||
# read file content, extract parties
|
||||
qif_content = QifTool.split_by_type(file_content)
|
||||
|
@ -181,18 +191,20 @@ class ImportQifWizard(Wizard):
|
|||
if len(to_create) > 0:
|
||||
self.showinfo.allowimport = True
|
||||
else:
|
||||
self.showinfo.info = gettext('cashbook_dataexchange.msg_wiz_no_bank')
|
||||
self.showinfo.info = gettext(
|
||||
'cashbook_dataexchange.msg_wiz_no_bank')
|
||||
elif model == 'cashbook.book':
|
||||
info_lst = []
|
||||
# read file content, extract categories
|
||||
qif_content = QifTool.split_by_type(file_content)
|
||||
if 'Bank' in qif_content.keys():
|
||||
(to_create, msg_list, fail_cnt) = QifTool.convert_transactions_to_create(
|
||||
(to_create, msg_list, fail_cnt) = \
|
||||
QifTool.convert_transactions_to_create(
|
||||
self.start.book,
|
||||
QifTool.qif_read_transactions(qif_content['Bank'])
|
||||
)
|
||||
QifTool.qif_read_transactions(qif_content['Bank']))
|
||||
if len(msg_list) > 0:
|
||||
info_lst.append(gettext('cashbook_dataexchange.msg_wiz_transactions_error'))
|
||||
info_lst.append(gettext(
|
||||
'cashbook_dataexchange.msg_wiz_transactions_error'))
|
||||
info_lst.append('')
|
||||
|
||||
short_lst = []
|
||||
|
@ -204,8 +216,12 @@ class ImportQifWizard(Wizard):
|
|||
|
||||
# count
|
||||
if fail_cnt == 0:
|
||||
debit = sum([x['amount'] for x in to_create if x['bookingtype'] in ['out', 'mvout', 'spout']])
|
||||
credit = sum([x['amount'] for x in to_create if x['bookingtype'] in ['in', 'mvin', 'spin']])
|
||||
debit = sum([
|
||||
x['amount'] for x in to_create
|
||||
if x['bookingtype'] in ['out', 'mvout', 'spout']])
|
||||
credit = sum([
|
||||
x['amount'] for x in to_create
|
||||
if x['bookingtype'] in ['in', 'mvin', 'spin']])
|
||||
balance = credit - debit
|
||||
|
||||
if len(msg_list) > 0:
|
||||
|
@ -213,13 +229,16 @@ class ImportQifWizard(Wizard):
|
|||
info_lst.append(gettext(
|
||||
'cashbook_dataexchange.msg_wiz_transactions_found',
|
||||
quantity=len(to_create),
|
||||
balance = Report.format_currency(balance, None, self.start.book.currency),
|
||||
credit = Report.format_currency(credit, None, self.start.book.currency),
|
||||
debit = Report.format_currency(debit, None, self.start.book.currency),
|
||||
))
|
||||
balance=Report.format_currency(
|
||||
balance, None, self.start.book.currency),
|
||||
credit=Report.format_currency(
|
||||
credit, None, self.start.book.currency),
|
||||
debit=Report.format_currency(
|
||||
debit, None, self.start.book.currency)))
|
||||
self.showinfo.allowimport = True
|
||||
else:
|
||||
info_lst.append(gettext('cashbook_dataexchange.msg_wiz_no_bank'))
|
||||
info_lst.append(gettext(
|
||||
'cashbook_dataexchange.msg_wiz_no_bank'))
|
||||
self.showinfo.info = '\n'.join(info_lst)
|
||||
|
||||
return 'showinfo'
|
||||
|
@ -241,7 +260,7 @@ class ImportQifWizard(Wizard):
|
|||
|
||||
if model == 'cashbook.category':
|
||||
if file_content:
|
||||
records = Category.create_from_qif(file_content)
|
||||
Category.create_from_qif(file_content)
|
||||
elif model == 'cashbook.book':
|
||||
if file_content:
|
||||
Book.create_from_qif(self.showinfo.book, file_content)
|
||||
|
@ -261,4 +280,3 @@ class ImportQifWizard(Wizard):
|
|||
return 'end'
|
||||
|
||||
# end ImportQifWizard
|
||||
|
||||
|
|
98
qiftool.py
98
qiftool.py
|
@ -30,7 +30,7 @@ class QifTool(Model):
|
|||
if current_type is None:
|
||||
continue
|
||||
|
||||
if not current_type in blocks.keys():
|
||||
if current_type not in blocks.keys():
|
||||
blocks[current_type] = []
|
||||
blocks[current_type].append(line.strip())
|
||||
|
||||
|
@ -82,7 +82,8 @@ class QifTool(Model):
|
|||
for line in booktxt.strip().split('\n'):
|
||||
line_txt = line[1:].strip()
|
||||
if line.startswith('D'): # date
|
||||
booking['date'] = datetime.strptime(line_txt, '%d.%m.%Y').date()
|
||||
booking['date'] = datetime.strptime(
|
||||
line_txt, '%d.%m.%Y').date()
|
||||
elif line.startswith('T'): # total
|
||||
booking['amount'] = cls.get_amount_from_txt(line_txt)
|
||||
elif line.startswith('U'): # total
|
||||
|
@ -117,9 +118,11 @@ class QifTool(Model):
|
|||
elif line.startswith('E'): # split: memo
|
||||
booking['split'][-1]['description'] = line_txt
|
||||
elif line.startswith('$'): # split: amount
|
||||
booking['split'][-1]['amount'] = cls.get_amount_from_txt(line_txt)
|
||||
booking['split'][-1]['amount'] = \
|
||||
cls.get_amount_from_txt(line_txt)
|
||||
elif line.startswith('£'): # split: amount
|
||||
booking['split'][-1]['amount'] = cls.get_amount_from_txt(line_txt)
|
||||
booking['split'][-1]['amount'] = \
|
||||
cls.get_amount_from_txt(line_txt)
|
||||
else:
|
||||
raise ValueError('unknown line-code: %s' % (line))
|
||||
result.append(booking)
|
||||
|
@ -148,7 +151,8 @@ class QifTool(Model):
|
|||
})
|
||||
# total
|
||||
result.append('T%(total)s' % {
|
||||
'total': Report.format_number(get_amount_by_bookingstate(line.amount, line), None),
|
||||
'total': Report.format_number(
|
||||
get_amount_by_bookingstate(line.amount, line), None),
|
||||
})
|
||||
# state
|
||||
result.append('C%(state)s' % {
|
||||
|
@ -164,8 +168,8 @@ class QifTool(Model):
|
|||
if p_address:
|
||||
if len(p_address.full_address.strip()) > 0:
|
||||
result.append('A%(address)s' % {
|
||||
'address': p_address.full_address.replace('\n', ', ').strip(),
|
||||
})
|
||||
'address': p_address.full_address.replace(
|
||||
'\n', ', ').strip()})
|
||||
# category
|
||||
if line.category:
|
||||
result.append('L%(category)s' % {
|
||||
|
@ -192,7 +196,9 @@ class QifTool(Model):
|
|||
'memo': splitline.description.replace('\n', '; ')
|
||||
})
|
||||
result.append('$%(total)s' % {
|
||||
'total': Report.format_number(get_amount_by_bookingstate(splitline.amount, line), None),
|
||||
'total': Report.format_number(
|
||||
get_amount_by_bookingstate(
|
||||
splitline.amount, line), None),
|
||||
})
|
||||
result.append('^')
|
||||
return '\n'.join(result)
|
||||
|
@ -210,8 +216,7 @@ class QifTool(Model):
|
|||
if len(parties) == 0:
|
||||
msg_txt = gettext(
|
||||
'cashbook_dataexchange.mds_import_party_notfound',
|
||||
pname = partyname,
|
||||
)
|
||||
pname=partyname)
|
||||
elif len(parties) == 1:
|
||||
party_id = parties[0].id
|
||||
else:
|
||||
|
@ -219,8 +224,7 @@ class QifTool(Model):
|
|||
msg_txt = gettext(
|
||||
'cashbook_dataexchange.mds_import_many_parties_found',
|
||||
pname=partyname,
|
||||
pname2 = parties[0].rec_name,
|
||||
)
|
||||
pname2=parties[0].rec_name)
|
||||
return (party_id, msg_txt)
|
||||
|
||||
@classmethod
|
||||
|
@ -294,12 +298,12 @@ class QifTool(Model):
|
|||
"""
|
||||
result = []
|
||||
for catname in catdict.keys():
|
||||
if do_search == True:
|
||||
if do_search is True:
|
||||
c_lst = Category.search([
|
||||
('cattype', '=', ctype),
|
||||
('name', '=', catname),
|
||||
('parent', '=', None) if parent is None else ('parent.id', '=', parent.id),
|
||||
])
|
||||
('parent', '=', None)
|
||||
if parent is None else ('parent.id', '=', parent.id)])
|
||||
else:
|
||||
c_lst = []
|
||||
|
||||
|
@ -312,13 +316,15 @@ class QifTool(Model):
|
|||
cat1['parent'] = parent.id
|
||||
|
||||
if len(catdict[catname]['childs']) > 0:
|
||||
childs = get_create(ctype, catdict[catname]['childs'], None, False)
|
||||
childs = get_create(
|
||||
ctype, catdict[catname]['childs'], None, False)
|
||||
if len(childs) > 0:
|
||||
cat1['childs'] = [('create', childs)]
|
||||
result.append(cat1)
|
||||
else:
|
||||
if len(catdict[catname]['childs']) > 0:
|
||||
result.extend(get_create(ctype, catdict[catname]['childs'], c_lst[0], True))
|
||||
result.extend(get_create(
|
||||
ctype, catdict[catname]['childs'], c_lst[0], True))
|
||||
return result
|
||||
to_create = []
|
||||
for typ1 in ['in', 'out']:
|
||||
|
@ -343,8 +349,7 @@ class QifTool(Model):
|
|||
if Party.search_count([
|
||||
('rec_name', 'ilike', '%%%(pname)s%%' % {
|
||||
'pname': transaction['party'],
|
||||
})
|
||||
]) == 0:
|
||||
})]) == 0:
|
||||
to_create.append({
|
||||
'name': transaction['party'],
|
||||
'addresses': [('create', [{
|
||||
|
@ -382,7 +387,8 @@ class QifTool(Model):
|
|||
fail_cnt = 0
|
||||
category = account = None
|
||||
if cat_name is not None:
|
||||
(category, msg_txt) = cls.get_category_by_name(book.company, cat_name)
|
||||
(category, msg_txt) = cls.get_category_by_name(
|
||||
book.company, cat_name)
|
||||
if category is None:
|
||||
msg_list.append(msg_txt)
|
||||
fail_cnt += 1
|
||||
|
@ -394,7 +400,8 @@ class QifTool(Model):
|
|||
return (category, account, msg_list, fail_cnt)
|
||||
|
||||
@classmethod
|
||||
def convert_transactions_to_create(cls, book, transactions, split2edit=True):
|
||||
def convert_transactions_to_create(
|
||||
cls, book, transactions, split2edit=True):
|
||||
""" convert read transactions to create-command
|
||||
split2edit: True = split-bookings are 'edit', False = dont change
|
||||
"""
|
||||
|
@ -409,14 +416,16 @@ class QifTool(Model):
|
|||
msg_list = []
|
||||
fail_cnt = 0
|
||||
for transaction in transactions:
|
||||
line = {x:transaction[x] for x in [
|
||||
'date', 'amount', 'description', 'state',
|
||||
] if x in transaction.keys()}
|
||||
line = {
|
||||
x: transaction[x]
|
||||
for x in ['date', 'amount', 'description', 'state']
|
||||
if x in transaction.keys()}
|
||||
|
||||
if 'description' in line.keys():
|
||||
line['description'] = updt_description(line['description'])
|
||||
|
||||
(category, account, msg_lst2, fail_cnt2) = cls.get_category_account(book, transaction)
|
||||
(category, account, msg_lst2, fail_cnt2) = \
|
||||
cls.get_category_account(book, transaction)
|
||||
msg_list.extend(msg_lst2)
|
||||
if fail_cnt2 > 0:
|
||||
fail_cnt += fail_cnt2
|
||||
|
@ -452,7 +461,7 @@ class QifTool(Model):
|
|||
del transaction['party']
|
||||
line['description'] = '; '.join(descr_lst)
|
||||
line['state'] = 'edit'
|
||||
if cls.check_counter_transaction(book, line) == True:
|
||||
if cls.check_counter_transaction(book, line) is True:
|
||||
# counter-transaction already exists
|
||||
continue
|
||||
else:
|
||||
|
@ -461,7 +470,8 @@ class QifTool(Model):
|
|||
# no amount --> ignore!
|
||||
tr_info = {'trdate': '-', 'amount': '-'}
|
||||
if 'date' in transaction.keys():
|
||||
tr_info['trdate'] = Report.format_date(transaction['date'], None)
|
||||
tr_info['trdate'] = Report.format_date(
|
||||
transaction['date'], None)
|
||||
if 'amount' in transaction.keys():
|
||||
tr_info['amount'] = Report.format_currency(
|
||||
transaction['amount'],
|
||||
|
@ -476,7 +486,8 @@ class QifTool(Model):
|
|||
|
||||
# party
|
||||
if 'party' in transaction.keys():
|
||||
(party_id, msg_txt) = cls.get_party_by_name(transaction['party'])
|
||||
(party_id, msg_txt) = cls.get_party_by_name(
|
||||
transaction['party'])
|
||||
if party_id is not None:
|
||||
line['party'] = party_id
|
||||
else:
|
||||
|
@ -496,28 +507,34 @@ class QifTool(Model):
|
|||
|
||||
split_lines = []
|
||||
for sp_line in transaction['split']:
|
||||
(category, account, msg_lst2, fail_cnt2) = cls.get_category_account(book, sp_line)
|
||||
(category, account, msg_lst2, fail_cnt2) = \
|
||||
cls.get_category_account(book, sp_line)
|
||||
msg_list.extend(msg_lst2)
|
||||
if fail_cnt2 > 0:
|
||||
fail_cnt += fail_cnt2
|
||||
continue
|
||||
|
||||
split_line = {
|
||||
'amount': sp_line['amount'] \
|
||||
if line['bookingtype'].endswith('in') else sp_line['amount'].copy_negate(),
|
||||
'description': updt_description(sp_line.get('description', None)),
|
||||
'amount': sp_line['amount']
|
||||
if line['bookingtype'].endswith('in')
|
||||
else sp_line['amount'].copy_negate(),
|
||||
'description': updt_description(
|
||||
sp_line.get('description', None)),
|
||||
}
|
||||
|
||||
if category:
|
||||
# category match to bookingtype?
|
||||
if ((category.cattype == 'in') and line['bookingtype'].endswith('out')) or\
|
||||
((category.cattype == 'out') and line['bookingtype'].endswith('in')):
|
||||
if ((category.cattype == 'in') and
|
||||
line['bookingtype'].endswith('out')) or \
|
||||
((category.cattype == 'out') and
|
||||
line['bookingtype'].endswith('in')):
|
||||
msg_list.append(gettext(
|
||||
'cashbook_dataexchange.mds_import_category_not_match',
|
||||
catname = '%s [%s]' % (category.rec_name, category.cattype),
|
||||
'cashbook_dataexchange.' +
|
||||
'mds_import_category_not_match',
|
||||
catname='%s [%s]' % (
|
||||
category.rec_name, category.cattype),
|
||||
bktype=line['bookingtype'],
|
||||
data = str(transaction),
|
||||
))
|
||||
data=str(transaction)))
|
||||
fail_cnt += 1
|
||||
continue
|
||||
split_line['splittype'] = 'cat'
|
||||
|
@ -533,7 +550,7 @@ class QifTool(Model):
|
|||
if len(split_lines) > 0:
|
||||
line['splitlines'] = [('create', split_lines)]
|
||||
|
||||
if split2edit == True:
|
||||
if split2edit is True:
|
||||
if 'splitlines' in line.keys():
|
||||
line['state'] = 'edit'
|
||||
|
||||
|
@ -595,7 +612,8 @@ class QifTool(Model):
|
|||
cattype = 'in'
|
||||
else:
|
||||
raise ValueError('invalid line: %s (%s)' % (line, cattxt))
|
||||
categories[cattype] = add_category(categories[cattype], catname, cattype)
|
||||
categories[cattype] = add_category(
|
||||
categories[cattype], catname, cattype)
|
||||
return categories
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
# -*- 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.
|
||||
|
||||
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
|
||||
from .test_module import CashbookExchangeTestCase
|
||||
|
||||
__all__ = ['suite']
|
||||
|
||||
|
||||
class CashbookExchangeTestCase(\
|
||||
CategoryTestCase,\
|
||||
PartyTestCase,\
|
||||
TransactionTestCase,\
|
||||
):
|
||||
'Test cashbook exchange module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
# end CashbookExchangeTestCase
|
||||
|
||||
def suite():
|
||||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookExchangeTestCase))
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
CashbookExchangeTestCase))
|
||||
return suite
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.tests.test_tryton import with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.modules.cashbook.tests import CashbookTestCase
|
||||
from .qifdata import qif_category, qif_types
|
||||
from .qifdata import qif_types
|
||||
|
||||
|
||||
class CategoryTestCase(CashbookTestCase):
|
||||
class CategoryTestCase(object):
|
||||
'Test cashbook categoy module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
|
@ -27,8 +26,7 @@ class CategoryTestCase(CashbookTestCase):
|
|||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'cashbook.category',
|
||||
}):
|
||||
'active_model': 'cashbook.category'}):
|
||||
(sess_id, start_state, end_state) = ImportWiz.create()
|
||||
w_obj = ImportWiz(sess_id)
|
||||
self.assertEqual(start_state, 'start')
|
||||
|
@ -49,7 +47,8 @@ class CategoryTestCase(CashbookTestCase):
|
|||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
self.assertEqual(
|
||||
result['view']['defaults']['info'],
|
||||
"""The following categories are now imported:\n
|
||||
Gehalt (in)
|
||||
Gehalt/Zulagen (in)
|
||||
|
@ -88,10 +87,14 @@ Lebensmittel (out)""")
|
|||
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
||||
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
||||
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
||||
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')
|
||||
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')
|
||||
|
||||
@with_transaction()
|
||||
def test_category_create_by_qif_emptydb(self):
|
||||
|
@ -102,8 +105,7 @@ Lebensmittel (out)""")
|
|||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
'company': company.id}):
|
||||
records = Category.create_from_qif(qif_types)
|
||||
|
||||
records = Category.search([], order=[('rec_name', 'ASC')])
|
||||
|
@ -120,10 +122,14 @@ Lebensmittel (out)""")
|
|||
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
||||
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
||||
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
||||
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')
|
||||
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')
|
||||
|
||||
result = Category.export_as_qif()
|
||||
self.assertEqual(result, """!Type:Cat
|
||||
|
@ -183,8 +189,7 @@ I
|
|||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
'company': company.id}):
|
||||
cat1, = Category.create([{
|
||||
'name': 'Telekommunikation',
|
||||
'cattype': 'out',
|
||||
|
@ -199,7 +204,7 @@ I
|
|||
self.assertEqual(records[0].rec_name, 'Telekommunikation')
|
||||
self.assertEqual(records[1].rec_name, 'Telekommunikation/Telefon')
|
||||
|
||||
records1 = Category.create_from_qif(qif_types)
|
||||
Category.create_from_qif(qif_types)
|
||||
|
||||
records = Category.search([], order=[('rec_name', 'ASC')])
|
||||
self.assertEqual(len(records), 15)
|
||||
|
@ -215,10 +220,14 @@ I
|
|||
self.assertEqual(records[8].rec_name, 'Telefon/Telco2-Handy')
|
||||
self.assertEqual(records[9].rec_name, 'Telefon/Telco3')
|
||||
self.assertEqual(records[10].rec_name, 'Telekommunikation')
|
||||
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')
|
||||
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')
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_split_types(self):
|
||||
|
@ -228,18 +237,25 @@ I
|
|||
|
||||
result = QifTool.split_by_type(qif_types)
|
||||
self.assertEqual(len(result.keys()), 2)
|
||||
self.assertEqual(result['Cat'], 'NGehalt\nI\n^\nNGehalt:Zulagen\n'+
|
||||
'I\n^\nNTelekommunikation\nE\n^\nNTelekommunikation:Online-Dienste\n'+
|
||||
'E\n^\nNTelekommunikation:Telefon\nE\n^\nNTelekommunikation:Telefon:Test1\n'+
|
||||
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' +
|
||||
'^\nNFernsehen:GEZ\nE\n^\nNLebensmittel\nE\n^')
|
||||
self.assertEqual(result['Bank'], 'D04.12.2013\nT7,12\nCX\nPOpening Balance\n'+
|
||||
'L[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\n'+
|
||||
'T-56,37\nPFoodshop Zehlendorf\nLLebensmittel\n^\nD06.12.2013\nCX\n'+
|
||||
'Mreturn of bottles\nT1,45\nPFoodshop Zehlendorf\nLLebensmittel\n^\n')
|
||||
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')
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_convert_transactions(self):
|
||||
|
@ -253,8 +269,7 @@ I
|
|||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
'company': company.id}):
|
||||
types = self.prep_type()
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
|
@ -313,17 +328,21 @@ I
|
|||
'company': company.id,
|
||||
}])
|
||||
|
||||
tr_list = QifTool.qif_read_transactions('D04.12.2013\nT7,12\nCX\n'+
|
||||
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'+
|
||||
'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\nEKlopapier\n'+
|
||||
'SLebensmittel\nELebensmittel\n$-49,36\nSKosmetik\n' +
|
||||
'EKlopapier\n' +
|
||||
'$-2,99\nSHaushaltschemie\nESagrotan\n$-3,49\n' +
|
||||
'S[S-Giro]\nEtransfer out\n$-3,49\n^\n')
|
||||
|
||||
(to_create, msg_txt, fail_cnt) = QifTool.convert_transactions_to_create(books[0], tr_list)
|
||||
(to_create, msg_txt, fail_cnt) = \
|
||||
QifTool.convert_transactions_to_create(books[0], tr_list)
|
||||
self.assertEqual(msg_txt, [])
|
||||
self.assertEqual(to_create, [{
|
||||
'date': date(2013, 12, 4),
|
||||
|
@ -335,11 +354,11 @@ I
|
|||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('29.00'),
|
||||
'description': '05.12/06.42UHR TT TELTOW',
|
||||
'state': 'edit',
|
||||
'bookingtype': 'mvout',
|
||||
'booktransf': books[1].id,
|
||||
'description': 'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW',
|
||||
'description':
|
||||
'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW',
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('56.37'),
|
||||
|
@ -377,8 +396,7 @@ I
|
|||
'amount': Decimal('3.49'),
|
||||
'description': 'transfer out',
|
||||
'booktransf': books[1].id,
|
||||
}],
|
||||
)],
|
||||
}])],
|
||||
}])
|
||||
Book.write(*[
|
||||
[books[0]],
|
||||
|
@ -394,9 +412,11 @@ I
|
|||
"""
|
||||
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
||||
|
||||
result = QifTool.qif_read_transactions('D04.12.2013\nT7,12\nCX\n'+
|
||||
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'+
|
||||
'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' +
|
||||
|
@ -453,7 +473,8 @@ I
|
|||
"""
|
||||
QifTool = Pool().get('cashbook_dataexchange.qiftool')
|
||||
|
||||
result = QifTool.qif_read_categories('NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^'+
|
||||
result = QifTool.qif_read_categories(
|
||||
'NGehalt\nI\n^\nNGehalt:Zulagen\nI\n^' +
|
||||
'NTelekommunikation\nE\n^\nNTelekommunikation:Online-Dienste\nE\n^')
|
||||
self.assertEqual(result, {
|
||||
'in': {
|
|
@ -3,15 +3,13 @@
|
|||
# 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.tests.test_tryton import with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from .qifdata import qif_types
|
||||
|
||||
|
||||
class PartyTestCase(ModuleTestCase):
|
||||
class PartyTestCase(object):
|
||||
'Test cashbook party module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
|
@ -26,8 +24,7 @@ class PartyTestCase(ModuleTestCase):
|
|||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'party.party',
|
||||
}):
|
||||
'active_model': 'party.party'}):
|
||||
(sess_id, start_state, end_state) = ImportWiz.create()
|
||||
w_obj = ImportWiz(sess_id)
|
||||
self.assertEqual(start_state, 'start')
|
26
tests/test_module.py
Normal file
26
tests/test_module.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- 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 trytond.tests.test_tryton import ModuleTestCase
|
||||
from trytond.modules.cashbook.tests.test_module import CashbookTestCase
|
||||
from .category import CategoryTestCase
|
||||
from .party import PartyTestCase
|
||||
from .transaction import TransactionTestCase
|
||||
|
||||
|
||||
class CashbookExchangeTestCase(
|
||||
CashbookTestCase,
|
||||
CategoryTestCase,
|
||||
PartyTestCase,
|
||||
TransactionTestCase,
|
||||
ModuleTestCase):
|
||||
'Test cashbook exchange module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
# end CashbookExchangeTestCase
|
||||
|
||||
|
||||
del ModuleTestCase
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.tests.test_tryton import with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from .qifdata import qif_types
|
||||
|
||||
|
||||
class TransactionTestCase(ModuleTestCase):
|
||||
class TransactionTestCase(object):
|
||||
'Test cashbook transaction module'
|
||||
module = 'cashbook_dataexchange'
|
||||
|
||||
|
@ -26,8 +26,7 @@ class TransactionTestCase(ModuleTestCase):
|
|||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
'company': company.id}):
|
||||
types = self.prep_type()
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
|
@ -57,14 +56,17 @@ class TransactionTestCase(ModuleTestCase):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'06/01/2022|to|-10.00 usd|transfer [S-Giro | 0.00 usd | Open]')
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
|
||||
Line.wfcheck(books[0].lines)
|
||||
self.assertEqual(len(books[1].lines), 1)
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'06/01/2022|from|10.00 usd|transfer [Cash Book | -10.00 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'06/01/2022|from|10.00 usd|transfer [Cash Book ' +
|
||||
'| -10.00 usd | Open]')
|
||||
|
||||
self.assertEqual(QifTool.check_counter_transaction(books[1], {
|
||||
'booktransf': books[0].id,
|
||||
|
@ -87,8 +89,7 @@ class TransactionTestCase(ModuleTestCase):
|
|||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'cashbook.book',
|
||||
}):
|
||||
'active_model': 'cashbook.book'}):
|
||||
types = self.prep_type()
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
|
@ -151,7 +152,8 @@ class TransactionTestCase(ModuleTestCase):
|
|||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
self.assertEqual(
|
||||
result['view']['defaults']['info'],
|
||||
"""The following transactionen are now imported:
|
||||
Credit: usd7.12
|
||||
Debit: usd83.92
|
||||
|
@ -169,10 +171,20 @@ Number of transactions: 4""")
|
|||
|
||||
self.assertEqual(len(books[0].lines), 4)
|
||||
|
||||
self.assertEqual(books[0].lines[0].rec_name, '12/04/2013|from|7.12 usd|Opening Balance [Bargeld | -7.12 usd | Open]')
|
||||
self.assertEqual(books[0].lines[1].rec_name, '12/05/2013|to|-29.00 usd|GA NR00002168 BLZ10000000 0; 05.12/06.42 [S-Giro | 29.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[2].rec_name, '12/05/2013|Exp|-56.37 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(books[0].lines[3].rec_name, '12/06/2013|Exp|1.45 usd|return of bottles [Lebensmittel]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'12/04/2013|from|7.12 usd|Opening Balance ' +
|
||||
'[Bargeld | -7.12 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[1].rec_name,
|
||||
'12/05/2013|to|-29.00 usd|GA NR00002168 BLZ10000000 ' +
|
||||
'0; 05.12/06.42 [S-Giro | 29.00 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[2].rec_name,
|
||||
'12/05/2013|Exp|-56.37 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(
|
||||
books[0].lines[3].rec_name,
|
||||
'12/06/2013|Exp|1.45 usd|return of bottles [Lebensmittel]')
|
||||
|
||||
self.assertEqual(Book.export_as_qif(books[0]), """!Type:Bank
|
||||
D12/04/2013
|
||||
|
@ -216,8 +228,7 @@ Mreturn of bottles
|
|||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
'active_model': 'cashbook.book',
|
||||
}):
|
||||
'active_model': 'cashbook.book'}):
|
||||
types = self.prep_type()
|
||||
books = Book.create([{
|
||||
'name': 'From Book',
|
||||
|
@ -283,7 +294,8 @@ L[To Book]
|
|||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
self.assertEqual(
|
||||
result['view']['defaults']['info'],
|
||||
"""The following transactionen are now imported:
|
||||
Credit: usd0.00
|
||||
Debit: usd57.55
|
||||
|
@ -302,11 +314,19 @@ Number of transactions: 2""")
|
|||
self.assertEqual(len(books[0].lines), 2)
|
||||
self.assertEqual(len(books[1].lines), 1)
|
||||
|
||||
self.assertEqual(books[0].lines[0].rec_name, '12/04/2013|to|-7.30 usd|Transfer to book [To Book | 7.30 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'12/04/2013|to|-7.30 usd|Transfer to book ' +
|
||||
'[To Book | 7.30 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].state, 'check')
|
||||
self.assertEqual(books[0].lines[1].rec_name, '12/05/2013|Exp|-50.25 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(
|
||||
books[0].lines[1].rec_name,
|
||||
'12/05/2013|Exp|-50.25 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(books[0].lines[1].state, 'check')
|
||||
self.assertEqual(books[1].lines[0].rec_name, '12/04/2013|from|7.30 usd|Transfer to book [From Book | -57.55 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'12/04/2013|from|7.30 usd|Transfer to book ' +
|
||||
'[From Book | -57.55 usd | Open]')
|
||||
self.assertEqual(books[1].lines[0].state, 'check')
|
||||
|
||||
# run wizard again - import to 'To Book'
|
||||
|
@ -359,7 +379,8 @@ $-7,00
|
|||
|
||||
self.assertEqual(list(result.keys()), ['view'])
|
||||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
self.assertEqual(
|
||||
result['view']['defaults']['info'],
|
||||
"""The following transactionen are now imported:
|
||||
Credit: usd0.00
|
||||
Debit: usd20.00
|
||||
|
@ -378,18 +399,37 @@ Number of transactions: 2""")
|
|||
self.assertEqual(len(books[0].lines), 3)
|
||||
self.assertEqual(len(books[1].lines), 3)
|
||||
|
||||
self.assertEqual(books[0].lines[0].rec_name, '12/04/2013|to|-7.30 usd|Transfer to book [To Book | -12.70 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].state, 'check')
|
||||
self.assertEqual(books[0].lines[1].rec_name, '12/05/2013|Exp|-50.25 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(books[0].lines[1].state, 'check')
|
||||
self.assertEqual(books[0].lines[2].rec_name, '12/06/2013|from|7.00 usd|Transfer to From-Book [To Book | -12.70 usd | Open]')
|
||||
self.assertEqual(books[0].lines[2].state, 'check')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'12/04/2013|to|-7.30 usd|Transfer to book ' +
|
||||
'[To Book | -12.70 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
books[0].lines[1].rec_name,
|
||||
'12/05/2013|Exp|-50.25 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(
|
||||
books[0].lines[1].state, 'check')
|
||||
self.assertEqual(
|
||||
books[0].lines[2].rec_name,
|
||||
'12/06/2013|from|7.00 usd|Transfer to From-Book ' +
|
||||
'[To Book | -12.70 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[2].state, 'check')
|
||||
|
||||
self.assertEqual(books[1].lines[0].rec_name, '12/04/2013|from|7.30 usd|Transfer to book [From Book | -50.55 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'12/04/2013|from|7.30 usd|Transfer to book [From Book ' +
|
||||
'| -50.55 usd | Open]')
|
||||
self.assertEqual(books[1].lines[0].state, 'check')
|
||||
self.assertEqual(books[1].lines[1].rec_name, '12/06/2013|Exp/Sp|-10.00 usd|Splitbooking with category and account [-]')
|
||||
self.assertEqual(
|
||||
books[1].lines[1].rec_name,
|
||||
'12/06/2013|Exp/Sp|-10.00 usd|Splitbooking with category' +
|
||||
' and account [-]')
|
||||
self.assertEqual(books[1].lines[1].state, 'check')
|
||||
self.assertEqual(books[1].lines[2].rec_name, '12/10/2013|Exp|-10.00 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(
|
||||
books[1].lines[2].rec_name,
|
||||
'12/10/2013|Exp|-10.00 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(books[1].lines[2].state, 'check')
|
||||
|
||||
# end PartyTestCase
|
Loading…
Reference in a new issue