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,33 +99,42 @@ First written: 2020/7/1
<td class="amount"></td> <td class="amount"></td>
<td class="actions"></td> <td class="actions"></td>
</tr> </tr>
{% for group in section.groups %} {% if section.groups %}
<tr class="second-level-header"> {% for group in section.groups %}
<td><div class="second-level-header">{{ group.title|title|escape }}</div></td> <tr class="second-level-header">
<td class="amount"></td> <td><div class="second-level-header">{{ group.title|title|escape }}</div></td>
<td class="amount"></td>
<td class="actions"></td>
</tr>
{% for item in group.details %}
<tr>
<td><div class="subject">{{ item.title|title|escape }}</div></td>
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
<td class="amount"></td> <td class="amount"></td>
<td class="actions"> <td class="amount"></td>
<a href="{% url "accounting:ledger" item.code period.spec %}" class="btn btn-info" role="button"> <td class="actions"></td>
<i class="fas fa-eye"></i> </tr>
<span class="d-none d-lg-inline">{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}</span> {% for item in group.details %}
</a> <tr>
</td> <td><div class="subject">{{ item.title|title|escape }}</div></td>
<td class="amount {% if item.balance < 0 %} text-danger {% endif %}">{{ item.balance|accounting_amount }}</td>
<td class="amount"></td>
<td class="actions">
<a href="{% url "accounting:ledger" item.code period.spec %}" class="btn btn-info" role="button">
<i class="fas fa-eye"></i>
<span class="d-none d-lg-inline">{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}</span>
</a>
</td>
</tr>
{% endfor %}
<tr class="total">
<td><div>{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</div></td>
<td class="amount"></td>
<td class="amount {% if group.total < 0 %} text-danger {% endif %}">{{ group.total|accounting_amount }}</td>
<td class="actions"></td>
</tr> </tr>
{% endfor %} {% endfor %}
{% else %}
<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">-</td>
<td class="actions"></td> <td class="actions"></td>
</tr> </tr>
{% endfor %} {% 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\
section.cumulative_total = None = cumulative_accounts[section.code]
else: section.cumulative_total.balance = None
section.cumulative_total\ section.cumulative_total.total = cumulative_total
= cumulative_accounts[section.code] else:
section.cumulative_total.balance = None section.cumulative_total = None
section.cumulative_total.total = cumulative_total 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),