gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: fix unshown negative am


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: fix unshown negative amount (#5148)
Date: Mon, 16 Oct 2017 11:19:00 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new 6f6650f  fix unshown negative amount (#5148)
6f6650f is described below

commit 6f6650fef7b20ff10e2b9635bf210e1e2f8dc876
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Oct 16 11:18:13 2017 +0200

    fix unshown negative amount (#5148)
---
 talerbank/app/models.py                   | 9 +++++++++
 talerbank/app/templates/profile_page.html | 2 +-
 talerbank/app/views.py                    | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/talerbank/app/models.py b/talerbank/app/models.py
index f1c3485..868b0d6 100644
--- a/talerbank/app/models.py
+++ b/talerbank/app/models.py
@@ -22,9 +22,18 @@ from django.db import models
 
 class BankAccount(models.Model):
     is_public = models.BooleanField(default=False)
+    # Handier than keeping the amount signed, for two reasons:
+    # (1) checking if someone is in debt is less verbose: with signed
+    # amounts we have to check if the amount is less than zero; this
+    # way we only check if a boolean is true. (2) The bank logic is
+    # ready to welcome a data type for amounts which doesn't have any
+    # sign notion, like Taler amounts do.
     debit = models.BooleanField(default=False)
     balance_value = models.IntegerField(default=0)
     balance_fraction = models.IntegerField(default=0)
+    # From today's (16/10/2017) Mumble talk, it emerged that bank shouldn't
+    # store amounts as floats, but: normal banks should not care about
+    # Taler when representing values around in their databases..
     balance = models.FloatField(default=0)
     currency = models.CharField(max_length=12, default="")
     account_no = models.AutoField(primary_key=True)
diff --git a/talerbank/app/templates/profile_page.html 
b/talerbank/app/templates/profile_page.html
index 2fa06c5..c64f215 100644
--- a/talerbank/app/templates/profile_page.html
+++ b/talerbank/app/templates/profile_page.html
@@ -39,7 +39,7 @@
 {% block content %}
   <section id="menu">
     <p>Account: # {{ account_no }}</p>
-    <p>Current balance: <b>{{ balance }} {{ currency }}</b></p>
+    <p>Current balance: <b>{{ sign }} {{ balance }} {{ currency }}</b></p>
   </section>
   <section id="main">
     <article>
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 36e7c58..45328f8 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -99,6 +99,7 @@ def profile_page(request):
     context = dict(
         name=user_account.user.username,
         balance=amounts.stringify(amounts.floatify(user_account.balance_obj)),
+        sign = "-" if user_account.debit else "",
         currency=user_account.currency,
         precision=settings.TALER_DIGITS,
         account_no=user_account.account_no,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]