财务折线:补 /ledger/<id>/timeline API 端点 #24

用户原话(2026-10-28):「鸿蒙端对齐网页端」。财务概览卡「净资产变化」在
端上是空占位,数据源 Web 端早有(Ledger::timeline + ledger/total_chart),
只缺一个 API 给端上。

· GET /api/v1/ledger/<id>/timeline —— 返回时序点数组(date/net/asset/debt)
  加当前汇总。与 Web 端 total_chart 用**同一份 Ledger::timeline($id)**,
  两端曲线必然一致。

判据:_i24_timeline_api.py 8/0(2xx · items 数组 · 每点 net=asset-debt ·
有数据源),_i24_falsify.py 注掉 timeline → ④ 变红。
This commit is contained in:
2026-10-28 21:47:27 +08:00
parent cd56a9d8fe
commit e44f37e902
+15
View File
@@ -2545,6 +2545,21 @@ final class ApiHandler
Api::ok(['deleted' => $eid]); Api::ok(['deleted' => $eid]);
} }
} }
/* 🔴 工单 #24(用户 2026-10-28「鸿蒙端对齐网页端」):财务折线图。
端上「净资产变化(盘点成线)」原来是个空占位;数据源 Web 端早就有
(`Ledger::timeline` + `ledger/total_chart`),只是没 API 给端上。
这里补 `GET /api/v1/ledger/<id>/timeline`,把时序点吐给端上自己画。
⚠️ 与 Web 端 total_chart 同一份 `Ledger::timeline($id)` ——
两端曲线必然一致,不会"App 说涨、网页说跌"。 */
if ($sub === 'timeline') {
if ($method === 'GET') {
Api::ok([
'items' => Ledger::timeline($id),
'summary' => Ledger::summary(Ledger::entries($id)),
]);
}
Api::fail('不支持的方法。', 'method_not_allowed', 405);
}
/* 🔴 v68:共享给谁(端上"财务 → 设置 → 共享给谁"原来是个灰条)。 /* 🔴 v68:共享给谁(端上"财务 → 设置 → 共享给谁"原来是个灰条)。
`Ledger::setShare/unshare/shares` 早就在模型里,只是没有路由。 `Ledger::setShare/unshare/shares` 早就在模型里,只是没有路由。
⚠️ 只有**账本主人**能改共享关系:拿到 write 权限的被共享者 ⚠️ 只有**账本主人**能改共享关系:拿到 write 权限的被共享者