fix(estimates): allow approved estimate revocation
This commit is contained in:
parent
31bdc1047d
commit
8d37eb29b3
14 changed files with 295 additions and 8 deletions
|
|
@ -58,6 +58,8 @@ def can_read_activity(action: str, permissions: set[str]) -> bool:
|
|||
return "knowledge.read" in permissions
|
||||
if action.startswith("repairs."):
|
||||
return "repairs.read" in permissions
|
||||
if action.startswith("repair_estimates."):
|
||||
return "repair_estimates.read" in permissions
|
||||
if action.startswith("inventory."):
|
||||
return "inventory.read" in permissions
|
||||
if action.startswith("audit_logs."):
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ def get_dashboard_summary(
|
|||
MetricCard(label="Warten auf Freigabe", value=RepairEstimateRepository.count_waiting(db)),
|
||||
MetricCard(label="KVs freigegeben heute", value=RepairEstimateRepository.count_approved_today(db)),
|
||||
MetricCard(label="KVs abgelehnt", value=RepairEstimateRepository.count_declined(db)),
|
||||
MetricCard(label="Heute zurückgenommene KV", value=RepairEstimateRepository.count_revoked_today(db)),
|
||||
])
|
||||
|
||||
if "inventory.read" in permissions:
|
||||
|
|
|
|||
|
|
@ -124,6 +124,19 @@ def cancel_estimate(
|
|||
return RepairEstimateService.cancel(db, repair, estimate, actor=current_user, request=request)
|
||||
|
||||
|
||||
@router.post("/repairs/{repair_id}/estimates/{estimate_id}/revoke", response_model=RepairEstimateResponse)
|
||||
def revoke_estimate(
|
||||
repair_id: int,
|
||||
estimate_id: int,
|
||||
request: Request,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(require_permission("repair_estimates.revoke")),
|
||||
):
|
||||
repair = get_repair_or_404(db, repair_id)
|
||||
estimate = get_estimate_or_404(db, repair_id, estimate_id)
|
||||
return RepairEstimateService.revoke(db, repair, estimate, actor=current_user, request=request)
|
||||
|
||||
|
||||
@router.get("/repairs/{repair_id}/estimates/{estimate_id}/events", response_model=list[RepairEstimateEventResponse])
|
||||
def list_estimate_events(
|
||||
repair_id: int,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue