From 702dfffbfa7c7b5ab0c59189f014e8377e51ef3c Mon Sep 17 00:00:00 2001 From: Christoffer Viken Date: Sun, 11 Jun 2017 14:25:27 +0000 Subject: [PATCH] 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. --- text_interface/addstock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text_interface/addstock.py b/text_interface/addstock.py index 213c75d..e463644 100644 --- a/text_interface/addstock.py +++ b/text_interface/addstock.py @@ -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 ""), \