evised the income statement.

This commit is contained in:
依瑪貓 2020-07-20 22:23:19 +08:00
parent 361b8c9881
commit 434b109a75
2 changed files with 41 additions and 29 deletions

View File

@ -87,7 +87,7 @@ First written: 2020/7/1
<thead> <thead>
<tr> <tr>
<th scope="col"></th> <th scope="col"></th>
<th class="amount" colspan="2" scope="col">{% trans "Amount" context "Period|" as text %}{{ text|force_escape }}</th> <th class="amount" colspan="2" scope="col">{% trans "Amount" context "Accounting|" as text %}{{ text|force_escape }}</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
</thead> </thead>
@ -99,6 +99,7 @@ First written: 2020/7/1
<td class="amount"></td> <td class="amount"></td>
<td class="actions"></td> <td class="actions"></td>
</tr> </tr>
{% if section.groups %}
{% for group in section.groups %} {% for group in section.groups %}
<tr class="second-level-header"> <tr class="second-level-header">
<td><div class="second-level-header">{{ group.title|title|escape }}</div></td> <td><div class="second-level-header">{{ group.title|title|escape }}</div></td>
@ -120,12 +121,20 @@ First written: 2020/7/1
</tr> </tr>
{% endfor %} {% endfor %}
<tr class="total"> <tr class="total">
<td><div>{% trans "Total" context "Period|" as text %}{{ text|force_escape }}</div></td> <td><div>{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</div></td>
<td class="amount"></td> <td class="amount"></td>
<td class="amount {% if group.total < 0 %} text-danger {% endif %}">{{ group.total|accounting_amount }}</td> <td class="amount {% if group.total < 0 %} text-danger {% endif %}">{{ group.total|accounting_amount }}</td>
<td class="actions"></td> <td class="actions"></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% else %}
<tr class="total">
<td><div>{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</div></td>
<td class="amount"></td>
<td class="amount">-</td>
<td class="actions"></td>
</tr>
{% endif %}
{% if section.cumulative_total is not None %} {% if section.cumulative_total is not None %}
<tr class="cum-total"> <tr class="cum-total">
<td><div>{{ section.cumulative_total.title|title|escape }}</div></td> <td><div>{{ section.cumulative_total.title|title|escape }}</div></td>
@ -134,6 +143,9 @@ First written: 2020/7/1
<td class="actions"></td> <td class="actions"></td>
</tr> </tr>
{% endif %} {% endif %}
{% if section.has_next %}
<tr><td colspan="4"></td></tr>
{% endif %}
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>

View File

@ -602,7 +602,6 @@ def income_statement(request, period_spec):
Q(code="4") | Q(code="5") | Q(code="6") Q(code="4") | Q(code="5") | Q(code="6")
| Q(code="7") | Q(code="8") | Q(code="9")).order_by("code")) | Q(code="7") | Q(code="8") | Q(code="9")).order_by("code"))
cumulative_accounts = { cumulative_accounts = {
"4": None,
"5": Subject(title=pgettext("Accounting|", "Gross Income")), "5": Subject(title=pgettext("Accounting|", "Gross Income")),
"6": Subject(title=pgettext("Accounting|", "Operating Income")), "6": Subject(title=pgettext("Accounting|", "Operating Income")),
"7": Subject(title=pgettext("Accounting|", "Before Tax Income")), "7": Subject(title=pgettext("Accounting|", "Before Tax Income")),
@ -623,13 +622,14 @@ def income_statement(request, period_spec):
section.total = sum([x.total for x in section.groups]) section.total = sum([x.total for x in section.groups])
cumulative_total = cumulative_total + section.total cumulative_total = cumulative_total + section.total
if section.code in cumulative_accounts: if section.code in cumulative_accounts:
if cumulative_accounts[section.code] is None:
section.cumulative_total = None
else:
section.cumulative_total\ section.cumulative_total\
= cumulative_accounts[section.code] = cumulative_accounts[section.code]
section.cumulative_total.balance = None section.cumulative_total.balance = None
section.cumulative_total.total = cumulative_total section.cumulative_total.total = cumulative_total
else:
section.cumulative_total = None
section.has_next = True
sections[-1].has_next = False
return render(request, "accounting/income-statement.html", { return render(request, "accounting/income-statement.html", {
"item_list": sections, "item_list": sections,
"reports": ReportUrl(period=period), "reports": ReportUrl(period=period),