2nd-uom-mixin begonnen

This commit is contained in:
Frederik Jaeckel 2023-01-12 23:37:20 +01:00
parent 657489fb0b
commit 239a706a83
6 changed files with 219 additions and 5 deletions

View file

@ -538,7 +538,7 @@ class CbInvTestCase(CashbookTestCase, InvestmentTestCase):
}])
@with_transaction()
def test_assetbook_check_bookingtype_mvout(self):
def test_assetbook_check_mvout(self):
""" create cashbook + line, bookingtype 'mvout'
transfer from cash to depot (buy asset, pay from cash)
"""
@ -643,4 +643,113 @@ 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_mvout_two_asset_accounts_invalid_category(self):
""" create cashbook + line, bookingtype 'mvout'
transfer from asset-book to asset-book, check deny of
invalid uom-catgories
"""
pool = Pool()
Book = pool.get('cashbook.book')
Line = pool.get('cashbook.line')
Category = pool.get('cashbook.category')
BType = pool.get('cashbook.type')
UOM = pool.get('product.uom')
Asset = pool.get('investment.asset')
ProdTempl = pool.get('product.template')
type_cash = self.prep_type()
type_depot = self.prep_type('Depot', 'D')
BType.write(*[
[type_depot],
{
'feature': 'asset',
}])
category_in = self.prep_category(cattype='in')
category_out = self.prep_category(name='Out Category', cattype='out')
company = self.prep_company()
party = self.prep_party()
asset1 = self.prep_asset_item(
company=company,
product = self.prep_asset_product(name='Product 1'))
asset2 = self.prep_asset_item(
company=company,
product = self.prep_asset_product(name='Product 2'))
uom_kg = UOM.search([('symbol', '=', 'kg')])[0]
uom_min = UOM.search([('symbol', '=', 'min')])[0]
ProdTempl.write(*[
[asset1.product.template],
{
'default_uom': uom_kg.id,
},
[asset2.product.template],
{
'default_uom': uom_min.id,
},
])
Asset.write(*[
[asset1],
{
'uom': uom_kg.id,
},
[asset2],
{
'uom': uom_min.id,
},
])
self.assertEqual(asset1.symbol, 'usd/kg')
self.assertEqual(asset2.symbol, 'usd/min')
book1, = Book.create([{
'name': 'Asset-Book - kg',
'btype': type_depot.id,
'asset': asset1.id,
'quantity_uom': asset1.uom.id,
'company': company.id,
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
'start_date': date(2022, 5, 1),
}])
book2, = Book.create([{
'name': 'Asset-Book - min',
'btype': type_depot.id,
'asset': asset2.id,
'quantity_uom': asset2.uom.id,
'company': company.id,
'currency': company.currency.id,
'number_sequ': self.prep_sequence().id,
'start_date': date(2022, 5, 1),
}])
self.assertEqual(book1.rec_name, 'Asset-Book - kg | 0.00 usd | Open')
self.assertEqual(book2.rec_name, 'Asset-Book - min | 0.00 usd | Open')
self.assertEqual(len(book1.lines), 0)
self.assertEqual(len(book2.lines), 0)
Book.write(*[
[book1],
{
'lines': [('create', [{
'date': date(2022, 5, 1),
'description': 'Transfer',
'category': category_out.id,
'bookingtype': 'mvout',
'booktransf': book2.id,
'amount': Decimal('1.0'),
'quantity': Decimal('1.5'),
'quantity_2nd_uom': Decimal('10.5'),
}])],
}])
self.assertEqual(len(book1.lines), 1)
self.assertEqual(book1.lines[0].quantity_uom.symbol, 'kg')
self.assertEqual(book1.lines[0].quantity2nd.symbol, 'min')
self.assertEqual(book1.lines[0].quantity_digits, 4)
self.assertEqual(book1.lines[0].quantity2nd_digits, 4)
Line.wfcheck(list(book1.lines))
# end CbInvTestCase

View file

@ -17,7 +17,7 @@ class ReconTestCase(ModuleTestCase):
@with_transaction()
def test_recon_set_start_quantity_by_cashbook(self):
""" set stat-quantity from cashbook-setting
""" set start-quantity of reconciliation from cashbook-setting
"""
pool = Pool()
Book = pool.get('cashbook.book')