evised the income statement.
This commit is contained in:
		| @@ -87,7 +87,7 @@ First written: 2020/7/1 | ||||
|           <thead> | ||||
|             <tr> | ||||
|               <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> | ||||
|             </tr> | ||||
|           </thead> | ||||
| @@ -99,33 +99,42 @@ First written: 2020/7/1 | ||||
|                 <td class="amount"></td> | ||||
|                 <td class="actions"></td> | ||||
|               </tr> | ||||
|               {% for group in section.groups %} | ||||
|                 <tr class="second-level-header"> | ||||
|                   <td><div class="second-level-header">{{ group.title|title|escape }}</div></td> | ||||
|                   <td class="amount"></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> | ||||
|               {% if section.groups %} | ||||
|                 {% for group in section.groups %} | ||||
|                   <tr class="second-level-header"> | ||||
|                     <td><div class="second-level-header">{{ group.title|title|escape }}</div></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> | ||||
|                     <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="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> | ||||
|                 {% endfor %} | ||||
|               {% else %} | ||||
|                 <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 {% if group.total < 0 %} text-danger {% endif %}">{{ group.total|accounting_amount }}</td> | ||||
|                   <td class="amount">-</td> | ||||
|                   <td class="actions"></td> | ||||
|                 </tr> | ||||
|               {% endfor %} | ||||
|               {% endif %} | ||||
|               {% if section.cumulative_total is not None %} | ||||
|                 <tr class="cum-total"> | ||||
|                   <td><div>{{ section.cumulative_total.title|title|escape }}</div></td> | ||||
| @@ -134,6 +143,9 @@ First written: 2020/7/1 | ||||
|                   <td class="actions"></td> | ||||
|                 </tr> | ||||
|               {% endif %} | ||||
|               {% if section.has_next %} | ||||
|                 <tr><td colspan="4"></td></tr> | ||||
|               {% endif %} | ||||
|             {% endfor %} | ||||
|           </tbody> | ||||
|         </table> | ||||
|   | ||||
| @@ -602,7 +602,6 @@ def income_statement(request, period_spec): | ||||
|         Q(code="4") | Q(code="5") | Q(code="6") | ||||
|         | Q(code="7") | Q(code="8") | Q(code="9")).order_by("code")) | ||||
|     cumulative_accounts = { | ||||
|         "4": None, | ||||
|         "5": Subject(title=pgettext("Accounting|", "Gross Income")), | ||||
|         "6": Subject(title=pgettext("Accounting|", "Operating 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]) | ||||
|         cumulative_total = cumulative_total + section.total | ||||
|         if section.code in cumulative_accounts: | ||||
|             if cumulative_accounts[section.code] is None: | ||||
|                 section.cumulative_total = None | ||||
|             else: | ||||
|                 section.cumulative_total\ | ||||
|                     = cumulative_accounts[section.code] | ||||
|                 section.cumulative_total.balance = None | ||||
|                 section.cumulative_total.total = cumulative_total | ||||
|             section.cumulative_total\ | ||||
|                 = cumulative_accounts[section.code] | ||||
|             section.cumulative_total.balance = None | ||||
|             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", { | ||||
|         "item_list": sections, | ||||
|         "reports": ReportUrl(period=period), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user