Sort accounts by name in balance sheet and P&L
This commit is contained in:
parent
1ce132d4b0
commit
bbd99af710
@ -97,7 +97,7 @@ def balance():
|
||||
balance_sheets = [accounting.balance_sheet(accounting.add_unrealized_gains(accounting.trial_balance(l, d, p), report_currency)) for d, p in zip(dates, pstarts)]
|
||||
|
||||
# Delete accounts with always zero balances
|
||||
accounts = sorted(l.accounts.values(), key=lambda a: a.name)
|
||||
accounts = list(l.accounts.values())
|
||||
for account in accounts[:]:
|
||||
if all(b.get_balance(account) == 0 and b.get_total(account) == 0 for b in balance_sheets):
|
||||
accounts.remove(account)
|
||||
@ -129,7 +129,7 @@ def pandl():
|
||||
pandls = [accounting.trial_balance(l, de, db) for de, db in zip(dates_end, dates_beg)]
|
||||
|
||||
# Delete accounts with always zero balances
|
||||
accounts = sorted(l.accounts.values(), key=lambda a: a.name)
|
||||
accounts = list(l.accounts.values())
|
||||
for account in accounts[:]:
|
||||
if all(p.get_balance(account) == 0 and p.get_total(account) == 0 for p in pandls):
|
||||
accounts.remove(account)
|
||||
|
@ -49,13 +49,13 @@
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
||||
{% for child in account.children if child in accounts %}
|
||||
{% for child in account.children|sort(attribute='name') if child in accounts %}
|
||||
{{ print_rows(child, invert, level + 1) }}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro do_accounts(root, label, invert, year_headers) %}
|
||||
{% for account_class in root.children if account_class in accounts %}
|
||||
{% for account_class in root.children|sort(attribute='name') if account_class in accounts %}
|
||||
<tr>
|
||||
{% if loop.first and year_headers %}
|
||||
<th class="h2">{{ account_class.bits[-1] }} {{ label }}</th>
|
||||
@ -65,7 +65,7 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% for account in account_class.children if account in accounts %}
|
||||
{% for account in account_class.children|sort(attribute='name') if account in accounts %}
|
||||
{{ print_rows(account, invert=invert) }}
|
||||
{% endfor %}
|
||||
|
||||
@ -104,7 +104,7 @@
|
||||
{# Equity #}
|
||||
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Equity</th></tr>
|
||||
|
||||
{% for account in ledger.get_account(config['equity_account']).children if account in accounts %}
|
||||
{% for account in ledger.get_account(config['equity_account']).children|sort(attribute='name') if account in accounts %}
|
||||
{{ print_rows(account, invert=True) }}
|
||||
{% endfor %}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
{% endfor %}
|
||||
</tr>
|
||||
|
||||
{% for child in account.children if child in accounts %}
|
||||
{% for child in account.children|sort(attribute='name') if child in accounts %}
|
||||
{{ print_rows(child, invert, level + 1) }}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
@ -49,7 +49,7 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% for account in root.children if account in accounts %}
|
||||
{% for account in root.children|sort(attribute='name') if account in accounts %}
|
||||
{{ print_rows(account, invert=invert) }}
|
||||
{% endfor %}
|
||||
|
||||
|
Reference in New Issue
Block a user