Changed the URL of the accounts in the balance sheet so that the net income in the current period links to the income statement in the accounting application.
This commit is contained in:
parent
3c294ffcb8
commit
bbfe9e7892
@ -67,6 +67,16 @@ class Account(models.Model):
|
||||
def title(self, value):
|
||||
self._title = value
|
||||
|
||||
_url = None
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
return self._url
|
||||
|
||||
@url.setter
|
||||
def url(self, value):
|
||||
self._url = value
|
||||
|
||||
class Meta:
|
||||
db_table = "accounting_accounts"
|
||||
ordering = ["code"]
|
||||
|
@ -100,7 +100,7 @@ First written: 2020/7/20
|
||||
<td><div class="account">{{ item.title|title }}</div></td>
|
||||
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url "accounting:ledger" item.code period.spec %}" class="btn btn-info" role="button">
|
||||
<a href="{{ item.url }}" class="btn btn-info" role="button">
|
||||
<i class="fas fa-eye"></i>
|
||||
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
@ -131,7 +131,7 @@ First written: 2020/7/20
|
||||
<td><div class="account">{{ item.title|title }}</div></td>
|
||||
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url "accounting:ledger" item.code period.spec %}" class="btn btn-info" role="button">
|
||||
<a href="{{ item.url }}" class="btn btn-info" role="button">
|
||||
<i class="fas fa-eye"></i>
|
||||
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
@ -168,7 +168,7 @@ First written: 2020/7/20
|
||||
<td><div class="account">{{ item.title|title }}</div></td>
|
||||
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url "accounting:ledger" item.code period.spec %}" class="btn btn-info" role="button">
|
||||
<a href="{{ item.url }}" class="btn btn-info" role="button">
|
||||
<i class="fas fa-eye"></i>
|
||||
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
|
||||
</a>
|
||||
@ -236,7 +236,7 @@ First written: 2020/7/20
|
||||
</li>
|
||||
{% for item in group.details %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center account">
|
||||
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
|
||||
<a class="list-group-item-action" href="{{ item.url }}">
|
||||
{{ item.title|title }}
|
||||
<div class="float-right">
|
||||
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
|
||||
@ -267,7 +267,7 @@ First written: 2020/7/20
|
||||
</li>
|
||||
{% for item in group.details %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center account">
|
||||
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
|
||||
<a class="list-group-item-action" href="{{ item.url }}">
|
||||
{{ item.title|title }}
|
||||
<div class="float-right">
|
||||
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
|
||||
@ -296,8 +296,8 @@ First written: 2020/7/20
|
||||
</li>
|
||||
{% for item in group.details %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center account">
|
||||
{# TODO: Link to the income statement for account #3353 #}
|
||||
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
|
||||
{# TODO: Link to the income statement for account #3351 #}
|
||||
<a class="list-group-item-action" href="{{ item.url }}">
|
||||
{{ item.title|title }}
|
||||
<div class="float-right">
|
||||
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
|
||||
|
@ -738,6 +738,9 @@ def balance_sheet(request, period_spec):
|
||||
When(record__is_credit=True, then=-1),
|
||||
default=1) * F("record__amount")))
|
||||
.filter(balance__isnull=False))
|
||||
for account in accounts:
|
||||
account.url = reverse(
|
||||
"accounting:ledger", args=[account.code, period.spec])
|
||||
balance = Record.objects\
|
||||
.filter(
|
||||
Q(transaction__date__lt=period.start)
|
||||
@ -752,6 +755,8 @@ def balance_sheet(request, period_spec):
|
||||
if balance is not None and balance != 0:
|
||||
brought_forward = Account.objects.get(code="3351")
|
||||
brought_forward.balance = -balance
|
||||
brought_forward.url = reverse(
|
||||
"accounting:income-statement", args=[period.spec])
|
||||
accounts.append(brought_forward)
|
||||
balance = Record.objects\
|
||||
.filter(
|
||||
@ -768,6 +773,8 @@ def balance_sheet(request, period_spec):
|
||||
if balance is not None and balance != 0:
|
||||
net_income = Account.objects.get(code="3353")
|
||||
net_income.balance = -balance
|
||||
net_income.url = reverse(
|
||||
"accounting:income-statement", args=[period.spec])
|
||||
accounts.append(net_income)
|
||||
groups = list(Account.objects.filter(
|
||||
code__in=[x.code[:2] for x in accounts]))
|
||||
|
Loading…
Reference in New Issue
Block a user