🚧 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", "Stück",
"Zehe", "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 csv
import json import json
import math
import os import os
import pprint import pprint
import re import re
import sys import sys
from collections import defaultdict from collections import defaultdict
from datetime import timedelta from datetime import timedelta
from pathlib import Path from pathlib import Path
@ -57,11 +59,21 @@ plan = read_plan()
# XXX move to lib # XXX move to lib
def grams(ingredient): def grams(ingredient):
conversion = None 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"]: for c in ingredient["conversions"]:
if c["unit"] in ["g / Gramm", "g"]: if c["unit"] in ["g / Gramm", "g"]:
conversion = c conversion = c
if conversion: 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(): def main():
@ -75,11 +87,16 @@ def main():
r_name = recipe["name"] r_name = recipe["name"]
for step in recipe["steps"]: for step in recipe["steps"]:
for ingredient in step["ingredients"]: for ingredient in step["ingredients"]:
i_name = ingredient["food"]["name"]
if not ingredient.get("food"): if not ingredient.get("food"):
raise ValueError("No food in ingredient") raise ValueError("No food in ingredient")
continue continue
i_grams = scale_factor * (grams(ingredient) or 0) g, warnings = grams(ingredient)
i_name = ingredient["food"]["name"] 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"][ i_description = ingredient["food"][
"description" "description"
] # XXX probably not what i wanted ] # XXX probably not what i wanted
@ -93,14 +110,17 @@ def main():
if not ingredient.get("food"): if not ingredient.get("food"):
raise ValueError("No food in ingredient") raise ValueError("No food in ingredient")
continue continue
r_gross_weight += (grams(ingredient) or 0) r_gross_weight += (grams(ingredient)[0] or 0)
r_gross_weight /= recipe["servings"] r_gross_weight /= recipe["servings"]
recipe["total_net_weight"] = plan[r_name]["total_net_weight"] recipe["total_net_weight"] = plan[r_name]["total_net_weight"]
recipe["wanted_servings"] = plan[r_name]["wanted_servings"] recipe["wanted_servings"] = plan[r_name]["wanted_servings"]
recipe["total_gross_weight"] = r_gross_weight * 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(markdown_alert("automatisch erstellt, nicht editieren..."))
print() print()
@ -123,7 +143,6 @@ def main():
print("## Zutaten") print("## Zutaten")
for ingredient, entries in inventory.items(): for ingredient, entries in inventory.items():
total = sum(amount for amount, _ in entries) total = sum(amount for amount, _ in entries)
@ -132,7 +151,26 @@ def main():
print(f"- **{total:.1f}g** **Total**") print(f"- **{total:.1f}g** **Total**")
for i_grams, r_name in entries: for i_grams, r_name in entries:
print(f"- {i_grams:.1f}g {r_name}") 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__": if __name__ == "__main__":
main() main()