Commit Graph

17 Commits

Author SHA1 Message Date
Henrik Jess Nielsen
d2f6746557 fix(qty): edited quantity shows green 'changed', not an alarming red
Editing a quantity always saved, but the 'modified' class painted the field
accent-red, which read as a validation error ('can't change it'). Recolor it
to the green success style used by the actual-price field. Also make updateQty
call recalcAll so the estimate/budget react to quantity changes too, not just
the meal stats.
2026-10-30 13:55:32 +01:00
Henrik Jess Nielsen
b688fa491a feat(stats): Estimeret total uses real offer prices for matched items
When a catalog item matches a current Lübeck offer, compute its line cost
from the offer instead of the hardcoded estimate: offer price is per unit
(e.g. per 100 g), so multiply by the item's quantity (qtyToKg × €/kg × rate).
Only weight-based offers (g/kg) are converted — units that can't be matched
cleanly keep the estimate, so the total never goes garbage. Data-offer-*
attrs on matched rows; recalcAll prefers the offer line price. The total (and
the budget-per-day) now move toward actual prices as matches land.
2026-10-30 13:45:25 +01:00
Henrik Jess Nielsen
abd50a7569 feat(stats): budget-per-day block + computed savings
- New budget block: 'Pris pr. aftensmadsdag' = Estimeret total ÷
  Aftensmadsdage, checked against a ~200 kr/day budget (green 'holder ✓',
  red 'over budget' with accent background). Updates live with the list.
- Estimeret besparelse is no longer a hardcoded ~1.800: it's 35% of actual
  spend once prices are entered, else 35% of the live estimate.
2026-10-30 13:42:59 +01:00
Henrik Jess Nielsen
92d1ab62a0 feat(list): grouped Basisvarer staples, deduped against the catalog
Expand 'Basisvarer — husk ved CITTI' into 7 categories (Grundvarer, Protein,
Grønt & frugt, Mejeri, Køl & frys, Husholdning, Krydderier) with German names
for in-store navigation. Compared against the existing CITTI catalog so
nothing is duplicated (ris/pasta/konserves/tun/olier/frozen veg/soya/
cleaning already covered). Added 'Ris (stor pose)' by request; skipped items
the user already keeps at home (sennep/honning/eddike/sølvpapir) and fresh
veg (frozen veg covers it). Checkoffs persist and are offline-safe.
2026-10-30 13:17:44 +01:00
Henrik Jess Nielsen
9dc431ebd5 feat(list): Basisvarer checklist to grab at CITTI
Add a 'Basisvarer — husk ved CITTI' checklist for everyday staples the user
wants to buy at CITTI rather than in DK: Rugbrød, Bananer, Havregryn,
Tomater, Toiletpapir — each with a German name for in-store navigation.
Checkoffs persist (prices table, keyed basis-*) and are offline-safe via
saveToServer/cittiFetch. Skips Kyllingebryst/Kaffe/Opvasketabs, which are
already in the CITTI catalog.
2026-10-30 13:07:54 +01:00
Henrik Jess Nielsen
dc53fbfb9b feat(stats): compute Kødportioner and Aftensmadsdage from the list
Both tiles were hardcoded. Parse the quantity strings (6 × ½ kg, 3 kg,
~700g, 2 stk.) live: Kødportioner = total Kød & fisk weight / 500g;
Aftensmadsdage = meat portions + pasta/tortelloni packs. Recomputed on
load and whenever a quantity changes, so the trip's food volume is
visible while editing. Defaults now read ~30 portions / ~36 dinners.
2026-10-30 12:51:24 +01:00
Henrik Jess Nielsen
32e6841b8c feat(stats): live 'Estimeret total' reflecting the actual list
Estimeret total was a hardcoded ~4.400. Make it dynamic: every list row
(fixed catalog, added extras, picked Lübeck offers) carries data-est in DKK,
and recalcAll sums them, so the tile updates live when you add/remove items
or pick/unpick offers. 'Faktisk betalt' was already live; the Aftensmadsdage
and Kødportioner tiles stay as illustrative figures.
2026-10-30 12:45:55 +01:00
Henrik Jess Nielsen
b640d9950c feat(pwa): offline support so the list works in-store with no net
No signal inside the store made the server-rendered app unusable. Make it
an installable PWA:
- service worker (static/sw.js) caches pages (network-first, cache fallback)
  and assets, served from root so scope is /
- offline.js: cittiFetch() queues check-off / price / qty / pick POSTs in
  localStorage when offline and replays them in order on reconnect, with an
  optimistic response and an Offline/Syncing status badge
- manifest + icon for add-to-home-screen; PWA meta tags on the in-store pages
- in-store mutations (saveToServer, pick/unpick) go through cittiFetch;
  archive/refresh/add still need net by design
- Dockerfile copies static/
Open once online first so the SW can cache; then it works offline.
2026-10-30 11:54:38 +01:00
Henrik Jess Nielsen
8dd435a7d0 feat(offers): Danish translation and AI matching via Claude
Offers come from the German avis, so add Claude-backed language help,
reusing BlaaAi's ANTHROPIC_API_KEY + Haiku pattern. Both degrade
gracefully: without a key, offers stay German and the token heuristic
still matches.

- Translate offer headings DE→DA in the fetch job, cached per heading
  in a translations table (only new headings cost a call). UI shows
  Danish primary + German subtitle for in-store navigation.
- AI match the fixed list against offers (offer_matches table): Claude
  returns same-product matches, far more precise than the token
  heuristic (which false-matched e.g. Nutella jar → advent calendar).
  load_deals() prefers AI matches, falls back to the heuristic.
- Haiku 5.5 by default (MATCH_MODEL/TRANSLATE_MODEL env overridable to
  Sonnet); no temperature param (Haiku 5.5 rejects non-default).
- requirements: add anthropic
2026-10-30 11:02:47 +01:00
Henrik Jess Nielsen
3b0ea28db5 feat(koeb-nu): read-only "buy now" shopping status vs current offers
Add a /koeb-nu page that analyses the list without touching quantities:
- which fixed items are on offer in Lübeck right now (honest per-unit
  offer price in EUR + DKK, no fabricated saving vs the Danish-origin
  estimate, since the units differ)
- what still needs ticking off, grouped by section (+ picked offers)
- a selection of this week's cheapest Tilbud specials not on the list,
  linking to the full Tilbud page
Header gets a 🛒 Køb nu link. The source carries no pre-price, so no
discount % is shown.
2026-10-30 10:43:22 +01:00
Henrik Jess Nielsen
65a99d2138 feat(offers): live Lübeck offer prices with pick-to-list and deal matching
Fetch CITTI Lübeck offers from the Tjek API (German dealer 3czmZx only —
never the Danish Flensburg booklet) and surface them in the app.

- New offers + offer_meta tables; defensive hotspots parser; upsert by
  offer id, prune per re-fetched catalog while preserving picked rows
- Daily in-process refresh scheduler (data.db lives on the app's own
  Nomad alloc disk, so a separate periodic job can't share it) plus a
  manual POST /api/offers/refresh and an "Opdater" button
- /tilbud page: browse all offers by catalog, search, EUR + DKK, and tick
  offers onto the shopping list; picks appear in a Lübeck-tilbud section
  on the main list and check off as bought via the existing /api/price
- Match the fixed catalog items against current offers and show a
  "på tilbud" badge with the matched offer name (conservative word-
  boundary token match, >=2 tokens for multi-word names)
- Dockerfile: add ca-certificates for urllib HTTPS to the Tjek API
2026-10-30 10:35:43 +01:00
Henrik Jess Nielsen
cf999ae228 feat(trips): archive current list and start a fresh one
Add a "Arkivér & ny liste" button that snapshots the current trip
(checked items, prices, quantities, extras and custom categories)
into a new trips table, then clears the mutable state so the list
resets to the fresh catalog.

- New trips table in init_db() storing a self-contained JSON snapshot
  plus computed totals and item count
- POST /api/archive with a no-op guard against archiving an empty list
- /historik list view and /historik/<id> read-only detail view
- Photo files are kept so archived trips can still show them
2026-10-30 10:15:27 +01:00
Henrik Jess Nielsen
7e5ef3c4b5 fix(mobile): allow pinch-to-zoom by removing maximum-scale restriction
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 40s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 01:37:05 +02:00
Henrik Jess Nielsen
1570b6eceb feat(items): add German product names for in-store navigation
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 47s
Each item now shows the German name (de field) below the Danish name
so it's easier to find products on shelves in Citti Flensburg.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 01:33:25 +02:00
Henrik Jess Nielsen
7709580cef fix(qty): make quantity input visibly editable with border and tap target
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 26s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 01:25:05 +02:00
Henrik Jess Nielsen
6ce940759c feat(shopping): editable quantity field per item
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 26s
Each item row now has an editable qty input showing the planned amount
(e.g. "6 × ½ kg"). Changes are auto-saved via debounce to the prices
table and highlighted in accent color when modified from the default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 01:18:04 +02:00
Henrik Jess Nielsen
1a3476c4d3 Add Flask shopping app with Nomad deployment
Some checks failed
deploy / deploy (push) Has been cancelled
Flask app serving the Citti shopping list with SQLite persistence,
per-category item addition, dynamic custom categories, photo upload,
and a post-trip price analysis page.

- Port 9756, DATA_DIR env var for persistent volume in Nomad
- Gitea Actions pipeline builds Docker image and deploys via Nomad API
- Makefile targets: run, install, build, push

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 00:54:07 +02:00