# CompleteProcessActivity ## Overview Marks a Process Activity as complete. It ensures that all validations are met, including system state and *Checklist* completion. Handles automatic *Employee* check-out if configured. The Process Activity is then marked as closed and optionally terminated based on configuration and current state. ## Action Groups * Orchestration.IndEqManagementOrchestration.CompleteProcessActivity.Pre * Orchestration.IndEqManagementOrchestration.CompleteProcessActivity.Post ## Input Object | Name | Type | Description | | --------------- | :------------------: | -------------------------------- | | ProcessActivity | IndEqProcessActivity | The Process Activity to complete | ## Output Object | Name | Type | Description | | --------------- | :------------------: | ------------------------------ | | ProcessActivity | IndEqProcessActivity | The completed Process Activity | ## Pre Conditions * `ProcessActivity.SystemState` must be `In Progress` or `Paused`. * No associated `ChecklistInstance` can exist. * The associated *Checklist* - Must be in `Terminated` universal state. - Must be in `Closed` system state. ## How it works 1. Validates the input and loads the Process Activity. 2. Ensures the activity is either `In Progress` or `Paused`. 3. Validates any linked Checklist: - Throws an exception if the Checklist is still active or in an invalid state. 4. Checks if employees are still checked-in: - If `EnableCheckIn` and `AutoCheckOutOnClose` are both enabled: - Automatically checks out all employees. - If employees remain checked-in and auto-check-out is not enabled: - The activity will be closed but not terminated. 5. Sets the Process Activity's state to `Closed`, sets the `EndDatetime` and `EndFlowPath`, then saves it. 6. If no employees remain checked-in, the Process Activity is also terminated. 7. Returns the updated Process Activity. ## Assumptions * Configuration for check-out and checklist validation is properly defined.