[account_financial_report] adds the following features to Trial Balance:

- Adds 'Period balance' column
- Renames the option 'Hide accounts at 0'. Means no initial, no debit, credit
  or ending balance for the period.
- Fixes logic to remove lines with 0 activity for the period.
- improve the calculation in the Trial Balance
  of undistributed profits/losses account, and provide a footer note
  to the user explaining why will the ending balances will not be zero, but the
  period's total profit and loss.
- add an extra line for P&L application so that the trial balance zeroes in the
  balance, and total debits = total credits
- refactoring of the unaffected earnings reporting in the general ledger
  and trial balance.
This commit is contained in:
Jordi Ballester Alomar
2018-11-07 14:57:35 +01:00
committed by chaule97
parent 9afe86cb7e
commit c90bafbb61
10 changed files with 534 additions and 254 deletions

View File

@@ -54,8 +54,6 @@ class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
]
@common.at_install(False)
@common.post_install(True)
class TestGeneralLedgerReport(common.TransactionCase):
def setUp(self):
@@ -344,10 +342,10 @@ class TestGeneralLedgerReport(common.TransactionCase):
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, -0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, -1000)
# Add reversale move of the initial move the first day of fiscal year
@@ -369,11 +367,11 @@ class TestGeneralLedgerReport(common.TransactionCase):
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@@ -393,11 +391,11 @@ class TestGeneralLedgerReport(common.TransactionCase):
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, -4000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 4000)
self.assertEqual(lines['unaffected'].final_balance, -3000)
def test_04_unaffected_account_balance_2_years(self):
# Generate the general ledger line
@@ -427,10 +425,10 @@ class TestGeneralLedgerReport(common.TransactionCase):
self.assertEqual(len(lines['unaffected']), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_debit, 1000)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 1000)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 1000)
@@ -460,9 +458,9 @@ class TestGeneralLedgerReport(common.TransactionCase):
self.assertEqual(len(lines['unaffected']), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_debit, 500)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 500)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_debit, 500)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 500)

View File

@@ -63,8 +63,6 @@ class TestTrialBalance(a_t_f_c.AbstractTestForeignCurrency):
return 'show_partner_details' in filters
@common.at_install(False)
@common.post_install(True)
class TestTrialBalanceReport(common.TransactionCase):
def setUp(self):
@@ -500,3 +498,143 @@ class TestTrialBalanceReport(common.TransactionCase):
self.assertEqual(lines['partner_receivable'].debit, 0)
self.assertEqual(lines['partner_receivable'].credit, 2000)
self.assertEqual(lines['partner_receivable'].final_balance, -1000)
def test_04_undistributed_pl(self):
# Add a P&L Move in the previous FY
move_name = 'current year pl move'
journal = self.env['account.journal'].search([], limit=1)
move_vals = {
'journal_id': journal.id,
'name': move_name,
'date': self.previous_fy_date_end,
'line_ids': [
(0, 0, {
'name': move_name,
'debit': 0.0,
'credit': 1000.0,
'account_id': self.account300.id}),
(0, 0, {
'name': move_name,
'debit': 1000.0,
'credit': 0.0,
'account_id': self.account100.id})
]}
move = self.env['account.move'].create(move_vals)
move.post()
# Generate the trial balance line
report_account_model = self.env['report_trial_balance_account']
company = self.env.ref('base.main_company')
trial_balance = self.env['report_trial_balance'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'hide_account_balance_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 0)
self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
# Add a P&L Move to the current FY
move_name = 'current year pl move'
journal = self.env['account.journal'].search([], limit=1)
move_vals = {
'journal_id': journal.id,
'name': move_name,
'date': self.date_start,
'line_ids': [
(0, 0, {
'name': move_name,
'debit': 0.0,
'credit': 1000.0,
'account_id': self.account300.id}),
(0, 0, {
'name': move_name,
'debit': 1000.0,
'credit': 0.0,
'account_id': self.account100.id})
]}
move = self.env['account.move'].create(move_vals)
move.post()
# Re Generate the trial balance line
trial_balance = self.env['report_trial_balance'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'hide_account_balance_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
# The unaffected earnings account is not affected by a journal entry
# made to the P&L in the current fiscal year.
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 0)
self.assertEqual(unaffected_balance_lines[0].final_balance, -1000)
# Add a Move including Unaffected Earnings to the current FY
move_name = 'current year unaffected earnings move'
journal = self.env['account.journal'].search([], limit=1)
move_vals = {
'journal_id': journal.id,
'name': move_name,
'date': self.date_start,
'line_ids': [
(0, 0, {
'name': move_name,
'debit': 0.0,
'credit': 1000.0,
'account_id': self.account110.id}),
(0, 0, {
'name': move_name,
'debit': 1000.0,
'credit': 0.0,
'account_id': self.account100.id})
]}
move = self.env['account.move'].create(move_vals)
move.post()
# Re Generate the trial balance line
trial_balance = self.env['report_trial_balance'].create({
'date_from': self.date_start,
'date_to': self.date_end,
'only_posted_moves': True,
'hide_account_balance_at_0': False,
'hierarchy_on': 'none',
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
trial_balance.compute_data_for_report()
# The unaffected earnings account affected by a journal entry
# made to the unaffected earnings in the current fiscal year.
unaffected_balance_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
('account_id', '=', self.account110.id),
])
self.assertEqual(len(unaffected_balance_lines), 1)
self.assertEqual(unaffected_balance_lines[0].initial_balance, -1000)
self.assertEqual(unaffected_balance_lines[0].debit, 0)
self.assertEqual(unaffected_balance_lines[0].credit, 1000)
self.assertEqual(unaffected_balance_lines[0].final_balance, -2000)
# The totals for the Trial Balance are zero
all_lines = report_account_model.search([
('report_id', '=', trial_balance.id),
])
self.assertEqual(sum(all_lines.mapped('initial_balance')), 0)
self.assertEqual(sum(all_lines.mapped('final_balance')), 0)
self.assertEqual(sum(all_lines.mapped('debit')),
sum(all_lines.mapped('credit')))