feat(backend): implement unit conversion for cost calculation

- Add UnitConverter (normalization, within-family, density tables)
- Update cost.py to convert recipe qty to grocery price unit
- Update generate.py _load_match_index to fetch ingredient name + unit
- Fix orchestrator email/shopping-list cost loops to use conversion
- Fix missing Ingredient import in generate.py
- Add 19 unit tests
This commit is contained in:
2026-05-24 13:46:50 -07:00
parent 3885d7d0dc
commit fd8ba3c4d2
6 changed files with 429 additions and 20 deletions
+2
View File
@@ -15,10 +15,12 @@ def _match(grocery_id, name, current, regular, is_on_sale, confidence=0.9):
return {
"grocery_item_id": grocery_id,
"grocery_item_name": name,
"ingredient_name": name.lower(),
"current_price": Decimal(str(current)),
"regular_price": Decimal(str(regular)),
"is_on_sale": is_on_sale,
"confidence": Decimal(str(confidence)),
"grocery_unit": None,
}