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:
parent
a03ca8f299
commit
702dfffbfa
|
@ -107,7 +107,7 @@ much money you're due in credits for the purchase when prompted.\n'''
|
||||||
old_price = product.price
|
old_price = product.price
|
||||||
old_hidden = product.hidden
|
old_hidden = product.hidden
|
||||||
product.price = int(ceil(float(value) / (max(product.stock, 0) + self.products[product][0])))
|
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
|
product.hidden = False
|
||||||
print "New stock for %s: %d" % (product.name, product.stock), \
|
print "New stock for %s: %d" % (product.name, product.stock), \
|
||||||
("- New price: " + str(product.price) if old_price != product.price else ""), \
|
("- New price: " + str(product.price) if old_price != product.price else ""), \
|
||||||
|
|
Loading…
Reference in New Issue