feat(export): 恢复旧导出引擎并加固换行与舍入、新增采纳来源溯源与项目目录排序

This commit is contained in:
lianjianwei2024
2026-11-06 10:15:07 +08:00
parent 0dcdddc4a1
commit f142910bbd
26 changed files with 1832 additions and 934 deletions

View File

@@ -325,6 +325,23 @@ def _t_bill_adopt(args):
hc = a.conn()
try:
r = a.api_bill_adopt(sc, hc, {"session_id": sid, "bill_id": bid, "src_bill_id": src})
if r.get("ok"):
# 决策 256:采纳来源快照(溯源定位)——从历史库取来源行拼渲染行同形快照
try:
b = hc.execute("""SELECT b.Name, b.Attr, b.Unit, b.Price, t.Name proj,
t.x_period_start_m p1, t.x_period_end_m p2
FROM bills b JOIN batches t ON t.id=b.batch_id WHERE b.id=?""", (src,)).fetchone()
if b:
per = ("%d-%02d" % (((b["p1"] or 0) // 12) - (1 if (b["p1"] or 0) % 12 == 0 else 0),
(b["p1"] or 0) % 12 or 12)) if b["p1"] else None
a.adopt_src_record(sc, sid, "bill", bid,
{"src": "project", "src_id": src, "name": b["Name"],
"attr": b["Attr"], "unit": b["Unit"], "price": b["Price"],
"proj": b["proj"],
"period": per or ("%d-%02d" % (((b["p2"] or 0) // 12) - (1 if (b["p2"] or 0) % 12 == 0 else 0),
(b["p2"] or 0) % 12 or 12))})
except Exception:
pass
sc.commit()
if r.get("ok"):
try:
@@ -476,6 +493,10 @@ def _t_lme_adopt(args):
txt = "采纳:%s+%s+%s|%s|%s" % (snap.get("name") or "", snap.get("proj") or "",
p(old["price"]), p(old["tax"]), p(old["taxp"]))
a.sess.save_lme_remark(sc, proj["id"], txt)
try:
a.adopt_src_record(sc, sid, "lme", proj["id"], snap) # 决策 256:来源快照(溯源定位)
except Exception:
pass
sc.commit()
finally:
sc.close()