fix: 模拟生成PDF

This commit is contained in:
sophie committed 2026-09-10 10:18:44 +08:00
1 parent c4a27324c8
commit 204e71b786
19 files changed
+2064 -110

No files matched your search

+14 -4
View File
@@ -1,9 +1,9 @@
"""
backend/app/api/workspace/voucher_check.py
用途:工作台立账凭证检核查询与强制重检 API(任务列表 / 批次明细 / 企微发送记录)。
用途:工作台立账凭证检核查询与强制重检 API(任务列表 / 最近一次检核 / 批次明细 / 企微发送记录)。
依赖:auth.jwt、response_utils envelope、voucher_check.query_service。
逻辑:对话与检核任务页共用;GET notifications 为企微发送记录;POST runs 仅 admin,以 force_all 入队周批排程。
逻辑:对话与检核任务页共用;GET runs/latest 不跟筛选;GET notifications 为企微发送记录;POST runs 仅 admin,以 force_all 入队周批排程。
"""
from __future__ import annotations
@@ -37,7 +37,7 @@ def _require_admin():
def workspace_voucher_runs():
"""
分页查看检核任务列表。
核心逻辑:委托 query_service.list_runs,按资料所属期间/业务方/状态筛选。
核心逻辑:委托 query_service.list_runs;period 为 YYYY 或 YYYY-MM,可再按业务方/状态筛选。
"""
_require_user()
data = query_service.list_runs(
@@ -69,6 +69,16 @@ def workspace_voucher_force_run():
return ok(data)
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs/latest", methods=["GET"])
def workspace_voucher_latest_run():
"""
读取最近一次立账凭证检核批次(含排队/执行中)。
核心逻辑:委托 query_service.get_latest_run;不跟列表 period/status;无批次时 data 为 null。
"""
_require_user()
return ok(query_service.get_latest_run())
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs/<int:run_id>/items", methods=["GET"])
def workspace_voucher_run_items(run_id: int):
"""
@@ -89,7 +99,7 @@ def workspace_voucher_run_items(run_id: int):
def workspace_voucher_notifications():
"""
分页查看企微缺件汇总发送记录。
核心逻辑:委托 query_service.list_notifications,可按期间和发送状态筛选。
核心逻辑:委托 query_service.list_notifications;period 为 YYYY 或 YYYY-MM,可再按发送状态筛选。
"""
_require_user()
data = query_service.list_notifications(
@@ -1,9 +1,9 @@
"""
backend/app/services/voucher_check/query_service.py
用途:查询检核批次列表、批次明细、企微发送记录,以及工作台强制重检入队。
依赖:models.voucher_check、ScheduleRun、aggregator、schedule.queue_service。
逻辑:只读引擎表;明细同时返回 invoice 行与 by_file_type;强制重检写入 run_options.mode=force_all。
用途:查询检核批次列表、最近一次检核、批次明细、企微发送记录,以及工作台强制重检入队。
依赖:models.voucher_check、ScheduleRun、aggregator、schedule.queue_service、schedule_seed。
逻辑:只读引擎表;列表 period 支持 YYYY 或 YYYY-MM;GET latest 不跟筛选;明细同时返回 invoice 行与 by_file_type;强制重检写入 run_options.mode=force_all。
"""
from __future__ import annotations
@@ -20,6 +20,7 @@ from app.models.voucher_check import (
)
from app.services.voucher_check.aggregator import aggregate_file_results
from app.services.voucher_check.erp_repository import previous_period_bounds
from app.services.voucher_check.schedule_seed import DEFAULT_VOUCHER_CHECK_PLATFORM_PATH
def parse_period_month(raw: str | None) -> date:
@@ -38,9 +39,92 @@ def parse_period_month(raw: str | None) -> date:
raise ValidationError(
"period 格式须为 YYYY-MM",
code="VOUCHER_CHECK.CONFIG_INVALID",
details={"period": text},
) from exc
def parse_period_filter(raw: str | None) -> tuple[date | None, date | None]:
"""
将工作台列表 period 解析为 [start, end) 半开区间。
核心逻辑:空值不过滤;YYYY 覆盖该自然年;YYYY-MM / YYYY-MM-DD 覆盖该自然月。
Args:
raw: 查询参数 period,允许 YYYY、YYYY-MM、YYYY-MM-DD 或空。
Returns:
(start, end);空 period 时为 (None, None)。
Raises:
ValidationError: 格式无法解析。
"""
if not raw or not str(raw).strip():
return None, None
text = str(raw).strip()
try:
if len(text) == 4 and text.isdigit():
year = int(text)
return date(year, 1, 1), date(year + 1, 1, 1)
start = parse_period_month(text)
if start.month == 12:
end = date(start.year + 1, 1, 1)
else:
end = date(start.year, start.month + 1, 1)
return start, end
except ValidationError as exc:
raise ValidationError(
"period 格式须为 YYYY 或 YYYY-MM",
code="VOUCHER_CHECK.CONFIG_INVALID",
details={"period": text},
) from exc
except (TypeError, ValueError, OverflowError) as exc:
raise ValidationError(
"period 格式须为 YYYY 或 YYYY-MM",
code="VOUCHER_CHECK.CONFIG_INVALID",
details={"period": text},
) from exc
def _apply_period_filter(query, column, period: str | None):
"""
按 period 的年或月区间过滤 period_month 列。
Args:
query: SQLAlchemy 查询。
column: 期间列,通常为 VoucherCheckRun.period_month。
period: YYYY、YYYY-MM,或空。
Returns:
加上区间条件后的查询;period 为空时原样返回。
"""
start, end = parse_period_filter(period)
if start is None or end is None:
return query
return query.filter(column >= start, column < end)
def _period_value_in_filter(period_month: str | None, period: str | None) -> bool:
"""
判断 YYYY-MM 文本是否落在列表 period 筛选区间内。
Args:
period_month: 批次期间,例如 2026-08。
period: 与列表查询相同的 YYYY 或 YYYY-MM。
Returns:
无需过滤或文本落在区间内时为 True。
"""
start, end = parse_period_filter(period)
if start is None or end is None:
return True
if not period_month:
return False
try:
row = datetime.strptime(str(period_month)[:7], "%Y-%m").date().replace(day=1)
except ValueError:
return False
return start <= row < end
def _serialize_engine_run(run: VoucherCheckRun) -> dict[str, Any]:
return {
"id": run.id,
@@ -93,6 +177,238 @@ def _serialize_schedule_fallback_run(run: ScheduleRun) -> dict[str, Any]:
}
def _as_summary_dict(raw: Any) -> dict[str, Any]:
"""把 JSON 字段收成 dict;非 dict 视为空。"""
return raw if isinstance(raw, dict) else {}
def _iso_dt(value: datetime | None) -> str | None:
"""将 datetime 转 ISO 文本,空值保持 None。"""
return value.isoformat() if value else None
def _latest_voucher_summary(schedule_run: ScheduleRun) -> dict[str, Any]:
"""从排程 response_summary_json 取出 voucher_check 快照。"""
summary = _as_summary_dict(schedule_run.response_summary_json)
voucher = summary.get("voucher_check")
return voucher if isinstance(voucher, dict) else {}
def _latest_current_step(schedule_run: ScheduleRun) -> dict[str, Any]:
"""从排程 response_summary_json 取出 runner 写入的 current_step。"""
summary = _as_summary_dict(schedule_run.response_summary_json)
current = summary.get("current_step")
return current if isinstance(current, dict) else {}
def _latest_run_mode(
schedule_run: ScheduleRun,
engine: VoucherCheckRun | None,
voucher_summary: dict[str, Any],
) -> str:
"""
解析最近一批的执行模式。
核心逻辑:优先引擎批次 mode;否则读 api_request_json.run_options,再回退 summary。
"""
if engine and engine.mode:
return str(engine.mode)
request_json = _as_summary_dict(schedule_run.api_request_json)
options = request_json.get("run_options")
option_mode = options.get("mode") if isinstance(options, dict) else None
return str(option_mode or voucher_summary.get("mode") or "incremental")
def _latest_period_month(
schedule_run: ScheduleRun,
engine: VoucherCheckRun | None,
voucher_summary: dict[str, Any],
) -> str:
"""最近一批的资料所属期间;无快照时回退上一个自然月。"""
if engine and engine.period_month:
return engine.period_month.strftime("%Y-%m")
raw = voucher_summary.get("period")
if raw:
return str(raw)[:7]
period_month, *_ = previous_period_bounds()
return period_month.strftime("%Y-%m")
def _latest_card_status(schedule_run: ScheduleRun, engine: VoucherCheckRun | None) -> str:
"""
将排程状态与引擎批次状态收成工作台卡片状态。
核心逻辑:queued/running 必须保留,不能走建批前失败那条 technical_failed 映射。
"""
schedule_status = str(schedule_run.status or "")
if schedule_status == "queued":
return "queued"
if schedule_status == "running":
return "running"
if schedule_status == "failed":
return "technical_failed"
if engine is not None:
return str(engine.status or "completed")
if schedule_status in {"success", "partial_failed"}:
return "completed"
return schedule_status or "queued"
def _latest_progress_percent(
*,
card_status: str,
step: str | None,
processed: int,
subject_count: int,
) -> int:
"""
按 runner 步骤估算进度百分比。
核心逻辑:无精确进度字段;scan_dms 用已处理 invoice / 总数插值,终态固定 100。
"""
if card_status in {"completed", "missing"}:
return 100
if not step and card_status == "queued":
return 8
if step == "scan_dms" and subject_count > 0:
return min(86, 22 + int(64 * processed / subject_count))
step_base = {
"queued": 8,
"fetch_erp": 18,
"scan_dms": 22,
"persist": 88,
"notify": 94,
"done": 100,
}
if step in step_base:
return step_base[step]
if card_status == "technical_failed":
return 18
if card_status == "running":
return 12
return 0
def _serialize_latest_run(schedule_run: ScheduleRun, engine: VoucherCheckRun | None) -> dict[str, Any]:
"""
序列化工作台「最近一次检核」卡片。
核心逻辑:进度与四指标来自 ScheduleRun.response_summary_json 与引擎快照;不跟列表 period 筛选。
"""
voucher_summary = _latest_voucher_summary(schedule_run)
current_step = _latest_current_step(schedule_run)
card_status = _latest_card_status(schedule_run, engine)
step_code = str(current_step.get("step") or "") or None
if not step_code and card_status == "queued":
step_code = "queued"
processed = int(current_step.get("processed_count") or 0)
subject_count = int(
(engine.subject_count if engine is not None else 0)
or voucher_summary.get("subject_count")
or 0
)
archived_file_count = int(
(engine.archived_file_count if engine is not None else 0)
or voucher_summary.get("archived_file_count")
or 0
)
missing_file_count = int(
(engine.missing_file_count if engine is not None else 0)
or voucher_summary.get("missing_file_count")
or 0
)
missing_invoice_count = int(
(engine.missing_invoice_count if engine is not None else 0)
or voucher_summary.get("missing_invoice_count")
or 0
)
started_at = (engine.started_at if engine is not None else None) or schedule_run.started_at
finished_at = (engine.finished_at if engine is not None else None) or schedule_run.finished_at
if card_status in {"queued", "running"}:
finished_at = None
return {
"schedule_run_id": schedule_run.id,
"engine_run_id": engine.id if engine is not None else None,
"run_no": schedule_run.run_no,
"period_month": _latest_period_month(schedule_run, engine, voucher_summary),
"mode": _latest_run_mode(schedule_run, engine, voucher_summary),
"status": card_status,
"progress_percent": _latest_progress_percent(
card_status=card_status,
step=step_code,
processed=processed,
subject_count=subject_count,
),
"subject_count": subject_count,
"archived_file_count": archived_file_count,
"missing_file_count": missing_file_count,
"missing_invoice_count": missing_invoice_count,
"processed_count": processed,
"started_at": _iso_dt(started_at),
"finished_at": _iso_dt(finished_at),
"error_message": schedule_run.error_message,
"current_step": {
"step": step_code,
"label": str(current_step.get("label") or "") or None,
"processed_count": processed,
}
if step_code
else None,
}
def _serialize_latest_from_engine(engine: VoucherCheckRun) -> dict[str, Any]:
"""
无对应排程时,用引擎批次充当最近一次检核。
核心逻辑:历史/测试数据可能只有 voucher_check_runs;终态进度为 100。
"""
card_status = str(engine.status or "completed")
return {
"schedule_run_id": engine.schedule_run_id,
"engine_run_id": engine.id,
"run_no": engine.run_no,
"period_month": engine.period_month.strftime("%Y-%m") if engine.period_month else None,
"mode": engine.mode,
"status": card_status,
"progress_percent": _latest_progress_percent(
card_status=card_status,
step="done" if card_status in {"completed", "missing"} else None,
processed=int(engine.subject_count or 0),
subject_count=int(engine.subject_count or 0),
),
"subject_count": int(engine.subject_count or 0),
"archived_file_count": int(engine.archived_file_count or 0),
"missing_file_count": int(engine.missing_file_count or 0),
"missing_invoice_count": int(engine.missing_invoice_count or 0),
"processed_count": int(engine.subject_count or 0),
"started_at": _iso_dt(engine.started_at),
"finished_at": _iso_dt(engine.finished_at),
"error_message": None,
"current_step": {"step": "done", "label": None, "processed_count": int(engine.subject_count or 0)}
if card_status in {"completed", "missing"}
else None,
}
def get_latest_run() -> dict[str, Any] | None:
"""
取立账凭证最近一次排程批次(按 ScheduleRun.id 倒序),不跟随列表 period/status。
核心逻辑:有排程则 join 引擎快照与 response_summary_json;仅有引擎批次时回退引擎表。
Returns:
卡片载荷;从未跑过任何批次时为 None。
"""
schedule_run = (
ScheduleRun.query.join(ScheduleTask, ScheduleRun.schedule_task_id == ScheduleTask.id)
.filter(ScheduleTask.platform_api_path == DEFAULT_VOUCHER_CHECK_PLATFORM_PATH)
.order_by(ScheduleRun.id.desc())
.first()
)
if schedule_run is not None:
engine = VoucherCheckRun.query.filter_by(schedule_run_id=schedule_run.id).first()
return _serialize_latest_run(schedule_run, engine)
latest_engine = VoucherCheckRun.query.order_by(VoucherCheckRun.id.desc()).first()
if latest_engine is None:
return None
return _serialize_latest_from_engine(latest_engine)
def list_runs(
*,
period: str | None = None,
@@ -105,12 +421,11 @@ def list_runs(
工作台任务列表:按执行时间倒序返回引擎批次及建批前失败的排程记录。
核心逻辑:正常场景读取 VoucherCheckRun 统计快照;若配置校验等错误发生在
create_run 之前,则回退显示对应 ScheduleRun,保证强制重检结果可见。
period 支持 YYYY(全年)或 YYYY-MM(单月)。
"""
page = max(1, int(page or 1))
page_size = max(1, min(int(page_size or 50), 200))
q = VoucherCheckRun.query
if period:
q = q.filter(VoucherCheckRun.period_month == parse_period_month(period))
q = _apply_period_filter(VoucherCheckRun.query, VoucherCheckRun.period_month, period)
if profile_code:
q = q.filter(VoucherCheckRun.profile_code == str(profile_code).strip())
if status:
@@ -120,7 +435,7 @@ def list_runs(
fallback_query = (
ScheduleRun.query.join(ScheduleTask, ScheduleRun.schedule_task_id == ScheduleTask.id)
.filter(
ScheduleTask.platform_api_path == "accounting-voucher-check",
ScheduleTask.platform_api_path == DEFAULT_VOUCHER_CHECK_PLATFORM_PATH,
ScheduleRun.status == "failed",
)
)
@@ -132,7 +447,7 @@ def list_runs(
row
for row in fallback_rows
if row.id not in engine_schedule_run_ids
and (not period or _serialize_schedule_fallback_run(row)["period_month"] == parse_period_month(period).strftime("%Y-%m"))
and _period_value_in_filter(_serialize_schedule_fallback_run(row)["period_month"], period)
]
merged = [_serialize_engine_run(row) for row in engine_rows]
merged.extend(_serialize_schedule_fallback_run(row) for row in fallback_rows)
@@ -284,6 +599,7 @@ def list_notifications(
"""
分页查询企微缺件汇总发送记录。
核心逻辑:以 voucher_check_notifications 为真相源,关联引擎批次取期间/批次号,并回填接收人姓名。
period 支持 YYYY(全年)或 YYYY-MM(单月)。
"""
page = max(1, int(page or 1))
page_size = max(1, min(int(page_size or 50), 200))
@@ -291,8 +607,7 @@ def list_notifications(
VoucherCheckRun,
VoucherCheckNotification.run_id == VoucherCheckRun.id,
)
if period:
q = q.filter(VoucherCheckRun.period_month == parse_period_month(period))
q = _apply_period_filter(q, VoucherCheckRun.period_month, period)
status_filter = str(send_status or "").strip()
if status_filter:
q = q.filter(VoucherCheckNotification.send_status == status_filter)
@@ -0,0 +1,253 @@
"""
backend/tests/voucher_check/test_workspace_latest_run.py
用途:工作台「最近一次检核」接口契约(含排队/执行中/终态/建批前失败)。
依赖:pytest、Flask client、voucher_check.query_service。
逻辑:GET /runs/latest 按 ScheduleRun.id 倒序,不跟列表 period;queued 不得被标成 technical_failed。
"""
from __future__ import annotations
from datetime import date, datetime
from tests.conftest import parse_api_data
from app import db
from app.models import ScheduleRun, User
from app.models.voucher_check import VoucherCheckRun
from app.services.voucher_check.schedule_seed import ensure_default_voucher_check_schedule
def _ensure_user(*, username: str, role: str) -> User:
"""测试用户幂等创建。"""
user = db.session.query(User).filter_by(username=username).first()
if user:
user.role = role
user.status = "active"
db.session.commit()
return user
user = User(
username=username,
email=f"{username}@example.com",
role=role,
status="active",
)
user.set_password("test")
db.session.add(user)
db.session.commit()
return user
def _add_schedule_run(
*,
run_no: str,
status: str,
mode: str | None = None,
error_message: str | None = None,
summary: dict | None = None,
started_at: datetime | None = None,
finished_at: datetime | None = None,
) -> ScheduleRun:
"""为本任务排程插入一条 ScheduleRun。"""
task = ensure_default_voucher_check_schedule(commit=True)
assert task is not None
payload = {"run_options": {"mode": mode}} if mode else None
run = ScheduleRun(
schedule_task_id=task.id,
run_no=run_no,
trigger_type="manual",
status=status,
total_count=0,
success_count=0,
failed_count=1 if status == "failed" else 0,
error_message=error_message,
api_request_json=payload,
response_summary_json=summary,
started_at=started_at,
finished_at=finished_at,
)
db.session.add(run)
db.session.flush()
return run
def _add_engine_run(
*,
schedule_run: ScheduleRun,
status: str = "missing",
period_month: date | None = None,
subject_count: int = 128,
archived_file_count: int = 742,
missing_file_count: int = 11,
missing_invoice_count: int = 6,
) -> VoucherCheckRun:
"""为排程批次挂一条引擎快照。"""
payload = schedule_run.api_request_json if isinstance(schedule_run.api_request_json, dict) else {}
options = payload.get("run_options") if isinstance(payload.get("run_options"), dict) else {}
engine = VoucherCheckRun(
schedule_run_id=schedule_run.id,
run_no=schedule_run.run_no,
profile_code="sales",
profile_version="1",
profile_snapshot_json={"profile_code": "sales"},
period_month=period_month or date(2026, 8, 1),
mode=str(options.get("mode") or "incremental"),
status=status,
subject_count=subject_count,
archived_file_count=archived_file_count,
missing_file_count=missing_file_count,
missing_invoice_count=missing_invoice_count,
started_at=schedule_run.started_at,
finished_at=schedule_run.finished_at,
)
db.session.add(engine)
return engine
def test_workspace_latest_run_returns_queued_force_all(app, client, user_headers):
"""入队中的强制重检必须显示 queued,而不是建批前失败口径。"""
with app.app_context():
_ensure_user(username="user", role="user")
_add_schedule_run(
run_no="RUN-LATEST-QUEUED",
status="queued",
mode="force_all",
)
db.session.commit()
response = client.get(
"/api/workspace/accounting-voucher-check/runs/latest",
headers=user_headers,
)
assert response.status_code == 200
payload = parse_api_data(response.get_json())
assert payload is not None
assert payload["run_no"] == "RUN-LATEST-QUEUED"
assert payload["status"] == "queued"
assert payload["mode"] == "force_all"
assert payload["progress_percent"] == 8
assert payload["current_step"]["step"] == "queued"
def test_workspace_latest_run_returns_completed_metrics(app, client, user_headers):
"""终态缺件批次返回四指标与 100% 进度。"""
with app.app_context():
_ensure_user(username="user", role="user")
sched = _add_schedule_run(
run_no="RUN-LATEST-DONE",
status="success",
mode="incremental",
started_at=datetime(2026, 9, 8, 1, 48, 7),
finished_at=datetime(2026, 9, 8, 1, 50, 19),
summary={
"current_step": {"step": "done", "label": "检核完成", "processed_count": 128},
"voucher_check": {"period": "2026-08", "mode": "incremental", "subject_count": 128},
},
)
_add_engine_run(schedule_run=sched, status="missing")
db.session.commit()
response = client.get(
"/api/workspace/accounting-voucher-check/runs/latest",
headers=user_headers,
)
assert response.status_code == 200
payload = parse_api_data(response.get_json())
# 关键断言:卡片数字来自引擎快照,状态用缺件而非排程 success。
assert payload["run_no"] == "RUN-LATEST-DONE"
assert payload["status"] == "missing"
assert payload["period_month"] == "2026-08"
assert payload["mode"] == "incremental"
assert payload["progress_percent"] == 100
assert payload["subject_count"] == 128
assert payload["archived_file_count"] == 742
assert payload["missing_file_count"] == 11
assert payload["missing_invoice_count"] == 6
def test_workspace_latest_run_running_progress_ignores_list_period(app, client, user_headers):
"""执行中进度跟 runner 步骤走,且 latest 不吃列表 period。"""
with app.app_context():
_ensure_user(username="user", role="user")
old = _add_schedule_run(
run_no="RUN-LATEST-OLD-AUG",
status="success",
mode="incremental",
finished_at=datetime(2026, 9, 1, 6, 0, 0),
)
_add_engine_run(schedule_run=old, status="completed", period_month=date(2026, 8, 1), subject_count=10)
_add_schedule_run(
run_no="RUN-LATEST-RUNNING",
status="running",
mode="force_all",
started_at=datetime(2026, 9, 9, 6, 5, 22),
summary={
"current_step": {
"step": "scan_dms",
"label": "扫描销售开票附件类型目录",
"processed_count": 54,
},
"voucher_check": {
"period": "2026-07",
"mode": "force_all",
"subject_count": 128,
"missing_file_count": 3,
"missing_invoice_count": 2,
},
},
)
db.session.commit()
latest = client.get(
"/api/workspace/accounting-voucher-check/runs/latest",
headers=user_headers,
)
assert latest.status_code == 200
payload = parse_api_data(latest.get_json())
assert payload["run_no"] == "RUN-LATEST-RUNNING"
assert payload["status"] == "running"
assert payload["period_month"] == "2026-07"
assert payload["processed_count"] == 54
assert payload["progress_percent"] == min(86, 22 + int(64 * 54 / 128))
assert payload["finished_at"] is None
filtered = client.get(
"/api/workspace/accounting-voucher-check/runs?period=2026-08",
headers=user_headers,
)
assert filtered.status_code == 200
nos = {item["run_no"] for item in parse_api_data(filtered.get_json())["items"]}
# 关键断言:列表按 8 月过滤看不到 7 月执行中批次,但 latest 仍是该批。
assert "RUN-LATEST-RUNNING" not in nos
assert payload["run_no"] == "RUN-LATEST-RUNNING"
def test_workspace_latest_run_pre_engine_failure(app, client, user_headers):
"""建批前失败仍作为最近一次检核,状态为技术失败。"""
with app.app_context():
_ensure_user(username="user", role="user")
_add_schedule_run(
run_no="RUN-LATEST-FAILED",
status="failed",
mode="incremental",
error_message="未配置销售开票附件文档库根目录",
started_at=datetime(2026, 9, 7, 8, 31, 51),
finished_at=datetime(2026, 9, 7, 8, 32, 10),
summary={
"current_step": {"step": "fetch_erp", "label": "拉取上月销售 invoice", "processed_count": 0},
"voucher_check": {"period": "2026-08"},
},
)
db.session.commit()
response = client.get(
"/api/workspace/accounting-voucher-check/runs/latest",
headers=user_headers,
)
assert response.status_code == 200
payload = parse_api_data(response.get_json())
assert payload["run_no"] == "RUN-LATEST-FAILED"
assert payload["status"] == "technical_failed"
assert payload["error_message"] == "未配置销售开票附件文档库根目录"
assert payload["current_step"]["step"] == "fetch_erp"
assert payload["progress_percent"] == 18
@@ -0,0 +1,185 @@
"""
backend/tests/voucher_check/test_workspace_period_filter.py
用途:工作台检核任务 / 企微发送记录的期间筛选(YYYY 全年、YYYY-MM 单月)。
依赖:pytest、Flask client、voucher_check.query_service。
逻辑:同一年多个月份应被 year 筛出;单月筛仍精确;建批前失败记录按年也能命中。
"""
from __future__ import annotations
from datetime import date, datetime
import pytest
from tests.conftest import parse_api_data, parse_api_error
from app import db
from app.core.errors import ValidationError
from app.models import ScheduleRun, User
from app.models.voucher_check import VoucherCheckNotification, VoucherCheckRun
from app.services.voucher_check.query_service import parse_period_filter
from app.services.voucher_check.schedule_seed import ensure_default_voucher_check_schedule
def _ensure_user(*, username: str, role: str) -> User:
"""测试用户幂等创建。"""
user = db.session.query(User).filter_by(username=username).first()
if user:
user.role = role
user.status = "active"
db.session.commit()
return user
user = User(
username=username,
email=f"{username}@example.com",
role=role,
status="active",
)
user.set_password("test")
db.session.add(user)
db.session.commit()
return user
def _engine_run(*, run_no: str, period_month: date, status: str = "missing") -> VoucherCheckRun:
"""构造列表用引擎批次。"""
return VoucherCheckRun(
run_no=run_no,
profile_code="sales",
profile_version="1",
profile_snapshot_json={"profile_code": "sales"},
period_month=period_month,
mode="incremental",
status=status,
subject_count=1,
finished_at=datetime(period_month.year, period_month.month, 2, 6, 0, 0),
)
def test_parse_period_filter_year_and_month():
"""YYYY 覆盖全年,YYYY-MM 只覆盖该月。"""
start, end = parse_period_filter("2026")
assert start == date(2026, 1, 1)
assert end == date(2027, 1, 1)
start, end = parse_period_filter("2026-08")
assert start == date(2026, 8, 1)
assert end == date(2026, 9, 1)
start, end = parse_period_filter("2026-12")
assert start == date(2026, 12, 1)
assert end == date(2027, 1, 1)
assert parse_period_filter(None) == (None, None)
with pytest.raises(ValidationError) as exc:
parse_period_filter("2026-13")
assert exc.value.code == "VOUCHER_CHECK.CONFIG_INVALID"
def test_workspace_lists_runs_by_year_or_month(app, client, user_headers):
"""任务列表 year 筛出同年多月,month 仍只返回单月。"""
with app.app_context():
_ensure_user(username="user", role="user")
db.session.add(_engine_run(run_no="VC-202608-Y", period_month=date(2026, 8, 1)))
db.session.add(_engine_run(run_no="VC-202607-Y", period_month=date(2026, 7, 1)))
db.session.add(_engine_run(run_no="VC-202512-Y", period_month=date(2025, 12, 1)))
db.session.commit()
year_resp = client.get(
"/api/workspace/accounting-voucher-check/runs?period=2026",
headers=user_headers,
)
assert year_resp.status_code == 200
year_payload = parse_api_data(year_resp.get_json())
year_nos = {item["run_no"] for item in year_payload["items"]}
# 关键断言:全年筛选包含 7、8 月,不含跨年 12 月。
assert "VC-202608-Y" in year_nos
assert "VC-202607-Y" in year_nos
assert "VC-202512-Y" not in year_nos
month_resp = client.get(
"/api/workspace/accounting-voucher-check/runs?period=2026-08",
headers=user_headers,
)
assert month_resp.status_code == 200
month_payload = parse_api_data(month_resp.get_json())
month_nos = {item["run_no"] for item in month_payload["items"]}
assert "VC-202608-Y" in month_nos
assert "VC-202607-Y" not in month_nos
def test_workspace_year_filter_includes_pre_engine_failure(app, client, admin_headers):
"""建批前失败记录在按年筛选时仍须出现。"""
with app.app_context():
_ensure_user(username="admin", role="admin")
task = ensure_default_voucher_check_schedule(commit=True)
assert task is not None
db.session.add(
ScheduleRun(
schedule_task_id=task.id,
run_no="RUN-PREENGINE-YEAR",
trigger_type="manual",
status="failed",
total_count=0,
success_count=0,
failed_count=1,
error_message="未配置销售开票附件文档库根目录",
response_summary_json={"voucher_check": {"period": "2026-08"}},
)
)
db.session.commit()
response = client.get(
"/api/workspace/accounting-voucher-check/runs?period=2026&status=technical_failed",
headers=admin_headers,
)
assert response.status_code == 200
payload = parse_api_data(response.get_json())
nos = {item["run_no"] for item in payload["items"]}
assert "RUN-PREENGINE-YEAR" in nos
def test_workspace_lists_notifications_by_year(app, client, user_headers):
"""企微发送记录按年筛选应覆盖该年各月。"""
with app.app_context():
_ensure_user(username="user", role="user")
august = _engine_run(run_no="VC-202608-N", period_month=date(2026, 8, 1))
july = _engine_run(run_no="VC-202607-N", period_month=date(2026, 7, 1), status="completed")
db.session.add_all([august, july])
db.session.flush()
db.session.add_all(
[
VoucherCheckNotification(
run_id=august.id,
send_status="sent",
summary_json={"period": "2026-08"},
),
VoucherCheckNotification(
run_id=july.id,
send_status="skipped_no_missing",
summary_json={"period": "2026-07"},
),
]
)
db.session.commit()
response = client.get(
"/api/workspace/accounting-voucher-check/notifications?period=2026",
headers=user_headers,
)
assert response.status_code == 200
payload = parse_api_data(response.get_json())
nos = {item["run_no"] for item in payload["items"]}
assert "VC-202608-N" in nos
assert "VC-202607-N" in nos
def test_workspace_rejects_invalid_period(app, client, user_headers):
"""非法 period 返回配置错误,而不是空列表。"""
with app.app_context():
_ensure_user(username="user", role="user")
response = client.get(
"/api/workspace/accounting-voucher-check/runs?period=2026-13",
headers=user_headers,
)
assert response.status_code == 400
error = parse_api_error(response.get_json())
assert error["code"] == "VOUCHER_CHECK.CONFIG_INVALID"
@@ -5,7 +5,7 @@
| **需求说明** | 产品、业务、测试 | [demand.md](demand.md) |
| **技术设计** | 研发 | [technical-design.md](technical-design.md) |
| **技术规格** | 研发、测试 | [technical.md](technical.md) |
| **原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html) · [说明](accounting-voucher-check-prototype.md) |
| **原型** | 产品、业务、测试 | [accounting-voucher-check-prototype.html](accounting-voucher-check-prototype.html) · [说明](accounting-voucher-check-prototype.md) · [最近一次检核卡片](accounting-voucher-check-latest-run-prototype.html) |
| **部署验收清单** | 运维、研发 | [ops-checklist.md](ops-checklist.md) |
**定位**:以业务方 Profile 驱动的批量资料检核;**每周二**增量处理上一个自然月。销售开票附件先落入文档库类型目录,再按 `invoice` 归入「所有归档」。
@@ -0,0 +1,409 @@
<!doctype html>
<!--
docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html
用途:立账凭证工作台「最近一次检核」卡片原型(Tab 下方、筛选栏上方)。
依赖:浏览器原生 HTML/CSS/JS,无需构建。
逻辑:默认展示最近一批终态;点「强制重检上月」切入执行中进度;原型预览可切换完成/执行中/失败。
-->
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>立账凭证 · 最近一次检核原型</title>
<style>
:root {
--ink: #142033;
--muted: #64748b;
--line: #e2e8f0;
--bg: #f4f7fb;
--panel: #fff;
--brand: #2563eb;
--brand-soft: #eff6ff;
--red: #b42318;
--green: #067647;
--amber: #b54708;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--ink);
font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, select { font: inherit; }
button { cursor: pointer; }
.page { width: min(1120px, calc(100% - 32px)); margin: 24px auto 48px; }
.proto-note {
margin-bottom: 16px;
padding: 10px 12px;
border: 1px dashed #bfdbfe;
border-radius: 10px;
background: #f8fbff;
color: #334155;
font-size: 12px;
}
.proto-note b { color: var(--brand); }
.proto-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
header h1 { margin: 0; font-size: 24px; }
header p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin: 18px 0 0; border-bottom: 1px solid var(--line); }
.tabs button {
border: 0;
border-bottom: 2px solid transparent;
margin-bottom: -1px;
padding: 10px 16px;
color: var(--muted);
background: transparent;
font-weight: 600;
}
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.filters {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
gap: 12px;
margin: 14px 0;
padding: 12px 16px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
.filters label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.filters select {
min-width: 76px;
padding: 6px 10px;
border: 1px solid var(--line);
border-radius: 12px;
background: #fff;
}
.btn {
display: inline-flex;
align-items: center;
gap: 6px;
border: 1px solid var(--line);
border-radius: 12px;
padding: 7px 12px;
background: #fff;
font-size: 13px;
font-weight: 650;
}
.btn.primary { border-color: var(--brand); color: #fff; background: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.latest {
overflow: hidden;
margin-top: 16px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
.latest-actions { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.btn.warn { border-color: #fcd34d; color: #92400e; background: #fffbeb; }
.latest-hd {
display: flex;
justify-content: space-between;
gap: 12px;
align-items: flex-start;
padding: 14px 16px 12px;
background: var(--brand-soft);
}
.latest-hd h2 { margin: 0; font-size: 15px; }
.latest-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.latest-meta span { margin-right: 12px; }
.badge {
display: inline-flex;
padding: 3px 10px;
border-radius: 99px;
font-size: 12px;
font-weight: 750;
white-space: nowrap;
}
.badge.ok { color: var(--green); background: #ecfdf3; }
.badge.miss { color: var(--red); background: #fff1f2; }
.badge.run { color: #175cd3; background: #dbeafe; }
.badge.fail { color: var(--red); background: #fff1f2; }
.latest-bd { padding: 14px 16px 16px; }
.bar { height: 10px; overflow: hidden; border-radius: 99px; background: #e8eef5; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: #0f766e; transition: width .35s ease; }
.bar.fail i { background: #e11d48; }
.bar-row { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 14px; color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric {
padding: 12px 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: #f8fafc;
}
.metric b { display: block; font-size: 22px; line-height: 1.2; }
.metric span { color: var(--muted); font-size: 12px; }
.metric.warn b { color: var(--red); }
.step-line { margin: 12px 0 0; color: #334155; font-size: 13px; }
.step-line small { display: block; margin-top: 2px; color: var(--muted); }
.latest-ft { display: flex; justify-content: flex-end; margin-top: 12px; }
.link { border: 0; padding: 0; color: #175cd3; background: transparent; font-weight: 700; }
.table-wrap {
overflow: auto;
margin-top: 14px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f8fafc; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.pill.miss { color: var(--red); background: #fff1f2; }
.pill.fail { color: #475569; background: #f1f5f9; }
.err { max-width: 240px; overflow: hidden; color: var(--red); text-overflow: ellipsis; }
.toast {
position: fixed; right: 18px; bottom: 18px;
padding: 10px 12px; border-radius: 9px; color: #fff; background: #142036;
opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; }
@media (max-width: 820px) {
.metrics { grid-template-columns: 1fr 1fr; }
.btn.warn { margin-left: 0; }
}
</style>
</head>
<body>
<div class="page">
<div class="proto-note">
这是<strong>原型</strong>,不是工作台代码。最近一次检核放在 Tab 下方、筛选栏上方:它是整页状态,不跟着年/月过滤。强制重检放在卡片上,点击后进度就在本卡更新。
<div class="proto-actions">
预览状态:
<button class="btn" type="button" data-preview="done">完成 · 缺件</button>
<button class="btn" type="button" data-preview="running">执行中</button>
<button class="btn" type="button" data-preview="failed">技术失败</button>
</div>
</div>
<header>
<h1>立账凭证检核任务</h1>
<p>每周二增量检核上一个自然月;扫描销售开票附件类型目录后按 invoice 归档,并汇总缺件。</p>
</header>
<nav class="tabs">
<button class="active" type="button">检核任务</button>
<button type="button" disabled>企微发送记录</button>
</nav>
<article class="latest" id="latest" aria-live="polite"></article>
<section class="filters">
<label>资料所属期间
<span>
<select><option>2026</option></select>
<select><option>8月</option><option>全部</option></select>
</span>
</label>
<label>状态
<select><option>全部</option><option>缺件</option><option>完整</option><option>技术失败</option></select>
</label>
<button class="btn primary" type="button">查询</button>
</section>
<section class="table-wrap">
<table>
<thead>
<tr>
<th>批次号</th>
<th>资料所属期间</th>
<th>invoice总数</th>
<th>invoice缺件数</th>
<th>缺件文件数</th>
<th>状态</th>
<th>执行时间</th>
<th>失败原因</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><b>RUN2026090801480719A3</b></td>
<td>2026-08</td>
<td>128</td>
<td>6</td>
<td>11</td>
<td><span class="pill miss">缺件</span></td>
<td>2026-09-08 09:50:19</td>
<td>—</td>
<td><button class="link" type="button">查看详情</button></td>
</tr>
<tr>
<td>RUN202609070831512538</td>
<td>2026-08</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td><span class="pill fail">技术失败</span></td>
<td>2026-09-07 16:32:10</td>
<td class="err">未配置销售开票附件文档库根目录</td>
<td><button class="link" type="button">查看详情</button></td>
</tr>
</tbody>
</table>
</section>
</div>
<div class="toast" id="toast"></div>
<script>
/**
* 原型状态机:完成 / 执行中 / 失败。强制重检走一套示意步骤,不请求后端。
*/
(() => {
const latestEl = document.getElementById("latest");
const toastEl = document.getElementById("toast");
let timer = null;
let busy = false;
const snapshots = {
done: {
title: "最近一次检核",
runNo: "RUN2026090801480719A3",
period: "2026-08",
mode: "增量",
status: "缺件",
statusClass: "miss",
barClass: "",
percent: 100,
started: "2026-09-08 09:48:07",
finished: "2026-09-08 09:50:19",
step: "本批已完成,缺件结果已写入 Excel。",
hint: "",
metrics: [128, 742, 11, 6],
},
running: {
title: "最近一次检核",
runNo: "RUN202609090605221C4B",
period: "2026-08",
mode: "全量重检",
status: "执行中",
statusClass: "run",
barClass: "",
percent: 42,
started: "2026-09-09 14:05:22",
finished: "进行中",
step: "扫描销售开票附件类型目录",
hint: "已处理 54 / 128 张 invoice",
metrics: [128, 310, 3, 2],
},
failed: {
title: "最近一次检核",
runNo: "RUN202609070831512538",
period: "2026-08",
mode: "增量",
status: "技术失败",
statusClass: "fail",
barClass: "fail",
percent: 18,
started: "2026-09-07 16:31:51",
finished: "2026-09-07 16:32:10",
step: "拉取上月销售 invoice 未完成",
hint: "未配置销售开票附件文档库根目录",
metrics: [0, 0, 0, 0],
},
};
const forceSteps = [
{ percent: 8, status: "排队中", step: "已入队强制重检上月", hint: "等待 schedule worker 领取", metrics: [0, 0, 0, 0] },
{ percent: 22, status: "执行中", step: "拉取上月销售 invoice", hint: "HXJM apa_file · 期间 2026-08", metrics: [128, 0, 0, 0] },
{ percent: 58, status: "执行中", step: "扫描销售开票附件类型目录", hint: "已处理 74 / 128 张 invoice", metrics: [128, 410, 5, 3] },
{ percent: 82, status: "执行中", step: "按 invoice 归档(同名跳过)", hint: "正在写入所有归档", metrics: [128, 690, 9, 5] },
{ percent: 100, status: "缺件", step: "本批已完成,缺件结果已写入 Excel。", hint: "", metrics: [128, 742, 11, 6], done: true },
];
function toast(message) {
toastEl.textContent = message;
toastEl.classList.add("show");
setTimeout(() => toastEl.classList.remove("show"), 2200);
}
function render(data) {
const warn = data.metrics[2] > 0 || data.metrics[3] > 0;
const labels = ["invoice总数", "已归档文件", "缺件文件数", "缺件 invoice 数"];
latestEl.innerHTML =
'<div class="latest-hd">' +
"<div><h2>" + data.title + "</h2>" +
'<p class="latest-meta"><span>批次 ' + data.runNo + "</span><span>期间 " + data.period + "</span><span>" + data.mode + "</span></p></div>" +
'<div class="latest-actions">' +
'<span class="badge ' + data.statusClass + '">' + data.status + "</span>" +
'<button class="btn warn" type="button" data-force="1"' + (busy ? " disabled" : "") + ">强制重检上月</button>" +
"</div>" +
"</div>" +
'<div class="latest-bd">' +
'<div class="bar ' + data.barClass + '"><i style="width:' + data.percent + '%"></i></div>' +
'<div class="bar-row"><span>进度 ' + data.percent + "%</span><span>开始:" + data.started + " 完成:" + data.finished + "</span></div>" +
'<div class="metrics">' +
data.metrics.map(function (value, index) {
const hot = warn && index > 1;
return '<div class="metric' + (hot ? " warn" : "") + '"><b>' + value + "</b><span>" + labels[index] + "</span></div>";
}).join("") +
"</div>" +
'<p class="step-line">' + data.step + (data.hint ? "<small>" + data.hint + "</small>" : "") + "</p>" +
(data.percent === 100 && data.statusClass !== "fail"
? '<div class="latest-ft"><button class="link" type="button">查看本批详情</button></div>'
: "") +
"</div>";
}
function show(key) {
if (timer) {
clearInterval(timer);
timer = null;
}
busy = false;
render(snapshots[key]);
}
function startForce() {
if (busy) return;
busy = true;
let index = 0;
const started = "2026-09-09 14:08:01";
const runNo = "RUN2026090906080119F2";
function paint() {
const step = forceSteps[index];
render({
title: "最近一次检核",
runNo: runNo,
period: "2026-08",
mode: "全量重检",
status: step.status,
statusClass: step.done ? "miss" : "run",
barClass: "",
percent: step.percent,
started: started,
finished: step.done ? "2026-09-09 14:10:26" : "进行中",
step: step.step,
hint: step.hint,
metrics: step.metrics,
});
if (step.done) {
clearInterval(timer);
timer = null;
busy = false;
toast("原型示意:强制重检已完成,列表稍后出现新批次。");
}
index += 1;
}
paint();
timer = setInterval(function () {
if (index >= forceSteps.length) return;
paint();
}, 900);
}
document.querySelectorAll("[data-preview]").forEach(function (button) {
button.addEventListener("click", function () {
show(button.getAttribute("data-preview"));
});
});
latestEl.addEventListener("click", function (event) {
if (event.target.closest("[data-force]")) startForce();
});
show("done");
})();
</script>
</body>
</html>
@@ -1,7 +1,7 @@
# 立账凭证资料检核需求说明
> 文档版本:v1.9
> 更新时间:2026-09-08
> 文档版本:v1.11
> 更新时间:2026-09-09
> 状态:一期销售需求确认中;采购及其它业务方待后续 Profile 配置
>
> 本文是本期需求权威。部署与冒烟见 [ops-checklist.md](ops-checklist.md)。旧共享盘存在性扫描、Chatflow Tool 与一票一状态表已移除,不得再按该口径扩展。
@@ -57,16 +57,17 @@
### 3.4 检核任务列表
检核任务列表是用户查看历史批次和进入详情的主入口。默认按最新批次展示,支持筛选后查看对应的执行明细、企业微信通知附件 Excel 和通知记录。
检核任务列表是用户查看历史批次和进入详情的主入口。默认展示**上一个自然月**的批次,支持把月份改为「全部」查看该年全部批次,再进入对应的执行明细、企业微信通知附件 Excel 和通知记录。
「最近一次检核」卡片放在 Tab 下方、筛选栏上方,只出现在「检核任务」Tab:展示**最近一批**(按执行时间,不跟年/月/状态筛选)的批次号、期间、模式、状态、进度、开始/完成时间、当前步骤,以及 invoice 总数 / 已归档 / 缺件文件 / 缺件 invoice。强制重检上月(仅管理员)放在这张卡片上,入队后进度在本卡更新。
| 区域 | 内容 |
| ------------ | ------------------------------------------------------------------------------------------------- |
| 顶部统计 | 当前筛选条件下的主体总数、已归档文件数、缺件文件数、缺件 `invoice` 数 |
| 筛选条件 | 资料所属期间、业务方、任务状态 |
| 任务列表字段 | 批次号、业务方、资料所属期间、执行时间、主体总数、已归档数、缺件文件数、缺件 `invoice` 数、状态 |
| 状态 | 缺件、已完成、技术失败、待配置 |
| 最近一次检核 | 最近一批进度与四指标;强制重检上月(全量 `force_all`,期间固定上一个自然月,不用筛选栏期间) |
| 筛选条件 | 资料所属期间(年必选、月可选「全部」;进页默认上一个自然月)、任务状态 |
| 任务列表字段 | 批次号、资料所属期间、执行时间、主体总数、缺件文件数、缺件 `invoice` 数、状态、失败原因 |
| 状态 | 排队中、执行中、缺件、完整、技术失败 |
| 操作 | 查看详情;进入该批次的执行记录,并可查看企业微信通知附件 Excel |
| 任务入口 | 支持新建任务、强制重检(仅上一个月);企微接收人从系统用户多选,可复用排程通知人选择器 |
### 3.5 企业微信发送记录
@@ -74,7 +75,7 @@
| 区域 | 内容 |
| -------- | --------------------------------------------------------------------------------------------- |
| 筛选条件 | 资料所属期间、发送状态 |
| 筛选条件 | 资料所属期间(与检核任务同一套年/月口径)、发送状态 |
| 列表字段 | 批次号、资料所属期间、invoice 总数、invoice 缺件数、缺件文件数、发送状态、未发送原因、接收人、发送时间、Excel |
| 操作 | 有附件时可下载该批 Excel;查看详情进入对应批次明细 |
@@ -0,0 +1,305 @@
"""
docs/features/accounting-voucher-check/hxops-po-sample.py
用途:用 ERP 打印件同款模拟数据生成「HXOPS 制式采购单」样张,供与 apmr900 对照。
依赖:reportlab、Windows 宋体、welltrust-logo.png(从原件抽出的页眉 Logo)。
逻辑:独立脚本,不接入周检核;数据写死自 采购单.pdf;不贴「无」图。
"""
from __future__ import annotations
from pathlib import Path
from reportlab.lib.colors import HexColor
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import mm
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas
FONT = "SimSun"
FONT_PATH = Path(r"C:\Windows\Fonts\simsun.ttc")
LOGO_PATH = Path(__file__).resolve().parent / "welltrust-logo.png"
INK = HexColor("#111111")
LINE = HexColor("#333333")
SOFT = HexColor("#666666")
# 数据来自 e:\Work\Agent\立账凭证\采购单.pdf(apmr900 / Crystal Reports)
SAMPLE = {
"company_phone": "0512-63136988",
"company_fax": "",
"company_address": "江苏省苏州市吴江区经济开发区山湖西路789号",
"company_name": "苏州和信精密科技有限公司",
"maker": "梁春艳",
"page": "1/1",
"po_date": "2016/5/28",
"po_no": "5201-1605280003",
"po_type": "原料采购单",
"price_term": "A01 取核价单价",
"ship_address": "",
"pay_term": "月结一个月",
"tax_type": "进项(17%含税)",
"currency": "RMB",
"bill_address": "",
"vendor_name": "北川科技(苏州)有限公司",
"vendor_code": "VCCD00013",
"vendor_tel": "0512-62810369",
"vendor_fax": "0512-62810368",
"vendor_addr": "苏州市工业园区胜浦分区银胜路61号",
"untax_total": "4,455.50",
"tax_total": "5,212.94",
"lines": [
{
"item_no": "3450541801",
"seq": "1",
"qty": "730",
"unit": "PCS",
"arrive": "2016/6/16",
"untax_price": "3.350000",
"untax_amt": "2,445.50",
"halogen": "RoHS",
"name": "FRAME CUBE CORNER",
"spec": "H20*W36.5*L36.7",
"tax_price": "3.919500",
"tax_amt": "2,861.24",
"origin_no": "3301-1605260004",
"version": "-0001",
"vendor_item": "3450541801",
},
{
"item_no": "3450541801",
"seq": "2",
"qty": "600",
"unit": "PCS",
"arrive": "2016/6/16",
"untax_price": "3.350000",
"untax_amt": "2,010.00",
"halogen": "RoHS",
"name": "FRAME CUBE CORNER",
"spec": "H20*W36.5*L36.7",
"tax_price": "3.919500",
"tax_amt": "2,351.70",
"origin_no": "3301-1605100007",
"version": "-0001",
"vendor_item": "3450541801",
},
],
}
def _register_font() -> None:
"""注册宋体,接近鼎捷报表常用中文字形。"""
pdfmetrics.registerFont(TTFont(FONT, str(FONT_PATH), subfontIndex=0))
def _text(c: canvas.Canvas, x: float, y: float, text: str, size: float = 9, color=INK) -> None:
c.setFillColor(color)
c.setFont(FONT, size)
c.drawString(x, y, text)
def _right(c: canvas.Canvas, x: float, y: float, text: str, size: float = 8, color=INK) -> None:
"""右对齐文字,用于数量和金额。"""
c.setFillColor(color)
c.setFont(FONT, size)
c.drawRightString(x, y, text)
def _hline(c: canvas.Canvas, x1: float, x2: float, y: float, width: float = 0.4) -> None:
c.setStrokeColor(LINE)
c.setLineWidth(width)
c.line(x1, y, x2, y)
def _rect(c: canvas.Canvas, x: float, y: float, w: float, h: float, fill=None) -> None:
c.setStrokeColor(LINE)
c.setLineWidth(0.5)
if fill is not None:
c.setFillColor(fill)
c.rect(x, y, w, h, stroke=1, fill=1)
else:
c.rect(x, y, w, h, stroke=1, fill=0)
def build_pdf(out_path: Path) -> None:
"""
按 A4 竖版画出采购单样张。
核心逻辑:版心对齐原件 Crystal 报表的信息分区,不复制 Crystal 精确坐标。
"""
_register_font()
out_path.parent.mkdir(parents=True, exist_ok=True)
page_w, page_h = A4
c = canvas.Canvas(str(out_path), pagesize=A4)
c.setTitle("HXOPS 制式采购单样张")
c.setAuthor("HXOPS")
left = 16 * mm
right = page_w - 16 * mm
y = page_h - 10 * mm
# [STEP 1] Logo 在左;右侧公司名、「采购单」、地址、电话;制表者/页次单独下一行靠右。
logo_w = 52 * mm
logo_h = 14 * mm
logo_bottom = y - logo_h
if LOGO_PATH.exists():
c.drawImage(
str(LOGO_PATH),
left,
logo_bottom,
width=logo_w,
height=logo_h,
mask="auto",
preserveAspectRatio=True,
anchor="sw",
)
text_x = left + 56 * mm
block_mid = (text_x + right) / 2
c.setFont(FONT, 11)
c.setFillColor(INK)
c.drawCentredString(block_mid, y - 3.5 * mm, SAMPLE["company_name"])
c.setFont(FONT, 10)
c.drawCentredString(block_mid, y - 8.2 * mm, "采购单")
_text(c, text_x, y - 13 * mm, f"地址:{SAMPLE['company_address']}", 8)
_text(c, text_x, y - 17.5 * mm, f"公司电话:{SAMPLE['company_phone']} 公司传真:", 8)
_text(c, right - 52 * mm, y - 22.5 * mm, f"制表者: {SAMPLE['maker']}", 8)
c.setFont(FONT, 8)
c.drawRightString(right, y - 22.5 * mm, f"页次: {SAMPLE['page']}")
y = min(logo_bottom, y - 24 * mm) - 2 * mm
_hline(c, left, right, y, 0.8)
y -= 6 * mm
# [STEP 2] 原件左栏采购单号、右栏采购日期(与上一版左右对调)
col2 = left + 98 * mm
val1 = left + 22 * mm
val2 = col2 + 20 * mm
_text(c, left, y, "采购单号:")
_text(c, val1, y, f"{SAMPLE['po_no']} {SAMPLE['po_type']}")
_text(c, col2, y, "采购日期:")
_text(c, val2, y, SAMPLE["po_date"])
y -= 5.2 * mm
_text(c, left, y, "付款条件:")
_text(c, val1, y, SAMPLE["pay_term"])
_text(c, col2, y, "税 种:")
_text(c, val2, y, SAMPLE["tax_type"])
y -= 5.2 * mm
_text(c, left, y, "价格条件:")
_text(c, val1, y, SAMPLE["price_term"])
_text(c, col2, y, "币 种:")
_text(c, val2, y, SAMPLE["currency"])
y -= 5.2 * mm
_text(c, left, y, "送货地址:")
_text(c, val1, y, SAMPLE["ship_address"] or " ")
y -= 5.2 * mm
_text(c, left, y, "帐单地址:")
_text(c, val1, y, SAMPLE["bill_address"] or " ")
y -= 6 * mm
_text(c, left, y, "供应厂商:")
_text(c, val1, y, f"{SAMPLE['vendor_code']} {SAMPLE['vendor_name']}")
_text(c, left + 118 * mm, y, f"Tel: {SAMPLE['vendor_tel']}")
y -= 5 * mm
_text(c, val1, y, SAMPLE["vendor_addr"], 8)
_text(c, left + 118 * mm, y, f"Fax: {SAMPLE['vendor_fax']}")
y -= 4 * mm
_hline(c, left, right, y, 0.8)
y -= 1 * mm
# [STEP 4] 按 Crystal 原件:无满格单元格;表头三行折行;项次在最左。
x_seq = left
x_item = left + 8 * mm
x_origin = left + 50 * mm
x_arrive = left + 80 * mm
x_qty = left + 108 * mm
x_unit = left + 116 * mm
x_price = left + 142 * mm
x_amt = left + 164 * mm
x_halo = left + 168 * mm
header_h = 11 * mm
table_top = y
_hline(c, left, right, table_top, 0.7)
h1 = table_top - 3.6 * mm
h2 = table_top - 7.0 * mm
h3 = table_top - 10.2 * mm
_text(c, x_seq, h1, "项次", 7)
_text(c, x_item, h1, "料件编号", 7)
_text(c, x_item, h2, "品名/规格", 7)
_text(c, x_item, h3, "厂商料号额外品名规格说明", 6.5)
_text(c, x_origin, h1, "原始编号", 7)
_text(c, x_origin, h2, "版本", 7)
_text(c, x_origin, h3, "行序", 6.5)
_text(c, x_arrive, h1, "到货日", 7)
_text(c, x_qty - 8 * mm, h1, "数 量", 7)
_text(c, x_unit, h1, "单 位", 7)
_right(c, x_price, h1, "税前单价", 7)
_right(c, x_price, h2, "含税单价", 7)
_right(c, x_amt, h1, "税前金额", 7)
_right(c, x_amt, h2, "含税金额", 7)
_text(c, x_halo, h1, "卤素", 7)
_text(c, x_halo, h2, "管控", 7)
_text(c, x_halo + 10 * mm, h1, "环保", 7)
_text(c, x_halo + 10 * mm, h2, "等级", 7)
c.setStrokeColor(LINE)
c.setLineWidth(0.4)
c.line(x_price - 22 * mm, h2 - 1.2 * mm, x_price, h2 - 1.2 * mm)
c.line(x_amt - 22 * mm, h2 - 1.2 * mm, x_amt, h2 - 1.2 * mm)
y = table_top - header_h
_hline(c, left, right, y, 0.5)
# [STEP 5] 每笔三行:料号/品名/规格,无斑马底、无竖线格
row_h = 13 * mm
for line in SAMPLE["lines"]:
r1 = y - 3.8 * mm
r2 = y - 7.6 * mm
r3 = y - 11.2 * mm
_text(c, x_seq, r1, line["seq"], 8)
_text(c, x_item, r1, line["item_no"], 8)
_text(c, x_item, r2, line["name"], 8)
_text(c, x_item, r3, line["spec"], 8)
_text(c, x_origin, r1, line["vendor_item"], 8)
_text(c, x_origin, r2, line["origin_no"], 8)
_text(c, x_arrive, r1, line["arrive"], 8)
_right(c, x_qty, r1, line["qty"], 8)
_text(c, x_unit, r1, line["unit"], 8)
_right(c, x_price, r1, line["untax_price"], 8)
_right(c, x_price, r2, line["tax_price"], 8)
_right(c, x_amt, r1, line["untax_amt"], 8)
_right(c, x_amt, r2, line["tax_amt"], 8)
_text(c, x_halo, r1, line["halogen"], 8)
y -= row_h
# [STEP 6] 合计靠右,金额带原件那种细框
y -= 6 * mm
box_w = 22 * mm
box_h = 4.6 * mm
_text(c, x_price - 28 * mm, y, "税前金额总和:", 8)
_rect(c, x_amt - box_w, y - 1.2 * mm, box_w, box_h)
_right(c, x_amt - 1.2 * mm, y, SAMPLE["untax_total"], 8)
y -= 6 * mm
_text(c, x_price - 28 * mm, y, "含税金额总和:", 8)
_rect(c, x_amt - box_w, y - 1.2 * mm, box_w, box_h)
_right(c, x_amt - 1.2 * mm, y, SAMPLE["tax_total"], 8)
# 底部按 ERP 截图:三字在线上方均分;横线穿过 (apmr900) / (结束)
foot_y = 18 * mm
span = right - left
_text(c, left + 10 * mm, foot_y + 5 * mm, "核准", 10)
c.setFont(FONT, 10)
c.drawCentredString(left + span / 2, foot_y + 5 * mm, "审核")
c.drawRightString(right - 10 * mm, foot_y + 5 * mm, "经办")
_hline(c, left, right, foot_y, 0.7)
_text(c, left, foot_y - 1.1 * mm, "(apmr900)", 8)
c.setFont(FONT, 8)
c.drawRightString(right, foot_y - 1.1 * mm, "(结束)")
c.showPage()
c.save()
if __name__ == "__main__":
targets = [
Path(r"e:\Code\hxops\docs\features\accounting-voucher-check\采购单-hxops-sample.pdf"),
Path(r"e:\Work\Agent\立账凭证\采购单-hxops-sample.pdf"),
]
for path in targets:
try:
build_pdf(path)
print(path)
except PermissionError:
print(f"skip locked: {path}")
@@ -105,8 +105,10 @@ VOUCHER_CHECK_DMS_ROOT_FOLDER_ID=<sales-root-folder-id>
### 4.3 工作台记录页
- [ ] 打开 `/workspace/accounting-voucher-check`
- [ ] 「检核任务」可按月/状态筛选,分页可用
- [ ] 「企微发送记录」可按月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口
- [ ] 「检核任务」Tab 下方有「最近一次检核」卡片(不跟年/月/状态筛选);排队/执行中进度会更新
- [ ] 「强制重检上月」在卡片上,仅管理员可见;确认后本卡切到排队/执行中
- [ ] 「检核任务」可按年/月/状态筛选(进页默认上月,月份「全部」看该年),分页可用
- [ ] 「企微发送记录」可按年/月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口
- [ ] 「查看详情」进入 `/workspace/accounting-voucher-check/runs/:runId`(`runId` 为 ScheduleRun.id)
### 4.4 文档库 / ERP 故障
@@ -1,7 +1,7 @@
# 立账凭证资料检核技术设计
> 文档版本:v2.3
> 更新时间:2026-09-08
> 文档版本:v2.5
> 更新时间:2026-09-09
> 状态:销售一期引擎已落地;ERP PO / OA 打印仍待接线
> 需求基线:[demand.md](demand.md)
>
@@ -162,14 +162,17 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
### 6.3 检核任务列表
检核任务列表以 `voucher_check_runs` 的批次统计快照为数据源,不在列表查询时重新汇总单文件结果。支持按 `period_month`、`profile_code` 和批次状态筛选,按执行时间倒序分页。
检核任务列表以 `voucher_check_runs` 的批次统计快照为数据源,不在列表查询时重新汇总单文件结果。`period` 支持 `YYYY`(该自然年)或 `YYYY-MM`(该自然月),并可按 `profile_code` 和批次状态筛选,按执行时间倒序分页。工作台进页默认上一个自然月;月份选「全部」时传 `YYYY`。建批前失败的 `ScheduleRun` 使用同一期间口径。企微发送记录列表共用该 `period` 参数。
「最近一次检核」走独立接口 `GET /api/workspace/accounting-voucher-check/runs/latest`:按 `ScheduleRun.id` 倒序取该平台最近一条排程,join 引擎快照与 `response_summary_json.current_step`,**不跟**列表 `period`/`status`。排队中、执行中的排程必须按 `queued`/`running` 返回,不得套用建批前失败的 `technical_failed` 映射。进度百分比由步骤码估算(`scan_dms` 用已处理 invoice / 总数插值),不是精确字节进度。
| 列/操作 | 数据来源或行为 |
| --------------------------------------------------- | -------------------------------------------------------------------------- |
| 最近一次检核卡片 | `GET .../runs/latest`;强制重检按钮仅 admin,入队后前端轮询本接口 |
| 批次号、业务方、资料所属期间、执行时间 | `voucher_check_runs` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照 |
| 状态 | `completed`、`missing`、`technical_failed`、`draft` 的前端业务映射 |
| 查看详情 | 携带 `run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照;执行中可来自 `response_summary_json.voucher_check` |
| 状态 | 列表:`completed`、`missing`、`technical_failed`;卡片另含 `queued`、`running` |
| 查看详情 | 携带 `schedule_run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 通知附件 | 通过该批次的 Excel 文件标识进入企业微信通知附件 Excel 预览或下载 |
## 7. 企业微信通知附件 Excel 设计
@@ -201,7 +204,7 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
## 9. 实施顺序
1. **已做**:Profile、文件规则、批次/单文件结果表、上月期间、周二 cron、销售 DMS 只读、directory_scan、缺件聚合、批次企微、工作台任务列表与企微发送记录。
1. **已做**:Profile、文件规则、批次/单文件结果表、上月期间、周二 cron、销售 DMS 只读、directory_scan、缺件聚合、批次企微、工作台任务列表、最近一次检核卡片与企微发送记录。
2. **已做**:`dms_archive` 建文件夹(`SaveFolder`)+ 复制(`Item/Copy`),重复策略同名跳过;命中文件记 `archived`。
3. **已预留**:`erp_po_print`、`oa_sales_release` Adapter,周任务不调用。
4. 接入 ERP PO 打印与 OA 模拟页,作为独立抓取任务写入类型目录。
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

+1 -1
View File
@@ -218,7 +218,7 @@
| 通用 Profile + Adapter 架构 | 实施中 | 销售 Profile 与 Adapter 协议已落地;周任务扫描文档库类型目录;ERP PO / OA 销货放行单打印仅占位 |
| 单一共享盘旧检核 | 已移除 | 已删除共享盘扫描、Chatflow Tool、`voucher_check_invoice_states` / `voucher_check_run_items` |
| 增量、归档与缺件通知 | 实施中 | 每周二上月;单文件结果;归档复制同名跳过;企微每批一条汇总 |
| 工作台查询 | 已实现 | 工作台含检核任务与企微发送记录两 Tab;「强制重检上月」;`/runs`、`/notifications` 只读引擎表 |
| 工作台查询 | 已实现 | 工作台含检核任务与企微发送记录两 Tab;期间为年+月(默认上月,月份可「全部」看该年);Tab 下「最近一次检核」卡片不跟筛选;「强制重检上月」在卡片上(admin);`GET /runs/latest`、`/runs`、`/notifications` |
### 采购合同审查
@@ -1,6 +1,6 @@
/**
* features/workspace/api/voucherCheck.api.ts
* 用途:工作台立账凭证检核任务列表、批次明细、企微发送记录与强制重检 API 客户端。
* 用途:工作台立账凭证检核任务列表、最近一次检核、批次明细、企微发送记录与强制重检 API 客户端。
* 依赖:@/shared/api/client、getAuthHeaders。
* 逻辑:AccountingVoucherCheckView / DetailView 调用;对应 /api/workspace/accounting-voucher-check/* 与排程 Excel 下载。
*/
@@ -71,8 +71,45 @@ export interface VoucherCheckForceRunResponse {
status: string;
}
export interface VoucherCheckLatestStep {
step: string;
label?: string | null;
processed_count: number;
}
export interface VoucherCheckLatestRun {
schedule_run_id: number | null;
engine_run_id?: number | null;
run_no: string;
period_month: string | null;
mode: string;
status: string;
progress_percent: number;
subject_count: number;
archived_file_count: number;
missing_file_count: number;
missing_invoice_count: number;
processed_count: number;
started_at?: string | null;
finished_at?: string | null;
error_message?: string | null;
current_step?: VoucherCheckLatestStep | null;
}
/**
* 读取最近一次立账凭证检核(含排队/执行中),不跟列表 period/status。
* @returns 无任何批次时为 null
*/
export function getLatestVoucherCheckRun() {
return requestJson<VoucherCheckLatestRun | null>(
'/api/workspace/accounting-voucher-check/runs/latest',
{ headers: getAuthHeaders() },
);
}
/**
* 分页查询检核任务列表。
* @param params.period - YYYY 表示该年全部月份,YYYY-MM 表示单月
*/
export function listVoucherCheckRuns(params: {
period?: string;
@@ -136,6 +173,7 @@ export interface VoucherCheckNotificationsResponse {
/**
* 分页查询企微缺件汇总发送记录。
* @param params.period - YYYY 表示该年全部月份,YYYY-MM 表示单月
*/
export function listVoucherCheckNotifications(params?: {
period?: string;
@@ -1,6 +1,6 @@
/**
* features/workspace/utils/voucherCheck.display.ts
* 用途:立账凭证检核列表与明细页共用的状态文案、缺件列表、缺件数、缺失占比与企微发送状态展示。
* 用途:立账凭证检核列表、最近一次检核卡片与明细页共用的状态/模式/步骤文案。
* 依赖:vue-i18n 的 t()。
* 逻辑:AccountingVoucherCheckView / AccountingVoucherCheckDetailView 调用。
*/
@@ -18,9 +18,37 @@ export function voucherCheckStatusLabel(t: (key: string) => string, value: strin
if (value === 'technical_error' || value === 'technical_failed') return t('workspace.voucherCheck.statusTechError');
if (value === 'failed') return t('workspace.voucherCheck.statusTechError');
if (value === 'pending') return t('workspace.voucherCheck.statusPending');
if (value === 'queued') return t('workspace.voucherCheck.statusQueued');
if (value === 'running') return t('workspace.voucherCheck.statusRunning');
return value || '-';
}
/**
* 将批次执行模式映射为工作台文案。
* @param t - i18n 翻译函数
* @param value - incremental / force_all / single
*/
export function voucherCheckModeLabel(t: (key: string) => string, value: string): string {
if (value === 'force_all') return t('workspace.voucherCheck.modeForceAll');
if (value === 'single') return t('workspace.voucherCheck.modeSingle');
return t('workspace.voucherCheck.modeIncremental');
}
/**
* 将 runner 步骤码映射为工作台当前步骤文案。
* @param t - i18n 翻译函数
* @param step - current_step.step
*/
export function voucherCheckStepLabel(t: (key: string) => string, step?: string | null): string {
if (step === 'queued') return t('workspace.voucherCheck.stepQueued');
if (step === 'fetch_erp') return t('workspace.voucherCheck.stepFetchErp');
if (step === 'scan_dms') return t('workspace.voucherCheck.stepScanDms');
if (step === 'persist') return t('workspace.voucherCheck.stepPersist');
if (step === 'notify') return t('workspace.voucherCheck.stepNotify');
if (step === 'done') return t('workspace.voucherCheck.stepDone');
return step || '-';
}
/**
* 将企微汇总发送状态码映射为工作台文案。
* @param t - i18n 翻译函数
@@ -1,28 +1,36 @@
<script setup lang="ts">
/**
* features/workspace/views/AccountingVoucherCheckView.vue
* 用途:立账凭证检核任务列表——按资料所属期间查看批次统计。
* 依赖:voucherCheck.api、vue-i18n、useMessage、DeleteConfirmDialog、PaginationBar、formatLocalDateTime、voucherCheck.display。
* 逻辑:路由 /workspace/accounting-voucher-check;Tab 切换检核任务与企微发送记录;查看详情进入独立明细页;企微 ?run_id= 重定向到明细路由。
* 用途:立账凭证检核任务列表——按资料所属期间(年 + 月)查看批次统计,并展示最近一次检核进度。
* 依赖:voucherCheck.api、vue-i18n、useMessage、DeleteConfirmDialog、PaginationBar、formatLocalDateTime、voucherCheck.display、auth。
* 逻辑:路由 /workspace/accounting-voucher-check;进页默认上一个自然月;「最近一次检核」不跟筛选;强制重检仅 admin,进度在本卡轮询。
*/
import { computed, onMounted, onUnmounted, ref } from 'vue';
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { Download, Loader2, RefreshCw, RotateCcw, Search } from 'lucide-vue-next';
import { ChevronDown, Download, Loader2, RotateCcw, Search } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { getStoredAuthUser } from '@/shared/utils/auth';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import { WORKSPACE_PATHS } from '../constants/routes';
import {
downloadVoucherCheckExcel,
getLatestVoucherCheckRun,
listVoucherCheckNotifications,
listVoucherCheckRuns,
triggerVoucherCheckForceAll,
type VoucherCheckLatestRun,
type VoucherCheckNotificationItem,
type VoucherCheckRunItem,
} from '../api/voucherCheck.api';
import { voucherCheckNotifyStatusLabel, voucherCheckStatusLabel } from '../utils/voucherCheck.display';
import {
voucherCheckModeLabel,
voucherCheckNotifyStatusLabel,
voucherCheckStatusLabel,
voucherCheckStepLabel,
} from '../utils/voucherCheck.display';
const { t } = useI18n();
const msg = useMessage();
@@ -36,7 +44,8 @@ const items = ref<VoucherCheckRunItem[]>([]);
const total = ref(0);
const page = ref(1);
const pageSize = ref(50);
const period = ref('');
const periodYear = ref('');
const periodMonth = ref('');
const status = ref('');
const listTab = ref<'tasks' | 'notifications'>('tasks');
const notifyLoading = ref(false);
@@ -45,19 +54,63 @@ const notifyTotal = ref(0);
const notifyPage = ref(1);
const notifyPageSize = ref(50);
const notifyStatus = ref('');
const latestRun = ref<VoucherCheckLatestRun | null>(null);
const latestLoading = ref(false);
let forcePollTimer: ReturnType<typeof setInterval> | null = null;
const isAdmin = computed(() => String(getStoredAuthUser()?.role || '').trim().toLowerCase() === 'admin');
const latestInProgress = computed(() => {
const cardStatus = latestRun.value?.status;
return cardStatus === 'queued' || cardStatus === 'running';
});
const latestHasMissing = computed(() => {
const row = latestRun.value;
if (!row) return false;
return (row.missing_file_count || 0) > 0 || (row.missing_invoice_count || 0) > 0;
});
const latestCanOpenDetail = computed(() => {
const row = latestRun.value;
if (!row?.schedule_run_id) return false;
return row.status === 'missing' || row.status === 'completed';
});
const MONTH_VALUES = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] as const;
/**
* 默认资料所属期间为上一个自然月 YYYY-MM。
* 进页默认资料所属期间为上一个自然月。
*/
function previousPeriod(): string {
function previousYearMonth(): { year: string; month: string } {
const d = new Date();
d.setDate(1);
d.setMonth(d.getMonth() - 1);
const m = String(d.getMonth() + 1).padStart(2, '0');
return `${d.getFullYear()}-${m}`;
return {
year: String(d.getFullYear()),
month: String(d.getMonth() + 1).padStart(2, '0'),
};
}
/**
* 组装列表查询 period:有月份则为 YYYY-MM,否则为 YYYY。
*/
const periodQuery = computed(() => {
if (!periodYear.value) return undefined;
if (periodMonth.value) return `${periodYear.value}-${periodMonth.value}`;
return periodYear.value;
});
const yearOptions = computed(() => {
const now = new Date().getFullYear();
const years: string[] = [];
for (let year = now - 5; year <= now; year += 1) {
years.push(String(year));
}
if (periodYear.value && !years.includes(periodYear.value)) {
years.unshift(periodYear.value);
years.sort();
}
return years;
});
const statusOptions = computed(() => [
{ value: '', label: t('workspace.voucherCheck.statusAll') },
{ value: 'missing', label: t('workspace.voucherCheck.statusMissing') },
@@ -89,7 +142,7 @@ async function loadNotifications() {
notifyLoading.value = true;
try {
const data = await listVoucherCheckNotifications({
period: period.value || undefined,
period: periodQuery.value,
send_status: notifyStatus.value || undefined,
page: notifyPage.value,
page_size: notifyPageSize.value,
@@ -117,6 +170,7 @@ function setListTab(tab: 'tasks' | 'notifications') {
}
page.value = 1;
void loadRuns();
void loadLatestRun();
}
/**
@@ -132,17 +186,6 @@ function searchCurrentTab() {
void loadNotifications();
}
/**
* 当前 Tab 刷新列表,不重置页码。
*/
function refreshCurrentTab() {
if (listTab.value === 'tasks') {
void loadRuns();
return;
}
void loadNotifications();
}
/**
* 下载该发送记录对应批次的 Excel。
* @param row - 企微发送记录
@@ -197,7 +240,7 @@ async function loadRuns() {
loading.value = true;
try {
const data = await listVoucherCheckRuns({
period: period.value || undefined,
period: periodQuery.value,
status: status.value || undefined,
page: page.value,
page_size: pageSize.value,
@@ -238,15 +281,96 @@ function openRunDetail(row: VoucherCheckRunItem) {
}
/**
* 停止强制重检后的列表轮询。
* 停止最近一次检核的进度轮询。
*/
function stopForcePoll() {
function stopLatestPoll() {
if (forcePollTimer) {
clearInterval(forcePollTimer);
forcePollTimer = null;
}
}
/**
* 拉取最近一次检核卡片;不跟下方列表的年/月/状态筛选。
* @param options.silent - 轮询时不切换卡片 loading,避免进度条闪烁
*/
async function loadLatestRun(options?: { silent?: boolean }) {
if (!options?.silent) latestLoading.value = true;
try {
latestRun.value = await getLatestVoucherCheckRun();
} catch (e: any) {
if (!options?.silent) {
msg.error(e?.message || t('workspace.voucherCheck.latestLoadFailed'));
}
} finally {
if (!options?.silent) latestLoading.value = false;
}
}
/**
* 排队或执行中时轮询卡片;进入终态后刷新下方列表。
*/
function syncLatestPoll() {
stopLatestPoll();
if (listTab.value !== 'tasks' || !latestInProgress.value) return;
forcePollTimer = setInterval(() => {
void (async () => {
const previous = latestRun.value?.status;
await loadLatestRun({ silent: true });
const next = latestRun.value?.status;
if ((previous === 'queued' || previous === 'running') && next !== 'queued' && next !== 'running') {
stopLatestPoll();
void loadRuns();
}
})();
}, 3000);
}
/**
* 最近一次检核状态徽章样式。
* @param value - 卡片状态
*/
function latestBadgeClass(value: string): string {
if (value === 'missing' || value === 'technical_failed') return 'bg-rose-50 text-rose-700';
if (value === 'completed') return 'bg-emerald-50 text-emerald-700';
if (value === 'queued' || value === 'running') return 'bg-blue-50 text-blue-700';
return 'bg-surface-soft text-secondary';
}
/**
* 卡片当前步骤主文案:终态用完成提示,其余按步骤码翻译。
* @param row - 最近一次检核
*/
function latestStepText(row: VoucherCheckLatestRun): string {
if (row.status === 'queued') return t('workspace.voucherCheck.stepQueued');
if (row.status === 'missing' && (row.current_step?.step === 'done' || !row.current_step)) {
return t('workspace.voucherCheck.latestDoneHint');
}
if (row.status === 'completed' && (row.current_step?.step === 'done' || !row.current_step)) {
return t('workspace.voucherCheck.latestCompleteHint');
}
if (row.status === 'technical_failed' && row.current_step?.step === 'fetch_erp') {
return t('workspace.voucherCheck.stepFetchErpIncomplete');
}
return voucherCheckStepLabel(t, row.current_step?.step);
}
/**
* 卡片步骤辅文案:失败原因、排队等待或扫描进度。
* @param row - 最近一次检核
*/
function latestHintText(row: VoucherCheckLatestRun): string {
if (row.error_message) return row.error_message;
if (row.status === 'queued') return t('workspace.voucherCheck.stepQueuedHint');
if (row.status === 'running' && row.current_step?.step === 'scan_dms' && row.subject_count > 0) {
return t('workspace.voucherCheck.processedHint', {
processed: row.processed_count,
total: row.subject_count,
});
}
return '';
}
/**
* 打开强制重检确认框;用公共 DeleteConfirmDialog 替代原生 window.confirm。
*/
@@ -264,13 +388,8 @@ async function forceRecheck() {
try {
const data = await triggerVoucherCheckForceAll();
msg.success(t('workspace.voucherCheck.forceQueued', { runNo: data.run_no }));
await loadRuns();
stopForcePoll();
const started = Date.now();
forcePollTimer = setInterval(() => {
void loadRuns();
if (Date.now() - started > 120_000) stopForcePoll();
}, 5000);
await loadLatestRun({ silent: true });
syncLatestPoll();
} catch (e: any) {
msg.error(e?.message || t('workspace.voucherCheck.forceFailed'));
} finally {
@@ -278,16 +397,40 @@ async function forceRecheck() {
}
}
/**
* 从最近一次检核卡片打开本批明细。
*/
function openLatestDetail() {
const row = latestRun.value;
if (!row?.schedule_run_id) {
msg.error(t('workspace.voucherCheck.loadFailed'));
return;
}
void router.push({
path: WORKSPACE_PATHS.accountingVoucherCheckDetail(row.schedule_run_id),
query: row.run_no ? { runNo: row.run_no } : undefined,
});
}
/**
* 仅在检核任务 Tab 且最近一批仍在排队/执行时轮询卡片。
*/
watch([listTab, latestInProgress], () => {
syncLatestPoll();
});
onMounted(async () => {
if (redirectLegacyRunQuery()) return;
period.value = previousPeriod();
const previous = previousYearMonth();
periodYear.value = previous.year;
periodMonth.value = previous.month;
const qStatus = route.query.status;
if (typeof qStatus === 'string' && qStatus) status.value = qStatus;
await loadRuns();
await Promise.all([loadRuns(), loadLatestRun()]);
});
onUnmounted(() => {
stopForcePoll();
stopLatestPoll();
});
</script>
@@ -321,22 +464,143 @@ onUnmounted(() => {
</button>
</div>
<article
v-if="listTab === 'tasks'"
class="overflow-hidden rounded-2xl border border-default bg-surface"
aria-live="polite"
>
<div class="flex flex-wrap items-start justify-between gap-3 bg-blue-50 px-4 py-3.5">
<div>
<h2 class="text-[15px] font-semibold text-primary">{{ $t('workspace.voucherCheck.latestTitle') }}</h2>
<p v-if="latestRun" class="mt-1 text-xs text-muted">
<span class="mr-3">{{ $t('workspace.voucherCheck.latestBatch', { runNo: latestRun.run_no }) }}</span>
<span class="mr-3">{{ $t('workspace.voucherCheck.latestPeriod', { period: latestRun.period_month || '-' }) }}</span>
<span>{{ voucherCheckModeLabel(t, latestRun.mode) }}</span>
</p>
</div>
<div class="flex shrink-0 items-center gap-2">
<span
v-if="latestRun"
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
:class="latestBadgeClass(latestRun.status)"
>
{{ voucherCheckStatusLabel(t, latestRun.status) }}
</span>
<button
v-if="isAdmin"
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-amber-300 bg-amber-50 px-3 py-1.5 text-sm font-medium text-amber-900 transition-colors hover:bg-amber-100 disabled:opacity-50"
:disabled="forcing || latestInProgress"
@click="openForceRecheck()"
>
<Loader2 v-if="forcing" class="h-3.5 w-3.5 animate-spin" />
<RotateCcw v-else class="h-3.5 w-3.5" />
{{ $t('workspace.voucherCheck.forceRecheck') }}
</button>
</div>
</div>
<div class="px-4 py-3.5">
<div v-if="latestLoading && !latestRun" class="flex items-center justify-center gap-2 py-8 text-sm text-muted">
<Loader2 class="h-4 w-4 animate-spin" />
{{ $t('workspace.voucherCheck.loading') }}
</div>
<p v-else-if="!latestRun" class="py-8 text-center text-sm text-muted">
{{ $t('workspace.voucherCheck.latestEmpty') }}
</p>
<template v-else>
<div class="h-2.5 overflow-hidden rounded-full bg-slate-200">
<div
class="h-full rounded-full transition-[width] duration-300"
:class="latestRun.status === 'technical_failed' ? 'bg-rose-600' : 'bg-teal-700'"
:style="{ width: `${latestRun.progress_percent || 0}%` }"
/>
</div>
<div class="mt-2 mb-3.5 flex flex-wrap justify-between gap-3 text-xs text-muted">
<span>{{ $t('workspace.voucherCheck.progress', { percent: latestRun.progress_percent || 0 }) }}</span>
<span>
{{ $t('workspace.voucherCheck.startedAt') }}:{{ formatLocalDateTime(latestRun.started_at) }}
 {{ $t('workspace.voucherCheck.finishedAt') }}:{{ latestInProgress ? $t('workspace.voucherCheck.inProgress') : formatLocalDateTime(latestRun.finished_at) }}
</span>
</div>
<div class="grid grid-cols-2 gap-2 md:grid-cols-4">
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b class="block text-[22px] font-semibold leading-tight text-primary">{{ latestRun.subject_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.subjectCount') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b class="block text-[22px] font-semibold leading-tight text-primary">{{ latestRun.archived_file_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.archivedFiles') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b
class="block text-[22px] font-semibold leading-tight"
:class="latestHasMissing ? 'text-rose-700' : 'text-primary'"
>{{ latestRun.missing_file_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.missingFiles') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b
class="block text-[22px] font-semibold leading-tight"
:class="latestHasMissing ? 'text-rose-700' : 'text-primary'"
>{{ latestRun.missing_invoice_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.missingInvoices') }}</span>
</div>
</div>
<p class="mt-3 text-[13px] text-slate-700">
{{ latestStepText(latestRun) }}
<small v-if="latestHintText(latestRun)" class="mt-0.5 block text-muted">{{ latestHintText(latestRun) }}</small>
</p>
<div v-if="latestCanOpenDetail" class="mt-3 flex justify-end">
<button
type="button"
class="text-sm font-semibold text-brand-700 hover:underline"
@click="openLatestDetail"
>
{{ $t('workspace.voucherCheck.viewLatestDetail') }}
</button>
</div>
</template>
</div>
</article>
<section class="flex flex-wrap items-end gap-3 rounded-2xl border border-default/80 bg-surface/70 px-4 py-3 shadow-sm">
<label class="flex flex-col gap-1 text-xs font-medium text-muted">
{{ $t('workspace.voucherCheck.period') }}
<input v-model="period" type="month" class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-primary" />
<span class="flex items-center gap-2">
<span class="period-select">
<select v-model="periodYear" class="period-select__control w-[4.75rem]">
<option v-for="year in yearOptions" :key="year" :value="year">{{ year }}</option>
</select>
<ChevronDown class="period-select__icon" aria-hidden="true" />
</span>
<span class="period-select">
<select v-model="periodMonth" class="period-select__control w-[4.75rem]">
<option value="">{{ $t('workspace.voucherCheck.periodMonthAll') }}</option>
<option v-for="month in MONTH_VALUES" :key="month" :value="month">
{{ $t('workspace.voucherCheck.periodMonthValue', { n: Number(month) }) }}
</option>
</select>
<ChevronDown class="period-select__icon" aria-hidden="true" />
</span>
</span>
</label>
<label v-if="listTab === 'tasks'" class="flex flex-col gap-1 text-xs font-medium text-muted">
{{ $t('workspace.voucherCheck.status') }}
<select v-model="status" class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-primary">
<option v-for="opt in statusOptions" :key="opt.value || 'all'" :value="opt.value">{{ opt.label }}</option>
</select>
<span class="period-select">
<select v-model="status" class="period-select__control w-[6rem]">
<option v-for="opt in statusOptions" :key="opt.value || 'all'" :value="opt.value">{{ opt.label }}</option>
</select>
<ChevronDown class="period-select__icon" aria-hidden="true" />
</span>
</label>
<label v-else class="flex flex-col gap-1 text-xs font-medium text-muted">
{{ $t('workspace.voucherCheck.notifyStatus') }}
<select v-model="notifyStatus" class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-primary">
<option v-for="opt in notifyStatusOptions" :key="opt.value || 'all'" :value="opt.value">{{ opt.label }}</option>
</select>
<span class="period-select">
<select v-model="notifyStatus" class="period-select__control w-[7.25rem]">
<option v-for="opt in notifyStatusOptions" :key="opt.value || 'all'" :value="opt.value">{{ opt.label }}</option>
</select>
<ChevronDown class="period-select__icon" aria-hidden="true" />
</span>
</label>
<button
type="button"
@@ -346,25 +610,6 @@ onUnmounted(() => {
<Search class="h-3.5 w-3.5" />
{{ $t('workspace.voucherCheck.search') }}
</button>
<button
type="button"
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
@click="refreshCurrentTab"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ $t('workspace.voucherCheck.refresh') }}
</button>
<button
v-if="listTab === 'tasks'"
type="button"
class="ml-auto inline-flex items-center gap-1 rounded-xl border border-amber-300 bg-amber-50 px-3 py-1.5 text-sm font-medium text-amber-900 transition-colors hover:bg-amber-100 disabled:opacity-50"
:disabled="forcing"
@click="openForceRecheck()"
>
<Loader2 v-if="forcing" class="h-3.5 w-3.5 animate-spin" />
<RotateCcw v-else class="h-3.5 w-3.5" />
{{ $t('workspace.voucherCheck.forceRecheck') }}
</button>
</section>
<section v-if="listTab === 'tasks'" class="overflow-hidden rounded-2xl border border-default bg-surface">
@@ -524,3 +769,51 @@ onUnmounted(() => {
/>
</div>
</template>
<style scoped>
/**
* 隐藏系统原生下拉箭头(含 Chromium ::picker-icon / Edge ::-ms-expand)。
* 只保留模板里的 ChevronDown,避免 Windows 下年份与月份箭头叠在一起。
*/
.period-select {
position: relative;
display: inline-flex;
align-items: center;
}
.period-select__control {
box-sizing: border-box;
border-radius: 0.75rem;
border: 1px solid var(--border-default);
background-color: var(--bg-surface);
background-image: none;
padding: 0.375rem 1.75rem 0.375rem 0.625rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--text-primary);
font-size: 0.875rem;
line-height: 1.25rem;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.period-select__control::-ms-expand {
display: none;
}
.period-select__control::picker-icon {
display: none;
content: none;
}
.period-select__icon {
pointer-events: none;
position: absolute;
right: 0.5rem;
height: 0.875rem;
width: 0.875rem;
color: var(--text-muted);
}
</style>
+31 -3
View File
@@ -784,6 +784,8 @@
"title": "Accounting voucher check tasks",
"subtitle": "Every Tuesday the job incrementally checks the previous calendar month, scans sales invoice attachment folders, archives by invoice, and summarizes missing files.",
"period": "Document period",
"periodMonthAll": "All",
"periodMonthValue": "Month {n}",
"status": "Status",
"statusAll": "All",
"statusComplete": "Complete",
@@ -791,6 +793,8 @@
"statusSkipped": "Skipped",
"statusTechError": "Technical failure",
"statusPending": "Pending",
"statusQueued": "Queued",
"statusRunning": "Running",
"invoiceNo": "invoice",
"invoiceDate": "Invoice date",
"invoicePlaceholder": "Filter by invoice",
@@ -800,7 +804,6 @@
"checkedAt": "Run time",
"result": "Result",
"search": "Search",
"refresh": "Refresh",
"loading": "Loading…",
"empty": "No check batches yet",
"loadFailed": "Failed to load voucher check tasks",
@@ -826,9 +829,34 @@
"viewDetail": "View details",
"forceRecheck": "Force recheck last month",
"failureReason": "Failure reason",
"forceConfirm": "This will fully recheck the previous calendar month. Already archived files will not be skipped, and the period filter above is ignored. Continue?",
"forceQueued": "Force recheck queued ({runNo}). The list will refresh when it finishes.",
"forceConfirm": "This will fully recheck the previous calendar month. Already archived files will not be skipped, and the period filter below is ignored. Continue?",
"forceQueued": "Force recheck queued ({runNo}). Progress will update on this card.",
"forceFailed": "Failed to queue the force recheck",
"latestTitle": "Latest check",
"latestEmpty": "No check batches yet",
"latestLoadFailed": "Failed to load the latest check",
"latestBatch": "Batch {runNo}",
"latestPeriod": "Period {period}",
"modeIncremental": "Incremental",
"modeForceAll": "Full recheck",
"modeSingle": "Single invoice",
"progress": "Progress {percent}%",
"startedAt": "Started",
"finishedAt": "Finished",
"inProgress": "In progress",
"viewLatestDetail": "View this batch",
"archivedFiles": "Archived files",
"processedHint": "Processed {processed} / {total} invoices",
"latestDoneHint": "This batch is complete. Missing-file results have been written to Excel.",
"latestCompleteHint": "This batch is complete.",
"stepQueued": "Force recheck of last month is queued",
"stepQueuedHint": "Waiting for the schedule worker to pick it up",
"stepFetchErp": "Fetching last month’s sales invoices",
"stepFetchErpIncomplete": "Fetching last month’s sales invoices did not finish",
"stepScanDms": "Scanning sales invoice attachment type folders",
"stepPersist": "Writing check records",
"stepNotify": "Sending the WeCom summary",
"stepDone": "Check complete",
"tabTasks": "Check tasks",
"tabNotifications": "WeCom send log",
"notifyEmpty": "No WeCom send records yet",
+31 -3
View File
@@ -720,6 +720,8 @@
"title": "งานตรวจเอกสารบัญชี",
"subtitle": "ทุกวันอังคารตรวจเดือนปฏิทินก่อนหน้าแบบเพิ่มส่วน แสกนโฟลเดอร์เอกสารขาย แล้วจัดเก็บตาม invoice พร้อมสรุปไฟล์ที่ขาด",
"period": "ช่วงเอกสาร",
"periodMonthAll": "ทั้งหมด",
"periodMonthValue": "เดือน {n}",
"status": "สถานะ",
"statusAll": "ทั้งหมด",
"statusComplete": "ครบ",
@@ -727,6 +729,8 @@
"statusSkipped": "ข้าม",
"statusTechError": "ล้มเหลวทางเทคนิค",
"statusPending": "รอดำเนินการ",
"statusQueued": "อยู่ในคิว",
"statusRunning": "กำลังทำงาน",
"invoiceNo": "invoice",
"invoiceDate": "วันที่ใบแจ้งหนี้",
"invoicePlaceholder": "กรองด้วย invoice",
@@ -736,7 +740,6 @@
"checkedAt": "เวลาที่รัน",
"result": "ผลลัพธ์",
"search": "ค้นหา",
"refresh": "รีเฟรช",
"loading": "กำลังโหลด…",
"empty": "ยังไม่มีรอบการตรวจ",
"loadFailed": "โหลดงานตรวจไม่สำเร็จ",
@@ -762,9 +765,34 @@
"viewDetail": "ดูรายละเอียด",
"forceRecheck": "ตรวจเดือนที่แล้วใหม่ทั้งชุด",
"failureReason": "สาเหตุที่ล้มเหลว",
"forceConfirm": "ระบบจะตรวจเดือนปฏิทินก่อนหน้าทั้งชุด ไม่ข้ามไฟล์ที่จัดเก็บแล้ว และไม่ใช้ช่วงที่กรองด้านบน ต้องการเริ่มหรือไม่?",
"forceQueued": "จัดคิวตรวจใหม่แล้ว ({runNo}) รายการจะรีเฟรชเมื่อเสร็จ",
"forceConfirm": "ระบบจะตรวจเดือนปฏิทินก่อนหน้าทั้งชุด ไม่ข้ามไฟล์ที่จัดเก็บแล้ว และไม่ใช้ช่วงที่กรองด้านล่าง ต้องการเริ่มหรือไม่?",
"forceQueued": "จัดคิวตรวจใหม่แล้ว ({runNo}) ความคืบหน้าจะอัปเดตบนการ์ดนี้",
"forceFailed": "จัดคิวตรวจใหม่ไม่สำเร็จ",
"latestTitle": "การตรวจล่าสุด",
"latestEmpty": "ยังไม่มีรอบการตรวจ",
"latestLoadFailed": "โหลดการตรวจล่าสุดไม่สำเร็จ",
"latestBatch": "รอบ {runNo}",
"latestPeriod": "ช่วง {period}",
"modeIncremental": "แบบเพิ่มทีละส่วน",
"modeForceAll": "ตรวจใหม่ทั้งชุด",
"modeSingle": "ใบเดียว",
"progress": "ความคืบหน้า {percent}%",
"startedAt": "เริ่ม",
"finishedAt": "เสร็จ",
"inProgress": "กำลังดำเนินการ",
"viewLatestDetail": "ดูรายละเอียดรอบนี้",
"archivedFiles": "ไฟล์ที่จัดเก็บแล้ว",
"processedHint": "ประมวลผลแล้ว {processed} / {total} ใบ invoice",
"latestDoneHint": "รอบนี้เสร็จแล้ว ผลไฟล์ที่ขาดถูกเขียนลง Excel",
"latestCompleteHint": "รอบนี้เสร็จแล้ว",
"stepQueued": "จัดคิวตรวจเดือนที่แล้วใหม่ทั้งชุดแล้ว",
"stepQueuedHint": "รอให้ schedule worker รับงาน",
"stepFetchErp": "กำลังดึง invoice ขายของเดือนที่แล้ว",
"stepFetchErpIncomplete": "ดึง invoice ขายของเดือนที่แล้วยังไม่เสร็จ",
"stepScanDms": "กำลังสแกนโฟลเดอร์ประเภทเอกสารใบแจ้งหนี้ขาย",
"stepPersist": "กำลังบันทึกผลตรวจ",
"stepNotify": "กำลังส่งสรุป WeCom",
"stepDone": "ตรวจเสร็จแล้ว",
"tabTasks": "งานตรวจ",
"tabNotifications": "ประวัติส่ง WeCom",
"notifyEmpty": "ยังไม่มีประวัติส่ง WeCom",
+31 -3
View File
@@ -784,6 +784,8 @@
"title": "立账凭证检核任务",
"subtitle": "每周二增量检核上一个自然月;扫描销售开票附件类型目录后按 invoice 归档,并汇总缺件。",
"period": "资料所属期间",
"periodMonthAll": "全部",
"periodMonthValue": "{n}月",
"status": "状态",
"statusAll": "全部",
"statusComplete": "完整",
@@ -791,6 +793,8 @@
"statusSkipped": "跳过",
"statusTechError": "技术失败",
"statusPending": "待处理",
"statusQueued": "排队中",
"statusRunning": "执行中",
"invoiceNo": "invoice",
"invoiceDate": "发票日期",
"invoicePlaceholder": "输入 invoice 筛选",
@@ -800,7 +804,6 @@
"checkedAt": "执行时间",
"result": "结论",
"search": "查询",
"refresh": "刷新",
"loading": "加载中…",
"empty": "暂无检核批次",
"loadFailed": "加载检核任务失败",
@@ -826,9 +829,34 @@
"viewDetail": "查看详情",
"forceRecheck": "强制重检上月",
"failureReason": "失败原因",
"forceConfirm": "将全量重检上一个自然月,不跳过已归档记录,也不使用上方筛选的期间。确定开始?",
"forceQueued": "已入队强制重检({runNo}),完成后列表会自动刷新。",
"forceConfirm": "将全量重检上一个自然月,不跳过已归档记录,也不使用下方筛选的期间。确定开始?",
"forceQueued": "已入队强制重检({runNo}),进度将在本卡更新。",
"forceFailed": "强制重检入队失败",
"latestTitle": "最近一次检核",
"latestEmpty": "暂无检核批次",
"latestLoadFailed": "加载最近一次检核失败",
"latestBatch": "批次 {runNo}",
"latestPeriod": "期间 {period}",
"modeIncremental": "增量",
"modeForceAll": "全量重检",
"modeSingle": "单票",
"progress": "进度 {percent}%",
"startedAt": "开始",
"finishedAt": "完成",
"inProgress": "进行中",
"viewLatestDetail": "查看本批详情",
"archivedFiles": "已归档文件",
"processedHint": "已处理 {processed} / {total} 张 invoice",
"latestDoneHint": "本批已完成,缺件结果已写入 Excel。",
"latestCompleteHint": "本批已完成。",
"stepQueued": "已入队强制重检上月",
"stepQueuedHint": "等待 schedule worker 领取",
"stepFetchErp": "拉取上月销售 invoice",
"stepFetchErpIncomplete": "拉取上月销售 invoice 未完成",
"stepScanDms": "扫描销售开票附件类型目录",
"stepPersist": "写入检核记录",
"stepNotify": "发送企微汇总",
"stepDone": "检核完成",
"tabTasks": "检核任务",
"tabNotifications": "企微发送记录",
"notifyEmpty": "暂无企业微信发送记录",
+31 -3
View File
@@ -784,6 +784,8 @@
"title": "立帳憑證檢核任務",
"subtitle": "每週二增量檢核上一個自然月;掃描銷售開票附件類型目錄後按 invoice 歸檔,並彙總缺件。",
"period": "資料所屬期間",
"periodMonthAll": "全部",
"periodMonthValue": "{n}月",
"status": "狀態",
"statusAll": "全部",
"statusComplete": "完整",
@@ -791,6 +793,8 @@
"statusSkipped": "跳過",
"statusTechError": "技術失敗",
"statusPending": "待處理",
"statusQueued": "排隊中",
"statusRunning": "執行中",
"invoiceNo": "invoice",
"invoiceDate": "發票日期",
"invoicePlaceholder": "輸入 invoice 篩選",
@@ -800,7 +804,6 @@
"checkedAt": "執行時間",
"result": "結論",
"search": "查詢",
"refresh": "重新整理",
"loading": "載入中…",
"empty": "暫無檢核批次",
"loadFailed": "載入檢核任務失敗",
@@ -826,9 +829,34 @@
"viewDetail": "查看詳情",
"forceRecheck": "強制重檢上月",
"failureReason": "失敗原因",
"forceConfirm": "將全量重檢上一個自然月,不跳過已歸檔紀錄,也不使用上方篩選的期間。確定開始?",
"forceQueued": "已排入強制重檢({runNo}),完成後列表會自動重新整理。",
"forceConfirm": "將全量重檢上一個自然月,不跳過已歸檔紀錄,也不使用下方篩選的期間。確定開始?",
"forceQueued": "已排入強制重檢({runNo}),進度將在本卡更新。",
"forceFailed": "強制重檢排入失敗",
"latestTitle": "最近一次檢核",
"latestEmpty": "暫無檢核批次",
"latestLoadFailed": "載入最近一次檢核失敗",
"latestBatch": "批次 {runNo}",
"latestPeriod": "期間 {period}",
"modeIncremental": "增量",
"modeForceAll": "全量重檢",
"modeSingle": "單票",
"progress": "進度 {percent}%",
"startedAt": "開始",
"finishedAt": "完成",
"inProgress": "進行中",
"viewLatestDetail": "查看本批詳情",
"archivedFiles": "已歸檔檔案",
"processedHint": "已處理 {processed} / {total} 張 invoice",
"latestDoneHint": "本批已完成,缺件結果已寫入 Excel。",
"latestCompleteHint": "本批已完成。",
"stepQueued": "已排入強制重檢上月",
"stepQueuedHint": "等待 schedule worker 領取",
"stepFetchErp": "拉取上月銷售 invoice",
"stepFetchErpIncomplete": "拉取上月銷售 invoice 未完成",
"stepScanDms": "掃描銷售開票附件類型目錄",
"stepPersist": "寫入檢核紀錄",
"stepNotify": "發送企微彙總",
"stepDone": "檢核完成",
"tabTasks": "檢核任務",
"tabNotifications": "企微發送紀錄",
"notifyEmpty": "暫無企業微信發送紀錄",