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()
|
@with_transaction()
|
||||||
def test_assetbook_check_bookingtype_mvout(self):
|
def test_assetbook_check_bookingtype_mvout(self):
|
||||||
""" create cashbook + line, bookingtype 'mvout'
|
""" 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(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)
|
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
|
# end CbInvTestCase
|
||||||
|
|
|
@ -5,10 +5,10 @@ full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<xpath expr="/tree/field[@name='balance']" position="after">
|
<xpath expr="/tree/field[@name='balance']" position="after">
|
||||||
<field name="current_value"/>
|
<field name="current_value" symbol="currency"/>
|
||||||
<field name="diff_amount"/>
|
<field name="diff_amount" symbol="currency"/>
|
||||||
<field name="diff_percent"/>
|
<field name="diff_percent"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity" symbol="quantity_uom"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -5,7 +5,7 @@ full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<xpath expr="/tree/field[@name='balance']" position="after">
|
<xpath expr="/tree/field[@name='balance']" position="after">
|
||||||
<field name="diff_amount"/>
|
<field name="diff_amount" symbol="quantity_uom"/>
|
||||||
<field name="diff_percent"/>
|
<field name="diff_percent"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<xpath expr="/form/field[@name='end_amount']" position="after">
|
<xpath expr="/form/field[@name='date']" position="after">
|
||||||
<newline/>
|
|
||||||
<label name="start_quantity" />
|
<label name="start_quantity" />
|
||||||
<field name="start_quantity" symbol="quantity_uom"/>
|
<field name="start_quantity" symbol="quantity_uom"/>
|
||||||
<label name="end_quantity"/>
|
<label name="end_quantity"/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue