From 376a5911562facbe699639a5cfef183239306709 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 17 Aug 2018 14:17:55 +0200 Subject: [PATCH] Do not show lines where there is no initial balance and no entries --- .../report/general_ledger.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/account_financial_report_webkit_xlsx/report/general_ledger.py b/account_financial_report_webkit_xlsx/report/general_ledger.py index d3bf2893..5e3d2a7a 100644 --- a/account_financial_report_webkit_xlsx/report/general_ledger.py +++ b/account_financial_report_webkit_xlsx/report/general_ledger.py @@ -168,6 +168,15 @@ class GeneralLedgerXlsx(ReportXlsx, report_xlsx_format): style_sums = self._get_style(wb, ('fill_yellow', 'money', 'bold')) for account in _p.objects: + display_initial_balance = _p['init_balance'][account.id] and \ + (_p['init_balance'][account.id].get( + 'debit', 0.0) != 0.0 or + _p['init_balance'][account.id].get('credit', 0.0) != 0.0) + if (not display_initial_balance and + not _p['ledger_lines'][account.id]): + # no lines and no initial balance, do no show account in report + continue + # Write account name = ' - '.join([account.code, account.name]) ws.write(row_pos, 0, name, style_account) @@ -187,10 +196,6 @@ class GeneralLedgerXlsx(ReportXlsx, report_xlsx_format): cumul_balance = cumul_balance_curr = 0 # Write initial balance - display_initial_balance = _p['init_balance'][account.id] and \ - (_p['init_balance'][account.id].get( - 'debit', 0.0) != 0.0 or - _p['init_balance'][account.id].get('credit', 0.0) != 0.0) if display_initial_balance: ws.write(row_pos, 8, _('Initial Balance'), style_initial_balance)