Commit c997f694 authored by rexxnor's avatar rexxnor

added rounding function

parent 5c470ce1
......@@ -18,6 +18,9 @@ def chargecard(request):
ownerid = request.GET.get('owner_id')
total = request.GET.get('total')
# round total
total = round(float(total), 1)
# prepare the query
try:
if ownerid == "" and pin == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855":
......@@ -40,7 +43,8 @@ def chargecard(request):
charge = Charge(owner_id=cardobject, amount=total, date_time=timezone.now())
# Add new balance
cardobject.current_balance = cardobject.current_balance + Money(total, currency='CHF')
cardobject.current_balance = cardobject.current_balance + Money(total,
currency='CHF')
# commit the transactions
charge.save()
......@@ -90,6 +94,9 @@ def buydrink(request):
ownerid = request.GET.get('ownerid')
pin = request.GET.get('pin')
# round total
total = round(float(total), 1)
try:
if ownerid == "" and pin == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855":
cardobject = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment