Skip to main content

การลงทะเบียนโครงการ (Project Registration) - Workflow

Referenced Templates

  • Location: frontend/src/assets/templates/01-project-registration/
  • Location: frontend/src/assets/templates/02-pre-work-procedures/

Application Flow Diagram

The complete Safety App workflow showing all roles and document flow:

Safety App - Main Flow

Open full size in new tab - Use Ctrl+scroll to zoom

Project Registration Location

The Project Registration workflow is the top section of the diagram (red border area). After project approval, the Work Permit workflow can begin.


Implementation Diagram (Dev Version)

The dev-version diagram shows the exact workflow states as implemented in code. This is the technical reference that always matches the codebase.

Project Registration Workflow (Dev)

Source files
  • SVG: frontend/src/assets/workflows/project-registration-workflow-dev.svg
  • Draw.io: frontend/src/assets/workflows/project-registration-workflow-dev.drawio.xml
  • States enum: ProjectRegistrationWorkflowStates in project-registration-state-metadata.config.ts
Maintenance

Cell IDs in the dev-version SVG match state keys directly (e.g., data-cell-id="fill-in-project-info"). This makes it easy to update the diagram when workflow states change.


Workflow Diagram (Simplified)

Optional Path

The dashed line shows the optional skip path (planned feature). When a project already has a PO Number, the Work Owner can skip the Purchasing review and send directly to Contractor.


States

Phase 1: Project Information

StateThai NameDescriptionExpected Role
Startedเริ่มต้นInitial state (automatic transition)-
FillInProjectInfoกรอกข้อมูลโครงการWork Owner fills project details, contractor selection, datesWorkOwner

Phase 2: Purchasing Information

StateThai NameDescriptionExpected Role
FillInPurchasingInfoกรอกข้อมูลจัดซื้อPurchasing department fills PO number, budget, durationPurchasing
ReviewPurchasingInfoรีวิวข้อมูลจัดซื้อWork Owner reviews purchasing informationWorkOwner

Phase 3: Contractor Acknowledgement

StateThai NameDescriptionExpected Role
FillInPreWorkProceduresFormรับทราบระเบียบปฏิบัติงานContractor acknowledges work proceduresContractor
ReviewPreWorkProceduresFormรีวิวเอกสารระเบียบปฏิบัติงานWork Owner reviews contractor acknowledgementWorkOwner

Terminal States

StateThai NameDescription
ApprovedอนุมัติProject approved - can proceed to Work Permit
CanceledยกเลิกProject canceled
Completedเสร็จสิ้นTerminal state (internal)

Commands

From FillInProjectInfo

CommandThai NameTo StateAssigneeOptional
RequestPurchasingInfoส่งไปจัดซื้อFillInPurchasingInfoPurchasing-
RequestPreWorkProceduresFormDirectส่งไปผู้รับเหมาFillInPreWorkProceduresFormContractor✅ HasPONo
CancelยกเลิกงานCanceled--
Optional Command

RequestPreWorkProceduresFormDirect is only available when the project has a PO Number (skip condition: HasPurchaseOrderNo). This allows Work Owner to bypass the Purchasing review phase.

From FillInPurchasingInfo

CommandThai NameTo StateAssignee
SubmitPurchasingInfoส่งกลับReviewPurchasingInfoWorkOwner

From ReviewPurchasingInfo

CommandThai NameTo StateAssignee
RequestPurchasingInfoส่งไปจัดซื้อFillInPurchasingInfoPurchasing
RequestPreWorkProceduresFormส่งไปผู้รับเหมาFillInPreWorkProceduresFormContractor
CancelยกเลิกงานCanceled-

From FillInPreWorkProceduresForm

CommandThai NameTo StateAssignee
SubmitPreWorkProceduresFormรับทราบระเบียบปฏิบัติงานReviewPreWorkProceduresFormWorkOwner

From ReviewPreWorkProceduresForm

CommandThai NameTo StateAssignee
ApproveอนุมัติApproved → Completed-
RequestPurchasingInfoส่งไปจัดซื้อFillInPurchasingInfoPurchasing
RequestPreWorkProceduresFormส่งไปผู้รับเหมาFillInPreWorkProceduresFormContractor
CancelยกเลิกงานCanceled-

Document Forms

IDFormThai NameDescription
1ProjectRegistrationFormแบบขอลงทะเบียนโครงการMain project registration form
2PreWorkProceduresFormเอกสารรับทราบระเบียบปฏิบัติงานContractor acknowledgement form

State-Documents Mapping

Each workflow state shows different documents in the UI.

StateDocuments Shown
fill-in-project-infoDoc 1 (ProjectRegistrationForm)
fill-in-purchasing-infoDoc 1 (ProjectRegistrationForm)
review-purchasing-infoDoc 1 (ProjectRegistrationForm)
fill-in-pre-work-procedures-formDoc 1, Doc 2 (PreWorkProceduresForm)
review-pre-work-procedures-formDoc 1, Doc 2
approvedDoc 1, Doc 2 (all for reference)
canceledDoc 1, Doc 2 (all for reference)
completedDoc 1, Doc 2 (all for reference)

Form Edit Permissions

Controls which roles can edit which documents at each state.

StateProjectRegistrationForm (Doc 1)PreWorkProceduresForm (Doc 2)
fill-in-project-info✅ WorkOwner editable-
fill-in-purchasing-info✅ Purchasing editable-
review-purchasing-info✅ WorkOwner editable-
fill-in-pre-work-procedures-form🔒 Locked (completed)✅ Contractor editable
review-pre-work-procedures-form🔒 Locked✅ WorkOwner editable
approved🔒 Locked (after approval)🔒 Locked (after approval)
canceled🔒 Locked (after cancellation)🔒 Locked (after cancellation)
completed🔒 Locked (after completion)🔒 Locked (after completion)

Expected Role per State

Shows which role(s) should be acting at each workflow state. Used for the role indicator badge in the UI.

StateExpected RoleThai
fill-in-project-infoWorkOwnerเจ้าของงาน
fill-in-purchasing-infoPurchasingจัดซื้อ
review-purchasing-infoWorkOwnerเจ้าของงาน
fill-in-pre-work-procedures-formContractorผู้รับเหมา
review-pre-work-procedures-formWorkOwnerเจ้าของงาน
approved(terminal)-
canceled(terminal)-

Roles Involved

RoleThai NameResponsibilities
WorkOwnerเจ้าของงานCreates project, selects contractor, reviews all submissions
Purchasingจัดซื้อFills PO information, budget details
Contractorผู้รับเหมาAcknowledges work procedures

Workflow Rules

Routing Flexibility

The Work Owner has flexibility in routing:

  1. Skip Purchasing (planned): If project already has PO Number, can skip Purchasing and send directly to Contractor
  2. Multiple Iterations: Can send back to Purchasing or Contractor multiple times for corrections
  3. Cancel Anytime: Can cancel from most states before final approval

State Transition Rules

RuleDescription
Purchasing can be skippedIf project has PO Number, Work Owner can skip directly to Contractor
Purchasing optional on revisionAfter first review, can choose to skip Purchasing
Contractor must acknowledgeBefore approval, Contractor must sign PreWorkProceduresForm
WorkOwner final approvalOnly WorkOwner can approve or cancel

Optional Command Configuration (Planned)

The workflow supports configurable optional commands that can be skipped based on conditions:

Skip ConditionWhen SatisfiedEffect
HasPurchaseOrderNoProject.PurchaseOrderNo is not emptyEnable "Skip to Contractor" command
HasPurchaseRequisitionNoProject.PurchaseRequisitionNo is not empty(Future use)
UserChoiceAlwaysUser can choose to skip (with confirmation)

Optional commands are configured as properties on the TaskCommand entity:

OptionalConfig {
IsOptional: true
SkipCondition: HasPurchaseOrderNo
SkipToCommandKey: "request-pre-work-procedures-form"
SkipReasonTh: "ข้าม - มี PO No. แล้ว"
SkipReasonEn: "Skip - Already has PO No."
}

Relationship to Work Permit Workflow

Sequential Workflows

Project Registration must be Approved before Work Permit can be created. Once approved, the project becomes available for Work Permit requests.


Source Code Reference

Backend Workflow:

  • backend/SafetyApp.Workflows.ProjectRegistration/ProjectRegistrationWorkflow.cs
  • States enum: ProjectRegistrationWorkflowStates
  • Commands: ProjectRegistrationWorkflowCommands

Key Methods:

  • GetState() - Returns current workflow state
  • GetCommands() - Returns available commands for current state
  • GetDocumentFormIds() - Returns document IDs for current state
  • GetFormEditPermissions() - Returns edit permissions per document per state

Testing Instructions

Test Scenarios

  1. Happy Path: FillInProjectInfo → FillInPurchasingInfo → ReviewPurchasingInfo → FillInPreWorkProcedures → ReviewPreWorkProcedures → Approved
  2. Skip Path (planned): FillInProjectInfo → FillInPreWorkProcedures (skip Purchasing) → ReviewPreWorkProcedures → Approved
  3. Cancel Early: FillInProjectInfo → Cancel
  4. Multiple Revisions: FillInProjectInfo → FillInPurchasingInfo → ReviewPurchasingInfo → FillInPurchasingInfo (revision) → ReviewPurchasingInfo → ...
  5. Direct to Contractor: After purchasing info complete, send directly to Contractor

Checklist

  • WorkOwner can create project and fill info
  • Purchasing can fill PO information
  • WorkOwner can review and route to Purchasing or Contractor
  • Contractor can acknowledge work procedures
  • WorkOwner can approve or cancel
  • Forms are locked/unlocked correctly per state
  • Role badges show correct expected role