diff --git a/accounting/models.py b/accounting/models.py index 0534ee3..178b17a 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -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"] diff --git a/accounting/templates/accounting/balance-sheet.html b/accounting/templates/accounting/balance-sheet.html index 1330fcf..66df392 100644 --- a/accounting/templates/accounting/balance-sheet.html +++ b/accounting/templates/accounting/balance-sheet.html @@ -100,7 +100,7 @@ First written: 2020/7/20
{{ item.title|title }}
{{ item.balance|accounting_amount }} - + {% trans "View" context "Accounting|" as text %}{{ text|force_escape }} @@ -131,7 +131,7 @@ First written: 2020/7/20
{{ item.title|title }}
{{ item.balance|accounting_amount }} - + {% trans "View" context "Accounting|" as text %}{{ text|force_escape }} @@ -168,7 +168,7 @@ First written: 2020/7/20
{{ item.title|title }}
{{ item.balance|accounting_amount }} - + {% trans "View" context "Accounting|" as text %}{{ text|force_escape }} @@ -236,7 +236,7 @@ First written: 2020/7/20 {% for item in group.details %}
  • - + {{ item.title|title }}
    @@ -267,7 +267,7 @@ First written: 2020/7/20
  • {% for item in group.details %}
  • - + {{ item.title|title }}
    @@ -296,8 +296,8 @@ First written: 2020/7/20
  • {% for item in group.details %}
  • - {# TODO: Link to the income statement for account #3353 #} - + {# TODO: Link to the income statement for account #3351 #} + {{ item.title|title }}
    diff --git a/accounting/views/reports.py b/accounting/views/reports.py index 13a010a..8015711 100644 --- a/accounting/views/reports.py +++ b/accounting/views/reports.py @@ -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]))