ソースを参照

Bug fix: fix order ingredient pricing for bottles.

Lee Morgan 4 年 前
コミット
af8d522470

+ 2 - 0
views/dashboardPage/js/classes/Order.js

@@ -26,6 +26,7 @@ class OrderIngredient{
             case "cm": return this._quantity * 100;
             case "in": return this._quantity * 39.3701;
             case "ft": return this._quantity * 3.2808;
+            case "bottle": return this._quantity * this._ingredient.convert.toBottle;
             default: return this._quantity;
         }
     }
@@ -60,6 +61,7 @@ class OrderIngredient{
             case "m": return this._pricePerUnit / 100;
             case "in": return (this._pricePerUnit / 39.3701) / 100; 
             case "ft": return (this._pricePerUnit / 3.2808) / 100;
+            case "bottle": return (this._pricePerUnit / this._ingredient.convert.toBottle) / 100;
             default: return this._pricePerUnit / 100;
         }
     }

+ 5 - 4
views/dashboardPage/js/sidebars/newOrder.js

@@ -71,14 +71,15 @@ let newOrder = {
             let newIngredient = {
                 ingredient: ingredients[i].ingredient.ingredient.id,
                 quantity: controller.toBase(quantity, unit),
-                pricePerUnit: this.convertPrice(controller.getBaseUnit(unit), price * 100)
+                pricePerUnit: (price * 100) / controller.unitMultiplier(unit, controller.getBaseUnit(unit))
             };
 
             if(ingredients[i].ingredient.ingredient.unit === "bottle"){
-                newIngredient.quantity = quantity / ingredients[i].ingredient.ingredient.convert.toBottle;
-                newIngredient.pricePerUnit = this.convertPrice(controller.getBaseUnit(unit), price * ingredients[i].ingredient.ingredient.convert.toBottle * 100);
+                let unitMultiplier = controller.unitMultiplier(unit, controller.getBaseUnit(unit));
+                let toBottle = ingredients[i].ingredient.ingredient.convert.toBottle;
+                newIngredient.quantity = quantity / toBottle;
+                newIngredient.pricePerUnit = toBottle * (price * 100);
             }
-            console.log(newIngredient);
 
             data.ingredients.push(newIngredient);
         }