mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 01:33:12 +00:00
25 lines
996 B
TypeScript
25 lines
996 B
TypeScript
import type { CompDocSaveStatus } from "@/domain/work-orders/types/completion-doc";
|
|
import type { WorkOrderTableRow } from "@/domain/work-orders/types/work-order-table-row";
|
|
import {
|
|
getClosabilityGaps,
|
|
tableRowToClosabilityInput,
|
|
} from "@/domain/work-orders/utils/wo-closability";
|
|
|
|
/**
|
|
* Completion is manual with confirmation, except that generating the completion document
|
|
* completes the WO — but only when the closability gate passes on the persisted row.
|
|
* Not-required (NN) and drafts never complete; Past Due rows must be
|
|
* rescheduled before any status change, so they are left for the dispatcher.
|
|
*/
|
|
export function shouldCompleteAfterCompletionDoc(
|
|
status: CompDocSaveStatus,
|
|
row: WorkOrderTableRow,
|
|
): boolean {
|
|
if (status !== "Yes" || row.docStatus !== "Yes") {
|
|
return false;
|
|
}
|
|
if (row.status === "Completed" || row.status === "Canceled" || row.isPastDue) {
|
|
return false;
|
|
}
|
|
return getClosabilityGaps(tableRowToClosabilityInput(row)).length === 0;
|
|
}
|