Added the accounting_amount template filter and applied it in the cash account.
This commit is contained in:
parent
9cab1c2194
commit
46b20ab500
@ -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 }}
|
||||
</span>
|
||||
{% endif %}</td>
|
||||
<td class="amount">{% if record.credit_amount is not None %}{{ record.credit_amount|intcomma:False }}{% endif %}</td>
|
||||
<td class="amount">{% if record.debit_amount is not None %}{{ record.debit_amount|intcomma:False }}{% endif %}</td>
|
||||
<td class="amount">{{ record.balance|intcomma:False }}</td>
|
||||
<td class="amount">{{ record.credit_amount|accounting_amount }}</td>
|
||||
<td class="amount">{{ record.debit_amount|accounting_amount }}</td>
|
||||
<td class="amount">{{ record.balance|accounting_amount }}</td>
|
||||
<td class="actions">
|
||||
{% if record.sn is not None %}
|
||||
<a href="{{ record.transaction.get_absolute_url }}" class="btn btn-info" role="button">
|
||||
|
0
accounting/templatetags/__init__.py
Normal file
0
accounting/templatetags/__init__.py
Normal file
41
accounting/templatetags/accounting.py
Normal file
41
accounting/templatetags/accounting.py
Normal file
@ -0,0 +1,41 @@
|
||||
# The accounting application of the Mia project.
|
||||
# by imacat <imacat@mail.imacat.idv.tw>, 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
|
Loading…
Reference in New Issue
Block a user