Improve calculation of BOM item overage

This commit is contained in:
Oliver Walters 2020-03-19 10:15:43 +11:00
parent 3fd0cf67b6
commit 15bc457714

View File

@ -1198,9 +1198,9 @@ class BomItem(models.Model):
overage = str(self.overage).strip() overage = str(self.overage).strip()
# Is the overage an integer value? # Is the overage a numerical value?
try: try:
ovg = int(overage) ovg = float(overage)
if ovg < 0: if ovg < 0:
ovg = 0 ovg = 0
@ -1223,7 +1223,7 @@ class BomItem(models.Model):
# Must be represented as a decimal # Must be represented as a decimal
percent = Decimal(percent) percent = Decimal(percent)
return int(percent * quantity) return float(percent * quantity)
except ValueError: except ValueError:
pass pass
@ -1245,7 +1245,12 @@ class BomItem(models.Model):
# Base quantity requirement # Base quantity requirement
base_quantity = self.quantity * build_quantity base_quantity = self.quantity * build_quantity
return base_quantity + self.get_overage_quantity(base_quantity) # Overage requiremet
ovrg_quantity = self.get_overage_quantity(base_quantity)
required = float(base_quantity) + float(ovrg_quantity)
return required
@property @property
def price_range(self): def price_range(self):