mirror of
https://github.com/nanoy42/coope
synced 2024-11-22 03:13:12 +00:00
Decrement stockBar and not stockHold on transactions
This commit is contained in:
parent
b26b304672
commit
aa97c26335
2 changed files with 11 additions and 5 deletions
|
@ -95,7 +95,7 @@ class Product(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.draft_category == self.DRAFT_NONE:
|
if self.draft_category == self.DRAFT_NONE:
|
||||||
return self.name + "(" + str(self.amount) + " €)"
|
return self.name + " (" + str(self.amount) + " €)"
|
||||||
else:
|
else:
|
||||||
return self.name + " (" + str(self.amount) + " €, " + str(self.deg) + "°)"
|
return self.name + " (" + str(self.amount) + " €, " + str(self.deg) + "°)"
|
||||||
|
|
||||||
|
|
|
@ -161,8 +161,11 @@ def order(request):
|
||||||
kegHistory.amountSold += Decimal(quantity * product.amount)
|
kegHistory.amountSold += Decimal(quantity * product.amount)
|
||||||
kegHistory.save()
|
kegHistory.save()
|
||||||
else:
|
else:
|
||||||
if(product.stockHold > 0):
|
if(product.stockBar > quantity):
|
||||||
product.stockHold -= 1
|
product.stockBar -= quantity
|
||||||
|
product.save()
|
||||||
|
else:
|
||||||
|
product.stockBar = 0
|
||||||
product.save()
|
product.save()
|
||||||
consumption, _ = Consumption.objects.get_or_create(customer=user, product=product)
|
consumption, _ = Consumption.objects.get_or_create(customer=user, product=product)
|
||||||
consumption.quantity += quantity
|
consumption.quantity += quantity
|
||||||
|
@ -195,8 +198,11 @@ def order(request):
|
||||||
consumption, _ = Consumption.objects.get_or_create(customer=user, product=article)
|
consumption, _ = Consumption.objects.get_or_create(customer=user, product=article)
|
||||||
consumption.quantity += quantity
|
consumption.quantity += quantity
|
||||||
consumption.save()
|
consumption.save()
|
||||||
if(article.stockHold > 0):
|
if(article.stockBar > quantity):
|
||||||
article.stockHold -= 1
|
article.stockBar -= quantity
|
||||||
|
article.save()
|
||||||
|
else:
|
||||||
|
article.stockBar = 0
|
||||||
article.save()
|
article.save()
|
||||||
user.profile.alcohol += Decimal(quantity * float(product.deg) * product.volume * 0.79 /10 /1000)
|
user.profile.alcohol += Decimal(quantity * float(product.deg) * product.volume * 0.79 /10 /1000)
|
||||||
user.save()
|
user.save()
|
||||||
|
|
Loading…
Reference in a new issue