Mix calculator
This commit is contained in:
@@ -177,7 +177,7 @@ def _apply_margin(cost: float, margin: float | None) -> float | None:
|
||||
return round(cost / (1 - margin), 4)
|
||||
|
||||
|
||||
def _extract_unit_quantity_kg(unit_of_measure: str) -> float:
|
||||
def extract_unit_quantity_kg(unit_of_measure: str) -> float:
|
||||
normalized = unit_of_measure.strip().lower()
|
||||
if normalized == "tonne":
|
||||
return 1000.0
|
||||
@@ -199,7 +199,7 @@ def calculate_product_cost(db: Session, product_id: int, overrides: dict | None
|
||||
|
||||
mix_result = calculate_mix_cost(db, product.mix_id, overrides=overrides)
|
||||
warnings = list(mix_result["warnings"])
|
||||
sale_unit_kg = _extract_unit_quantity_kg(product.unit_of_measure)
|
||||
sale_unit_kg = extract_unit_quantity_kg(product.unit_of_measure)
|
||||
|
||||
mix_cost_per_kg = mix_result["mix_cost_per_kg"] or 0.0
|
||||
cleaned_product_cost = round(mix_cost_per_kg * sale_unit_kg, 4)
|
||||
|
||||
Reference in New Issue
Block a user