ifx bugs
parent
b90f6c917e
commit
a907d362fc
|
|
@ -101,6 +101,13 @@ def _wan(amount: Any) -> str:
|
|||
return "0.0"
|
||||
|
||||
|
||||
def _number(value: Any, digits: int = 1) -> str:
|
||||
try:
|
||||
return f"{float(value or 0):,.{digits}f}"
|
||||
except (TypeError, ValueError):
|
||||
return f"{0:.{digits}f}"
|
||||
|
||||
|
||||
def _date_range(db: Session, period_id: int | None, year: int | None, month: int | None,
|
||||
label: str) -> tuple[str, str, str]:
|
||||
ids = resolve_period_ids(db, period_id, year, month)
|
||||
|
|
@ -201,7 +208,7 @@ def _finance_table(data: dict) -> str:
|
|||
|
||||
body = []
|
||||
for item in quarters:
|
||||
target = _wan(item.get("target"))
|
||||
target = _number(item.get("target"), 2)
|
||||
rate = item.get("rate")
|
||||
rate_text = f"{float(rate) * 100:.1f}%" if rate is not None else "—"
|
||||
cls = "current" if item.get("current") else ""
|
||||
|
|
@ -221,7 +228,7 @@ def _finance_table(data: dict) -> str:
|
|||
f"<strong>{_wan(total.get('acc_amount'))}</strong>",
|
||||
f"<strong>{_esc(total.get('sign_count', 0))}</strong>",
|
||||
f"<strong>{_wan(total.get('sign_amount'))}</strong>",
|
||||
f"<strong>{_wan(total.get('target'))}</strong>", "",
|
||||
f"<strong>{_number(total.get('target'), 2)}</strong>", "",
|
||||
], "sum"))
|
||||
return (
|
||||
"<table><thead><tr><th>季度</th><th>验收项目数</th><th>验收金额(万元)</th>"
|
||||
|
|
@ -337,8 +344,9 @@ def build_html(payload: dict) -> str:
|
|||
("定制验收", len(custom["accepted"])),
|
||||
]
|
||||
ctx = finance_data.get("context") or {}
|
||||
report_title = _esc(payload["range_label"]) + "工作汇报"
|
||||
head = (
|
||||
"<h1>工作汇报</h1>"
|
||||
"<h1>" + report_title + "</h1>"
|
||||
+ '<p class="sub">统计区间:'
|
||||
+ _esc(payload["range_label"])
|
||||
+ " | 财务年度:"
|
||||
|
|
@ -368,7 +376,7 @@ def build_html(payload: dict) -> str:
|
|||
return (
|
||||
"<!doctype html><html lang=\"zh-CN\"><head><meta charset=\"utf-8\">"
|
||||
'<meta name="viewport" content="width=device-width,initial-scale=1">'
|
||||
"<title>工作汇报-" + _esc(payload["range_label"]) + "</title><style>" + STYLE + "</style></head><body>"
|
||||
"<title>" + report_title + "</title><style>" + STYLE + "</style></head><body>"
|
||||
+ '<main class="page">' + head + body + "</main></body></html>"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ def test_看板导出完整工作汇报页(h):
|
|||
assert ".html" in resp.headers["content-disposition"]
|
||||
|
||||
body = resp.text
|
||||
range_label = week["full_label"]
|
||||
assert f"<h1>{range_label}工作汇报</h1>" in body
|
||||
assert f"<title>{range_label}工作汇报</title>" in body
|
||||
for text in ("工作汇报", "一、日常工作", "二、自研产品", "三、年度任务财务情况", "四、定制项目",
|
||||
"准备验收材料", "新增乙", "验收丙", "计收目标(万元)"):
|
||||
assert text in body, text
|
||||
|
|
@ -48,6 +51,7 @@ def test_看板导出完整工作汇报页(h):
|
|||
assert "高风险戊" not in body
|
||||
assert "本期没有重点工作" not in body
|
||||
assert "2028 Q1" in body
|
||||
assert "35.00" in body and "225.00" in body and "160.00" in body and "260.00" in body
|
||||
assert "历史遗留任务" not in body
|
||||
assert body.index("自研乙") < body.index("方案评审通过") < body.index("自研甲") < body.index("联调完成")
|
||||
assert body.index("三、年度任务财务情况") < body.index("四、定制项目")
|
||||
|
|
|
|||
Loading…
Reference in New Issue