diff --git a/accounting/templates/accounting/cash.html b/accounting/templates/accounting/cash.html
index 54814b5..e82ac25 100644
--- a/accounting/templates/accounting/cash.html
+++ b/accounting/templates/accounting/cash.html
@@ -22,6 +22,7 @@ First written: 2020/7/1
{% endcomment %}
{% load i18n %}
{% load humanize %}
+{% load accounting %}
{% block settings %}
{% blocktrans asvar title with subject=subject.title_zhtw period=period.description context "Accounting|" %}Cash Account for {{ subject }} in {{ period }}{% endblocktrans %}
@@ -106,9 +107,9 @@ First written: 2020/7/1
{{ text|force_escape }}
{% endif %}
-
{% if record.credit_amount is not None %}{{ record.credit_amount|intcomma:False }}{% endif %} |
- {% if record.debit_amount is not None %}{{ record.debit_amount|intcomma:False }}{% endif %} |
- {{ record.balance|intcomma:False }} |
+ {{ record.credit_amount|accounting_amount }} |
+ {{ record.debit_amount|accounting_amount }} |
+ {{ record.balance|accounting_amount }} |
{% if record.sn is not None %}
diff --git a/accounting/templatetags/__init__.py b/accounting/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/accounting/templatetags/accounting.py b/accounting/templatetags/accounting.py
new file mode 100644
index 0000000..1cb2ddf
--- /dev/null
+++ b/accounting/templatetags/accounting.py
@@ -0,0 +1,41 @@
+# The accounting application of the Mia project.
+# by imacat , 2020/7/13
+
+# 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.
+
+"""The template tags and filters of the accounting application.
+
+"""
+import re
+
+from django import template
+
+register = template.Library()
+
+
+@register.filter
+def accounting_amount(value):
+ if value is None:
+ return ""
+ print(value)
+ s = str(abs(value))
+ while True:
+ m = re.match("^([1-9][0-9]*)([0-9]{3})", s)
+ if m is None:
+ break
+ s = m.group(1) + "," + m.group(2)
+ if value < 0:
+ s = "(%s)" % (s)
+ return s
|