diff --git a/accounting/templates/accounting/accounts/index.html b/accounting/templates/accounting/accounts/index.html index aa6f07b..8fda04b 100644 --- a/accounting/templates/accounting/accounts/index.html +++ b/accounting/templates/accounting/accounts/index.html @@ -37,7 +37,6 @@ First written: 2020/7/1 {{ _("New")|force_escape }} - {% report_url as reports %} {% with current_report_icon="fas fa-list-ol" current_report_title=_("Accounts") %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/balance-sheet.html b/accounting/templates/accounting/balance-sheet.html index a98d6bb..8caab1a 100644 --- a/accounting/templates/accounting/balance-sheet.html +++ b/accounting/templates/accounting/balance-sheet.html @@ -53,7 +53,7 @@ First written: 2020/7/20 - {% with current_report_icon="fas fa-balance-scale" current_report_title=_("Balance Sheet") %} + {% with current_report_icon="fas fa-balance-scale" current_report_title=_("Balance Sheet") period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/cash-summary.html b/accounting/templates/accounting/cash-summary.html index 561688f..32bfd99 100644 --- a/accounting/templates/accounting/cash-summary.html +++ b/accounting/templates/accounting/cash-summary.html @@ -52,7 +52,7 @@ First written: 2020/7/15 - {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Summary") %} + {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Summary") cash_account=account %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html index 5befbf5..ae6a510 100644 --- a/accounting/templates/accounting/cash.html +++ b/accounting/templates/accounting/cash.html @@ -53,7 +53,7 @@ First written: 2020/7/1 - {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Account") %} + {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Account") cash_account=account period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/include/report-chooser.html b/accounting/templates/accounting/include/report-chooser.html index d5afc13..5c7961a 100644 --- a/accounting/templates/accounting/include/report-chooser.html +++ b/accounting/templates/accounting/include/report-chooser.html @@ -20,6 +20,7 @@ Author: imacat@mail.imacat.idv.tw (imacat) First written: 2020/7/9 {% endcomment %} {% load i18n %} +{% load accounting %} @@ -61,36 +62,37 @@ First written: 2020/7/9 {{ _("Book")|force_escape }} + {% report_url cash_account=cash_account ledger_account=ledger_account period=period as report_url %} - + {{ _("Cash Account")|force_escape }} - + {{ _("Cash Summary")|force_escape }} - + {{ _("Ledger")|force_escape }} - + {{ _("Ledger Summary")|force_escape }} - + {{ _("Journal")|force_escape }} - + {{ _("Trial Balance")|force_escape }} - + {{ _("Income Statement")|force_escape }} - + {{ _("Balance Sheet")|force_escape }} diff --git a/accounting/templates/accounting/income-statement.html b/accounting/templates/accounting/income-statement.html index a4fefa9..a3b8170 100644 --- a/accounting/templates/accounting/income-statement.html +++ b/accounting/templates/accounting/income-statement.html @@ -53,7 +53,7 @@ First written: 2020/7/19 - {% with current_report_icon="fas fa-file-invoice" current_report_title=_("Income Statement") %} + {% with current_report_icon="fas fa-file-invoice" current_report_title=_("Income Statement") period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/journal.html b/accounting/templates/accounting/journal.html index 6bda40c..c6ea64f 100644 --- a/accounting/templates/accounting/journal.html +++ b/accounting/templates/accounting/journal.html @@ -53,7 +53,7 @@ First written: 2020/7/17 - {% with current_report_icon="fas fa-book" current_report_title=_("Journal") %} + {% with current_report_icon="fas fa-book" current_report_title=_("Journal") period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/ledger-summary.html b/accounting/templates/accounting/ledger-summary.html index 46eb272..978cc54 100644 --- a/accounting/templates/accounting/ledger-summary.html +++ b/accounting/templates/accounting/ledger-summary.html @@ -52,7 +52,7 @@ First written: 2020/7/16 - {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger Summary") %} + {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger Summary") ledger_account=account %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/ledger.html b/accounting/templates/accounting/ledger.html index 8ce8af4..0935576 100644 --- a/accounting/templates/accounting/ledger.html +++ b/accounting/templates/accounting/ledger.html @@ -53,7 +53,7 @@ First written: 2020/7/16 - {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger") %} + {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger") ledger_account=account period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templates/accounting/trial-balance.html b/accounting/templates/accounting/trial-balance.html index dcfa889..8beefc6 100644 --- a/accounting/templates/accounting/trial-balance.html +++ b/accounting/templates/accounting/trial-balance.html @@ -53,7 +53,7 @@ First written: 2020/7/19 - {% with current_report_icon="fas fa-balance-scale-right" current_report_title=_("Trial Balance") %} + {% with current_report_icon="fas fa-balance-scale-right" current_report_title=_("Trial Balance") period=period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} diff --git a/accounting/templatetags/accounting.py b/accounting/templatetags/accounting.py index c5325be..fcacc19 100644 --- a/accounting/templatetags/accounting.py +++ b/accounting/templatetags/accounting.py @@ -47,15 +47,18 @@ def accounting_amount(value): @register.simple_tag -def report_url(cash=None, ledger=None, period=None): +def report_url(cash_account, ledger_account, period): """Returns accounting report URL helper. Args: - cash (Account): The current cash account. - ledger (Account): The current ledger account. + cash_account (Account): The current cash account. + ledger_account (Account): The current ledger account. period (Period): The period. Returns: ReportUrl: The accounting report URL helper. """ - return ReportUrl(cash=cash, ledger=ledger, period=period) + return ReportUrl( + cash=cash_account or None, + ledger=ledger_account or None, + period=period or None) diff --git a/accounting/views.py b/accounting/views.py index 2ad8ec9..14f41ae 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -163,7 +163,6 @@ def cash(request, account, period): "pagination": pagination, "account": account, "period": period, - "reports": ReportUrl(cash=account, period=period), "shortcut_accounts": [x for x in accounts if x.code in shortcut_accounts], "all_accounts": [x for x in accounts @@ -263,7 +262,6 @@ def cash_summary(request, account): "item_list": pagination.items, "pagination": pagination, "account": account, - "reports": ReportUrl(cash=account), "shortcut_accounts": [x for x in accounts if x.code in shortcut_accounts], "all_accounts": [x for x in accounts if @@ -347,7 +345,6 @@ def ledger(request, account, period): "pagination": pagination, "account": account, "period": period, - "reports": ReportUrl(ledger=account, period=period), "accounts": get_ledger_accounts(), }) @@ -412,7 +409,6 @@ def ledger_summary(request, account): "item_list": pagination.items, "pagination": pagination, "account": account, - "reports": ReportUrl(ledger=account), "accounts": get_ledger_accounts(), }) @@ -496,7 +492,6 @@ def journal(request, period): return render(request, "accounting/journal.html", { "item_list": pagination.items, "pagination": pagination, - "reports": ReportUrl(period=period), "period": period, }) @@ -601,7 +596,6 @@ def trial_balance(request, period): return render(request, "accounting/trial-balance.html", { "item_list": accounts, "total_item": total_account, - "reports": ReportUrl(period=period), "period": period, }) @@ -678,7 +672,6 @@ def income_statement(request, period): sections[-1].has_next = False return render(request, "accounting/income-statement.html", { "item_list": sections, - "reports": ReportUrl(period=period), "period": period, }) @@ -780,7 +773,6 @@ def balance_sheet(request, period): "assets": by_code["1"], "liabilities": by_code["2"], "owners_equity": by_code["3"], - "reports": ReportUrl(period=period), "period": period, }) @@ -813,7 +805,6 @@ def search(request): return render(request, "accounting/search.html", { "item_list": pagination.items, "pagination": pagination, - "reports": ReportUrl(), })