Statusmaschine (transitionWorkOrder inkl. eventData), Zuweisung, Completion-Guards, Materialvorgabe, Checklisten/Pflichtfotos, Liste/Dashboard-Presets, Suche, Sync-Konflikte, Einstellungen (Auftragsarten, Vorlagen, Nummernkreise). Tests: Übergangsmatrix je Rolle, Kernlogik, Scope/Mandantentrennung, Nummernkreis-Parallelität. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35 lines
1.7 KiB
TypeScript
35 lines
1.7 KiB
TypeScript
import type { ServiceCtx } from "@/server/services/context";
|
|
import { transitionWorkOrder, type TransitionResult } from "@/server/services/work-orders/transition";
|
|
|
|
/**
|
|
* Billing workflow (US-009). All paths go through transitionWorkOrder, which enforces
|
|
* `work_order:release_billing` and — for the release — an approved completion report.
|
|
* The event `work_order.released_for_billing` is emitted by the transition.
|
|
*/
|
|
export async function releaseForBilling(
|
|
ctx: ServiceCtx,
|
|
input: { workOrderId: string; baseVersion?: number },
|
|
): Promise<TransitionResult> {
|
|
return transitionWorkOrder(ctx, { workOrderId: input.workOrderId, to: "released_for_billing", baseVersion: input.baseVersion });
|
|
}
|
|
|
|
/** Reject: back to the team for correction (in_review → in_progress), reason mandatory. */
|
|
export async function rejectForCorrection(
|
|
ctx: ServiceCtx,
|
|
input: { workOrderId: string; reason: string; baseVersion?: number },
|
|
): Promise<TransitionResult> {
|
|
return transitionWorkOrder(ctx, { workOrderId: input.workOrderId, to: "in_progress", reason: input.reason, baseVersion: input.baseVersion });
|
|
}
|
|
|
|
/** Revoke a billing release (released_for_billing → in_review), reason mandatory. */
|
|
export async function revokeBillingRelease(
|
|
ctx: ServiceCtx,
|
|
input: { workOrderId: string; reason: string; baseVersion?: number },
|
|
): Promise<TransitionResult> {
|
|
return transitionWorkOrder(ctx, { workOrderId: input.workOrderId, to: "in_review", reason: input.reason, baseVersion: input.baseVersion });
|
|
}
|
|
|
|
export async function markBilled(ctx: ServiceCtx, input: { workOrderId: string; baseVersion?: number }): Promise<TransitionResult> {
|
|
return transitionWorkOrder(ctx, { workOrderId: input.workOrderId, to: "billed", baseVersion: input.baseVersion });
|
|
}
|