# Plan the week's dinners

The plan is the same one the family swipes together in the app (Madplan tab); you and the app work on
the same plan. Weeks: `next` (default), `this`, or an ISO week like `2026-W42`.

1. **Look first.** `get_week_plan(week)` shows each dinner day, what is chosen, open dish wishes, the
   household's tag requirements ("Krav til ugen"). If the family already
   planned it, don't overwrite their choices: only fill gaps or make the changes the user asks for.
2. **Respect the household.** `get_household_settings` tells you persons, which days have dinner, which
   are busy (max minutes), excluded ingredients and hidden dishes. The tools refuse dishes the household
   excludes; don't try to work around that.
   **Before choosing dinners:** ask what is in the fridge (or read `get_inventory`) and record new things
   with `update_inventory`; the planner (`fill_week`) then prefers dinners that use them up, fresh food first.
3. **Choose.**
   - Specific dishes: `plan_dinner(day, dish)`. `dish` is a name or id from `find_dishes`. If the name
     matches several dishes you get the candidates back: ask the user or pick the obvious one.
   - Let the planner choose the rest: `fill_week(week)`. It keeps every chosen dish, places open dish
     wishes first (and marks them done), balances proteins, keeps busy days quick and avoids dishes from
     the last weeks. It keeps to the household's weekly budget (`get_household_settings`). When the hard
     budget can't cover every dinner it leaves days empty and asks; ask the user, and only on a yes call
     `fill_week(week, allow_over_budget=true)`.
   - Freezer days ("Fra fryseren"): the household can ask for some each week (setting `freezer_days`, edited
     in the app) and `fill_week` places them. By hand `plan_dinner(day, "fra fryseren")` is always allowed,
     also several times a week, whatever the stock. It adds nothing to the shopping list. When the household
     tracks its freezer, `get_freezer` shows the stock and today's questions; `update_freezer` records what
     was taken up (`take`) or that it was something else (`none`), and leftovers frozen (`freeze`, `no_freeze`).
     Ask these only on the day itself; never guess.
   - A night out or leftovers: `clear_dinner(day)`.
   - Guests: `plan_dinner(day, dish, servings=6)`.
   - More than one dish on a day (a salad or side next to the main dish): `plan_dinner(day, dish, add=true)`.
   - A wish that isn't a dish yet (the plan lists it as unmatched): offer to create it (`how_to("add_dish")`).
4. **Show the user** the week in a short list (day: dish, minutes) and mention unmet tag requirements and where the week stands against the budget (the `Budget:` line; mention it when it is over or uncertain).
5. **Nothing to publish or save**: every change (plan_dinner, clear_dinner, fill_week) is saved as the week's menu at
   once (there is no separate publish step), so the app, the shopping trips and "hvad skal vi have" agree straight away.
6. **Shopping happens in trips**, not per week. In the app's Liste tab the family picks which dishes they
   shop for ("Hvad handler I ind til?": dishes not bought yet, this and next week), ticks "har vi" at home
   and "i kurven" in the shop, and "Færdig med at handle" marks the dishes bought, so dishes added later
   never make them buy the same things twice. A dish they got only some things for stays partly bought:
   the next trip only has what it still needs. The list gives the day and date each fresh item is used, to
   compare with the pack's date; a pack that won't last: `buy_later(item, dish)` leaves that amount for a later
   trip. From here: `start_trip`, `get_shopping_list`,
   `remove_from_shopping_list` ("we have it"), `finish_trip` (ask which dishes they got everything for),
   `cancel_trip`.

A flexible dish on the week answers with its choices; ask and save them with `pick_for_dish` (`how_to("flexible_dish")`).
