diff --git a/drcr/models.py b/drcr/models.py
index 7c6390b..284a1eb 100644
--- a/drcr/models.py
+++ b/drcr/models.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
+from markupsafe import Markup
+
from . import AMOUNT_DPS
class Transaction:
@@ -75,10 +77,12 @@ class Amount:
return Amount(-self.quantity, self.commodity)
def format(self):
- if len(self.commodity) == 1:
- return '{0}{1:,.{dps}f}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS)
+ if self.commodity == '$':
+ return Markup('{:,.{dps}f}'.format(self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
+ elif len(self.commodity) == 1:
+ return Markup('{0}{1:,.{dps}f}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
else:
- return '{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS)
+ return Markup('{1:,.{dps}f} {0}'.format(self.commodity, self.quantity / (10**AMOUNT_DPS), dps=AMOUNT_DPS).replace(',', ' '))
def quantity_string(self):
if self.commodity == '$':
diff --git a/drcr/templates/general_journal/general_journal.html b/drcr/templates/general_journal/general_journal.html
index 463b76c..291eeb2 100644
--- a/drcr/templates/general_journal/general_journal.html
+++ b/drcr/templates/general_journal/general_journal.html
@@ -29,16 +29,16 @@
Date |
- Description |
- Dr |
- Cr |
+ Description |
+ Dr |
+ Cr |
{% for transaction in transactions %}
{{ transaction.dt.strftime('%Y-%m-%d') }} |
- {{ transaction.description }} |
+ {{ transaction.description }} |
|
|
@@ -46,9 +46,10 @@
|
{{ posting.description or '' }} |
- {{ 'Dr' if posting.quantity >= 0 else 'Cr' }} {{ posting.account }} |
- {{ posting.amount().format() if posting.quantity >= 0 else '' }} |
- {{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }} |
+ {{ 'Dr' if posting.quantity >= 0 else 'Cr' }} |
+ {{ posting.account }} |
+ {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }} |
+ {{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }} |
{% endfor %}
{% endfor %}
diff --git a/drcr/templates/general_ledger.html b/drcr/templates/general_ledger.html
index bd3cfad..11c7613 100644
--- a/drcr/templates/general_ledger.html
+++ b/drcr/templates/general_ledger.html
@@ -25,16 +25,16 @@
Date |
- Description |
- Dr |
- Cr |
+ Description |
+ Dr |
+ Cr |
{% for transaction in transactions %}
{{ transaction.dt.strftime('%Y-%m-%d') }} |
- {{ transaction.description }} |
+ {{ transaction.description }} |
|
|
@@ -42,9 +42,10 @@
|
{{ posting.description or '' }} |
- {{ 'Dr' if posting.quantity >= 0 else 'Cr' }} {{ posting.account }} |
- {{ posting.amount().format() if posting.quantity >= 0 else '' }} |
- {{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }} |
+ {{ 'Dr' if posting.quantity >= 0 else 'Cr' }} |
+ {{ posting.account }} |
+ {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }} |
+ {{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }} |
{% endfor %}
{% endfor %}
diff --git a/drcr/templates/statements/statement_lines.html b/drcr/templates/statements/statement_lines.html
index e5107cf..38e67de 100644
--- a/drcr/templates/statements/statement_lines.html
+++ b/drcr/templates/statements/statement_lines.html
@@ -34,9 +34,9 @@
Date |
Description |
Charged to |
- Dr |
- Cr |
- Balance |
+ Dr |
+ Cr |
+ Balance |
@@ -56,9 +56,9 @@
{% endif %}
- {{ line.amount().format() if line.quantity >= 0 else '' }} |
- {{ (line.amount()|abs).format() if line.quantity < 0 else '' }} |
- {{ line.balance or '' }} |
+ {{ line.amount().format() if line.quantity >= 0 else '' }} |
+ {{ (line.amount()|abs).format() if line.quantity < 0 else '' }} |
+ {{ line.balance or '' }} |
{% endfor %}
diff --git a/drcr/templates/transactions.html b/drcr/templates/transactions.html
index 1320f5a..99f514b 100644
--- a/drcr/templates/transactions.html
+++ b/drcr/templates/transactions.html
@@ -42,8 +42,8 @@
{{ transaction.dt.strftime('%Y-%m-%d') }} |
{{ transaction.description }} |
{% for p in transaction.postings if p.account != account %}{{ p.account }}{% endfor %} |
- {{ posting.amount().format() if posting.quantity >= 0 else '' }} |
- {{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }} |
+ {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }} |
+ {{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }} |
{{ (running_total|abs).format() }} |
{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }} |
@@ -63,8 +63,8 @@
|
{{ 'Dr' if posting.quantity >= 0 else 'Cr' }} |
{{ account }} |
- {{ posting.amount().format() if posting.quantity >= 0 else '' }} |
- {{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }} |
+ {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }} |
+ {{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }} |
{{ (running_total|abs).format() }} |
{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }} |
@@ -74,8 +74,8 @@
|
{{ 'Dr' if posting.quantity >= 0 else 'Cr' }} |
{{ posting.account }} |
- {{ posting.amount().format() if posting.quantity >= 0 else '' }} |
- {{ (posting.amount()|abs).format() if posting.quantity < 0 else '' }} |
+ {{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }} |
+ {{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }} |
|
|