book: tree/list optimiert
This commit is contained in:
parent
fd36a3f4ce
commit
66a933d21b
4 changed files with 71 additions and 72 deletions
|
@ -471,6 +471,72 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
|
|||
}
|
||||
])
|
||||
|
||||
@with_transaction()
|
||||
def test_assetbook_check_sign_mismatch(self):
|
||||
""" create cashbook + line, bookingtype 'in',
|
||||
check detection of sign mismatch between quantity and amount
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
|
||||
category_in = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product = self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'buy some',
|
||||
'category': category_in.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'quantity': Decimal('1.5'),
|
||||
}])],
|
||||
}])
|
||||
|
||||
self.assertEqual(book.rec_name, 'Asset-Book | 1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].amount, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].credit, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].debit, Decimal('0.0'))
|
||||
self.assertEqual(book.lines[0].quantity, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[0].quantity_credit, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[0].quantity_debit, Decimal('0.0'))
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
"Quantity and Amount must with same sign for line 05/01/2022|Rev|1.00 usd|buy some [Cat1].",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
{
|
||||
'lines': [('write', [book.lines[0]], {
|
||||
'quantity': Decimal('-1.5'),
|
||||
})],
|
||||
}])
|
||||
|
||||
@with_transaction()
|
||||
def test_assetbook_check_bookingtype_mvout(self):
|
||||
""" create cashbook + line, bookingtype 'mvout'
|
||||
|
@ -577,70 +643,4 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
|
|||
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)
|
||||
|
||||
@with_transaction()
|
||||
def test_assetbook_check_sign_mismatch(self):
|
||||
""" create cashbook + line, bookingtype 'in',
|
||||
check detection of sign mismatch between quantity and amount
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
BType = pool.get('cashbook.type')
|
||||
|
||||
type_depot = self.prep_type('Depot', 'D')
|
||||
BType.write(*[
|
||||
[type_depot],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
|
||||
category_in = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product = self.prep_asset_product(name='Product 1'))
|
||||
self.assertEqual(asset.symbol, 'usd/u')
|
||||
|
||||
book, = Book.create([{
|
||||
'name': 'Asset-Book',
|
||||
'btype': type_depot.id,
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'buy some',
|
||||
'category': category_in.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'quantity': Decimal('1.5'),
|
||||
}])],
|
||||
}])
|
||||
|
||||
self.assertEqual(book.rec_name, 'Asset-Book | 1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].amount, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].credit, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].debit, Decimal('0.0'))
|
||||
self.assertEqual(book.lines[0].quantity, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[0].quantity_credit, Decimal('1.5'))
|
||||
self.assertEqual(book.lines[0].quantity_debit, Decimal('0.0'))
|
||||
|
||||
self.assertRaisesRegex(UserError,
|
||||
"Quantity and Amount must with same sign for line 05/01/2022|Rev|1.00 usd|buy some [Cat1].",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
{
|
||||
'lines': [('write', [book.lines[0]], {
|
||||
'quantity': Decimal('-1.5'),
|
||||
})],
|
||||
}])
|
||||
|
||||
# end CbInvTestCase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue