fix(receivables): unwrap response envelope once + align card/column field names

- Receivables.vue: const d = r (was r.data || r) -> cards/table no longer blank

- cards: pending_balance(待收余额) / overdue / completed_amount / completed_count

- columns: counterparty(+description fallback) / owner(未分配) / settled_amount / plan_date / aging_bucket

- cash.py: summary.completed_count + _plan_dict.settled_amount (existing keys untouched)

- api/index.ts untouched (global interceptor)

(cherry picked from commit d60557622441b971970fb9dc86ef7491c3a9d72b)
This commit is contained in:
Hermes CI Fix
2026-10-02 21:12:20 +08:00
parent ac4bbc6891
commit 29dc5c0bdc
2 changed files with 18 additions and 10 deletions
+4
View File
@@ -68,6 +68,7 @@ def _plan_dict(p: CashPlan) -> dict:
"plan_type_label": "收款" if p.plan_type == "receive" else "付款",
"amount": round(p.amount or 0, 2),
"paid_amount": paid,
"settled_amount": round(p.amount or 0, 2) if p.status == "completed" else paid,
"receivable_balance": max(balance, 0),
"plan_date": p.plan_date.strftime("%Y-%m-%d") if p.plan_date else "",
"counterparty": p.counterparty or "",
@@ -583,6 +584,7 @@ def api_receivables(
overdue_amount = 0.0
aging_amount = {}
completed_amount = 0.0
completed_count = 0
for p in plans:
d = _plan_dict(p)
if status:
@@ -605,6 +607,7 @@ def api_receivables(
aging_amount[d["aging_bucket"]] = aging_amount.get(d["aging_bucket"], 0) + d["receivable_balance"]
elif d["status"] == "completed":
completed_amount += d["amount"]
completed_count += 1
owners = [r[0] for r in db.query(CashPlan.owner).filter(
CashPlan.entity_id == entity_id,
@@ -625,6 +628,7 @@ def api_receivables(
"overdue_count": overdue_count,
"overdue_amount": round(overdue_amount, 2),
"completed_amount": round(completed_amount, 2),
"completed_count": completed_count,
"aging": {k: round(v, 2) for k, v in sorted(aging_amount.items(), key=lambda x: x[0])},
},
"data": items,