Skip to content

Commit

Permalink
created hasEngagement condition
Browse files Browse the repository at this point in the history
  • Loading branch information
atGit2021 committed Jun 6, 2024
1 parent acb3254 commit 0199362
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/project/workflow/project-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { TransitionType as Type } from '../../workflow/dto';
import { ProjectStep as Step } from '../dto';
import { ProjectWorkflowEvent } from './dto';
import {
hasEngagement,
hasValidRoleForProjectType,
IsMultiplication,
IsNotMultiplication,
Expand Down Expand Up @@ -117,15 +118,23 @@ export const ProjectWorkflow = defineWorkflow({
to: Step.PrepForFinancialEndorsement,
label: 'Endorse Plan',
type: Type.Approve,
conditions: [IsNotMultiplication, hasValidRoleForProjectType],
conditions: [
IsNotMultiplication,
hasValidRoleForProjectType,
hasEngagement,
],
},
'Pending Consultant Endorsement -> Prep for Financial Endorsement Without Consultant Endorsement':
{
from: Step.PendingConsultantEndorsement,
to: Step.PrepForFinancialEndorsement,
label: 'Do Not Endorse Plan',
type: Type.Neutral,
conditions: [IsNotMultiplication, hasValidRoleForProjectType],
conditions: [
IsNotMultiplication,
hasValidRoleForProjectType,
hasEngagement,
],
},

// Prep for Financial Endorsement
Expand Down
10 changes: 10 additions & 0 deletions src/components/project/workflow/transitions/conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export const hasValidRoleForProjectType: Condition = {
},
};

export const hasEngagement: Condition = {
description: 'Has an engagement',
resolve({ project }) {
return {
status: project.engagementTotal > 0 ? 'ENABLED' : 'DISABLED',
disabledReason: `The project requires an engagement`,
};
},
};

export const RequireOngoingEngagementsToBeFinalizingCompletion: Condition = {
description:
'All engagements must be Finalizing Completion or in a terminal status',
Expand Down

0 comments on commit 0199362

Please sign in to comment.