diff --git a/CLAUDE.md b/CLAUDE.md
index aec431d..b309b4e 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -191,6 +191,24 @@ Vorlagen ersetzt. `tests/seed.test.ts` prüft die Dateien. Ein Haushalt
Listennamen. Eine neue Stück-Zutat braucht beide Formen in allen vier Sprachen —
`tests/ingredient-name.test.ts` wacht.
+## Preise und Kosten (V2a, 26.11.16)
+
+- Drei Preisquellen, Rang in `lib/pricing.ts` (`currentPrices`): Bon im Hauptladen >
+ anderer Bon > eigener Preis (`price_points.source = 'manual'`) > Richtpreis
+ (`default_prices`, global, aus `db/seed/prices.de.json`, Migration 0009 — grobe
+ Schätzung, als solche beschriftet). Rechnen nur in `lib/pricing.ts` (rein, getestet),
+ Laden in `lib/costs.ts`.
+- Kosten pro Portion: Σ Menge × geltender Preis, passt die Einheit nicht, wird nicht
+ geraten. Grundvorrat (`STAPLE_SQL`: `is_staple` oder Gewürze, Öl/Essig, Backzutaten)
+ zählt pauschal +5 % — **nicht** `pantry_default`, das steuert nur „Hast du noch?“.
+ Konfidenz = Anteil mit Bonpreis (0–3 Punkte, Wort für Bildschirmleser).
+- Preisklassen aus den Terzilen des Haushalts (ab drei Gerichten mit Preis), keine
+ festen Beträge. Vorschlag: höchstens ein teures je `expensive_per_slots` Slots,
+ Wünsche zählen mit und werden nie gestrichen; „günstig“ +0,25 im Score.
+- Richtwert je Runde (`households.budget_per_round`, optional, nur Admins in „Mehr“):
+ Ampel grün ≤ 100 %, gelb ≤ 115 %, rot darüber, immer mit Wort. Farben als Token
+ `--ok`, `--warn`, `--over`.
+
## Gerichte (Arbeitspaket 4)
- Seiten unter `app/(app)/gerichte/`: Pool (Kacheln, „Ausprobieren“), Hinzufügen,
diff --git a/OlaresManifest.yaml b/OlaresManifest.yaml
index af38680..dcf2b91 100644
--- a/OlaresManifest.yaml
+++ b/OlaresManifest.yaml
@@ -21,7 +21,7 @@ metadata:
title: What's cooking?
description: The family decides together what's for dinner — and the shopping list writes itself. Runs entirely on your own box.
icon: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
- version: 26.11.15
+ version: 26.11.16
categories:
- Applications
@@ -61,7 +61,7 @@ permission:
appData: true
spec:
- versionName: '26.11.15'
+ versionName: '26.11.16'
featuredImage: https://git.aimighty.olares.de/aimighty/bilder/raw/branch/main/lunch/icon.png
promoteImage:
diff --git a/app/(app)/gerichte/[id]/page.tsx b/app/(app)/gerichte/[id]/page.tsx
index 0b96080..d2cf773 100644
--- a/app/(app)/gerichte/[id]/page.tsx
+++ b/app/(app)/gerichte/[id]/page.tsx
@@ -8,6 +8,9 @@ import { PortionScaler } from "@/components/dishes/portion-scaler";
import { requireSession } from "@/lib/auth/session";
import { withHousehold } from "@/lib/db";
import { getDish } from "@/lib/dishes";
+import { Confidence } from "@/components/costs/confidence";
+import { CostSection } from "@/components/costs/cost-section";
+import { STAPLE_SQL, dishCosts, householdCurrency, loadPrices } from "@/lib/costs";
export const dynamic = "force-dynamic";
@@ -19,10 +22,21 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
const session = await requireSession();
const locale = await getLocale();
const t = await getTranslations("dishes");
- const { dish, people } = await withHousehold(session.householdId, async (c) => ({
- dish: await getDish(c, id, locale),
- people: (await c.query("select count(*)::int as n from members where role <> 'guest'")).rows[0].n as number,
- }));
+ const tc = await getTranslations("costs");
+ const { dish, people, cost, prices, currency, staples } = await withHousehold(session.householdId, async (c) => {
+ const currency = await householdCurrency(c);
+ const prices = await loadPrices(c, currency);
+ return {
+ dish: await getDish(c, id, locale),
+ people: (await c.query("select count(*)::int as n from members where role <> 'guest'")).rows[0].n as number,
+ cost: (await dishCosts(c, prices, [id])).get(id) ?? null,
+ prices,
+ currency,
+ staples: new Set(
+ (await c.query(`select di.ingredient_id from dish_ingredients di join ingredients i on i.id = di.ingredient_id where di.dish_id = $1 and ${STAPLE_SQL}`, [id])).rows.map((r) => r.ingredient_id as string),
+ ),
+ };
+ });
if (!dish) notFound();
const canWrite = session.role === "admin" || session.role === "member";
const meta = [dish.effortMinutes ? t("minutes", { n: dish.effortMinutes }) : null, dish.base ? t(`bases.${dish.base}`) : null]
@@ -47,9 +61,24 @@ export default async function DishPage({ params }: { params: Promise<{ id: strin
{dish.tags.length ?
+ {tc("perPortion", { price: new Intl.NumberFormat(locale, { style: "currency", currency }).format(cost.perPortion) })}
+
+
+ ) : null}
{canWrite ? {
+ const p = prices.get(i.ingredientId);
+ const fits = p && p.unit === i.unit;
+ return { ingredientId: i.ingredientId, name: i.name, unit: i.unit, pricePerUnit: fits ? p.pricePerUnit : null, source: fits ? p.source : null, staple: staples.has(i.ingredientId) };
+ })}
+ />
{dish.sourceUrl ? (
{t("detail.source")}:{" "}
diff --git a/app/(app)/gerichte/page.tsx b/app/(app)/gerichte/page.tsx
index 865cbd3..cc51004 100644
--- a/app/(app)/gerichte/page.tsx
+++ b/app/(app)/gerichte/page.tsx
@@ -1,12 +1,13 @@
import { Coins, Plus } from "lucide-react";
import Link from "next/link";
-import { getTranslations } from "next-intl/server";
+import { getLocale, getTranslations } from "next-intl/server";
import { DishTile } from "@/components/dishes/dish-tile";
import { UndoArchive } from "@/components/dishes/undo-archive";
import { buttonVariants } from "@/components/ui/button";
import { requireSession } from "@/lib/auth/session";
import { withHousehold } from "@/lib/db";
import { listDishes } from "@/lib/dishes";
+import { costOverview } from "@/lib/costs";
import { currentRound } from "@/lib/rounds";
import { cn } from "@/lib/utils";
@@ -19,8 +20,9 @@ export default async function DishesPage({ searchParams }: { searchParams: Promi
const { ansicht, entfernt } = await searchParams;
const trial = ansicht === "ausprobieren";
const t = await getTranslations("dishes");
- const { all, removed, roundOpen } = await withHousehold(session.householdId, async (c) => ({
+ const { all, removed, roundOpen, money } = await withHousehold(session.householdId, async (c) => ({
all: await listDishes(c),
+ money: await costOverview(c),
roundOpen: (await currentRound(c))?.status === "open",
removed:
entfernt && /^[0-9a-f-]{36}$/.test(entfernt)
@@ -31,8 +33,18 @@ export default async function DishesPage({ searchParams }: { searchParams: Promi
}));
const dishes = all.filter((d) => d.isTrial === trial);
const canWrite = session.role === "admin" || session.role === "member";
+ const tc = await getTranslations("costs");
+ const locale = await getLocale();
+ const fmt = new Intl.NumberFormat(locale, { style: "currency", currency: money.currency });
+ // Kosten pro Portion und Preisklasse (aus den Terzilen des Haushalts) in der Kachelzeile.
+ const cost = (id: string) => {
+ const c = money.costs.get(id)?.perPortion;
+ if (c == null) return null;
+ const cls = money.classes.get(id);
+ return `${fmt.format(c)}${cls && cls !== "normal" ? ` · ${tc(`class.${cls}`)}` : ""}`;
+ };
const meta = (d: (typeof all)[number]) =>
- [d.effortMinutes ? t("minutes", { n: d.effortMinutes }) : null, d.base ? t(`bases.${d.base}`) : null].filter(Boolean).join(" · ");
+ [d.effortMinutes ? t("minutes", { n: d.effortMinutes }) : null, d.base ? t(`bases.${d.base}`) : null, cost(d.id)].filter(Boolean).join(" · ");
return (
diff --git a/app/(app)/mehr/page.tsx b/app/(app)/mehr/page.tsx
index 1bc3ca8..bad7921 100644
--- a/app/(app)/mehr/page.tsx
+++ b/app/(app)/mehr/page.tsx
@@ -7,6 +7,7 @@ import { RemoveButton } from "@/components/more/remove-button";
import { requireAdult } from "@/lib/auth/session";
import { KidDevices, KidsAdmin } from "@/components/more/kids-admin";
import { InstallHint } from "@/components/install-hint";
+import { BudgetSettings } from "@/components/more/budget-settings";
import { withHousehold } from "@/lib/db";
import { isLocale } from "@/lib/locale";
@@ -23,8 +24,9 @@ function Section({ title, children }: { title: string; children: React.ReactNode
export default async function MorePage() {
const session = await requireAdult();
const t = await getTranslations("more");
+ const tc = await getTranslations("costs.settings");
const locale = await getLocale();
- const { members, passkeys, founder, aiReady, kids, kidDevices } = await withHousehold(session.householdId, async (client) => {
+ const { members, passkeys, founder, aiReady, kids, kidDevices, money } = await withHousehold(session.householdId, async (client) => {
const members = (await client.query("select id, display_name, role from members order by created_at")).rows;
const founder = (await client.query("select created_by from households")).rows[0]?.created_by as string | null;
const passkeys = (
@@ -40,7 +42,8 @@ export default async function MorePage() {
where token_hash is not null or link_expires_at > now() order by created_at`,
)
).rows;
- return { members, passkeys, founder, aiReady, kids, kidDevices };
+ const money = (await client.query("select budget_per_round::float as budget, expensive_per_slots as per, currency from households")).rows[0];
+ return { members, passkeys, founder, aiReady, kids, kidDevices, money };
});
const date = new Intl.DateTimeFormat(locale, { dateStyle: "medium" });
@@ -72,6 +75,12 @@ export default async function MorePage() {
+ {session.role === "admin" ? (
+
+ ) : null}
+
{session.role === "admin" ? (
diff --git a/app/(app)/plan/page.tsx b/app/(app)/plan/page.tsx
index 13d2f54..ce32137 100644
--- a/app/(app)/plan/page.tsx
+++ b/app/(app)/plan/page.tsx
@@ -1,7 +1,8 @@
import Link from "next/link";
import { getLocale, getTranslations } from "next-intl/server";
import { buttonVariants } from "@/components/ui/button";
-import { PlanBoard } from "@/components/plan/plan-board";
+import { PlanBoard, type SlotCost } from "@/components/plan/plan-board";
+import { costOverview } from "@/lib/costs";
import { requireAdult } from "@/lib/auth/session";
import { withHousehold } from "@/lib/db";
import { listDishes } from "@/lib/dishes";
@@ -23,6 +24,13 @@ export default async function PlanPage() {
slots: await planSlots(c, round.id),
members: (await c.query("select id, display_name as name from members where role <> 'guest' order by display_name")).rows,
dishes: (await listDishes(c)).map((d) => ({ id: d.id, title: d.title })),
+ money: await (async () => {
+ const o = await costOverview(c);
+ const budget = (await c.query("select budget_per_round::float as b from households")).rows[0]?.b ?? null;
+ const costs: Record = {};
+ for (const [id, x] of o.costs) costs[id] = { perPortion: x.perPortion, confidence: x.confidence, cls: o.classes.get(id) ?? null };
+ return { currency: o.currency, budget, costs };
+ })(),
wishCount: (await c.query("select count(*)::int as n from wishes where round_id = $1 and not is_veto", [round.id])).rows[0].n as number,
};
});
@@ -41,7 +49,7 @@ export default async function PlanPage() {
) : null}
{"slots" in data && data.slots ? (
-
+
) : (
{t("noRound")}
diff --git a/app/api/household/budget/route.ts b/app/api/household/budget/route.ts
new file mode 100644
index 0000000..bf9b3b3
--- /dev/null
+++ b/app/api/household/budget/route.ts
@@ -0,0 +1,20 @@
+import { z } from "zod";
+import { guardWrite, isResponse } from "@/lib/auth/guard";
+import { fail, json, readJson } from "@/lib/auth/http";
+import { withHousehold } from "@/lib/db";
+
+export const dynamic = "force-dynamic";
+
+// Richtwert je Runde (optional) und wie viele Slots auf ein teures Gericht kommen — nur Admins.
+export async function PUT(request: Request) {
+ const session = await guardWrite(request, ["admin"]);
+ if (isResponse(session)) return session;
+ const body = z
+ .object({ budget: z.number().positive().max(10000).nullable(), expensivePerSlots: z.number().int().min(1).max(14) })
+ .safeParse(await readJson(request));
+ if (!body.success) return fail("invalid", 400);
+ await withHousehold(session.householdId, (c) =>
+ c.query("update households set budget_per_round = $2, expensive_per_slots = $3 where id = $1", [session.householdId, body.data.budget, body.data.expensivePerSlots]),
+ );
+ return json({ ok: true });
+}
diff --git a/app/api/prices/route.ts b/app/api/prices/route.ts
new file mode 100644
index 0000000..cac5ea7
--- /dev/null
+++ b/app/api/prices/route.ts
@@ -0,0 +1,25 @@
+import { z } from "zod";
+import { guardWrite, isResponse } from "@/lib/auth/guard";
+import { fail, json, readJson } from "@/lib/auth/http";
+import { PriceRefused, setManualPrice } from "@/lib/costs";
+import { withHousehold } from "@/lib/db";
+import { INPUT_UNITS } from "@/lib/dishes";
+
+export const dynamic = "force-dynamic";
+
+// Eigener Preis an einer Zutat („2,49 € für 500 g“), Konzept: Preisquelle „manuell“.
+export async function POST(request: Request) {
+ const session = await guardWrite(request);
+ if (isResponse(session)) return session;
+ const body = z
+ .object({ ingredientId: z.string().uuid(), price: z.number().min(0).max(1000), amount: z.number().positive().max(100000), unit: z.enum(INPUT_UNITS) })
+ .safeParse(await readJson(request));
+ if (!body.success) return fail("invalid", 400);
+ try {
+ await withHousehold(session.householdId, (c) => setManualPrice(c, session.householdId, body.data.ingredientId, body.data.price, body.data.amount, body.data.unit));
+ return json({ ok: true }, 201);
+ } catch (error) {
+ if (error instanceof PriceRefused) return fail(error.message, 400);
+ throw error;
+ }
+}
diff --git a/app/globals.css b/app/globals.css
index 2fa206d..0910656 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -20,6 +20,9 @@
--secondary-foreground: var(--foreground);
--accent: oklch(0.48 0.11 295); /* tiefer Lavendel: Etiketten, Links */
--ring: oklch(0.48 0.11 295);
+ --ok: oklch(0.58 0.13 155); /* Ampel: im Rahmen */
+ --warn: oklch(0.75 0.15 75); /* Ampel: knapp darüber */
+ --over: oklch(0.58 0.19 25); /* Ampel: deutlich darüber */
--radius: 1rem;
}
@@ -54,6 +57,9 @@
--color-secondary-foreground: var(--secondary-foreground);
--color-accent: var(--accent);
--color-ring: var(--ring);
+ --color-ok: var(--ok);
+ --color-warn: var(--warn);
+ --color-over: var(--over);
--radius-xl: var(--radius);
--font-sans: var(--font-geist-sans), ui-sans-serif, system-ui, sans-serif;
--font-serif: var(--font-newsreader), ui-serif, Georgia, serif;
diff --git a/components/costs/confidence.tsx b/components/costs/confidence.tsx
new file mode 100644
index 0000000..a57c23a
--- /dev/null
+++ b/components/costs/confidence.tsx
@@ -0,0 +1,14 @@
+import { cn } from "@/lib/utils";
+
+// Konfidenz als Punkte (Konzept: „3 von 3 heißt sicher, 1 von 3 heißt Schätzung“).
+// Die Zahl steht für Bildschirmleser auch im Text.
+export function Confidence({ dots, label }: { dots: number; label: string }) {
+ return (
+
+ {label}
+ {[0, 1, 2].map((i) => (
+
+ ))}
+
+ );
+}
diff --git a/components/costs/cost-section.tsx b/components/costs/cost-section.tsx
new file mode 100644
index 0000000..e90994d
--- /dev/null
+++ b/components/costs/cost-section.tsx
@@ -0,0 +1,132 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useLocale, useTranslations } from "next-intl";
+import { useRef, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { ErrorNotice } from "@/components/ui/notice";
+import { parseNumber } from "@/lib/units";
+
+export type PriceRow = {
+ ingredientId: string;
+ name: string;
+ unit: "g" | "ml" | "piece";
+ pricePerUnit: number | null;
+ source: "receipt" | "manual" | "default" | null;
+ staple: boolean;
+};
+
+const UNITS: Record
= { g: ["g", "kg"], ml: ["ml", "l"], piece: ["piece"] };
+
+// Kosten eines Gerichts: je Zutat der geltende Preis mit Quelle; wer schreiben
+// darf, trägt einen eigenen Preis ein („2,49 € für 500 g“).
+export function CostSection({ rows, currency, canWrite }: { rows: PriceRow[]; currency: string; canWrite: boolean }) {
+ const t = useTranslations("costs");
+ const locale = useLocale();
+ const router = useRouter();
+ const dialog = useRef(null);
+ const [edit, setEdit] = useState(null);
+ const [price, setPrice] = useState("");
+ const [amount, setAmount] = useState("");
+ const [unit, setUnit] = useState("g");
+ const [error, setError] = useState(false);
+ const money = new Intl.NumberFormat(locale, { style: "currency", currency });
+
+ // Preis lesbar: je kg/l oder je Stück.
+ const shown = (r: PriceRow) => {
+ if (r.pricePerUnit === null) return t("noPrice");
+ if (r.unit === "piece") return t("perPiece", { price: money.format(r.pricePerUnit) });
+ return t(r.unit === "g" ? "perKg" : "perL", { price: money.format(r.pricePerUnit * 1000) });
+ };
+
+ function open(r: PriceRow) {
+ setEdit(r);
+ setPrice("");
+ setAmount(r.unit === "piece" ? "1" : "500");
+ setUnit(r.unit);
+ setError(false);
+ dialog.current?.showModal();
+ }
+
+ async function save(e: React.FormEvent) {
+ e.preventDefault();
+ const p = parseNumber(price);
+ const a = parseNumber(amount);
+ if (!edit || p === null || a === null || a <= 0) return setError(true);
+ const res = await fetch("/api/prices", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ ingredientId: edit.ingredientId, price: p, amount: a, unit }),
+ });
+ if (!res.ok) return setError(true);
+ dialog.current?.close();
+ router.refresh();
+ }
+
+ return (
+
+
+ {t("title")}
+
+
+ {rows.map((r) => (
+ -
+
+ {r.name}
+
+ {shown(r)}
+ {r.source ? ` · ${t(`source.${r.source}`)}` : ""}
+ {r.staple ? ` · ${t("staple")}` : ""}
+
+
+ {canWrite ? (
+
+ ) : null}
+
+ ))}
+
+ {t("explain")}
+
+
+ );
+}
diff --git a/components/more/budget-settings.tsx b/components/more/budget-settings.tsx
new file mode 100644
index 0000000..3c9cef8
--- /dev/null
+++ b/components/more/budget-settings.tsx
@@ -0,0 +1,61 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useTranslations } from "next-intl";
+import { useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { ErrorNotice } from "@/components/ui/notice";
+import { parseNumber } from "@/lib/units";
+
+// Richtwert je Runde (leer = keiner) und die Regel für teure Gerichte.
+export function BudgetSettings({ budget, per, currency }: { budget: number | null; per: number; currency: string }) {
+ const t = useTranslations("costs.settings");
+ const router = useRouter();
+ const [value, setValue] = useState(budget ? String(budget).replace(".", ",") : "");
+ const [slots, setSlots] = useState(per);
+ const [state, setState] = useState<"idle" | "saved" | "error">("idle");
+
+ async function save(e: React.FormEvent) {
+ e.preventDefault();
+ const b = value.trim() ? parseNumber(value) : null;
+ if (value.trim() && (b === null || b <= 0)) return setState("error");
+ const res = await fetch("/api/household/budget", {
+ method: "PUT",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ budget: b, expensivePerSlots: slots }),
+ });
+ setState(res.ok ? "saved" : "error");
+ if (res.ok) router.refresh();
+ }
+
+ return (
+
+ );
+}
diff --git a/components/plan/plan-board.tsx b/components/plan/plan-board.tsx
index e78a158..ace4a02 100644
--- a/components/plan/plan-board.tsx
+++ b/components/plan/plan-board.tsx
@@ -5,7 +5,9 @@ import { SortableContext, arrayMove, sortableKeyboardCoordinates, useSortable, v
import { CSS } from "@dnd-kit/utilities";
import { ArrowDown, ArrowUp, GripVertical, Lock, LockOpen, Plus, Replace, Trash2 } from "lucide-react";
import { useRouter } from "next/navigation";
-import { useTranslations } from "next-intl";
+import { useLocale, useTranslations } from "next-intl";
+import { Confidence } from "@/components/costs/confidence";
+import { traffic } from "@/lib/pricing";
import { useRef, useState } from "react";
import { DishPhoto } from "@/components/dishes/dish-tile";
import { Button } from "@/components/ui/button";
@@ -27,6 +29,8 @@ export type Slot = {
reason: Reason | null;
};
type Member = { id: string; name: string };
+export type SlotCost = { perPortion: number | null; confidence: number; cls: "cheap" | "normal" | "expensive" | null };
+export type Budget = { currency: string; budget: number | null; costs: Record };
type Dish = { id: string; title: string };
async function send(method: string, url: string, body?: object) {
@@ -36,8 +40,23 @@ async function send(method: string, url: string, body?: object) {
// Plan einer Runde: Vorschlag, Nachjustieren (ziehen, sperren, ersetzen,
// streichen, Portionen, Koch), Freigeben. Nach der Freigabe bleibt er änderbar.
-export function PlanBoard({ slots: initial, members, dishes, status }: { slots: Slot[]; members: Member[]; dishes: Dish[]; status: string }) {
+export function PlanBoard({
+ slots: initial,
+ members,
+ dishes,
+ status,
+ money,
+}: {
+ slots: Slot[];
+ members: Member[];
+ dishes: Dish[];
+ status: string;
+ money: Budget;
+}) {
const t = useTranslations("plan");
+ const tc = useTranslations("costs");
+ const locale = useLocale();
+ const fmt = new Intl.NumberFormat(locale, { style: "currency", currency: money.currency });
const router = useRouter();
const [slots, setSlots] = useState(initial);
const [busy, setBusy] = useState(false);
@@ -91,6 +110,16 @@ export function PlanBoard({ slots: initial, members, dishes, status }: { slots:
dialog.current?.showModal();
}
+ // Summe der Runde: Kosten pro Portion × Portionen; Gerichte ohne Preis fehlen und werden genannt.
+ const priced = slots.filter((s) => s.dishId && money.costs[s.dishId]?.perPortion != null);
+ const total = priced.reduce((sum, s) => sum + money.costs[s.dishId!]!.perPortion! * s.portions, 0);
+ const light = traffic(total, money.budget);
+ const costLine = (s: Slot) => {
+ const c = s.dishId ? money.costs[s.dishId] : undefined;
+ if (!c || c.perPortion == null) return null;
+ return { text: [tc("perPortion", { price: fmt.format(c.perPortion) }), c.cls && c.cls !== "normal" ? tc(`class.${c.cls}`) : null].filter(Boolean).join(" · "), dots: c.confidence };
+ };
+
const reasonText = (r: Reason | null) => {
if (!r) return null;
return r.k === "wish" ? t("reason.wish", { names: r.n.join(", ") }) : t(`reason.${r.k}`);
@@ -120,6 +149,7 @@ export function PlanBoard({ slots: initial, members, dishes, status }: { slots:
members={members}
busy={busy}
reason={reasonText(slot.reason)}
+ cost={costLine(slot)}
onMove={(by) => move(index, by)}
onChange={(change) => act("PATCH", "/api/plan/slots", { id: slot.id, ...change })}
onRemove={() => act("DELETE", "/api/plan/slots", { id: slot.id })}
@@ -130,6 +160,24 @@ export function PlanBoard({ slots: initial, members, dishes, status }: { slots:
+ {priced.length ? (
+
+
+ {tc("roundTitle")}
+
+
+ {tc("roundTotal", { price: fmt.format(total) })}
+ {light ? (
+
+
+ {tc(`traffic.${light}`, { budget: fmt.format(money.budget!) })}
+
+ ) : null}
+
+ {priced.length < slots.filter((s) => s.dishId).length ? {tc("roundMissing", { n: slots.filter((s) => s.dishId).length - priced.length })}
: null}
+
+ ) : null}
+
{slots.length ? (
diff --git a/db/migrations/0009_default_prices.sql b/db/migrations/0009_default_prices.sql
new file mode 100644
index 0000000..8eacfc3
--- /dev/null
+++ b/db/migrations/0009_default_prices.sql
@@ -0,0 +1,14 @@
+-- Richtpreise (Konzept, „Drei Preisquellen“): eine mitgelieferte Liste, damit
+-- Kosten ab Tag 1 geschätzt werden. Global wie die Zutaten, eingespielt aus
+-- db/seed/prices.de.json; eigene Preise und Bonpreise (price_points) gehen vor.
+create table default_prices (
+ ingredient_id uuid not null references ingredients (id) on delete cascade,
+ currency text not null check (currency ~ '^[A-Z]{3}$'),
+ price_per_unit numeric(12, 6) not null check (price_per_unit >= 0), -- je g, ml oder Stück
+ unit text not null check (unit in ('g', 'ml', 'piece')),
+ primary key (ingredient_id, currency)
+);
+alter table default_prices enable row level security;
+alter table default_prices force row level security;
+create policy default_prices_read on default_prices for select using (true);
+create policy default_prices_maintain on default_prices using (app_maintenance()) with check (app_maintenance());
diff --git a/db/seed/prices.de.json b/db/seed/prices.de.json
new file mode 100644
index 0000000..1529480
--- /dev/null
+++ b/db/seed/prices.de.json
@@ -0,0 +1,1566 @@
+{
+ "currency": "EUR",
+ "note": "Richtpreise: grobe Schätzung Supermarkt Deutschland, Herbst 2026. Bon- und eigene Preise gehen vor.",
+ "prices": [
+ {
+ "key": "potato",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "floury_potato",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "sweet_potato",
+ "eur": 2.99,
+ "per": 1000.0
+ },
+ {
+ "key": "onion",
+ "eur": 0.25,
+ "per": 1.0
+ },
+ {
+ "key": "red_onion",
+ "eur": 0.35,
+ "per": 1.0
+ },
+ {
+ "key": "spring_onion",
+ "eur": 0.99,
+ "per": 8.0
+ },
+ {
+ "key": "shallot",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "garlic",
+ "eur": 0.15,
+ "per": 1.0
+ },
+ {
+ "key": "leek",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "carrot",
+ "eur": 1.29,
+ "per": 1000.0
+ },
+ {
+ "key": "celeriac",
+ "eur": 2.49,
+ "per": 1000.0
+ },
+ {
+ "key": "celery",
+ "eur": 1.49,
+ "per": 6.0
+ },
+ {
+ "key": "parsnip",
+ "eur": 2.49,
+ "per": 500.0
+ },
+ {
+ "key": "beetroot",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "soup_greens",
+ "eur": 1.49,
+ "per": 1.0
+ },
+ {
+ "key": "tomato",
+ "eur": 2.99,
+ "per": 1000.0
+ },
+ {
+ "key": "cherry_tomato",
+ "eur": 1.99,
+ "per": 250.0
+ },
+ {
+ "key": "cucumber",
+ "eur": 0.79,
+ "per": 1.0
+ },
+ {
+ "key": "bell_pepper_red",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "bell_pepper_yellow",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "bell_pepper_green",
+ "eur": 0.79,
+ "per": 1.0
+ },
+ {
+ "key": "zucchini",
+ "eur": 0.89,
+ "per": 1.0
+ },
+ {
+ "key": "eggplant",
+ "eur": 1.29,
+ "per": 1.0
+ },
+ {
+ "key": "broccoli",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "cauliflower",
+ "eur": 2.49,
+ "per": 1.0
+ },
+ {
+ "key": "white_cabbage",
+ "eur": 1.29,
+ "per": 1000.0
+ },
+ {
+ "key": "red_cabbage",
+ "eur": 1.49,
+ "per": 1000.0
+ },
+ {
+ "key": "savoy_cabbage",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "brussels_sprouts",
+ "eur": 2.49,
+ "per": 500.0
+ },
+ {
+ "key": "kohlrabi",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "spinach",
+ "eur": 1.99,
+ "per": 250.0
+ },
+ {
+ "key": "lettuce",
+ "eur": 1.29,
+ "per": 1.0
+ },
+ {
+ "key": "iceberg_lettuce",
+ "eur": 1.19,
+ "per": 1.0
+ },
+ {
+ "key": "romaine",
+ "eur": 1.49,
+ "per": 1.0
+ },
+ {
+ "key": "lambs_lettuce",
+ "eur": 1.79,
+ "per": 150.0
+ },
+ {
+ "key": "rocket",
+ "eur": 1.49,
+ "per": 125.0
+ },
+ {
+ "key": "mushrooms",
+ "eur": 1.99,
+ "per": 400.0
+ },
+ {
+ "key": "green_beans",
+ "eur": 2.49,
+ "per": 500.0
+ },
+ {
+ "key": "pumpkin",
+ "eur": 2.49,
+ "per": 1000.0
+ },
+ {
+ "key": "fennel",
+ "eur": 1.29,
+ "per": 1.0
+ },
+ {
+ "key": "asparagus_white",
+ "eur": 8.99,
+ "per": 1000.0
+ },
+ {
+ "key": "asparagus_green",
+ "eur": 3.99,
+ "per": 500.0
+ },
+ {
+ "key": "radish",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "chili_pepper",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "ginger",
+ "eur": 5.99,
+ "per": 1000.0
+ },
+ {
+ "key": "pak_choi",
+ "eur": 1.49,
+ "per": 1.0
+ },
+ {
+ "key": "bean_sprouts",
+ "eur": 1.49,
+ "per": 200.0
+ },
+ {
+ "key": "apple",
+ "eur": 0.4,
+ "per": 1.0
+ },
+ {
+ "key": "banana",
+ "eur": 0.25,
+ "per": 1.0
+ },
+ {
+ "key": "pear",
+ "eur": 0.5,
+ "per": 1.0
+ },
+ {
+ "key": "orange",
+ "eur": 0.45,
+ "per": 1.0
+ },
+ {
+ "key": "lemon",
+ "eur": 0.4,
+ "per": 1.0
+ },
+ {
+ "key": "lime",
+ "eur": 0.35,
+ "per": 1.0
+ },
+ {
+ "key": "clementine",
+ "eur": 0.25,
+ "per": 1.0
+ },
+ {
+ "key": "grapes",
+ "eur": 2.99,
+ "per": 500.0
+ },
+ {
+ "key": "strawberries",
+ "eur": 2.99,
+ "per": 500.0
+ },
+ {
+ "key": "raspberries",
+ "eur": 2.49,
+ "per": 125.0
+ },
+ {
+ "key": "blueberries",
+ "eur": 2.49,
+ "per": 250.0
+ },
+ {
+ "key": "kiwi",
+ "eur": 0.35,
+ "per": 1.0
+ },
+ {
+ "key": "pineapple",
+ "eur": 2.49,
+ "per": 1.0
+ },
+ {
+ "key": "mango",
+ "eur": 1.49,
+ "per": 1.0
+ },
+ {
+ "key": "avocado",
+ "eur": 1.19,
+ "per": 1.0
+ },
+ {
+ "key": "peach",
+ "eur": 0.6,
+ "per": 1.0
+ },
+ {
+ "key": "plums",
+ "eur": 2.99,
+ "per": 1000.0
+ },
+ {
+ "key": "cherries",
+ "eur": 4.99,
+ "per": 500.0
+ },
+ {
+ "key": "rhubarb",
+ "eur": 3.99,
+ "per": 1000.0
+ },
+ {
+ "key": "parsley",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "chives",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "dill",
+ "eur": 0.99,
+ "per": 1.0
+ },
+ {
+ "key": "basil",
+ "eur": 1.79,
+ "per": 1.0
+ },
+ {
+ "key": "coriander",
+ "eur": 1.29,
+ "per": 1.0
+ },
+ {
+ "key": "mint",
+ "eur": 1.29,
+ "per": 1.0
+ },
+ {
+ "key": "rosemary",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "thyme",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "sage",
+ "eur": 0.1,
+ "per": 1.0
+ },
+ {
+ "key": "lemongrass",
+ "eur": 0.6,
+ "per": 1.0
+ },
+ {
+ "key": "bread",
+ "eur": 2.49,
+ "per": 750.0
+ },
+ {
+ "key": "wholemeal_bread",
+ "eur": 2.79,
+ "per": 750.0
+ },
+ {
+ "key": "toast_bread",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "bread_rolls",
+ "eur": 0.35,
+ "per": 1.0
+ },
+ {
+ "key": "baguette",
+ "eur": 1.19,
+ "per": 1.0
+ },
+ {
+ "key": "tortilla_wraps",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "burger_buns",
+ "eur": 0.4,
+ "per": 1.0
+ },
+ {
+ "key": "pita_bread",
+ "eur": 0.7,
+ "per": 1.0
+ },
+ {
+ "key": "ground_beef",
+ "eur": 3.99,
+ "per": 400.0
+ },
+ {
+ "key": "ground_mixed",
+ "eur": 3.49,
+ "per": 500.0
+ },
+ {
+ "key": "ground_pork",
+ "eur": 2.99,
+ "per": 500.0
+ },
+ {
+ "key": "ground_lamb",
+ "eur": 4.99,
+ "per": 400.0
+ },
+ {
+ "key": "beef_stew",
+ "eur": 6.99,
+ "per": 500.0
+ },
+ {
+ "key": "beef_steak",
+ "eur": 6.99,
+ "per": 300.0
+ },
+ {
+ "key": "beef_roast",
+ "eur": 16.99,
+ "per": 1000.0
+ },
+ {
+ "key": "beef_soup_meat",
+ "eur": 9.99,
+ "per": 1000.0
+ },
+ {
+ "key": "pork_schnitzel",
+ "eur": 4.99,
+ "per": 500.0
+ },
+ {
+ "key": "pork_chop",
+ "eur": 4.49,
+ "per": 600.0
+ },
+ {
+ "key": "pork_tenderloin",
+ "eur": 5.99,
+ "per": 500.0
+ },
+ {
+ "key": "pork_neck",
+ "eur": 6.99,
+ "per": 1000.0
+ },
+ {
+ "key": "pork_belly",
+ "eur": 6.99,
+ "per": 1000.0
+ },
+ {
+ "key": "kassler",
+ "eur": 4.99,
+ "per": 500.0
+ },
+ {
+ "key": "chicken_breast",
+ "eur": 4.99,
+ "per": 400.0
+ },
+ {
+ "key": "chicken_thigh",
+ "eur": 5.99,
+ "per": 1000.0
+ },
+ {
+ "key": "chicken_drumsticks",
+ "eur": 4.49,
+ "per": 1000.0
+ },
+ {
+ "key": "chicken_wings",
+ "eur": 4.99,
+ "per": 1000.0
+ },
+ {
+ "key": "whole_chicken",
+ "eur": 4.99,
+ "per": 1200.0
+ },
+ {
+ "key": "chicken_strips",
+ "eur": 4.49,
+ "per": 400.0
+ },
+ {
+ "key": "turkey_breast",
+ "eur": 5.99,
+ "per": 500.0
+ },
+ {
+ "key": "ground_turkey",
+ "eur": 3.99,
+ "per": 400.0
+ },
+ {
+ "key": "bacon_diced",
+ "eur": 1.49,
+ "per": 125.0
+ },
+ {
+ "key": "bacon_rashers",
+ "eur": 1.79,
+ "per": 125.0
+ },
+ {
+ "key": "ham_cooked",
+ "eur": 1.49,
+ "per": 150.0
+ },
+ {
+ "key": "ham_cured",
+ "eur": 2.29,
+ "per": 100.0
+ },
+ {
+ "key": "salami",
+ "eur": 1.79,
+ "per": 100.0
+ },
+ {
+ "key": "chorizo",
+ "eur": 2.49,
+ "per": 200.0
+ },
+ {
+ "key": "frankfurters",
+ "eur": 0.5,
+ "per": 1.0
+ },
+ {
+ "key": "bratwurst",
+ "eur": 0.7,
+ "per": 1.0
+ },
+ {
+ "key": "pork_sausages",
+ "eur": 0.45,
+ "per": 1.0
+ },
+ {
+ "key": "smoked_sausage",
+ "eur": 1.0,
+ "per": 1.0
+ },
+ {
+ "key": "liver_sausage",
+ "eur": 1.29,
+ "per": 150.0
+ },
+ {
+ "key": "salmon_fillet",
+ "eur": 5.99,
+ "per": 250.0
+ },
+ {
+ "key": "smoked_salmon",
+ "eur": 2.99,
+ "per": 150.0
+ },
+ {
+ "key": "cod_fillet",
+ "eur": 5.99,
+ "per": 400.0
+ },
+ {
+ "key": "pollock_fillet",
+ "eur": 3.99,
+ "per": 400.0
+ },
+ {
+ "key": "hake",
+ "eur": 4.49,
+ "per": 400.0
+ },
+ {
+ "key": "smoked_haddock",
+ "eur": 4.99,
+ "per": 300.0
+ },
+ {
+ "key": "prawns",
+ "eur": 3.99,
+ "per": 200.0
+ },
+ {
+ "key": "mussels",
+ "eur": 5.99,
+ "per": 1000.0
+ },
+ {
+ "key": "squid",
+ "eur": 4.99,
+ "per": 400.0
+ },
+ {
+ "key": "milk",
+ "eur": 1.15,
+ "per": 1000.0
+ },
+ {
+ "key": "butter",
+ "eur": 2.39,
+ "per": 250.0
+ },
+ {
+ "key": "cream",
+ "eur": 0.99,
+ "per": 200.0
+ },
+ {
+ "key": "sour_cream",
+ "eur": 0.89,
+ "per": 200.0
+ },
+ {
+ "key": "creme_fraiche",
+ "eur": 0.99,
+ "per": 150.0
+ },
+ {
+ "key": "schmand",
+ "eur": 0.89,
+ "per": 200.0
+ },
+ {
+ "key": "quark",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "yogurt",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "greek_yogurt",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "clarified_butter",
+ "eur": 3.49,
+ "per": 500.0
+ },
+ {
+ "key": "oat_milk",
+ "eur": 1.49,
+ "per": 1000.0
+ },
+ {
+ "key": "gouda",
+ "eur": 2.29,
+ "per": 400.0
+ },
+ {
+ "key": "grated_cheese",
+ "eur": 1.79,
+ "per": 200.0
+ },
+ {
+ "key": "emmental",
+ "eur": 1.99,
+ "per": 250.0
+ },
+ {
+ "key": "parmesan",
+ "eur": 2.99,
+ "per": 150.0
+ },
+ {
+ "key": "mozzarella",
+ "eur": 0.89,
+ "per": 125.0
+ },
+ {
+ "key": "feta",
+ "eur": 1.79,
+ "per": 200.0
+ },
+ {
+ "key": "cheddar",
+ "eur": 2.49,
+ "per": 200.0
+ },
+ {
+ "key": "cream_cheese",
+ "eur": 1.29,
+ "per": 175.0
+ },
+ {
+ "key": "mascarpone",
+ "eur": 1.79,
+ "per": 250.0
+ },
+ {
+ "key": "ricotta",
+ "eur": 1.69,
+ "per": 250.0
+ },
+ {
+ "key": "goat_cheese",
+ "eur": 1.99,
+ "per": 150.0
+ },
+ {
+ "key": "camembert",
+ "eur": 1.49,
+ "per": 250.0
+ },
+ {
+ "key": "mountain_cheese",
+ "eur": 3.49,
+ "per": 250.0
+ },
+ {
+ "key": "gruyere",
+ "eur": 3.99,
+ "per": 250.0
+ },
+ {
+ "key": "manchego",
+ "eur": 3.49,
+ "per": 250.0
+ },
+ {
+ "key": "cheese_slices",
+ "eur": 1.49,
+ "per": 200.0
+ },
+ {
+ "key": "egg",
+ "eur": 0.3,
+ "per": 1.0
+ },
+ {
+ "key": "tofu",
+ "eur": 1.99,
+ "per": 400.0
+ },
+ {
+ "key": "gnocchi",
+ "eur": 1.29,
+ "per": 500.0
+ },
+ {
+ "key": "fresh_tortellini",
+ "eur": 1.99,
+ "per": 400.0
+ },
+ {
+ "key": "fresh_tagliatelle",
+ "eur": 1.79,
+ "per": 400.0
+ },
+ {
+ "key": "maultaschen",
+ "eur": 0.45,
+ "per": 1.0
+ },
+ {
+ "key": "spaetzle",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "puff_pastry",
+ "eur": 1.29,
+ "per": 275.0
+ },
+ {
+ "key": "shortcrust_pastry",
+ "eur": 1.29,
+ "per": 275.0
+ },
+ {
+ "key": "pizza_dough",
+ "eur": 1.49,
+ "per": 400.0
+ },
+ {
+ "key": "flammkuchen_dough",
+ "eur": 1.49,
+ "per": 260.0
+ },
+ {
+ "key": "fresh_yeast",
+ "eur": 0.12,
+ "per": 42.0
+ },
+ {
+ "key": "hummus",
+ "eur": 1.49,
+ "per": 200.0
+ },
+ {
+ "key": "frozen_peas",
+ "eur": 1.49,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_spinach",
+ "eur": 1.29,
+ "per": 750.0
+ },
+ {
+ "key": "creamed_spinach",
+ "eur": 1.49,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_mixed_veg",
+ "eur": 1.69,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_broccoli",
+ "eur": 1.79,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_green_beans",
+ "eur": 1.79,
+ "per": 750.0
+ },
+ {
+ "key": "fish_fingers",
+ "eur": 0.25,
+ "per": 1.0
+ },
+ {
+ "key": "frozen_fish_fillet",
+ "eur": 3.99,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_prawns",
+ "eur": 3.99,
+ "per": 250.0
+ },
+ {
+ "key": "oven_fries",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "potato_croquettes",
+ "eur": 1.79,
+ "per": 750.0
+ },
+ {
+ "key": "frozen_berries",
+ "eur": 2.99,
+ "per": 500.0
+ },
+ {
+ "key": "vanilla_ice_cream",
+ "eur": 2.49,
+ "per": 900.0
+ },
+ {
+ "key": "spaghetti",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "penne",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "fusilli",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "macaroni",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "tagliatelle",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "lasagne_sheets",
+ "eur": 1.29,
+ "per": 500.0
+ },
+ {
+ "key": "soup_pasta",
+ "eur": 0.89,
+ "per": 500.0
+ },
+ {
+ "key": "egg_noodles",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "rice_noodles",
+ "eur": 1.79,
+ "per": 250.0
+ },
+ {
+ "key": "long_grain_rice",
+ "eur": 1.49,
+ "per": 1000.0
+ },
+ {
+ "key": "basmati_rice",
+ "eur": 2.49,
+ "per": 1000.0
+ },
+ {
+ "key": "risotto_rice",
+ "eur": 2.29,
+ "per": 1000.0
+ },
+ {
+ "key": "paella_rice",
+ "eur": 2.49,
+ "per": 1000.0
+ },
+ {
+ "key": "pudding_rice",
+ "eur": 1.29,
+ "per": 1000.0
+ },
+ {
+ "key": "couscous",
+ "eur": 1.69,
+ "per": 500.0
+ },
+ {
+ "key": "bulgur",
+ "eur": 1.69,
+ "per": 500.0
+ },
+ {
+ "key": "quinoa",
+ "eur": 2.49,
+ "per": 500.0
+ },
+ {
+ "key": "polenta",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "red_lentils",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "brown_lentils",
+ "eur": 1.79,
+ "per": 500.0
+ },
+ {
+ "key": "dried_chickpeas",
+ "eur": 1.79,
+ "per": 500.0
+ },
+ {
+ "key": "dried_white_beans",
+ "eur": 1.79,
+ "per": 500.0
+ },
+ {
+ "key": "split_peas",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "chopped_tomatoes",
+ "eur": 0.69,
+ "per": 400.0
+ },
+ {
+ "key": "peeled_tomatoes",
+ "eur": 0.69,
+ "per": 400.0
+ },
+ {
+ "key": "passata",
+ "eur": 0.79,
+ "per": 500.0
+ },
+ {
+ "key": "tomato_paste",
+ "eur": 0.59,
+ "per": 200.0
+ },
+ {
+ "key": "sundried_tomatoes",
+ "eur": 2.29,
+ "per": 280.0
+ },
+ {
+ "key": "kidney_beans",
+ "eur": 0.79,
+ "per": 400.0
+ },
+ {
+ "key": "black_beans",
+ "eur": 0.99,
+ "per": 400.0
+ },
+ {
+ "key": "chickpeas",
+ "eur": 0.79,
+ "per": 400.0
+ },
+ {
+ "key": "white_beans",
+ "eur": 0.79,
+ "per": 400.0
+ },
+ {
+ "key": "baked_beans",
+ "eur": 0.99,
+ "per": 415.0
+ },
+ {
+ "key": "lentils_canned",
+ "eur": 1.29,
+ "per": 800.0
+ },
+ {
+ "key": "sweetcorn",
+ "eur": 0.89,
+ "per": 285.0
+ },
+ {
+ "key": "canned_mushrooms",
+ "eur": 1.29,
+ "per": 580.0
+ },
+ {
+ "key": "tuna_canned",
+ "eur": 1.49,
+ "per": 185.0
+ },
+ {
+ "key": "anchovies",
+ "eur": 1.99,
+ "per": 50.0
+ },
+ {
+ "key": "coconut_milk",
+ "eur": 1.29,
+ "per": 400.0
+ },
+ {
+ "key": "sauerkraut",
+ "eur": 0.99,
+ "per": 770.0
+ },
+ {
+ "key": "red_cabbage_jar",
+ "eur": 1.49,
+ "per": 720.0
+ },
+ {
+ "key": "gherkins",
+ "eur": 1.49,
+ "per": 670.0
+ },
+ {
+ "key": "black_olives",
+ "eur": 1.29,
+ "per": 160.0
+ },
+ {
+ "key": "green_olives",
+ "eur": 1.29,
+ "per": 160.0
+ },
+ {
+ "key": "capers",
+ "eur": 1.49,
+ "per": 100.0
+ },
+ {
+ "key": "roasted_peppers",
+ "eur": 1.99,
+ "per": 450.0
+ },
+ {
+ "key": "canned_peaches",
+ "eur": 1.49,
+ "per": 820.0
+ },
+ {
+ "key": "applesauce",
+ "eur": 1.29,
+ "per": 700.0
+ },
+ {
+ "key": "condensed_milk",
+ "eur": 1.49,
+ "per": 400.0
+ },
+ {
+ "key": "vegetable_stock",
+ "eur": 1.49,
+ "per": 1000.0
+ },
+ {
+ "key": "chicken_stock",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "beef_stock",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "fish_stock",
+ "eur": 2.49,
+ "per": 400.0
+ },
+ {
+ "key": "stock_cube",
+ "eur": 0.15,
+ "per": 1.0
+ },
+ {
+ "key": "gravy",
+ "eur": 1.49,
+ "per": 500.0
+ },
+ {
+ "key": "mustard",
+ "eur": 0.79,
+ "per": 250.0
+ },
+ {
+ "key": "dijon_mustard",
+ "eur": 1.99,
+ "per": 200.0
+ },
+ {
+ "key": "ketchup",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "mayonnaise",
+ "eur": 1.79,
+ "per": 500.0
+ },
+ {
+ "key": "soy_sauce",
+ "eur": 1.99,
+ "per": 250.0
+ },
+ {
+ "key": "worcestershire_sauce",
+ "eur": 2.49,
+ "per": 150.0
+ },
+ {
+ "key": "hot_sauce",
+ "eur": 2.49,
+ "per": 150.0
+ },
+ {
+ "key": "sweet_chili_sauce",
+ "eur": 1.99,
+ "per": 300.0
+ },
+ {
+ "key": "bbq_sauce",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "pesto",
+ "eur": 2.29,
+ "per": 190.0
+ },
+ {
+ "key": "tomato_sauce_jar",
+ "eur": 1.79,
+ "per": 500.0
+ },
+ {
+ "key": "red_curry_paste",
+ "eur": 2.49,
+ "per": 110.0
+ },
+ {
+ "key": "horseradish",
+ "eur": 1.49,
+ "per": 200.0
+ },
+ {
+ "key": "salsa_dip",
+ "eur": 1.99,
+ "per": 315.0
+ },
+ {
+ "key": "salt",
+ "eur": 0.49,
+ "per": 500.0
+ },
+ {
+ "key": "black_pepper",
+ "eur": 1.99,
+ "per": 100.0
+ },
+ {
+ "key": "paprika",
+ "eur": 1.49,
+ "per": 100.0
+ },
+ {
+ "key": "smoked_paprika",
+ "eur": 1.99,
+ "per": 75.0
+ },
+ {
+ "key": "cumin",
+ "eur": 1.79,
+ "per": 50.0
+ },
+ {
+ "key": "curry_powder",
+ "eur": 1.79,
+ "per": 100.0
+ },
+ {
+ "key": "turmeric",
+ "eur": 1.49,
+ "per": 50.0
+ },
+ {
+ "key": "cinnamon",
+ "eur": 1.29,
+ "per": 50.0
+ },
+ {
+ "key": "nutmeg",
+ "eur": 1.99,
+ "per": 50.0
+ },
+ {
+ "key": "oregano",
+ "eur": 0.99,
+ "per": 15.0
+ },
+ {
+ "key": "italian_herbs",
+ "eur": 0.99,
+ "per": 20.0
+ },
+ {
+ "key": "chili_flakes",
+ "eur": 1.49,
+ "per": 50.0
+ },
+ {
+ "key": "olive_oil",
+ "eur": 5.99,
+ "per": 750.0
+ },
+ {
+ "key": "sunflower_oil",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "rapeseed_oil",
+ "eur": 1.99,
+ "per": 1000.0
+ },
+ {
+ "key": "sesame_oil",
+ "eur": 2.49,
+ "per": 250.0
+ },
+ {
+ "key": "balsamic_vinegar",
+ "eur": 1.99,
+ "per": 500.0
+ },
+ {
+ "key": "white_wine_vinegar",
+ "eur": 1.29,
+ "per": 750.0
+ },
+ {
+ "key": "flour",
+ "eur": 0.79,
+ "per": 1000.0
+ },
+ {
+ "key": "cornstarch",
+ "eur": 1.29,
+ "per": 400.0
+ },
+ {
+ "key": "sugar",
+ "eur": 0.99,
+ "per": 1000.0
+ },
+ {
+ "key": "brown_sugar",
+ "eur": 1.79,
+ "per": 1000.0
+ },
+ {
+ "key": "icing_sugar",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "vanilla_sugar",
+ "eur": 0.99,
+ "per": 40.0
+ },
+ {
+ "key": "baking_powder",
+ "eur": 0.79,
+ "per": 45.0
+ },
+ {
+ "key": "dry_yeast",
+ "eur": 0.59,
+ "per": 21.0
+ },
+ {
+ "key": "breadcrumbs",
+ "eur": 0.99,
+ "per": 400.0
+ },
+ {
+ "key": "cocoa_powder",
+ "eur": 2.49,
+ "per": 250.0
+ },
+ {
+ "key": "dark_chocolate",
+ "eur": 1.29,
+ "per": 100.0
+ },
+ {
+ "key": "semolina",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "rolled_oats",
+ "eur": 0.89,
+ "per": 500.0
+ },
+ {
+ "key": "muesli",
+ "eur": 2.49,
+ "per": 750.0
+ },
+ {
+ "key": "cornflakes",
+ "eur": 1.99,
+ "per": 375.0
+ },
+ {
+ "key": "honey",
+ "eur": 3.99,
+ "per": 500.0
+ },
+ {
+ "key": "jam",
+ "eur": 1.99,
+ "per": 450.0
+ },
+ {
+ "key": "chocolate_spread",
+ "eur": 2.99,
+ "per": 400.0
+ },
+ {
+ "key": "peanut_butter",
+ "eur": 2.49,
+ "per": 350.0
+ },
+ {
+ "key": "maple_syrup",
+ "eur": 5.99,
+ "per": 250.0
+ },
+ {
+ "key": "walnuts",
+ "eur": 2.49,
+ "per": 200.0
+ },
+ {
+ "key": "hazelnuts",
+ "eur": 2.29,
+ "per": 200.0
+ },
+ {
+ "key": "almonds",
+ "eur": 2.49,
+ "per": 200.0
+ },
+ {
+ "key": "ground_almonds",
+ "eur": 2.29,
+ "per": 200.0
+ },
+ {
+ "key": "flaked_almonds",
+ "eur": 2.29,
+ "per": 200.0
+ },
+ {
+ "key": "pine_nuts",
+ "eur": 2.99,
+ "per": 75.0
+ },
+ {
+ "key": "cashews",
+ "eur": 2.79,
+ "per": 200.0
+ },
+ {
+ "key": "peanuts",
+ "eur": 1.99,
+ "per": 200.0
+ },
+ {
+ "key": "sunflower_seeds",
+ "eur": 1.29,
+ "per": 250.0
+ },
+ {
+ "key": "pumpkin_seeds",
+ "eur": 1.99,
+ "per": 200.0
+ },
+ {
+ "key": "sesame_seeds",
+ "eur": 1.49,
+ "per": 250.0
+ },
+ {
+ "key": "raisins",
+ "eur": 1.49,
+ "per": 250.0
+ },
+ {
+ "key": "dried_apricots",
+ "eur": 2.29,
+ "per": 250.0
+ },
+ {
+ "key": "desiccated_coconut",
+ "eur": 1.29,
+ "per": 200.0
+ },
+ {
+ "key": "milk_chocolate",
+ "eur": 1.29,
+ "per": 100.0
+ },
+ {
+ "key": "crisps",
+ "eur": 1.79,
+ "per": 150.0
+ },
+ {
+ "key": "butter_biscuits",
+ "eur": 1.49,
+ "per": 250.0
+ },
+ {
+ "key": "ladyfingers",
+ "eur": 1.79,
+ "per": 200.0
+ },
+ {
+ "key": "mineral_water",
+ "eur": 0.25,
+ "per": 1500.0
+ },
+ {
+ "key": "apple_juice",
+ "eur": 1.49,
+ "per": 1000.0
+ },
+ {
+ "key": "orange_juice",
+ "eur": 1.79,
+ "per": 1000.0
+ },
+ {
+ "key": "white_wine",
+ "eur": 4.99,
+ "per": 750.0
+ },
+ {
+ "key": "red_wine",
+ "eur": 4.99,
+ "per": 750.0
+ },
+ {
+ "key": "beer",
+ "eur": 0.99,
+ "per": 500.0
+ },
+ {
+ "key": "ground_coffee",
+ "eur": 5.99,
+ "per": 500.0
+ },
+ {
+ "key": "black_tea",
+ "eur": 0.08,
+ "per": 1.0
+ }
+ ]
+}
\ No newline at end of file
diff --git a/e2e/gerichte.spec.ts b/e2e/gerichte.spec.ts
index 1f62d9a..9363205 100644
--- a/e2e/gerichte.spec.ts
+++ b/e2e/gerichte.spec.ts
@@ -59,8 +59,8 @@ test("an own dish is created with searched ingredients, then edited", async ({ p
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Gemüsecurry");
await expect(page.locator("main")).toContainText("vegetarisch");
// 2 Zwiebeln für 4 Portionen → 1 Zwiebel für 2 Portionen (Einzahl).
- await expect(page.locator("ul li", { hasText: "Zwiebel" })).toContainText(/^1\s*Zwiebel$/);
- await expect(page.locator("ul li", { hasText: "Kokosmilch" })).toContainText("200 ml");
+ await expect(page.locator("ul li", { hasText: "Zwiebel" }).first()).toContainText(/^1\s*Zwiebel$/);
+ await expect(page.locator("ul li", { hasText: "Kokosmilch" }).first()).toContainText("200 ml");
await page.getByRole("link", { name: "Bearbeiten" }).click();
await expect(page.locator("#title")).toHaveValue("Gemüsecurry");
diff --git a/e2e/plan.spec.ts b/e2e/plan.spec.ts
index 58d7b70..2098223 100644
--- a/e2e/plan.spec.ts
+++ b/e2e/plan.spec.ts
@@ -30,9 +30,9 @@ test("a locked slot survives a new suggestion; portions and cook change", async
await expect(items(page).filter({ hasText: "Gemüsecurry mit Reis" }).getByRole("button", { name: /sperren/ })).toHaveAttribute("aria-pressed", "true");
const spaghetti = items(page).filter({ hasText: "Spaghetti Bolognese" });
- const before = await spaghetti.getByText(/Portion/).innerText();
+ const before = await spaghetti.getByText(/^\d+ Portion(en)?$/).innerText();
await spaghetti.getByRole("button", { name: "Spaghetti Bolognese: mehr Portionen" }).click();
- await expect(spaghetti.getByText(/Portion/)).not.toHaveText(before);
+ await expect(spaghetti.getByText(/^\d+ Portion(en)?$/)).not.toHaveText(before);
const lentils = items(page).filter({ hasText: "Linseneintopf" });
await lentils.getByRole("combobox", { name: "Wer kocht Linseneintopf?" }).selectOption({ label: "Koch: Ben" });
@@ -64,6 +64,33 @@ test("a dish can be replaced, moved by keyboard and removed", async ({ page }) =
await expect(page.getByText("3 Mahlzeiten")).toBeVisible();
});
+test("costs: per portion in the plan, a budget light, and an own price on the dish", async ({ page }) => {
+ await page.goto("/plan");
+ const cost = page.locator("section", { hasText: "Kosten der Runde" });
+ await expect(cost).toContainText(/etwa \d+,\d{2}\s€/);
+ await expect(items(page).first()).toContainText(/pro Portion/);
+ await expect(items(page).first().getByText("Kosten unsicher")).toBeAttached(); // nur Richtpreise: keine Punkte
+
+ // Richtwert in „Mehr“: 1 € ist sicher zu wenig → rot, mit Wort.
+ await page.goto("/mehr");
+ await page.getByLabel("Richtwert je Runde in EUR").fill("1");
+ await page.getByRole("button", { name: "Speichern" }).first().click();
+ await expect(page.getByText("Gespeichert.")).toBeVisible();
+ await page.goto("/plan");
+ await expect(cost).toContainText("deutlich über 1,00");
+
+ // Eigener Preis an einer Zutat des Gerichts.
+ await page.goto("/gerichte");
+ await page.getByRole("link", { name: /Spaghetti Bolognese/ }).click();
+ const section = page.locator("section", { hasText: "Kosten" }).last();
+ await section.getByRole("button", { name: "Preis für Spaghetti eintragen" }).click();
+ const dialog = page.getByRole("dialog");
+ await dialog.getByLabel("Preis in EUR").fill("1,99");
+ await dialog.getByLabel("für").fill("500");
+ await dialog.getByRole("button", { name: "Speichern" }).click();
+ await expect(section.locator("li", { hasText: "Spaghetti" })).toContainText("3,98 € je kg · eigener Preis");
+});
+
test("approving shows the plan on Today and closes wishing", async ({ page }) => {
await page.goto("/plan");
const first = (await titles(page).first().innerText()).trim();
diff --git a/lib/backup.ts b/lib/backup.ts
index d2d2aac..46f3791 100644
--- a/lib/backup.ts
+++ b/lib/backup.ts
@@ -57,6 +57,7 @@ export const EXCLUDED: Record = {
starter_dish_steps: "Vorlage aus db/seed",
store_chains: "Vorlage aus db/seed",
chain_aisles: "Vorlage aus db/seed",
+ default_prices: "Richtpreise aus db/seed/prices.de.json",
};
const FORMAT = 1;
diff --git a/lib/costs.ts b/lib/costs.ts
new file mode 100644
index 0000000..dd02fcc
--- /dev/null
+++ b/lib/costs.ts
@@ -0,0 +1,79 @@
+import "server-only";
+import type { PoolClient } from "pg";
+import { currentPrices, dishCost, priceClasses, type DishCost, type PriceClass, type PricePoint } from "./pricing";
+import { toBase, type BaseUnit, type InputUnit } from "./units";
+
+// Preise und Kosten aus der Datenbank (Rechnen in lib/pricing.ts).
+
+/** Grundvorrat für die Kosten: was die 5-%-Pauschale abdeckt (Gewürze, Öl und Essig,
+ * Backzutaten) oder am Gericht als Grundvorrat markiert ist. Nicht `pantry_default` —
+ * das steuert nur die Frage „Hast du noch?“; Nudeln und Dosentomaten kosten Geld. */
+export const STAPLE_SQL = "(di.is_staple or i.category in ('spices', 'oil_vinegar', 'baking'))";
+
+export async function householdCurrency(client: PoolClient): Promise {
+ return ((await client.query("select currency from households")).rows[0]?.currency as string | undefined) ?? "EUR";
+}
+
+/** Alle Preispunkte des Haushalts plus Richtpreise in seiner Währung. */
+export async function loadPrices(client: PoolClient, currency: string): Promise