From 29dc5c0bdc1a7358f28a0ba7cf155f42e64456f8 Mon Sep 17 00:00:00 2001 From: Hermes CI Fix Date: Thu, 1 Oct 2026 16:10:46 +0800 Subject: [PATCH] fix(receivables): unwrap response envelope once + align card/column field names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- backend/app/api/cash.py | 4 ++++ frontend/src/views/Receivables.vue | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/app/api/cash.py b/backend/app/api/cash.py index 41940a75..748518f2 100644 --- a/backend/app/api/cash.py +++ b/backend/app/api/cash.py @@ -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, diff --git a/frontend/src/views/Receivables.vue b/frontend/src/views/Receivables.vue index 9a4d795e..581ac8a5 100644 --- a/frontend/src/views/Receivables.vue +++ b/frontend/src/views/Receivables.vue @@ -17,9 +17,9 @@ -
¥{{ (summary.total_balance || 0).toFixed(2) }}万
应收总额
+
¥{{ (summary.pending_balance || 0).toFixed(2) }}万
待收余额
¥{{ (summary.overdue_amount || 0).toFixed(2) }}万
逾期金额 ({{ summary.overdue_count || 0 }}笔)
-
¥{{ (summary.total_paid || 0).toFixed(2) }}万
已回款
+
¥{{ (summary.completed_amount || 0).toFixed(2) }}万
已回款
{{ summary.completed_count || 0 }}
已完成笔数
@@ -39,17 +39,21 @@ - - + + + + + + - - - + + + @@ -119,7 +123,7 @@ async function loadData() { if (owner.value) params.owner = owner.value if (status.value) params.status = status.value const r: any = await api.get('/cash/receivables', { params }) - const d = r.data || r || {} + const d = r || {} summary.value = d.summary || {} owners.value = d.owners || [] const rawItems = d.data || d.items || d.receivables || []