From 4c821a73ea4ef6f35e470061a23b749809e4d002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 17 Jul 2020 23:27:49 +0800 Subject: [PATCH] Added the accounting journal in the accounting application. --- accounting/templates/accounting/journal.html | 202 +++++++++++++++++++ accounting/urls.py | 2 +- accounting/views/__init__.py | 26 +++ 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 accounting/templates/accounting/journal.html diff --git a/accounting/templates/accounting/journal.html b/accounting/templates/accounting/journal.html new file mode 100644 index 0000000..e879dfd --- /dev/null +++ b/accounting/templates/accounting/journal.html @@ -0,0 +1,202 @@ +{% 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/1 +{% endcomment %} +{% load i18n %} +{% load humanize %} +{% load mia_core %} +{% load accounting %} + +{% block settings %} + {% blocktrans asvar title with subject=current_subject.title|title period=period.description context "Accounting|" %}Cash Account for {{ subject }} in {{ period }}{% endblocktrans %} + {% setvar "title" title %} + {% setvar "use_period_chooser" True %} +{% endblock %} + +{% block content %} + +
+
+ + +
+ {% with current_report_icon="fas fa-book" %} + {% trans "Journal" context "Accounting|" as current_report_title %} + {% include "accounting/include/report-chooser.html" %} + {% endwith %} + +
+ +{% include "mia_core/include/period-chooser.html" %} + +{% if records %} + {% include "mia_core/include/pagination.html" %} + + {# The table for large screens #} + + + + + + + + + + + + + + {% for record in records %} + + + + + + + + + + {% endfor %} + +
{% trans "Date" context "Accounting|" as text %}{{ text|force_escape }}{% trans "Subject" context "Accounting|" as text %}{{ text|force_escape }}{% trans "Summary" context "Accounting|" as text %}{{ text|force_escape }}{% trans "Debit" context "Accounting|" as text %}{{ text|force_escape }}{% trans "Credit" context "Accounting|" as text %}{{ text|force_escape }}{% trans "Notes" context "Accounting|" as text %}{{ text|force_escape }}{% trans "View" context "Accounting|" as text %}{{ text|force_escape }}
{{ record.transaction.date|smart_date }}{{ record.subject.title|title }}
{{ record.summary|default:"" }}{% if not record.is_balanced %} + + {% trans "Unbalanced" context "Accounting|" as text %} + {{ text|force_escape }} + + {% endif %}{% if record.has_order_hole %} + + {% trans "Need Reorder" context "Accounting|" as text %} + {{ text|force_escape }} + + {% endif %}
{{ record.debit_amount|accounting_amount }}{{ record.credit_amount|accounting_amount }}{{ record.transaction.note|default:"" }} + {% if record.sn is not None %} + + + {% trans "View" context "Accounting|" as text %}{{ text|force_escape }} + + {% endif %} +
+ + {# The list for small screens #} + +{% else %} +

{{ _("There is currently no data.")|force_escape }}

+{% endif %} + +{% endblock %} diff --git a/accounting/urls.py b/accounting/urls.py index 3ea8884..2390540 100644 --- a/accounting/urls.py +++ b/accounting/urls.py @@ -59,7 +59,7 @@ urlpatterns = [ path("journal", mia_core_views.todo, name="journal.home"), path("journal/", - mia_core_views.todo, name="journal"), + views.journal, name="journal"), path("trial-balance", mia_core_views.todo, name="trial-balance.home"), path("trial-balance/", diff --git a/accounting/views/__init__.py b/accounting/views/__init__.py index e9af170..69f3c47 100644 --- a/accounting/views/__init__.py +++ b/accounting/views/__init__.py @@ -509,3 +509,29 @@ ORDER BY month""", "reports": ReportUrl(cash=current_subject), "subjects": subjects, }) + + +@require_GET +@digest_login_required +def journal(request, period_spec): + """The ledger report.""" + # The period + first_txn = Transaction.objects.order_by("date").first() + data_start = first_txn.date if first_txn is not None else None + last_txn = Transaction.objects.order_by("-date").first() + data_end = last_txn.date if last_txn is not None else None + period = Period(period_spec, data_start, data_end) + # The accounting records + records = Record.objects.filter( + transaction__date__gte=period.start, + transaction__date__lte=period.end).order_by( + "transaction__date", "is_credit", "ord") + # The brought-forward records + # TODO: To be done. + + pagination = Pagination(request, records, True) + return render(request, "accounting/journal.html", { + "records": pagination.records, + "pagination": pagination, + "period": period, + })