line: quantity_credit/debit + test

book: berechnet 'quantity' aus quantity_credit/debit
This commit is contained in:
Frederik Jaeckel 2022-12-30 23:55:00 +01:00
parent e0895f3e4c
commit e94a869166
6 changed files with 210 additions and 133 deletions

View file

@ -55,6 +55,7 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
"""
pool = Pool()
Book = pool.get('cashbook.book')
Line = pool.get('cashbook.line')
BType = pool.get('cashbook.type')
Asset = pool.get('investment.asset')
@ -129,17 +130,24 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
self.assertEqual(book.lines[0].amount, Decimal('2.5'))
self.assertEqual(book.lines[0].quantity, Decimal('1.453'))
self.assertEqual(book.lines[0].quantity_credit, Decimal('1.453'))
self.assertEqual(book.lines[0].quantity_debit, Decimal('0.0'))
self.assertEqual(book.lines[0].quantity_digits, 3)
self.assertEqual(book.lines[0].quantity_uom.symbol, 'u')
self.assertEqual(book.lines[1].amount, Decimal('4.0'))
self.assertEqual(book.lines[1].quantity, Decimal('3.3'))
self.assertEqual(book.lines[1].quantity_credit, Decimal('3.3'))
self.assertEqual(book.lines[1].quantity_debit, Decimal('0.0'))
self.assertEqual(book.lines[1].quantity_digits, 3)
self.assertEqual(book.lines[1].quantity_uom.symbol, 'u')
self.assertEqual(book.symbol, '€/u')
self.assertEqual(book.asset.rec_name, 'Product 1 | 2.8000 usd/u | 05/02/2022')
# wf --> check
Line.wfcheck(book.lines)
# check quantities at cashbook
with Transaction().set_context({
'qdate': date(2022, 5, 5),
@ -466,6 +474,7 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
@with_transaction()
def test_assetbook_check_bookingtype_mvout(self):
""" create cashbook + line, bookingtype 'mvout'
transfer from cash to depot (buy asset, pay from cash)
"""
pool = Pool()
Book = pool.get('cashbook.book')
@ -537,7 +546,10 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
self.assertEqual(len(book.lines), 1)
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Asset-Book | 1.00 usd | Open]')
self.assertEqual(book.lines[0].state, 'check')
self.assertEqual(book.lines[0].bookingtype, 'mvout')
self.assertEqual(book.lines[0].quantity, Decimal('1.5'))
self.assertEqual(book.lines[0].quantity_credit, Decimal('0.0'))
self.assertEqual(book.lines[0].quantity_debit, Decimal('1.5'))
self.assertEqual(len(book.lines[0].references), 1)
self.assertEqual(book.lines[0].reference, None)
self.assertEqual(book.lines[0].references[0].id, book2.lines[0].id)
@ -546,6 +558,10 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
self.assertEqual(book2.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer Out [Book 1 | -1.00 usd | Open]')
self.assertEqual(book2.lines[0].state, 'check')
self.assertEqual(book2.lines[0].quantity, Decimal('1.5'))
self.assertEqual(book2.lines[0].quantity_credit, Decimal('1.5'))
self.assertEqual(book2.lines[0].quantity_debit, Decimal('0.0'))
self.assertEqual(book2.lines[0].bookingtype, 'mvin')
self.assertEqual(book2.lines[0].asset_rate, Decimal('0.6667'))
self.assertEqual(book2.lines[0].reference.rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Asset-Book | 1.00 usd | Open]')
self.assertEqual(len(book2.lines[0].references), 0)