feat(plugin): XQ0052 0.7.0 未进台账的新券不再静默丢,新增空槽自动回收开关
- 明细出现模板 AH~AZ 没有的支付方式时,日志/核对报「券名 + 金额 + 笔数 + 日期」, 并列出「本月 0 笔、可回收的券列」(明细列 ↔ 汇总列对位) - 新增配置项 ledger_auto_slot(默认关):开启后把「本月 0 笔」的券列改名 (明细 AP~AZ 第 2 行 + 汇总 W~AG 第 3 行同步,位置不动、汇总公式不用改), 改名前校验汇总公式确实同列对位,对不上跳过并告警 - _selftest 新增空槽回收纯逻辑用例(列字母换算/未匹配识别/空槽判定/槽位不足/公式对位) - 同步 README 与 ui 产物
This commit is contained in:
@@ -122,6 +122,13 @@ class HupanStoredCardPlugin(ScenePlugin):
|
||||
"enum": [config.RESET_ON, config.RESET_OFF],
|
||||
"description": "自动切月=月份不符时清明细/新办卡、汇总日期行滚到当月、期初取上月末",
|
||||
},
|
||||
"ledger_auto_slot": {
|
||||
"type": "string", "title": "新券自动回收", "default": config.AUTO_SLOT_OFF,
|
||||
"enum": [config.AUTO_SLOT_OFF, config.AUTO_SLOT_ON],
|
||||
"description": "默认关:明细出现模板没有的券时,只在日志/核对里报金额和可回收空槽,由人改表头;"
|
||||
"打开后自动把「本月 0 笔」的券列改名(明细 AP~AZ + 汇总 W~AG 同步,"
|
||||
"位置不动、汇总公式不用改),当天数据就能接住",
|
||||
},
|
||||
"push_users": {
|
||||
"type": "string", "title": "钉钉推送接收人", "default": config.DEFAULT_PUSH_USERS,
|
||||
"description": "姓名/工号,多个用「、」「,」「;」或换行分隔(如同名须带工号);"
|
||||
@@ -224,6 +231,8 @@ class HupanStoredCardPlugin(ScenePlugin):
|
||||
recalc=str(fields.get("ledger_recalc") or config.RECALC_ON) == config.RECALC_ON,
|
||||
month_reset=str(fields.get("ledger_month_reset")
|
||||
or config.RESET_ON) == config.RESET_ON,
|
||||
auto_slot=str(fields.get("ledger_auto_slot")
|
||||
or config.AUTO_SLOT_OFF) == config.AUTO_SLOT_ON,
|
||||
ctx=ctx)
|
||||
elif not ledger_dir:
|
||||
ctx.log("未配置台账文件夹,跳过台账维护(只出两份导出表)", "WARN")
|
||||
@@ -346,7 +355,8 @@ class HupanStoredCardPlugin(ScenePlugin):
|
||||
|
||||
# ------------------------------------------------------------------ 台账
|
||||
def _maintain_ledger(self, hotel_report, cfg, day, path, snapshot: dict,
|
||||
backup: bool, recalc: bool, month_reset: bool, ctx) -> dict:
|
||||
backup: bool, recalc: bool, month_reset: bool,
|
||||
auto_slot: bool, ctx) -> dict:
|
||||
from .logic.ledger import LedgerError, LedgerMaintainer
|
||||
from .logic.provider import SnapshotProvider
|
||||
|
||||
@@ -354,9 +364,11 @@ class HupanStoredCardPlugin(ScenePlugin):
|
||||
ctx.log("台账文件不存在,跳过维护:%s" % path, "WARN")
|
||||
return {"skipped": "台账文件不存在", "path": path}
|
||||
ctx.log("--- 维护台账:%s" % path)
|
||||
ctx.log("新券自动回收:" + ("开(只回收本月 0 笔的券列)" if auto_slot else "关(只提示)"))
|
||||
maint = LedgerMaintainer(path, log=ctx.log,
|
||||
progress=lambda p: ctx.progress(55 + int(p * 0.45)),
|
||||
backup=backup, recalc=recalc, month_reset=month_reset)
|
||||
backup=backup, recalc=recalc, month_reset=month_reset,
|
||||
auto_slot=auto_slot)
|
||||
provider = SnapshotProvider(hotel_report, cfg, snapshot, log=ctx.log)
|
||||
try:
|
||||
res = maint.run(day, provider)
|
||||
@@ -404,6 +416,10 @@ def _ledger_summary(ledger: dict) -> str:
|
||||
int(reset.get("detail_cleared") or 0),
|
||||
int(reset.get("newcard_cleared") or 0),
|
||||
"、".join("%s=%s" % (k, v) for k, v in (reset.get("init") or {}).items())))
|
||||
for item in ledger.get("slot_recycled") or []:
|
||||
text += ("\n· 券列自动回收:明细 %s2 / 汇总 %s3「%s」→「%s」"
|
||||
% (item.get("slot"), item.get("summary"),
|
||||
item.get("old") or "空", item.get("new")))
|
||||
checks = ledger.get("checks") or []
|
||||
bad = [c for c in checks if not c.get("ok")]
|
||||
text += ("\n· 台账:补 %d 天、明细 +%s 行、新办卡 +%s 行、余额 %s 人(合计 %s)"
|
||||
|
||||
Reference in New Issue
Block a user