From c7e1fd323d735495b0dd0b98b3c80f5feec58652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 8 Aug 2020 13:43:11 +0800 Subject: [PATCH] Replaced the account and period template variables with the resolver matches from the request, reducing the variables passed from the view to the templates in the accounting application. --- .../templates/accounting/balance-sheet.html | 10 ++++---- .../templates/accounting/cash-summary.html | 22 ++++++++--------- accounting/templates/accounting/cash.html | 24 ++++++++++--------- .../accounting/income-statement.html | 14 ++++++----- accounting/templates/accounting/journal.html | 10 ++++---- .../templates/accounting/ledger-summary.html | 20 ++++++++-------- accounting/templates/accounting/ledger.html | 18 +++++++------- .../templates/accounting/trial-balance.html | 14 ++++++----- accounting/views.py | 10 -------- 9 files changed, 72 insertions(+), 70 deletions(-) diff --git a/accounting/templates/accounting/balance-sheet.html b/accounting/templates/accounting/balance-sheet.html index 8caab1a..fbd58a9 100644 --- a/accounting/templates/accounting/balance-sheet.html +++ b/accounting/templates/accounting/balance-sheet.html @@ -27,7 +27,7 @@ First written: 2020/7/20 {% load accounting %} {% block settings %} - {% blocktrans asvar title with prep_period=period.prep_desc %}Balance Sheet {{ prep_period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=request.resolver_match.kwargs.period.prep_desc %}Balance Sheet {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} @@ -53,17 +53,19 @@ First written: 2020/7/20 - {% with current_report_icon="fas fa-balance-scale" current_report_title=_("Balance Sheet") period=period %} + {% with current_report_icon="fas fa-balance-scale" current_report_title=_("Balance Sheet") period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {# The table for large screens #}
diff --git a/accounting/templates/accounting/cash-summary.html b/accounting/templates/accounting/cash-summary.html index 32bfd99..05d0c78 100644 --- a/accounting/templates/accounting/cash-summary.html +++ b/accounting/templates/accounting/cash-summary.html @@ -27,7 +27,7 @@ First written: 2020/7/15 {% load accounting %} {% block settings %} - {% blocktrans asvar title with account=account.title %}Cash Summary for {{ account }}{% endblocktrans %} + {% blocktrans asvar title with account=request.resolver_match.kwargs.account.title %}Cash Summary for {{ account }}{% endblocktrans %} {% setvar "title" title %} {% static "accounting/css/report.css" as file %}{% add_css file %} {% endblock %} @@ -52,25 +52,25 @@ First written: 2020/7/15
- {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Summary") cash_account=account %} + {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Summary") cash_account=request.resolver_match.kwargs.account %} {% include "accounting/include/report-chooser.html" %} {% endwith %}
@@ -102,7 +102,7 @@ First written: 2020/7/15 {{ item.cumulative_balance|accounting_amount }} {% if item.month is not None %} - + {{ _("View")|force_escape }} @@ -118,7 +118,7 @@ First written: 2020/7/15 {% for item in item_list %}
  • {% if item.month is not None %} - + {{ item.label }}
    diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html index ae6a510..e68c445 100644 --- a/accounting/templates/accounting/cash.html +++ b/accounting/templates/accounting/cash.html @@ -27,7 +27,7 @@ First written: 2020/7/1 {% load accounting %} {% block settings %} - {% blocktrans asvar title with account=account.title prep_period=period.prep_desc %}Cash Account for {{ account }} {{ prep_period }}{% endblocktrans %} + {% blocktrans asvar title with account=request.resolver_match.kwargs.account.title prep_period=request.resolver_match.kwargs.period.prep_desc %}Cash Account for {{ account }} {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} @@ -53,37 +53,39 @@ First written: 2020/7/1
  • - {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Account") cash_account=account period=period %} + {% with current_report_icon="fas fa-money-bill-wave" current_report_title=_("Cash Account") cash_account=request.resolver_match.kwargs.account period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %}
    -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {% if item_list %} {% include "mia_core/include/pagination.html" %} diff --git a/accounting/templates/accounting/income-statement.html b/accounting/templates/accounting/income-statement.html index a3b8170..e371a64 100644 --- a/accounting/templates/accounting/income-statement.html +++ b/accounting/templates/accounting/income-statement.html @@ -27,7 +27,7 @@ First written: 2020/7/19 {% load accounting %} {% block settings %} - {% blocktrans asvar title with prep_period=period.prep_desc %}Income Statement {{ prep_period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=request.resolver_match.kwargs.period.prep_desc %}Income Statement {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} @@ -53,17 +53,19 @@ First written: 2020/7/19 - {% with current_report_icon="fas fa-file-invoice" current_report_title=_("Income Statement") period=period %} + {% with current_report_icon="fas fa-file-invoice" current_report_title=_("Income Statement") period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {# The table for large screens #}
    @@ -103,7 +105,7 @@ First written: 2020/7/19 {{ item.amount|accounting_amount }} - + {{ _("View")|force_escape }} @@ -163,7 +165,7 @@ First written: 2020/7/19 {% for item in group.details %}
    - {% with current_report_icon="fas fa-book" current_report_title=_("Journal") period=period %} + {% with current_report_icon="fas fa-book" current_report_title=_("Journal") period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {% if item_list %} {% include "mia_core/include/pagination.html" %} diff --git a/accounting/templates/accounting/ledger-summary.html b/accounting/templates/accounting/ledger-summary.html index 978cc54..dacdbaa 100644 --- a/accounting/templates/accounting/ledger-summary.html +++ b/accounting/templates/accounting/ledger-summary.html @@ -27,7 +27,7 @@ First written: 2020/7/16 {% load accounting %} {% block settings %} - {% blocktrans asvar title with account=account.title %}Ledger Summary for {{ account }}{% endblocktrans %} + {% blocktrans asvar title with account=request.resolver_match.kwargs.account.title %}Ledger Summary for {{ account }}{% endblocktrans %} {% setvar "title" title %} {% static "accounting/css/report.css" as file %}{% add_css file %} {% endblock %} @@ -52,18 +52,18 @@ First written: 2020/7/16 - {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger Summary") ledger_account=account %} + {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger Summary") ledger_account=request.resolver_match.kwargs.account %} {% include "accounting/include/report-chooser.html" %} {% endwith %}
    @@ -87,7 +87,7 @@ First written: 2020/7/16 {% for item in item_list %} - + {{ item.label }} {{ item.debit|accounting_amount }} {{ item.credit|accounting_amount }} @@ -95,7 +95,7 @@ First written: 2020/7/16 {{ item.cumulative_balance|accounting_amount }} {% if item.month is not None %} - + {{ _("View")|force_escape }} @@ -109,9 +109,9 @@ First written: 2020/7/16 {# The list for small screens #}
    - {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger") ledger_account=account period=period %} + {% with current_report_icon="fas fa-file-invoice-dollar" current_report_title=_("Ledger") ledger_account=request.resolver_match.kwargs.account period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %}
    -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {% if item_list %} {% include "mia_core/include/pagination.html" %} diff --git a/accounting/templates/accounting/trial-balance.html b/accounting/templates/accounting/trial-balance.html index 8beefc6..db789f1 100644 --- a/accounting/templates/accounting/trial-balance.html +++ b/accounting/templates/accounting/trial-balance.html @@ -27,7 +27,7 @@ First written: 2020/7/19 {% load accounting %} {% block settings %} - {% blocktrans asvar title with prep_period=period.prep_desc %}Trial Balance {{ prep_period }}{% endblocktrans %} + {% blocktrans asvar title with prep_period=request.resolver_match.kwargs.period.prep_desc %}Trial Balance {{ prep_period }}{% endblocktrans %} {% setvar "title" title %} {% setvar "use_period_chooser" True %} {% static "accounting/css/report.css" as file %}{% add_css file %} @@ -53,17 +53,19 @@ First written: 2020/7/19 - {% with current_report_icon="fas fa-balance-scale-right" current_report_title=_("Trial Balance") period=period %} + {% with current_report_icon="fas fa-balance-scale-right" current_report_title=_("Trial Balance") period=request.resolver_match.kwargs.period %} {% include "accounting/include/report-chooser.html" %} {% endwith %} -{% include "mia_core/include/period-chooser.html" %} +{% with period=request.resolver_match.kwargs.period %} + {% include "mia_core/include/period-chooser.html" %} +{% endwith %} {% if item_list %} {% include "mia_core/include/pagination.html" %} @@ -92,7 +94,7 @@ First written: 2020/7/19 {{ item.debit_amount|accounting_amount }} {{ item.credit_amount|accounting_amount }} - + {{ _("View")|force_escape }} @@ -124,7 +126,7 @@ First written: 2020/7/19