From 8d98ba88f75852f5cc4b5d66c5b30210b7eefe6c Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Tue, 22 Sep 2026 11:59:00 +0800 Subject: Backfill cash ledger from historical transactions and add reconciliation QA (3d-32) --- qa/run.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'qa/run.sh') diff --git a/qa/run.sh b/qa/run.sh index d28a084..3058c07 100755 --- a/qa/run.sh +++ b/qa/run.sh @@ -110,6 +110,37 @@ for _ in $(seq 1 60); do done [ "$api_up" = 1 ] || { cat "$API_LOG" >&2; die "API did not become ready"; } +log "checking cash-reconciliation API (curl assertion)" +RECON_FUND_ID="$(curl -s -X POST "http://127.0.0.1:$API_PORT/api/funds" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -H "Idempotency-Key: qa-recon-fund-$RANDOM" \ + -d '{"name":"QA 现金对账","initialCash":"1000.00","initialUnitNav":"1.00000000","isSynthetic":true}' \ + | python3 -c 'import sys,json; print(json.load(sys.stdin)["id"])')" +[ -n "$RECON_FUND_ID" ] || die "cash reconciliation assertion: fund creation failed" + +curl -s -X POST "http://127.0.0.1:$API_PORT/api/funds/$RECON_FUND_ID/capital/deposit" \ + -H "Authorization: Bearer $AUTH_TOKEN" \ + -H "Content-Type: application/json" \ + -H "Idempotency-Key: qa-recon-deposit-$RANDOM" \ + -d '{"amount":"2500.00","note":"qa"}' >/dev/null + +curl -s -H "Authorization: Bearer $AUTH_TOKEN" "http://127.0.0.1:$API_PORT/api/funds/$RECON_FUND_ID/cash-reconciliation" \ + | python3 -c ' +import sys, json +d = json.load(sys.stdin) +required = ["openingCash", "netInflow", "closingCash", "ledgerBalance", "difference", "sources", "events"] +missing = [k for k in required if k not in d] +assert not missing, "missing fields: %s" % missing +assert d["difference"] == "0.00", "difference=%s" % d["difference"] +assert d["openingCash"] == "1000.00", d["openingCash"] +assert d["closingCash"] == "3500.00", d["closingCash"] +src = {s["source"]: s for s in d["sources"]} +assert src.get("capital_deposit", {}).get("netAmount") == "2500.00", d["sources"] +assert src["capital_deposit"]["eventCount"] == 1, d["sources"] +print("PASS C1 现金对账字段齐全且 difference==0 -- diff=%s sources=%s" % (d["difference"], d["sources"])) +' || die "cash reconciliation curl assertion failed" + log "compiling F# to JS (fable)" ( cd "$ROOT/src/FundLab.Web" && dotnet fable FundLab.Web.fsproj --outDir dist --noCache ) > "$TMP_DIR/fable.log" 2>&1 -- cgit v1.2.3