Patch to handle negative stock issues

Negative stock can severely influence auto-pricing.
Therefore when stock is added an assumption,
that stock is at least 0 for that product.
This commit is contained in:
Christoffer Viken 2017-06-11 14:25:27 +00:00
parent a03ca8f299
commit 702dfffbfa

View File

@ -107,7 +107,7 @@ much money you're due in credits for the purchase when prompted.\n'''
old_price = product.price
old_hidden = product.hidden
product.price = int(ceil(float(value) / (max(product.stock, 0) + self.products[product][0])))
product.stock += self.products[product][0]
product.stock = max(self.products[product][0], product.stock + self.products[product][0])
product.hidden = False
print "New stock for %s: %d" % (product.name, product.stock), \
("- New price: " + str(product.price) if old_price != product.price else ""), \