From aa669e9f530f67c2117f874dd1e54abf3e325a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 6 Mar 2023 08:15:10 +0800 Subject: [PATCH] Replaced tables with CSS "display: grid" for the journal, ledger, and income and expenses, to allow using as the table row. --- src/accounting/static/css/style.css | 54 ++++++++++--- .../accounting/report/income-expenses.html | 79 +++++++++++-------- .../templates/accounting/report/journal.html | 50 ++++++------ .../templates/accounting/report/ledger.html | 74 +++++++++-------- 4 files changed, 157 insertions(+), 100 deletions(-) diff --git a/src/accounting/static/css/style.css b/src/accounting/static/css/style.css index 9f99a8a..197a27f 100644 --- a/src/accounting/static/css/style.css +++ b/src/accounting/static/css/style.css @@ -109,24 +109,60 @@ border-top: thick double slategray; } -/* The accounting report */ -.accounting-ledger-table thead { +/* The report table */ +.accounting-report-table-header, .accounting-report-table-footer { + font-size: 1.2rem; + font-weight: bolder; +} +.accounting-report-table-header { border-bottom: thick double slategray; } -.accounting-amount { +.accounting-report-table-footer { + font-style: italic; + border-top: thick double slategray; +} +.accounting-report-table-row { + display: grid; +} +a.accounting-report-table-row { + color: inherit; + text-decoration: none; +} +.accounting-report-table-row > div { + padding: .5rem; +} +.accounting-report-table .accounting-amount { text-align: right; } -td.accounting-amount { +.accounting-report-table-body .accounting-amount { font-style: italic; } +.accounting-report-table-body .accounting-report-table-row:nth-child(2n+1) { + background-color: #f2f2f2; +} +.accounting-report-table-body .accounting-report-table-row:hover { + background-color: rgba(0, 0, 0, 0.075); +} +.accounting-journal-table .accounting-report-table-row { + grid-template-columns: 1fr 1fr 2fr 4fr 1fr 1fr; +} +.accounting-ledger-table .accounting-report-table-row { + grid-template-columns: 1fr 4fr 1fr 1fr 1fr; +} +.accounting-ledger-table .accounting-report-table-footer .accounting-report-table-row { + grid-template-columns: 5fr 1fr 1fr 1fr; +} +.accounting-income-expenses-table .accounting-report-table-row { + grid-template-columns: 1fr 2fr 4fr 1fr 1fr 1fr; +} +.accounting-income-expenses-table .accounting-report-table-footer .accounting-report-table-row { + grid-template-columns: 7fr 1fr 1fr 1fr; +} + +/* The accounting report */ .accounting-mobile-journal-credit { padding-left: 1rem; } -.accounting-ledger-table tfoot { - border-top: thick double slategray; - font-weight: bolder; - font-style: italic; -} .accounting-report-row { border: none; } diff --git a/src/accounting/templates/accounting/report/income-expenses.html b/src/accounting/templates/accounting/report/income-expenses.html index c18bd4d..5436088 100644 --- a/src/accounting/templates/accounting/report/income-expenses.html +++ b/src/accounting/templates/accounting/report/income-expenses.html @@ -149,40 +149,51 @@ First written: 2023/3/5 {% if list %} {% include "accounting/include/pagination.html" %} - - - - - - - - - - - - - {% for item in list %} - - - - - - - - - {% endfor %} - - {% if report.total_row is not none %} - - - - - - - - - {% endif %} -
{{ A_("Date") }}{{ A_("Account") }}{{ A_("Summary") }}{{ A_("Income") }}{{ A_("Expense") }}{{ A_("Balance") }}
{{ A_("Total") }}{{ report.total_row.income|accounting_format_amount }}{{ report.total_row.expense|accounting_format_amount }}{{ report.total_row.balance|accounting_format_amount }}
+
+
+
+
{{ A_("Date") }}
+
{{ A_("Account") }}
+
{{ A_("Summary") }}
+
{{ A_("Income") }}
+
{{ A_("Expense") }}
+
{{ A_("Balance") }}
+
+
+
+ {% for item in list %} + {% if item.transaction %} + +
{{ item.date|accounting_format_date }}
+
{{ item.account.title|title }}
+
{{ item.summary|accounting_default }}
+
{{ item.income|accounting_format_amount|accounting_default }}
+
{{ item.expense|accounting_format_amount|accounting_default }}
+
{{ item.balance|accounting_format_amount }}
+
+ {% else %} +
+
{{ item.date|accounting_format_date }}
+
{{ item.account.title|title }}
+
{{ item.summary|accounting_default }}
+
{{ item.income|accounting_format_amount|accounting_default }}
+
{{ item.expense|accounting_format_amount|accounting_default }}
+
{{ item.balance|accounting_format_amount }}
+
+ {% endif %} + {% endfor %} +
+ {% if report.total_row is not none %} + + {% endif %} +
{% for item in list %} diff --git a/src/accounting/templates/accounting/report/journal.html b/src/accounting/templates/accounting/report/journal.html index 0839ec7..a73f481 100644 --- a/src/accounting/templates/accounting/report/journal.html +++ b/src/accounting/templates/accounting/report/journal.html @@ -24,7 +24,7 @@ First written: 2023/3/4 {% block accounting_scripts %} - + {# #} {% endblock %} {% block header %}{% block title %}{{ _("Journal %(period)s", period=report.period.desc|title) }}{% endblock %}{% endblock %} @@ -91,30 +91,30 @@ First written: 2023/3/4 {% if list %} {% include "accounting/include/pagination.html" %} - - - - - - - - - - - - - {% for item in list %} - - - - - - - - - {% endfor %} - -
{{ A_("Date") }}{{ A_("Currency") }}{{ A_("Account") }}{{ A_("Summary") }}{{ A_("Debit") }}{{ A_("Credit") }}
+
{% for item in list %} diff --git a/src/accounting/templates/accounting/report/ledger.html b/src/accounting/templates/accounting/report/ledger.html index 7fc2973..e8df947 100644 --- a/src/accounting/templates/accounting/report/ledger.html +++ b/src/accounting/templates/accounting/report/ledger.html @@ -149,38 +149,48 @@ First written: 2023/3/5 {% if list %} {% include "accounting/include/pagination.html" %} - - - - - - - - - - - - {% for item in list %} - - - - - - - - {% endfor %} - - {% if report.total_row is not none %} - - - - - - - - - {% endif %} -
{{ A_("Date") }}{{ A_("Summary") }}{{ A_("Debit") }}{{ A_("Credit") }}{{ A_("Balance") }}
{{ A_("Total") }}{{ report.total_row.debit|accounting_format_amount }}{{ report.total_row.credit|accounting_format_amount }}{{ report.total_row.balance|accounting_format_amount }}
+
+
+
+
{{ A_("Date") }}
+
{{ A_("Summary") }}
+
{{ A_("Debit") }}
+
{{ A_("Credit") }}
+
{{ A_("Balance") }}
+
+
+
+ {% for item in list %} + {% if item.transaction %} + +
{{ item.date|accounting_format_date }}
+
{{ item.summary|accounting_default }}
+
{{ item.debit|accounting_format_amount|accounting_default }}
+
{{ item.credit|accounting_format_amount|accounting_default }}
+
{{ item.balance|accounting_format_amount }}
+
+ {% else %} +
+
{{ item.date|accounting_format_date }}
+
{{ item.summary|accounting_default }}
+
{{ item.debit|accounting_format_amount|accounting_default }}
+
{{ item.credit|accounting_format_amount|accounting_default }}
+
{{ item.balance|accounting_format_amount }}
+
+ {% endif %} + {% endfor %} +
+ {% if report.total_row is not none %} + + {% endif %} +
{% for item in list %}