PayrollManagementSystem/backend/tests/unit/test_tplus_materials.py
liuwenxin 108bf87225 feat(核算)!: 添加 T+ 正式核算与采集托管
补齐源快照、资料预演、正式导入及工资核算的依赖链路。
新增版本化输入、逐段 FIFO、生成锁和结构化当月调整,
并提供默认关闭的周期采集、有限重试及 Windows 托管。

原始客户资料、私有配置及首页改动不纳入本次提交。

BREAKING CHANGE: 升级前需应用新增迁移,并通过
PAYROLL_MAKER_USER_ID 绑定实际工资制作人,否则业务只读。
旧单批次核算默认关闭;历史兼容需显式启用
PAYROLL_ALLOW_LEGACY_CALCULATION。生产启用和真实金额待验收。
2026-11-02 09:42:53 +08:00

41 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""恢复库核对包不能用缺记录证明零运费、已发绩效或已确认零期初。"""
from app.services.tplus.materials import QUERIES, render_markdown, summarize
def records():
data = {name: [] for name in QUERIES}
data["customer"] = [{"id": 9395, "code": "0060201", "name": "测试客户", "customerType": None}]
return data
def test_缺初始化记录只形成候选余额():
report = summarize(records(), 9395, "2026-03")
assert report["opening_candidate"] == "0.00" and not report["opening_confirmed"]
assert not report["ready_for_amount"] and not report["formal_payroll_written"]
assert {m["key"] for m in report["missing"]} >= {"GUIDANCE", "FREIGHT", "HISTORICAL_PAYROLL"}
def test_2017初始化不直接当作切换余额():
data = records()
data["opening"] = [{"origDate": "2017-05-31", "amount": "10000"}]
report = summarize(data, 9395, "2026-03")
assert report["opening_candidate"] is None
assert "2026-02-28" in report["opening_explanation"]
def test_超过范围明确标记核对包不完整():
data = records()
data["items"] = [{"id": i} for i in range(201)]
report = summarize(data, 9395, "2026-03")
assert report["truncated"] == ["items"]
assert len(report["evidence"]["items"]) == 200
def test_报告明确待补不制造实际金额():
report = summarize(records(), 9395, "2026-03")
report["evidence_hash"] = "test"
output = render_markdown(report)
assert "候选期初余额:0.00" in output
assert "实际工资金额尚未验收" in output