Skip to content

Commit

Permalink
[FIX] account_financial_report: Improve test when duplicated group co…
Browse files Browse the repository at this point in the history
…de in CI
  • Loading branch information
carlosdauden committed Jun 22, 2021
1 parent 7c7e8f6 commit e61fbeb
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions account_financial_report/tests/test_trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def setUp(self):
self.group1 = group_obj.create(
{'code_prefix': '1',
'name': 'Group 1'})
self.group1_bis = group_obj.create(
{'code_prefix': '1',
'name': 'Group 1 bis'})
self.group11 = group_obj.create(
{'code_prefix': '11',
'name': 'Group 11',
Expand Down Expand Up @@ -168,6 +171,17 @@ def _get_group_lines(self, group_id, trial_balance):
}
return lines

def _get_group_lines_by_code(self, group_code, trial_balance):
group = next(filter(
lambda g: g['code'] == group_code and g['type'] == 'group_type',
trial_balance))
return {
'initial_balance': group['initial_balance'],
'debit': group['debit'],
'credit': group['credit'],
'final_balance': group['ending_balance']
}

def check_partner_in_report(self, account_id, partner_id, total_amount):
partner_in_report = False
if account_id in total_amount.keys():
Expand Down Expand Up @@ -243,7 +257,8 @@ def test_01_account_balance_computed(self):
# Check the initial and final balance
account_receivable_lines = self._get_account_lines(
self.account100.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group1_lines = self._get_group_lines_by_code(
self.group1.code_prefix, trial_balance)

self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
Expand Down Expand Up @@ -281,8 +296,10 @@ def test_01_account_balance_computed(self):
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
group1_lines = self._get_group_lines_by_code(
self.group1.code_prefix, trial_balance)
group2_lines = self._get_group_lines_by_code(
self.group2.code_prefix, trial_balance)

self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
Expand Down Expand Up @@ -329,8 +346,10 @@ def test_01_account_balance_computed(self):
self.account100.id, trial_balance)
account_income_lines = self._get_account_lines(
self.account200.id, trial_balance)
group1_lines = self._get_group_lines(self.group1.id, trial_balance)
group2_lines = self._get_group_lines(self.group2.id, trial_balance)
group1_lines = self._get_group_lines_by_code(
self.group1.code_prefix, trial_balance)
group2_lines = self._get_group_lines_by_code(
self.group2.code_prefix, trial_balance)

self.assertEqual(account_receivable_lines['initial_balance'], 1000)
self.assertEqual(account_receivable_lines['debit'], 0)
Expand Down

0 comments on commit e61fbeb

Please sign in to comment.