🚧 frühstück bestellung

This commit is contained in:
neingeist 2026-04-26 13:18:19 +02:00
parent 98cc0059c7
commit b03f8e36bb
3 changed files with 56 additions and 6 deletions

View file

@ -30,3 +30,11 @@ VALID_UNITS = [
"Stück",
"Zehe",
]
FOOD_NO_UNIT_OK = [
"Wasser",
"Salz",
"Pfeffer",
"Salz & Pfeffer",
"Gewürzgurkenwasser",
]

View file

@ -0,0 +1,4 @@
- [x] zatar bringt mascha mit
- [x] currypulver bringt britta mit
- [x] für margarine (= alsan) gibt es schon ticket EINKAUF-501
- [ ] asia-artikel: extra ticket?

View file

@ -1,9 +1,11 @@
import csv
import json
import math
import os
import pprint
import re
import sys
from collections import defaultdict
from datetime import timedelta
from pathlib import Path
@ -57,11 +59,21 @@ plan = read_plan()
# XXX move to lib
def grams(ingredient):
conversion = None
warnings = []
if not ingredient["unit"] and ingredient["food"]["name"] not in FOOD_NO_UNIT_OK:
warnings.append(f"🟡 No unit for {ingredient["food"]["name"]}")
for c in ingredient["conversions"]:
if c["unit"] in ["g / Gramm", "g"]:
conversion = c
if conversion:
return conversion.get("amount")
return conversion.get("amount"), warnings
else:
if ingredient["unit"]:
warnings.append(f"🟡 No conversion to grams for unit {ingredient["unit"]["name"]}")
return None, warnings
def main():
@ -75,11 +87,16 @@ def main():
r_name = recipe["name"]
for step in recipe["steps"]:
for ingredient in step["ingredients"]:
i_name = ingredient["food"]["name"]
if not ingredient.get("food"):
raise ValueError("No food in ingredient")
continue
i_grams = scale_factor * (grams(ingredient) or 0)
i_name = ingredient["food"]["name"]
g, warnings = grams(ingredient)
if warnings:
print(r_name, "-", i_name)
for w in warnings:
print(f"- {w}")
i_grams = scale_factor * (g or 0)
i_description = ingredient["food"][
"description"
] # XXX probably not what i wanted
@ -93,14 +110,17 @@ def main():
if not ingredient.get("food"):
raise ValueError("No food in ingredient")
continue
r_gross_weight += (grams(ingredient) or 0)
r_gross_weight += (grams(ingredient)[0] or 0)
r_gross_weight /= recipe["servings"]
recipe["total_net_weight"] = plan[r_name]["total_net_weight"]
recipe["wanted_servings"] = plan[r_name]["wanted_servings"]
recipe["total_gross_weight"] = r_gross_weight * plan[r_name]["wanted_servings"]
print("---")
print("tags: GPN24, Fruehstueck")
print("---")
print("# GPN24 Frühstück Aufstriche Inventar + Bestellung")
print(markdown_alert("automatisch erstellt, nicht editieren..."))
print()
@ -123,7 +143,6 @@ def main():
print("## Zutaten")
for ingredient, entries in inventory.items():
total = sum(amount for amount, _ in entries)
@ -132,7 +151,26 @@ def main():
print(f"- **{total:.1f}g** **Total**")
for i_grams, r_name in entries:
print(f"- {i_grams:.1f}g {r_name}")
print()
print()
print("## Für die Bestellung nochmal als Tabelle")
table_data = []
for ingredient, entries in inventory.items():
total = sum(amount for amount, _ in entries)
table_data.append((math.ceil(total), ingredient))
table_headers = ("Gewicht (g)", "Zutat")
print(tabulate(table_data, headers=table_headers, tablefmt="github"))
print()
print()
print("## Notes")
with open("fruehstueck_bestellung+inventar-notes.md") as notes_fd:
print(notes_fd.read())
if __name__ == "__main__":
main()