From 15bc457714714c09bfb8b826deda07bf8c5f941d Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 19 Mar 2020 10:15:43 +1100 Subject: [PATCH] Improve calculation of BOM item overage --- InvenTree/part/models.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 39c61079ea..d8cb8b07e0 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1198,9 +1198,9 @@ class BomItem(models.Model): overage = str(self.overage).strip() - # Is the overage an integer value? + # Is the overage a numerical value? try: - ovg = int(overage) + ovg = float(overage) if ovg < 0: ovg = 0 @@ -1223,7 +1223,7 @@ class BomItem(models.Model): # Must be represented as a decimal percent = Decimal(percent) - return int(percent * quantity) + return float(percent * quantity) except ValueError: pass @@ -1245,7 +1245,12 @@ class BomItem(models.Model): # Base quantity requirement 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 def price_range(self):