mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-03 01:03:21 +00:00
fix(work-orders): allow comp-doc generate without existing completion document
canGenerateCompDoc now ignores the completion-document closability gap so PM/Overdue drafts can enter generation. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
67c4ee8119
commit
dd60b1d72e
2 changed files with 7 additions and 1 deletions
|
|
@ -115,9 +115,11 @@ export type CompDocGateResult = { allowed: true } | { allowed: false; reason: st
|
|||
/**
|
||||
* Gate for completion-document generation. CompDocDialog (not yet on `dev`) should call this
|
||||
* before opening generate flow and surface `reason` when blocked.
|
||||
*
|
||||
* Intentionally omits the "Completion document" closability gap — generate is how that gap is filled.
|
||||
*/
|
||||
export function canGenerateCompDoc(row: WoClosabilityInput): CompDocGateResult {
|
||||
const gaps = getClosabilityGaps(row);
|
||||
const gaps = getClosabilityGaps(row).filter((gap) => gap !== "Completion document");
|
||||
if (gaps.length > 0) {
|
||||
return { allowed: false, reason: formatClosabilityMissingTitle(gaps) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ describe("canGenerateCompDoc", () => {
|
|||
expect(canGenerateCompDoc(makeInput())).toEqual({ allowed: true });
|
||||
});
|
||||
|
||||
it("allows generation when only the completion document is missing", () => {
|
||||
expect(canGenerateCompDoc(makeInput({ docStatus: "No" }))).toEqual({ allowed: true });
|
||||
});
|
||||
|
||||
it("blocks generation with design reason when only pending uplift exists", () => {
|
||||
expect(canGenerateCompDoc(makeInput({ hasPendingUplift: true }))).toEqual({
|
||||
allowed: false,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue