71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
"""
|
|
backend/app/api/workspace/voucher_check.py
|
|
|
|
用途:工作台立账凭证检核记录查询 API(批次明细 / 最新状态)。
|
|
依赖:auth.jwt、response_utils envelope、voucher_check.query_service。
|
|
逻辑:对话与检核记录页共用;标准 {success,data|error,request_id} envelope。
|
|
"""
|
|
|
|
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.response import ok
|
|
from app.services.voucher_check import query_service
|
|
|
|
workspace_voucher_check_bp = Blueprint("workspace_voucher_check", __name__)
|
|
|
|
|
|
def _require_user():
|
|
user = get_current_user()
|
|
if not user:
|
|
raise UnauthorizedError()
|
|
return user
|
|
|
|
|
|
@workspace_voucher_check_bp.route("/accounting-voucher-check/runs/<int:run_id>/items", methods=["GET"])
|
|
def workspace_voucher_run_items(run_id: int):
|
|
"""
|
|
分页查看批次明细。
|
|
核心逻辑:委托 query_service.list_run_items,可按 result 过滤。
|
|
"""
|
|
_require_user()
|
|
data = query_service.list_run_items(
|
|
run_id=run_id,
|
|
result=request.args.get("result"),
|
|
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/states", methods=["GET"])
|
|
def workspace_voucher_states():
|
|
"""
|
|
按月份、状态、发票号筛选最新状态。
|
|
"""
|
|
_require_user()
|
|
data = query_service.list_states(
|
|
scope_code=str(request.args.get("scope_code") or "HXJM"),
|
|
period=request.args.get("period"),
|
|
status=request.args.get("status"),
|
|
invoice_no=request.args.get("invoice_no"),
|
|
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/states/<path:invoice_no>", methods=["GET"])
|
|
def workspace_voucher_state_detail(invoice_no: str):
|
|
"""查看单票最近状态和历史批次快照。"""
|
|
_require_user()
|
|
data = query_service.get_invoice_latest(
|
|
invoice_no=invoice_no,
|
|
scope_code=str(request.args.get("scope_code") or "HXJM"),
|
|
period=request.args.get("period"),
|
|
)
|
|
return ok(data)
|