extend evaluation for cashbook-profit/loss amount/percent/diff - todo
This commit is contained in:
parent
0b590b87c7
commit
82bdf3e05b
11 changed files with 265 additions and 21 deletions
|
@ -510,6 +510,31 @@ class ReportTestCase(CashbookTestCase):
|
|||
self.assertEqual(len(evaluation.currencies), 0)
|
||||
self.assertEqual(len(evaluation.categories), 0)
|
||||
|
||||
# investment - profit/loss amount
|
||||
if 'cashbooks_gldiff' in [x[0] for x in Evaluation.get_sel_etype()]:
|
||||
# no change if switch between cashbook-types
|
||||
Evaluation.write(*[
|
||||
[evaluation],
|
||||
{
|
||||
'dtype': 'cashbooks_gldiff',
|
||||
}])
|
||||
self.assertEqual(len(evaluation.cashbooks), 3)
|
||||
self.assertEqual(len(evaluation.types), 0)
|
||||
self.assertEqual(len(evaluation.currencies), 0)
|
||||
self.assertEqual(len(evaluation.categories), 0)
|
||||
|
||||
Evaluation.write(*[
|
||||
[evaluation],
|
||||
{
|
||||
'dtype': 'cashbooks_glperc',
|
||||
}])
|
||||
self.assertEqual(len(evaluation.cashbooks), 3)
|
||||
self.assertEqual(len(evaluation.types), 0)
|
||||
self.assertEqual(len(evaluation.currencies), 0)
|
||||
self.assertEqual(len(evaluation.categories), 0)
|
||||
else :
|
||||
print('\n--== Module "cashbook_investment" not installed ==--')
|
||||
|
||||
Evaluation.write(*[
|
||||
[evaluation],
|
||||
{
|
||||
|
@ -684,6 +709,90 @@ class ReportTestCase(CashbookTestCase):
|
|||
if DashboardAction is not None:
|
||||
self.assertEqual(DashboardAction.search_count([]), 1)
|
||||
|
||||
@with_transaction()
|
||||
def test_report_chart_hbar_book_investment(self):
|
||||
""" create 3x cashbooks, add bookings, rates
|
||||
create report with cashbooks, check
|
||||
"""
|
||||
pool = Pool()
|
||||
Evaluation = pool.get('cashbook_report.evaluation')
|
||||
Book = pool.get('cashbook.book')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id,
|
||||
}):
|
||||
if 'cashbooks_gldiff' not in [x[0] for x in Evaluation.get_sel_etype()]:
|
||||
print('\n--== Module "cashbook_investment" not installed ==--')
|
||||
return
|
||||
|
||||
AccType = pool.get('cashbook.type')
|
||||
Asset = pool.get('investment.asset')
|
||||
Product = pool.get('product.template')
|
||||
Uom = pool.get('product.uom')
|
||||
|
||||
at, = AccType.create([{
|
||||
'name': 'depot',
|
||||
'short': 'D',
|
||||
'feature': 'asset',
|
||||
'company': company.id,
|
||||
}])
|
||||
|
||||
prod_templ, = Product.create([{
|
||||
'name': 'Aurum',
|
||||
'type': 'assets',
|
||||
'list_price': Decimal('1.0'),
|
||||
'default_uom': Uom.search([('symbol', '=', 'u')])[0].id,
|
||||
'products': [('create', [{
|
||||
'description': 'Au',
|
||||
}])],
|
||||
}])
|
||||
|
||||
asset, = Asset.create([{
|
||||
'company': company.id,
|
||||
'product': prod_templ.products[0].id,
|
||||
'currency': company.currency.id,
|
||||
'currency_digits': 4,
|
||||
'uom': prod_templ.default_uom.id,
|
||||
'rates': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'rate': Decimal('1750.0'),
|
||||
}, ])],
|
||||
}])
|
||||
|
||||
AccType.write(*[
|
||||
[books[0].btype],
|
||||
{
|
||||
'feature': 'asset',
|
||||
}])
|
||||
|
||||
books = self.prep_report_3books()
|
||||
Book.write(*[
|
||||
books,
|
||||
{
|
||||
'asset': asset.id,
|
||||
'quantity_uom': asset.uom.id,
|
||||
'quantity_digits': 3,
|
||||
}])
|
||||
self.assertEqual(books[0].rec_name, 'ss')
|
||||
|
||||
evaluation, = Evaluation.create([{
|
||||
'name': 'Evaluation 1',
|
||||
'dtype': 'cashbooks_gldiff',
|
||||
'chart': 'hbar',
|
||||
'cashbooks': [('add', [x.id for x in books])],
|
||||
}])
|
||||
self.assertEqual(evaluation.dtype, 'cashbooks_gldiff')
|
||||
self.assertEqual(evaluation.chart, 'hbar')
|
||||
self.assertEqual(evaluation.legend, True)
|
||||
self.assertEqual(evaluation.maincolor, 'default')
|
||||
self.assertEqual(evaluation.bgcolor, '#ffffc0')
|
||||
self.assertEqual(evaluation.currency.code, 'EUR')
|
||||
|
||||
self.assertEqual(evaluation.line_values[0].balance, Decimal('23.81'))
|
||||
self.assertEqual(evaluation.line_values[1].balance, Decimal('11.90'))
|
||||
self.assertEqual(evaluation.line_values[2].balance, Decimal('23.00'))
|
||||
|
||||
@with_transaction()
|
||||
def test_report_chart_pie_book_red(self):
|
||||
""" create 3x cashbooks, add bookings,
|
||||
|
@ -719,7 +828,7 @@ class ReportTestCase(CashbookTestCase):
|
|||
<field name="name"/>
|
||||
</x>
|
||||
<y>
|
||||
<field name="balance" fill="1" empty="0" string="Cashbooks"/>
|
||||
<field name="balance" fill="1" empty="0" string="Cashbooks [Amount]"/>
|
||||
</y>
|
||||
</graph>
|
||||
""")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue