import: für umbuchungen optimiert + test
This commit is contained in:
parent
9e6cfb210f
commit
2db020f5d8
9 changed files with 277 additions and 114 deletions
|
@ -54,7 +54,7 @@ L[Bargeld]
|
|||
D05.12.2013
|
||||
CX
|
||||
M05.12/06.42UHR TT TELTOW
|
||||
T290,00
|
||||
T-29,00
|
||||
PGA NR00002168 BLZ10000000 0
|
||||
L[S-Giro]
|
||||
^
|
||||
|
@ -65,6 +65,13 @@ T-56,37
|
|||
PFoodshop Zehlendorf
|
||||
LLebensmittel
|
||||
^
|
||||
D06.12.2013
|
||||
CX
|
||||
Mreturn of bottles
|
||||
T1,45
|
||||
PFoodshop Zehlendorf
|
||||
LLebensmittel
|
||||
^
|
||||
"""
|
||||
|
||||
qif_category = """!Type:Cat
|
||||
|
|
|
@ -236,9 +236,10 @@ I
|
|||
'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\nT290,00\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^\n')
|
||||
'T-56,37\nPFoodshop Zehlendorf\nLLebensmittel\n^\nD06.12.2013\nCX\n'+
|
||||
'Mreturn of bottles\nT1,45\nPFoodshop Zehlendorf\nLLebensmittel\n^\n')
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_convert_transactions(self):
|
||||
|
@ -255,7 +256,7 @@ I
|
|||
'company': company.id,
|
||||
}):
|
||||
types = self.prep_type()
|
||||
book, = Book.create([{
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
|
@ -263,9 +264,29 @@ I
|
|||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2010, 1, 1),
|
||||
'start_balance': Decimal('0.0'),
|
||||
}, {
|
||||
'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),
|
||||
'start_balance': Decimal('0.0'),
|
||||
}, {
|
||||
'name': 'Bargeld',
|
||||
'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')
|
||||
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')
|
||||
|
||||
parties = Party.create([{
|
||||
'name': 'Opening Balance',
|
||||
|
@ -293,42 +314,34 @@ I
|
|||
'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'+
|
||||
'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'+
|
||||
'$-2,99\nSHaushaltschemie\nESagrotan\n$-3,49\n^\n')
|
||||
|
||||
(to_create, msg_txt, fail_cnt) = QifTool.convert_transactions_to_create(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),
|
||||
'amount': Decimal('7.12'),
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'party': parties[0].id,
|
||||
'category': categories[4].id,
|
||||
'state': 'edit',
|
||||
'bookingtype': 'mvin',
|
||||
'booktransf': books[2].id,
|
||||
'description': 'Opening Balance',
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('290.00'),
|
||||
'amount': Decimal('29.00'),
|
||||
'description': '05.12/06.42UHR TT TELTOW',
|
||||
'state': 'check',
|
||||
'bookingtype': 'in',
|
||||
'party': parties[1].id,
|
||||
'category': categories[3].id,
|
||||
'state': 'edit',
|
||||
'bookingtype': 'mvout',
|
||||
'booktransf': books[1].id,
|
||||
'description': 'GA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW',
|
||||
}, {
|
||||
'date': date(2013, 12, 5),
|
||||
'amount': Decimal('56.37'),
|
||||
|
@ -362,12 +375,12 @@ I
|
|||
)],
|
||||
}])
|
||||
Book.write(*[
|
||||
[book],
|
||||
[books[0]],
|
||||
{
|
||||
'lines': [('create', to_create)],
|
||||
}])
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(book.balance, Decimal('184.91'))
|
||||
self.assertEqual(len(books[0].lines), 4)
|
||||
self.assertEqual(books[0].balance, Decimal('-134.09'))
|
||||
|
||||
@with_transaction()
|
||||
def test_qiftool_read_transactions(self):
|
||||
|
|
|
@ -31,7 +31,7 @@ class TransactionTestCase(ModuleTestCase):
|
|||
'active_model': 'cashbook.book',
|
||||
}):
|
||||
types = self.prep_type()
|
||||
book, = Book.create([{
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
|
@ -39,6 +39,22 @@ class TransactionTestCase(ModuleTestCase):
|
|||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2010, 1, 1),
|
||||
'start_balance': Decimal('0.0'),
|
||||
}, {
|
||||
'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),
|
||||
'start_balance': Decimal('0.0'),
|
||||
}, {
|
||||
'name': 'Bargeld',
|
||||
'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([{
|
||||
|
@ -53,12 +69,6 @@ class TransactionTestCase(ModuleTestCase):
|
|||
}])
|
||||
|
||||
Category.create([{
|
||||
'name':'Bargeld',
|
||||
'cattype': 'in',
|
||||
}, {
|
||||
'name': 'S-Giro',
|
||||
'cattype': 'in',
|
||||
}, {
|
||||
'name': 'Lebensmittel',
|
||||
'cattype': 'out',
|
||||
}])
|
||||
|
@ -76,10 +86,10 @@ class TransactionTestCase(ModuleTestCase):
|
|||
r1 = {}
|
||||
r1['file_'] = qif_types.encode('utf8')
|
||||
r1['company'] = company.id
|
||||
r1['book'] = book.id
|
||||
r1['book'] = books[0].id
|
||||
w_obj.start.file_ = r1['file_']
|
||||
w_obj.start.company = company.id
|
||||
w_obj.start.book = book.id
|
||||
w_obj.start.book = books[0].id
|
||||
|
||||
result = ImportWiz.execute(sess_id, {'start': r1}, 'readf')
|
||||
|
||||
|
@ -87,46 +97,53 @@ class TransactionTestCase(ModuleTestCase):
|
|||
self.assertEqual(result['view']['defaults']['company'], company.id)
|
||||
self.assertEqual(result['view']['defaults']['info'],
|
||||
"""The following transactionen are now imported:
|
||||
Credit: usd297.12
|
||||
Debit: usd56.37
|
||||
Balance: usd240.75
|
||||
Number of transactions: 3""")
|
||||
Credit: usd7.12
|
||||
Debit: usd83.92
|
||||
Balance: -usd76.80
|
||||
Number of transactions: 4""")
|
||||
|
||||
r1 = {
|
||||
'company': company.id,
|
||||
'book': book.id,
|
||||
'book': books[0].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(len(books[0].lines), 4)
|
||||
|
||||
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]')
|
||||
self.assertEqual(books[0].lines[0].rec_name, '12/05/2013|Exp|-56.37 usd|some food [Lebensmittel]')
|
||||
self.assertEqual(books[0].lines[1].rec_name, '12/06/2013|Exp|1.45 usd|return of bottles [Lebensmittel]')
|
||||
self.assertEqual(books[0].lines[2].rec_name, '12/04/2013|from|7.12 usd|Opening Balance [Bargeld | 0.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[3].rec_name, '12/05/2013|to|-29.00 usd|GA NR00002168 BLZ10000000 0; 05.12/06.42 [S-Giro | 0.00 usd | Open]')
|
||||
|
||||
self.assertEqual(Book.export_as_qif(book), """!Type:Bank
|
||||
D12/04/2013
|
||||
T7.12
|
||||
CX
|
||||
POpening Balance
|
||||
LBargeld
|
||||
^
|
||||
D12/05/2013
|
||||
T290.00
|
||||
CX
|
||||
PGA NR00002168 BLZ10000000 0
|
||||
LS-Giro
|
||||
M05.12/06.42UHR TT TELTOW
|
||||
^
|
||||
self.assertEqual(Book.export_as_qif(books[0]), """!Type:Bank
|
||||
D12/05/2013
|
||||
T-56.37
|
||||
CX
|
||||
PFoodshop Zehlendorf
|
||||
LLebensmittel
|
||||
Msome food
|
||||
^
|
||||
D12/06/2013
|
||||
T1.45
|
||||
CX
|
||||
PFoodshop Zehlendorf
|
||||
LLebensmittel
|
||||
Mreturn of bottles
|
||||
^
|
||||
D12/04/2013
|
||||
T7.12
|
||||
C*
|
||||
L[Bargeld]
|
||||
MOpening Balance
|
||||
^
|
||||
D12/05/2013
|
||||
T-29.00
|
||||
C*
|
||||
L[S-Giro]
|
||||
MGA NR00002168 BLZ10000000 0; 05.12/06.42UHR TT TELTOW
|
||||
^""")
|
||||
|
||||
# end PartyTestCase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue