Files
einkaufsapp/tools/render_view.py

26 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
import sys
view = json.load(sys.stdin)
print(f'Liste: {view["list_name"]} (rev {view["rev"]})')
for market in view["markets"]:
print(f' [{market["market_name"]}] offen: {market["open_count"]} '
f'Summe: {market["total_cents"]} ct')
for cat in market["categories"]:
print(f' <{cat["category_name"]}>')
for item in cat["items"]:
menge = ""
if item.get("pack_size") or (item.get("count") or 1) > 1:
pack = (f'{item["pack_size"]} {item.get("pack_unit") or ""}'.strip()
if item.get("pack_size") else "")
count = item.get("count") or 1
menge = f' {count} × {pack}'.rstrip() if count > 1 and pack \
else (f' {pack}' if pack else f' {count} Stück')
preis = (f' [{item["price_cents"]} ct je Gebinde'
f', gesamt {item.get("total_cents")} ct]'
if item["price_cents"] else "")
eigenschaft = f' ({item.get("variant")})' if item.get("variant") else ""
print(f' - {item["article_name"]}{eigenschaft}{menge}{preis} '
f'[{item["status"]}]')
print(f' Gesamtsumme: {view["grand_total_cents"]} ct')