Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] add a few more tests #649

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mis_builder/models/aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,11 @@ def do_queries(
aml_model = aml_model.with_context(active_test=False)
company_rates = self._get_company_rates(date_to)
# {(domain, mode): {account_id: (debit, credit)}}
self._data = defaultdict(lambda: defaultdict(lambda: SimpleArray((0.0, 0.0))))
self._data = defaultdict(
lambda: defaultdict(
lambda: SimpleArray((AccountingNone, AccountingNone)),
)
)
domain_by_mode = {}
ends = []
for key in self._map_account_ids:
Expand Down
10 changes: 9 additions & 1 deletion mis_builder/tests/test_aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def setUp(self):
self.aep.parse_expr("bali[700IN]")
self.aep.parse_expr("bale[700IN]")
self.aep.parse_expr("balp[700IN]")
self.aep.parse_expr("balp[700NA]") # account that does not exist
self.aep.parse_expr("bali[400AR]")
self.aep.parse_expr("bale[400AR]")
self.aep.parse_expr("balp[400AR]")
Expand Down Expand Up @@ -200,6 +201,8 @@ def test_aep_basic(self):
# check ending balance
self.assertEqual(self._eval("bale[400AR]"), 400)
self.assertEqual(self._eval("bale[700IN]"), -300)
# check result for non existing account
self.assertIs(self._eval("bale[700NA]"), AccountingNone)

# let's query for March
self._do_queries(
Expand Down Expand Up @@ -234,9 +237,14 @@ def test_aep_basic(self):

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

# TODO allocate profits, and then...

# let's query for December where there is no data
self._do_queries(
datetime.date(self.curr_year, 12, 1), datetime.date(self.curr_year, 12, 31)
)
self.assertIs(self._eval("balp[700IN]"), AccountingNone)

def test_aep_by_account(self):
self.aep.done_parsing()
self._do_queries(
Expand Down
Loading