Moved getting the ReportUrl utility from the views to the report chooser template, to simplify the view in the accounting application.
This commit is contained in:
parent
45ed53b085
commit
4f02dd88da
@ -37,7 +37,6 @@ First written: 2020/7/1
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ _("New")|force_escape }}
|
||||
</a>
|
||||
{% report_url as reports %}
|
||||
{% with current_report_icon="fas fa-list-ol" current_report_title=_("Accounts") %}
|
||||
{% include "accounting/include/report-chooser.html" %}
|
||||
{% endwith %}
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/20
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#period-modal">
|
||||
|
@ -52,7 +52,7 @@ First written: 2020/7/15
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<div class="btn-group">
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/1
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<div class="btn-group">
|
||||
|
@ -20,6 +20,7 @@ Author: imacat@mail.imacat.idv.tw (imacat)
|
||||
First written: 2020/7/9
|
||||
{% endcomment %}
|
||||
{% load i18n %}
|
||||
{% load accounting %}
|
||||
|
||||
<!-- the accounting record search dialog -->
|
||||
<form action="{% url "accounting:search" %}" method="GET">
|
||||
@ -61,36 +62,37 @@ First written: 2020/7/9
|
||||
</span>
|
||||
<span class="d-md-none">{{ _("Book")|force_escape }}</span>
|
||||
</button>
|
||||
{% report_url cash_account=cash_account ledger_account=ledger_account period=period as report_url %}
|
||||
<div class="dropdown-menu account-picker">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "cash" %} active {% endif %}" href="{{ reports.cash }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "cash" %} active {% endif %}" href="{{ report_url.cash }}">
|
||||
<i class="fas fa-money-bill-wave"></i>
|
||||
{{ _("Cash Account")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "cash-summary" %} active {% endif %}" href="{{ reports.cash_summary }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "cash-summary" %} active {% endif %}" href="{{ report_url.cash_summary }}">
|
||||
<i class="fas fa-money-bill-wave"></i>
|
||||
{{ _("Cash Summary")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "ledger" %} active {% endif %}" href="{{ reports.ledger }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "ledger" %} active {% endif %}" href="{{ report_url.ledger }}">
|
||||
<i class="fas fa-file-invoice-dollar"></i>
|
||||
{{ _("Ledger")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "ledger-summary" %} active {% endif %}" href="{{ reports.ledger_summary }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "ledger-summary" %} active {% endif %}" href="{{ report_url.ledger_summary }}">
|
||||
<i class="fas fa-file-invoice-dollar"></i>
|
||||
{{ _("Ledger Summary")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "journal" %} active {% endif %}" href="{{ reports.journal }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "journal" %} active {% endif %}" href="{{ report_url.journal }}">
|
||||
<i class="fas fa-book"></i>
|
||||
{{ _("Journal")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "trial-balance" %} active {% endif %}" href="{{ reports.trial_balance }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "trial-balance" %} active {% endif %}" href="{{ report_url.trial_balance }}">
|
||||
<i class="fas fa-balance-scale-right"></i>
|
||||
{{ _("Trial Balance")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "income-statement" %} active {% endif %}" href="{{ reports.income_statement }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "income-statement" %} active {% endif %}" href="{{ report_url.income_statement }}">
|
||||
<i class="fas fa-file-invoice"></i>
|
||||
{{ _("Income Statement")|force_escape }}
|
||||
</a>
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "balance-sheet" %} active {% endif %}" href="{{ reports.balance_sheet }}">
|
||||
<a class="dropdown-item {% if request.resolver_match.url_name == "balance-sheet" %} active {% endif %}" href="{{ report_url.balance_sheet }}">
|
||||
<i class="fas fa-balance-scale"></i>
|
||||
{{ _("Balance Sheet")|force_escape }}
|
||||
</a>
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/19
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#period-modal">
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/17
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#period-modal">
|
||||
|
@ -52,7 +52,7 @@ First written: 2020/7/16
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<div class="btn-group">
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/16
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<div class="btn-group">
|
||||
|
@ -53,7 +53,7 @@ First written: 2020/7/19
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 %}
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#period-modal">
|
||||
|
@ -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)
|
||||
|
@ -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(),
|
||||
})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user