将月份状态、资料输出、调整单编排及工作区查询、 CSV 生成移至现有服务层,路由仅绑定参数并返回响应。 保持接口路径、参数、响应模型和权限依赖一致, 补充九项内存库行为回归并同步测试记录。
69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
"""正式工资资料、FIFO核算和逐段明细入口。"""
|
|
|
|
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Path, Query
|
|
|
|
from app.api.deps import DbSession, LoginUser, PayrollWriter, RequestMetaDep
|
|
from app.core.response import PageQuery, ok
|
|
from app.schemas.payroll import AllocationAdjustmentIn, PayrollMonthIn, PayrollSetupIn
|
|
from app.services import payroll_calculation, payroll_inputs, payroll_months, settlement_service
|
|
|
|
router = APIRouter(prefix="/payroll", tags=["正式工资核算"])
|
|
|
|
|
|
@router.get("/months/{month}")
|
|
def month_state(
|
|
month: Annotated[str, Path(pattern=r"^20[0-9]{2}-(0[1-9]|1[0-2])$")],
|
|
session: DbSession,
|
|
_: LoginUser,
|
|
):
|
|
return ok(payroll_months.month_state(session, month))
|
|
|
|
|
|
@router.get("/businesses/{business_id}/input")
|
|
def input_detail(business_id: int, session: DbSession, _: LoginUser):
|
|
return ok(payroll_inputs.detail(session, business_id))
|
|
|
|
|
|
@router.post("/businesses/{business_id}/input")
|
|
def save_input(
|
|
business_id: int,
|
|
payload: PayrollSetupIn,
|
|
session: DbSession,
|
|
actor: PayrollWriter,
|
|
meta: RequestMetaDep,
|
|
):
|
|
return ok(payroll_inputs.setup(session, business_id, payload, actor, meta))
|
|
|
|
|
|
@router.post("/businesses/{business_id}/calculate")
|
|
def calculate(
|
|
business_id: int,
|
|
payload: PayrollMonthIn,
|
|
session: DbSession,
|
|
actor: PayrollWriter,
|
|
meta: RequestMetaDep,
|
|
):
|
|
return ok(
|
|
payroll_calculation.calculate(
|
|
session, business_id, payload.month, operator=actor, meta=meta, reason=payload.reason
|
|
)
|
|
)
|
|
|
|
|
|
@router.get("/ledger/{ledger_id}/allocations")
|
|
def allocations(
|
|
ledger_id: int, query: Annotated[PageQuery, Query()], session: DbSession, _: LoginUser
|
|
):
|
|
return ok(payroll_calculation.allocation_page(session, ledger_id, query))
|
|
|
|
|
|
@router.post("/allocation-adjustments")
|
|
def adjustment(
|
|
payload: AllocationAdjustmentIn, session: DbSession, actor: PayrollWriter, meta: RequestMetaDep
|
|
):
|
|
return ok(
|
|
settlement_service.create_allocation_adjustment(session, payload, operator=actor, meta=meta)
|
|
)
|