mirror of
https://github.com/nanoy42/coope
synced 2024-11-26 06:32:27 +00:00
Fix order
This commit is contained in:
parent
320022adf1
commit
c6f45b4407
1 changed files with 12 additions and 10 deletions
|
@ -205,6 +205,7 @@ def order(request):
|
||||||
consumption.save()
|
consumption.save()
|
||||||
ch = ConsumptionHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, product=product, amount=Decimal(quantity*product.amount), coopeman=request.user)
|
ch = ConsumptionHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, product=product, amount=Decimal(quantity*product.amount), coopeman=request.user)
|
||||||
ch.save()
|
ch.save()
|
||||||
|
if(paymentMethod.affect_balance):
|
||||||
if(user.profile.balance >= Decimal(product.amount*quantity)):
|
if(user.profile.balance >= Decimal(product.amount*quantity)):
|
||||||
user.profile.debit += Decimal(product.amount*quantity)
|
user.profile.debit += Decimal(product.amount*quantity)
|
||||||
else:
|
else:
|
||||||
|
@ -215,8 +216,9 @@ def order(request):
|
||||||
quantity = int(m["quantity"])
|
quantity = int(m["quantity"])
|
||||||
mh = MenuHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, menu=menu, amount=int(quantity*menu.amount), coopeman=request.user)
|
mh = MenuHistory(customer=user, quantity=quantity, paymentMethod=paymentMethod, menu=menu, amount=int(quantity*menu.amount), coopeman=request.user)
|
||||||
mh.save()
|
mh.save()
|
||||||
if(user.profile.balance >= Decimal(menu.amount*quantity)):
|
if(paymentMethod.affect_balance):
|
||||||
user.profile.debit += Decimal(menu.amount*quantity)
|
if(user.profile.balance >= Decimal(product.amount*quantity)):
|
||||||
|
user.profile.debit += Decimal(product.amount*quantity)
|
||||||
else:
|
else:
|
||||||
error_message = "Solde insuffisant"
|
error_message = "Solde insuffisant"
|
||||||
raise Exception(error_message)
|
raise Exception(error_message)
|
||||||
|
|
Loading…
Reference in a new issue