diff --git a/backend/app/api/workspace/voucher_check.py b/backend/app/api/workspace/voucher_check.py index 4a5e8d96..6cd20461 100644 --- a/backend/app/api/workspace/voucher_check.py +++ b/backend/app/api/workspace/voucher_check.py @@ -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//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( diff --git a/backend/app/services/voucher_check/query_service.py b/backend/app/services/voucher_check/query_service.py index 4219013a..f66b9145 100644 --- a/backend/app/services/voucher_check/query_service.py +++ b/backend/app/services/voucher_check/query_service.py @@ -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) diff --git a/backend/tests/voucher_check/test_workspace_latest_run.py b/backend/tests/voucher_check/test_workspace_latest_run.py new file mode 100644 index 00000000..de950445 --- /dev/null +++ b/backend/tests/voucher_check/test_workspace_latest_run.py @@ -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 diff --git a/backend/tests/voucher_check/test_workspace_period_filter.py b/backend/tests/voucher_check/test_workspace_period_filter.py new file mode 100644 index 00000000..84a163b1 --- /dev/null +++ b/backend/tests/voucher_check/test_workspace_period_filter.py @@ -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" diff --git a/docs/features/accounting-voucher-check/README.md b/docs/features/accounting-voucher-check/README.md index d0997668..c4da665b 100644 --- a/docs/features/accounting-voucher-check/README.md +++ b/docs/features/accounting-voucher-check/README.md @@ -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` 归入「所有归档」。 diff --git a/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html b/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html new file mode 100644 index 00000000..1f3ade5b --- /dev/null +++ b/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html @@ -0,0 +1,409 @@ + + + + + + + 立账凭证 · 最近一次检核原型 + + + +
+
+ 这是原型,不是工作台代码。最近一次检核放在 Tab 下方、筛选栏上方:它是整页状态,不跟着年/月过滤。强制重检放在卡片上,点击后进度就在本卡更新。 +
+ 预览状态: + + + +
+
+ +
+

立账凭证检核任务

+

每周二增量检核上一个自然月;扫描销售开票附件类型目录后按 invoice 归档,并汇总缺件。

+
+ + + +
+ +
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
批次号资料所属期间invoice总数invoice缺件数缺件文件数状态执行时间失败原因
RUN2026090801480719A32026-08128611缺件2026-09-08 09:50:19—
RUN2026090708315125382026-08000技术失败2026-09-07 16:32:10未配置销售开票附件文档库根目录
+
+
+
+ + + diff --git a/docs/features/accounting-voucher-check/demand.md b/docs/features/accounting-voucher-check/demand.md index f8e92b11..7edf1292 100644 --- a/docs/features/accounting-voucher-check/demand.md +++ b/docs/features/accounting-voucher-check/demand.md @@ -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;查看详情进入对应批次明细 | diff --git a/docs/features/accounting-voucher-check/hxops-po-sample.py b/docs/features/accounting-voucher-check/hxops-po-sample.py new file mode 100644 index 00000000..ded51324 --- /dev/null +++ b/docs/features/accounting-voucher-check/hxops-po-sample.py @@ -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}") diff --git a/docs/features/accounting-voucher-check/ops-checklist.md b/docs/features/accounting-voucher-check/ops-checklist.md index 0b7fd610..3c167ee4 100644 --- a/docs/features/accounting-voucher-check/ops-checklist.md +++ b/docs/features/accounting-voucher-check/ops-checklist.md @@ -105,8 +105,10 @@ VOUCHER_CHECK_DMS_ROOT_FOLDER_ID= ### 4.3 工作台记录页 - [ ] 打开 `/workspace/accounting-voucher-check` -- [ ] 「检核任务」可按月/状态筛选,分页可用 -- [ ] 「企微发送记录」可按月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口 +- [ ] 「检核任务」Tab 下方有「最近一次检核」卡片(不跟年/月/状态筛选);排队/执行中进度会更新 +- [ ] 「强制重检上月」在卡片上,仅管理员可见;确认后本卡切到排队/执行中 +- [ ] 「检核任务」可按年/月/状态筛选(进页默认上月,月份「全部」看该年),分页可用 +- [ ] 「企微发送记录」可按年/月/发送状态筛选,能看到接收人、未发送原因与 Excel 下载入口 - [ ] 「查看详情」进入 `/workspace/accounting-voucher-check/runs/:runId`(`runId` 为 ScheduleRun.id) ### 4.4 文档库 / ERP 故障 diff --git a/docs/features/accounting-voucher-check/technical-design.md b/docs/features/accounting-voucher-check/technical-design.md index 28b841c7..e34bcc1b 100644 --- a/docs/features/accounting-voucher-check/technical-design.md +++ b/docs/features/accounting-voucher-check/technical-design.md @@ -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 模拟页,作为独立抓取任务写入类型目录。 diff --git a/docs/features/accounting-voucher-check/welltrust-logo.png b/docs/features/accounting-voucher-check/welltrust-logo.png new file mode 100644 index 00000000..511754e0 Binary files /dev/null and b/docs/features/accounting-voucher-check/welltrust-logo.png differ diff --git a/docs/funclist.md b/docs/funclist.md index f5c716d3..6eb8d65e 100644 --- a/docs/funclist.md +++ b/docs/funclist.md @@ -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` | ### 采购合同审查 diff --git a/frontend/src/features/workspace/api/voucherCheck.api.ts b/frontend/src/features/workspace/api/voucherCheck.api.ts index f61073b6..5cd0056d 100644 --- a/frontend/src/features/workspace/api/voucherCheck.api.ts +++ b/frontend/src/features/workspace/api/voucherCheck.api.ts @@ -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( + '/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; diff --git a/frontend/src/features/workspace/utils/voucherCheck.display.ts b/frontend/src/features/workspace/utils/voucherCheck.display.ts index 182d818b..db3d5598 100644 --- a/frontend/src/features/workspace/utils/voucherCheck.display.ts +++ b/frontend/src/features/workspace/utils/voucherCheck.display.ts @@ -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 翻译函数 diff --git a/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue b/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue index b9af71ec..142cc29a 100644 --- a/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue +++ b/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue @@ -1,28 +1,36 @@ @@ -321,22 +464,143 @@ onUnmounted(() => { +
+
+
+

{{ $t('workspace.voucherCheck.latestTitle') }}

+

+ {{ $t('workspace.voucherCheck.latestBatch', { runNo: latestRun.run_no }) }} + {{ $t('workspace.voucherCheck.latestPeriod', { period: latestRun.period_month || '-' }) }} + {{ voucherCheckModeLabel(t, latestRun.mode) }} +

+
+
+ + {{ voucherCheckStatusLabel(t, latestRun.status) }} + + +
+
+
+
+ + {{ $t('workspace.voucherCheck.loading') }} +
+

+ {{ $t('workspace.voucherCheck.latestEmpty') }} +

+ +
+
+
- -
@@ -524,3 +769,51 @@ onUnmounted(() => { /> + + diff --git a/frontend/src/locales/en/workspace.json b/frontend/src/locales/en/workspace.json index 7796a997..cb851fb9 100644 --- a/frontend/src/locales/en/workspace.json +++ b/frontend/src/locales/en/workspace.json @@ -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", diff --git a/frontend/src/locales/th/workspace.json b/frontend/src/locales/th/workspace.json index 081ba62b..df60622c 100644 --- a/frontend/src/locales/th/workspace.json +++ b/frontend/src/locales/th/workspace.json @@ -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", diff --git a/frontend/src/locales/zh-CN/workspace.json b/frontend/src/locales/zh-CN/workspace.json index bea8f60f..8a410f42 100644 --- a/frontend/src/locales/zh-CN/workspace.json +++ b/frontend/src/locales/zh-CN/workspace.json @@ -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": "暂无企业微信发送记录", diff --git a/frontend/src/locales/zh-TW/workspace.json b/frontend/src/locales/zh-TW/workspace.json index 4cf57b18..ad6b9970 100644 --- a/frontend/src/locales/zh-TW/workspace.json +++ b/frontend/src/locales/zh-TW/workspace.json @@ -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": "暫無企業微信發送紀錄",