add placeholders for subject of booking

This commit is contained in:
Frederik Jaeckel 2024-03-09 19:34:44 +01:00
parent 42aeefaa19
commit acc8911a8d
5 changed files with 88 additions and 14 deletions

View file

@ -353,6 +353,23 @@ class PlannerTestCase(object):
IrDate.today = MagicMock(return_value=date.today())
@with_transaction()
def test_planner_check_description_template(self):
""" check replacement of template strings in description
"""
pool = Pool()
Planner = pool.get('cashbook.planner')
asset_book = self.prep_planner_asset_book()
self.assertEqual(Planner.fill_placeholder({
'date': date(2022, 5, 2),
'amount': Decimal('12.4567'),
'quantity': Decimal('32.4423'),
'cashbook': asset_book.id,
'description': '- ${amount} - ${date} - ${month} - ' +
'${year} - ${quantity}'}),
'- usd12.46 - 05/02/2022 - 5 - 2022 - 32.4423\xa0u')
@with_transaction()
def test_planner_cronjobs_booking_with_category(self):
""" create job, configure booking with category, run job
@ -397,8 +414,7 @@ class PlannerTestCase(object):
self.assertEqual(len(job.cashbook.lines), 1)
self.assertEqual(
job.cashbook.lines[0].rec_name,
"06/01/2022|Exp|-10.00 usd|booking " +
"${month}/${year}, ${date} [Cat1]")
"06/01/2022|Exp|-10.00 usd|booking 6/2022, 06/01/2022 [Cat1]")
self.assertEqual(job.cashbook.lines[0].state, 'check')
with Transaction().set_context({'date': date(2022, 6, 1)}):
@ -464,8 +480,8 @@ class PlannerTestCase(object):
self.assertEqual(len(cashbook.lines), 1)
self.assertEqual(
cashbook.lines[0].rec_name,
"06/01/2022|to|-10.00 usd|booking ${month}/${year}, " +
"${date} [Book 2 | 10.00 usd | Open]")
"06/01/2022|to|-10.00 usd|booking 6/2022, 06/01/2022 " +
"[Book 2 | 10.00 usd | Open]")
self.assertEqual(cashbook.lines[0].state, 'check')
target_book, = Cashbook.browse([job.booktransf])
@ -473,8 +489,8 @@ class PlannerTestCase(object):
self.assertEqual(len(target_book.lines), 1)
self.assertEqual(
target_book.lines[0].rec_name,
"06/01/2022|from|10.00 usd|booking ${month}/${year}, " +
"${date} [Book 1 | -10.00 usd | Open]")
"06/01/2022|from|10.00 usd|booking 6/2022, 06/01/2022 " +
"[Book 1 | -10.00 usd | Open]")
self.assertEqual(target_book.lines[0].state, 'check')
self.assertEqual(target_book.lines[0].state, 'check')
@ -775,12 +791,4 @@ class PlannerTestCase(object):
IrDate.today = MagicMock(return_value=date.today())
@with_transaction()
def test_planner_cronjobs_booking_transfer_asset_eur_usd2(self):
""" create job, configure transfer-booking to asset-cashbook,
from euro to usd,
asset-unit = u, cashbook-unit = 10x u
"""
raise ValueError('stop')
# end PlannerTestCase