-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
Extend the ingredient consolidation logic to handle multiple recipes from a meal plan. When generating a shopping list for a week's worth of meals, ingredients across all recipes should be intelligently combined. This prevents duplicate items and provides accurate quantities for bulk shopping.
Acceptance Criteria (Gherkin)
Scenario: Consolidate same ingredients across recipes
Given Monday dinner needs "2 cups flour"
And Wednesday lunch needs "1.5 cups flour"
When I generate a shopping list for the week
Then the list contains "flour, 3.5 cups"
Scenario: Handle different units
Given recipe A needs "500g chicken"
And recipe B needs "1 lb chicken"
When consolidated
Then the list shows "chicken, 1.5 lbs" (or equivalent normalized unit)
Scenario: Respect serving adjustments
Given recipe A serves 4 and I planned for 2
And recipe B serves 2 and I planned for 6
When consolidated
Then ingredients are scaled (0.5x for A, 3x for B) before combining
Scenario: Preserve recipe associations
Given I generate a list from 5 recipes
When I view a shopping list item
Then I can see which recipes required it
And the quantity breakdown per recipe
Scenario: Category organization
Given ingredients from multiple recipes
When the shopping list is generated
Then items are grouped by category (produce, dairy, etc.)Technical Notes
File: backend/src/services/multi-recipe-consolidation.service.ts
Service Methods:
interface MealPlanShoppingListRequest {
mealPlanId: string;
dateRange?: { start: Date; end: Date };
excludeRecipeIds?: string[];
}
interface ConsolidatedIngredient {
name: string;
normalizedName: string;
totalQuantity: number;
unit: string;
category: string;
sources: {
recipeId: string;
recipeName: string;
quantity: number;
servingsPlanned: number;
}[];
}
async generateFromMealPlan(request: MealPlanShoppingListRequest): Promise<ConsolidatedIngredient[]>Algorithm:
- Fetch all meal plan items in date range
- For each item, get recipe ingredients scaled to planned servings
- Normalize ingredient names (lowercase, singular, standardized)
- Group by normalized name
- Convert units to common base where possible
- Sum quantities
- Track source recipe for each contribution
Unit Normalization:
- Leverage Measurement Conversion Service #49 Measurement Conversion Service
- Prefer larger sensible units (cups over tablespoons for large amounts)
- Keep original units if conversion not possible
Dependencies
- Ingredient Consolidation Logic #40 Ingredient Consolidation Logic
- Meal Plan CRUD Endpoints #52 Meal Plan CRUD Endpoints
- Measurement Conversion Service #49 Measurement Conversion Service
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels