Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Party payable and receivable seems to be incorrect if the balances are checked after closing fiscal year
diff --git a/tests/test_account.py b/tests/test_account.py
index b0aef15..6651b9b 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -735,6 +735,11 @@ class AccountTestCase(ModuleTestCase):
Journal = pool.get('account.journal')
Account = pool.get('account.account')
Move = pool.get('account.move')
+ Period = pool.get('account.period')
+ AccountType = pool.get('account.account.type')
+ Sequence = pool.get('ir.sequence')
+ BalanceNonDeferral = pool.get(
+ 'account.fiscalyear.balance_non_deferral', type='wizard')
company = create_company()
with set_company(company):
@@ -803,6 +808,64 @@ class AccountTestCase(ModuleTestCase):
self.assertEqual(party.payable, Decimal('90'))
self.assertEqual(party.payable_today, Decimal('30'))
+ # Close the fiscal year and then test the balance again
+ # Balance non-deferral
+ journal_sequence, = Sequence.search([
+ ('code', '=', 'account.journal'),
+ ])
+ journal_closing, = Journal.create([{
+ 'name': 'Closing',
+ 'code': 'CLO',
+ 'type': 'situation',
+ 'sequence': journal_sequence.id,
+ }])
+ period_closing, = Period.create([{
+ 'name': 'Closing',
+ 'start_date': fiscalyear.end_date,
+ 'end_date': fiscalyear.end_date,
+ 'fiscalyear': fiscalyear.id,
+ 'type': 'adjustment',
+ }])
+ type_equity, = AccountType.search([
+ ('name', '=', 'Equity'),
+ ])
+ account_pl, = Account.create([{
+ 'name': 'P&L',
+ 'type': type_equity.id,
+ 'deferral': True,
+ 'parent': revenue.parent.id,
+ 'kind': 'other',
+ }])
+
+ session_id = BalanceNonDeferral.create()[0]
+ balance_non_deferral = BalanceNonDeferral(session_id)
+
+ balance_non_deferral.start.fiscalyear = fiscalyear
+ balance_non_deferral.start.journal = journal_closing
+ balance_non_deferral.start.period = period_closing
+ balance_non_deferral.start.credit_account = account_pl
+ balance_non_deferral.start.debit_account = account_pl
+
+ balance_non_deferral._execute('balance')
+
+ moves = Move.search([
+ ('state', '=', 'draft'),
+ ('period.fiscalyear', '=', fiscalyear.id),
+ ])
+ Move.post(moves)
+
+ # Close fiscalyear
+ FiscalYear.close([fiscalyear])
+
+ # Check deferral
+ self.assertEqual(revenue.deferrals, ())
+
+ party = Party(party.id)
+ self.assertEqual(party.receivable, Decimal('300'))
+ self.assertEqual(party.receivable_today, Decimal('100'))
+ self.assertEqual(party.payable, Decimal('90'))
+ self.assertEqual(party.payable_today, Decimal('30'))
+
@with_transaction()
def test_sort_taxes(self):
"Test sort_taxes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.