#!/usr/bin/env bash
# Deterministic check for the Invoice Chaser sample script. No API key, no network, Python 3 standard library only.
# Run from this folder: bash run-script.sh   (exit code 0 = pass, 1 = fail)
set -e
cd "$(dirname "$0")"
OUT=$(python3 late_fee.py --amount 2400 --due 2026-09-15 --today 2026-10-16 --monthly-rate 0.015)
echo "$OUT"
echo "$OUT" | python3 -c '
import json, sys
got = json.load(sys.stdin)
want = json.load(open("expected-script-output.json"))
bad = {k: (got.get(k), v) for k, v in want.items() if got.get(k) != v}
extra = sorted(set(got) - set(want))
if extra:
    bad["unexpected keys"] = extra
print("\nPASS: output matches expected-script-output.json" if not bad else "\nFAIL: %s" % bad)
sys.exit(1 if bad else 0)
'
