financial page with bank data
All checks were successful
Deploy / build-deploy (push) Successful in 1m48s

This commit is contained in:
Jorijn van der Graaf 2026-08-14 04:14:13 +02:00
commit 33c68c2f44
11 changed files with 394 additions and 87 deletions

View file

@ -158,6 +158,51 @@ if [ "$RAIL" = mollie ]; then
esac
fi
# /financials has two inputs and a fresh dev run has neither: sales fold out of
# the order ledger, donations and expenses come from the bank-aggregates file.
# So the page honestly renders its empty state — which is worth previewing too,
# and is why this is opt-in rather than always on.
#
# DEV_FINANCIALS=1 seeds both with obviously-sample figures, so the FILLED
# layout can be designed against without waiting for real money or touching
# production. The aggregates file is re-read on every request, so you can edit
# it while the server runs and just refresh.
#
# DEV_FINANCIALS=<path> instead previews a REAL aggregates file — the one
# staged for production, say. No sample orders are seeded in that case: sales
# fold from the ledger, and inventing them would misrepresent the very figures
# you are checking. A closed shop showing €0 of sales is the truth.
if [ "${DEV_FINANCIALS:-0}" != 0 ] && [ "${DEV_FINANCIALS:-0}" != 1 ]; then
if [ ! -f "$DEV_FINANCIALS" ]; then
echo "dev: DEV_FINANCIALS='$DEV_FINANCIALS' is not a file" >&2
exit 1
fi
cp "$DEV_FINANCIALS" "$WORK/orders.jsonl.financials.json"
echo "dev: previewing REAL financials from $DEV_FINANCIALS (no sample orders seeded)"
elif [ "${DEV_FINANCIALS:-0}" = 1 ]; then
# Labels say SAMPLE and the amounts are flat round numbers on purpose:
# plausible-looking figures here were once mistaken for real bank data.
# Nothing in this block comes from anywhere — it exists to fill the layout.
cat > "$WORK/orders.jsonl.financials.json" <<'JSON'
{"as_of":"2026-01-01",
"donations":{"count":4,"total_minor":10000},
"expenses":[{"label":"SAMPLE hosting","total_minor":10000},
{"label":"SAMPLE insurance","total_minor":20000},
{"label":"SAMPLE inventory","total_minor":300000},
{"label":"SAMPLE payment fees","total_minor":5000}]}
JSON
# Two paid orders, written straight to the ledger: the product is
# coming-soon, so checkout refuses and there is no other way to make the
# sales row non-zero. Same event shapes Orders.cpp appends.
cat > "$WORK/orders.jsonl" <<'JSON'
{"type":"order","at":"2026-08-10T10:00:00Z","id":"1111111111111111aaaaaaaaaaaaaaaa","ref":"CC-111111","product":"fp6-pmos","color":"green","quantity":1,"unit_minor":56330,"email":"sample@example.org","name":"Sample Buyer","street":"1 Example St","postal":"1000AA","city":"Amsterdam","country":"NL","goods_minor":56330,"shipping_minor":713,"total_minor":57043,"vat_included":true,"status":"awaiting_payment","pay_choice":"bank","pay_url":"","pay_id":"dev-1"}
{"type":"status","at":"2026-08-10T10:04:00Z","id":"1111111111111111aaaaaaaaaaaaaaaa","status":"paid","via":"ideal"}
{"type":"order","at":"2026-08-12T14:30:00Z","id":"2222222222222222bbbbbbbbbbbbbbbb","ref":"CC-222222","product":"fp6-pmos","color":"white","quantity":1,"unit_minor":65488,"email":"other@example.org","name":"Other Buyer","street":"2 Example Rd","postal":"3000BB","city":"Rotterdam","country":"DE","goods_minor":65488,"shipping_minor":2500,"total_minor":67988,"vat_included":true,"status":"awaiting_payment","pay_choice":"crypto","pay_url":"","pay_id":"dev-2"}
{"type":"status","at":"2026-08-12T14:33:00Z","id":"2222222222222222bbbbbbbbbbbbbbbb","status":"paid","via":"bitcoin"}
JSON
echo "dev: seeded SAMPLE financials (DEV_FINANCIALS=1) — figures are invented"
fi
"$SRV/catcrafts-server" --serve "$BACKEND_PORT" \
--orders="$WORK/orders.jsonl" --rail="$RAIL" \
--redirect-base="http://localhost:$PORT" >"$WORK/server.log" 2>&1 &
@ -189,10 +234,17 @@ cat <<EOF
/posts fediverse posts
/demos demo list; /demos/raytracer loads the wasm
/legal/privacy privacy notice
/financials open financials$(case "${DEV_FINANCIALS:-0}" in
0) printf '%s' " — empty; DEV_FINANCIALS=1 seeds sample figures,
DEV_FINANCIALS=<file> previews a real one";;
1) printf '%s' " (SAMPLE data — invented figures)";;
*) printf '%s' " (real figures from $DEV_FINANCIALS)";; esac)
/feed.xml Atom feed
/media/* mirrored post media (run tools/fetch-media.sh to populate)
Orders from this session go to a temp file and are discarded on exit.
Orders from this session go to a temp file and are discarded on exit.$([ "${DEV_FINANCIALS:-0}" = 1 ] && printf '%s' "
Edit the aggregates and just refresh — they are re-read every request:
\$EDITOR $WORK/orders.jsonl.financials.json")
Payment rail: $RAIL$([ "$RAIL" = fake ] && printf '%s' " — simulate a customer paying with:
touch $WORK/orders.jsonl.fake-paid")
Ctrl-C to stop.