1
This commit is contained in:
1 parent
78576f5745
commit
63b997a7e4
68 files changed
+3680
-1413
No files matched your search
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/app/api/workspace/voucher_check.py
|
||||
|
||||
用途:工作台立账凭证检核记录查询 API(批次明细 / 最新状态)。
|
||||
用途:工作台立账凭证检核查询与强制重检 API(任务列表 / 批次明细 / 兼容旧状态)。
|
||||
依赖:auth.jwt、response_utils envelope、voucher_check.query_service。
|
||||
逻辑:对话与检核记录页共用;标准 {success,data|error,request_id} envelope。
|
||||
逻辑:对话与检核任务页共用;POST runs 仅 admin,以 force_all 入队周批排程。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -11,7 +11,7 @@ from __future__ import annotations
|
||||
from flask import Blueprint, request
|
||||
|
||||
from app.core.auth.jwt import get_current_user
|
||||
from app.core.errors import UnauthorizedError
|
||||
from app.core.errors import ForbiddenError, UnauthorizedError, ValidationError
|
||||
from app.core.response import ok
|
||||
from app.services.voucher_check import query_service
|
||||
|
||||
@@ -25,6 +25,50 @@ def _require_user():
|
||||
return user
|
||||
|
||||
|
||||
def _require_admin():
|
||||
"""工作台强制重检仅管理员可触发,鉴权方式与本蓝图 GET 一致。"""
|
||||
user = _require_user()
|
||||
if getattr(user, "role", None) != "admin":
|
||||
raise ForbiddenError("Admin privilege required")
|
||||
return user
|
||||
|
||||
|
||||
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs", methods=["GET"])
|
||||
def workspace_voucher_runs():
|
||||
"""
|
||||
分页查看检核任务列表。
|
||||
核心逻辑:委托 query_service.list_runs,按资料所属期间/业务方/状态筛选。
|
||||
"""
|
||||
_require_user()
|
||||
data = query_service.list_runs(
|
||||
period=request.args.get("period"),
|
||||
profile_code=request.args.get("profile_code"),
|
||||
status=request.args.get("status"),
|
||||
page=request.args.get("page", default=1, type=int) or 1,
|
||||
page_size=request.args.get("page_size", default=50, type=int) or 50,
|
||||
)
|
||||
return ok(data)
|
||||
|
||||
|
||||
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs", methods=["POST"])
|
||||
def workspace_voucher_force_run():
|
||||
"""
|
||||
强制重检上一个自然月(不走增量跳过)。
|
||||
核心逻辑:body.mode 仅接受 force_all;入队默认周批排程,由 schedule worker 执行。
|
||||
"""
|
||||
user = _require_admin()
|
||||
payload = request.get_json(silent=True) or {}
|
||||
mode = str(payload.get("mode") or "force_all").strip().lower()
|
||||
if mode != "force_all":
|
||||
raise ValidationError(
|
||||
"工作台仅支持 force_all",
|
||||
code="VOUCHER_CHECK.CONFIG_INVALID",
|
||||
details={"mode": mode},
|
||||
)
|
||||
data = query_service.enqueue_force_all_run(triggered_by_user_id=getattr(user, "id", None))
|
||||
return ok(data)
|
||||
|
||||
|
||||
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs/<int:run_id>/items", methods=["GET"])
|
||||
def workspace_voucher_run_items(run_id: int):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user