Added the balance sheet in the accounting application.

This commit is contained in:
2020-07-21 00:31:31 +08:00
parent c2c8ee66ab
commit a18df0e928
4 changed files with 405 additions and 3 deletions

View File

@ -0,0 +1,330 @@
{% extends "base.html" %}
{% comment %}
The Mia Accounting Application
cash.html: The template for the cash account reports
Copyright (c) 2020 imacat.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2020/7/20
{% endcomment %}
{% load static %}
{% load i18n %}
{% load humanize %}
{% load mia_core %}
{% load accounting %}
{% block settings %}
{% blocktrans asvar title with period=period.description context "Accounting|" %}Balance Sheet in {{ period }}{% endblocktrans %}
{% setvar "title" title %}
{% setvar "use_period_chooser" True %}
{% static "accounting/css/report.css" as css %}
{% setvar "css" css %}
{% endblock %}
{% block content %}
<div class="btn-group btn-actions">
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<i class="fas fa-edit"></i>
{% trans "New" context "Accounting|" as text %}
{{ text|force_escape }}
</button>
<div class="dropdown-menu">
{% url "accounting:transaction.create" "expense" as url %}
<a class="dropdown-item" href="{% url_query url r=request.get_full_path %}">
{% trans "Cash Expense" context "Accounting|" as text %}
{{ text|force_escape }}
</a>
{% url "accounting:transaction.create" "income" as url %}
<a class="dropdown-item" href="{% url_query url r=request.get_full_path %}">
{% trans "Cash Income" context "Accounting|" as text %}
{{ text|force_escape }}
</a>
{% url "accounting:transaction.create" "transfer" as url %}
<a class="dropdown-item" href="{% url_query url r=request.get_full_path %}">
{% trans "Transfer" context "Accounting|" as text %}
{{ text|force_escape }}
</a>
</div>
</div>
{% with current_report_icon="fas fa-balance-scale" %}
{% trans "Balance Sheet" context "Accounting|" as current_report_title %}
{% include "accounting/include/report-chooser.html" %}
{% endwith %}
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#period-modal">
<i class="far fa-calendar-alt"></i>
<span class="d-none d-md-inline">{{ period.description }}</span>
<span class="d-md-none">{% trans "Period" context "Period|" as text %}{{ text|force_escape }}</span>
</button>
</div>
{% include "mia_core/include/period-chooser.html" %}
{# The table for large screens #}
<div class="d-none d-lg-block report-block report-block-lg">
<div class="row justify-content-center">
<h2>{{ title|escape }}</h2>
</div>
<div class="row">
<div class="col-sm-6">
<table class="table table-borderless table-hover table-sm balance-sheet-table">
<thead>
<tr>
<th colspan="3" scope="col">{{ section_1.title|title }}</th>
</tr>
</thead>
<tbody>
{% for group in section_1.groups %}
<tr class="group-title">
<td><div>{{ group.title|title }}</div></td>
<td class="amount"></td>
<td class="actions"></td>
</tr>
{% for item in group.details %}
<tr>
<td><div class="subject">{{ 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">
<i class="fas fa-eye"></i>
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
</a>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
<div class="col-sm-6">
<table class="table table-borderless table-hover table-sm balance-sheet-table">
<thead>
<tr>
<th colspan="3" scope="col">{{ section_2.title|title }}</th>
</tr>
</thead>
<tbody>
{% for group in section_2.groups %}
<tr class="group-title">
<td><div>{{ group.title|title }}</div></td>
<td class="amount"></td>
<td class="actions"></td>
</tr>
{% for item in group.details %}
<tr>
<td><div class="subject">{{ 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">
<i class="fas fa-eye"></i>
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
</a>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
<tr class="total">
<td>{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</td>
<td class="amount {% if section_2.balance < 0 %} text-danger {% endif %}">
{{ section_2.balance|accounting_amount }}
</td>
</tr>
</tfoot>
</table>
<table class="table table-borderless table-hover table-sm balance-sheet-table">
<thead>
<tr>
<th colspan="3" scope="col">{{ section_3.title|title }}</th>
</tr>
</thead>
<tbody>
{% for group in section_3.groups %}
<tr class="group-title">
<td><div>{{ group.title|title }}</div></td>
<td class="amount"></td>
<td class="actions"></td>
</tr>
{% for item in group.details %}
<tr>
<td><div class="subject">{{ 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">
<i class="fas fa-eye"></i>
{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
</a>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
<tr class="total">
<td>{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</td>
<td class="amount {% if section_3.balance < 0 %} text-danger {% endif %}">
{{ section_3.balance|accounting_amount }}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-6 assets-total">
<table class="table table-borderless table-hover table-sm balance-sheet-total-table">
<tfoot>
<tr class="total">
<td class="align-middle">{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</td>
<td class="text-right align-middle font-italic {% if section_1.balance < 0 %} text-danger {% endif %}">
{{ section_1.balance|accounting_amount }}
</td>
</tr>
</tfoot>
</table>
</div>
<div class="col-sm-6 liabilities-total">
<table class="table table-borderless table-hover table-sm balance-sheet-total-table">
<tfoot>
<tr class="total">
<td class="align-middle">{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}</td>
<td class="text-right align-middle font-italic {% if section_2.balance|add:section_3.balance < 0 %} text-danger {% endif %}">
{{ section_2.balance|add:section_3.balance|accounting_amount }}
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
{# The list for small screens #}
<div class="d-lg-none report-block report-block-sm">
<div class="row justify-content-center">
<h2>{{ title|escape }}</h2>
</div>
<div class="row">
<div class="col-sm-6">
<ul class="list-group balance-sheet-list">
<li class="list-group-item section-title">
{{ section_1.title|title }}
</li>
{% for group in section_1.groups %}
<li class="list-group-item d-flex justify-content-between align-items-center group-title">
{{ group.title|title }}
</li>
{% for item in group.details %}
<li class="list-group-item d-flex justify-content-between align-items-center subject">
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
{{ item.title|title }}
<div class="float-right">
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
{{ item.balance|accounting_amount }}
</span>
</div>
</a>
</li>
{% endfor %}
{% endfor %}
<li class="list-group-item d-flex justify-content-between align-items-center grand-total">
{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}
<span class="badge {% if section_1.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
{{ section_1.balance|accounting_amount }}
</span>
</li>
</ul>
</div>
<div class="col-sm-6">
<ul class="list-group balance-sheet-list">
<li class="list-group-item section-title">
{{ section_2.title|title }}
</li>
{% for group in section_2.groups %}
<li class="list-group-item d-flex justify-content-between align-items-center group-title">
{{ group.title|title }}
</li>
{% for item in group.details %}
<li class="list-group-item d-flex justify-content-between align-items-center subject">
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
{{ item.title|title }}
<div class="float-right">
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
{{ item.balance|accounting_amount }}
</span>
</div>
</a>
</li>
{% endfor %}
{% endfor %}
<li class="list-group-item d-flex justify-content-between align-items-center total">
{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}
<span class="badge {% if section_2.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
{{ section_2.balance|accounting_amount }}
</span>
</li>
</ul>
<ul class="list-group balance-sheet-list">
<li class="list-group-item section-title">
{{ section_3.title|title }}
</li>
{% for group in section_3.groups %}
<li class="list-group-item d-flex justify-content-between align-items-center group-title">
{{ group.title|title }}
</li>
{% for item in group.details %}
<li class="list-group-item d-flex justify-content-between align-items-center subject">
<a class="list-group-item-action" href="{% url "accounting:ledger" item.code period.spec %}">
{{ item.title|title }}
<div class="float-right">
<span class="badge {% if item.balance < 0 %} badge-warning {% else %} badge-secondary {% endif %} badge-pill">
{{ item.balance|accounting_amount }}
</span>
</div>
</a>
</li>
{% endfor %}
{% endfor %}
<li class="list-group-item d-flex justify-content-between align-items-center total">
{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}
<span class="badge {% if section_3.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
{{ section_3.balance|accounting_amount }}
</span>
</li>
</ul>
<ul class="list-group balance-sheet-list">
<li class="list-group-item d-flex justify-content-between align-items-center grand-total">
{% trans "Total" context "Accounting|" as text %}{{ text|force_escape }}
<span class="badge {% if section_2.balance|add:section_3.balance < 0 %} badge-danger {% else %} badge-info {% endif %} badge-pill">
{{ section_2.balance|add:section_3.balance|accounting_amount }}
</span>
</li>
</ul>
</div>
</div>
</div>
{% endblock %}