Skip to content

Commit

Permalink
[TST] add test for fldp
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Nov 11, 2024
1 parent 2ce56f2 commit 0e63372
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions mis_builder/tests/test_aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def setUp(self):
amount=300,
debit_acc=self.account_ar,
credit_acc=self.account_in,
credit_quantity=3,
)
# create move in March this year
self._create_move(
Expand All @@ -90,6 +91,7 @@ def setUp(self):
self.aep.parse_expr("crdp[700I%]")
self.aep.parse_expr("bali[400%]")
self.aep.parse_expr("bale[700%]")
self.aep.parse_expr("fldp.quantity[700%]")
self.aep.parse_expr("balp[]" "[('account_id.code', '=', '400AR')]")
self.aep.parse_expr(
"balp[]" "[('account_id.account_type', '=', " " 'asset_receivable')]"
Expand All @@ -104,17 +106,32 @@ def setUp(self):
self.aep.parse_expr("bal_700IN") # deprecated
self.aep.parse_expr("bals[700IN]") # deprecated

def _create_move(self, date, amount, debit_acc, credit_acc, post=True):
def _create_move(
self, date, amount, debit_acc, credit_acc, post=True, credit_quantity=0
):
move = self.move_model.create(
{
"journal_id": self.journal.id,
"date": fields.Date.to_string(date),
"line_ids": [
(0, 0, {"name": "/", "debit": amount, "account_id": debit_acc.id}),
(
0,
0,
{"name": "/", "credit": amount, "account_id": credit_acc.id},
{
"name": "/",
"debit": amount,
"account_id": debit_acc.id,
},
),
(
0,
0,
{
"name": "/",
"credit": amount,
"account_id": credit_acc.id,
"quantity": credit_quantity,
},
),
],
}
Expand Down Expand Up @@ -193,6 +210,8 @@ def test_aep_basic(self):
# check ending balance
self.assertEqual(self._eval("bale[400AR]"), 400)
self.assertEqual(self._eval("bale[700IN]"), -300)
# check fldp.quantity
self.assertEqual(self._eval("fldp.quantity[700%]"), 3)

# let's query for March
self._do_queries(
Expand Down Expand Up @@ -224,6 +243,8 @@ def test_aep_basic(self):
self.assertEqual(self._eval("debp[400A%]"), 500)
self.assertEqual(self._eval("bal_700IN"), -500)
self.assertEqual(self._eval("bals[700IN]"), -800)
# check fldp.quantity
self.assertEqual(self._eval("fldp.quantity[700%]"), 0)

# unallocated p&l from previous year
self.assertEqual(self._eval("balu[]"), -100)
Expand Down

0 comments on commit 0e63372

Please sign in to comment.