InfraNotes Core · v2
Welcome
Select a document from the sidebar to read it.
Invoice Approval Workflow System
Overview
The approval workflow system allows organizations to implement customizable approval processes for invoices. This system enables businesses to enforce financial governance by requiring one or more approvers to review and authorize invoices before they can be processed further.
Key Features
- Configurable Approval Chains: Define multi-step approval workflows with sequential steps
- Multiple Approver Types: Support for individual users, roles, or team-based approvers
- Delegation Support: Allow approvers to delegate their responsibility to others
- Centralized Workflows: Create reusable workflow templates that can be applied to multiple invoices
- Approval Tracking: Complete history and audit trail of the approval process
- Notifications: Automated notifications for pending approvals and status changes
- Amount-based Thresholds: Optional amount thresholds to determine which workflow applies
Implementation Components
The approval workflow system consists of the following components:
Database Schema
- approval_workflows: Defines reusable workflow templates
- approval_workflow_steps: Configures the steps within a workflow
- approval_instances: Tracks active approval processes
- approval_actions: Records individual approval decisions
- approval_delegates: Manages approver delegations
Models
- ApprovalWorkflow: Defines a reusable approval workflow
- ApprovalWorkflowStep: Defines a single step in an approval chain
- ApprovalInstance: Represents an active approval process
- ApprovalActionRecord: Records an approval action (approve/reject/delegate)
- ApprovalDelegate: Represents a delegation of approval authority
Services
- ApprovalWorkflowService: Manages workflows and processes approval actions
- NotificationService: Sends notifications for approval events
API Endpoints
Workflow Management
POST /api/approval/workflows: Create a new workflowGET /api/approval/workflows: List workflowsGET /api/approval/workflows/{id}: Get a specific workflowPUT /api/approval/workflows/{id}: Update a workflowDELETE /api/approval/workflows/{id}: Delete a workflow
Workflow Steps
POST /api/approval/workflows/{id}/steps: Add a step to a workflowPUT /api/approval/workflows/{id}/steps/{stepId}: Update a workflow stepDELETE /api/approval/workflows/{id}/steps/{stepId}: Delete a workflow step
Approval Operations
POST /api/approval/request: Request approval for an invoicePOST /api/approval/instances/{id}/approve: Approve a requestPOST /api/approval/instances/{id}/reject: Reject a requestPOST /api/approval/instances/{id}/delegate: Delegate approval to another userPOST /api/approval/instances/{id}/cancel: Cancel an approval request
Approval Status
GET /api/approval/instances: List approval instancesGET /api/approval/instances/{id}: Get a specific approval instanceGET /api/approval/pending: Get pending approvals for the current user
Delegation Management
POST /api/approval/delegates: Add a delegateGET /api/approval/delegates: List delegatesDELETE /api/approval/delegates/{id}: Remove a delegate
Usage Examples
Creating a Workflow
// POST /api/approval/workflows
{
"name": "Invoice Approval - Finance",
"description": "Standard invoice approval workflow for finance department",
"entity_type": "invoice",
"is_active": true,
"min_amount_threshold": 1000.00,
"max_amount_threshold": 10000.00,
"is_default": false
}
Adding Steps to a Workflow
// POST /api/approval/workflows/123/steps
{
"step_order": 1,
"approver_type": "user",
"approver_id": 456,
"name": "Department Manager Approval",
"description": "Initial approval by department manager",
"is_required": true
}
Requesting Approval
// POST /api/approval/request
{
"entity_type": "invoice",
"entity_id": 789,
"workflow_id": 123,
"notes": "Please approve this invoice for project XYZ"
}
Approving a Request
// POST /api/approval/instances/456/approve
{
"notes": "Approved - within budget and properly documented"
}
Rejecting a Request
// POST /api/approval/instances/456/reject
{
"notes": "Rejected - missing supporting documentation"
}
Delegating Approval
// POST /api/approval/instances/456/delegate
{
"delegate_id": 789,
"notes": "Please review this invoice while I'm on vacation"
}
Integration with Invoice System
The approval workflow system integrates seamlessly with the existing invoice management system:
-
The invoice model has been extended with approval-related fields:
approval_status: Current approval statusapproval_workflow_id: Reference to the associated workflowrequires_approval: Flag indicating if approval is requiredlast_approval_action_at: Timestamp of the last approval action
-
Invoice repository methods have been extended with:
SetApprovalStatus: Updates the approval status of an invoiceSetApprovalWorkflow: Associates a workflow with an invoiceGetInvoicesByApprovalStatus: Finds invoices by approval statusGetInvoicesPendingApproval: Gets invoices pending approval for a user
-
The approval workflow can be triggered:
- Manually via API call
- Automatically based on invoice amount
- Based on other configurable business rules
Permissions
The approval workflow system introduces new permission types:
invoice:approval:request: Ability to request approval for invoicesinvoice:approval:approve: Ability to approve invoicesinvoice:approval:reject: Ability to reject invoicesinvoice:approval:cancel: Ability to cancel approval requestsapproval:workflow:view: Ability to view approval workflowsapproval:workflow:create: Ability to create approval workflowsapproval:workflow:update: Ability to update approval workflowsapproval:workflow:delete: Ability to delete approval workflowsapproval:workflow:step:manage: Ability to manage workflow stepsapproval:workflow:set:default: Ability to set a workflow as defaultapproval:delegate:manage: Ability to manage approval delegatesapproval:actions:view: Ability to view approval actionsapproval:workflow:assign: Ability to assign workflows to entities
Future Enhancements
The following enhancements are planned for future development:
- Role-based Approval: Enhanced support for role-based approvals
- Team-based Approval: Support for any team member to approve
- Amount-based Routing: Automatic workflow selection based on amount
- Deadline Handling: Tracking and escalation for overdue approvals
- Front-end Components: Approval dashboard and workflow configuration UI
- Parallel Approvals: Support for approval steps that can happen in parallel
- Conditional Routing: Dynamic approval chains based on invoice attributes
- Mobile Approvals: Mobile-friendly approval interface and notifications
- Analytics: Analytics on approval times, bottlenecks, and trends
API Usage Examples
Creating a Workflow
Endpoint: POST /api/approval/workflows
Request Body:
{
"name": "Invoice Approval Workflow",
"description": "Standard workflow for invoice approvals",
"entity_type": "invoice",
"is_active": true,
"min_amount_threshold": 1000,
"max_amount_threshold": 10000,
"is_default": true
}
Response: The created workflow with its ID.
Adding a Workflow Step
Endpoint: POST /api/approval/workflows/{id}/steps
Request Body:
{
"approver_type": "user",
"approver_id": 123,
"name": "Finance Manager Approval",
"description": "Requires approval from a finance manager",
"step_order": 1,
"is_required": true
}
Response: The created workflow step with its ID.
Requesting Approval
Endpoint: POST /api/approval/request
Request Body:
{
"entity_type": "invoice",
"entity_id": 456,
"workflow_id": 1,
"notes": "Please review and approve this invoice"
}
Response: The created approval instance with status "pending".
Approving a Request
Endpoint: POST /api/approval/instances/{id}/approve
Request Body:
{
"notes": "Looks good, approved."
}
Response: The updated approval instance with status changes.
Rejecting a Request
Endpoint: POST /api/approval/instances/{id}/reject
Request Body:
{
"notes": "Invoice amount exceeds budget allocation."
}
Response: The updated approval instance with status "rejected".
Getting Pending Approvals
Endpoint: GET /api/approval/pending
Response: A list of approval instances waiting for the current user's approval.
Tips for Implementation
- Workflow Design: Start with simple workflows with 1-2 steps before creating complex approval chains
- Testing: Test each approval step with different user roles to ensure the workflow functions correctly
- Error Handling: Implement proper error handling for scenarios like approver unavailability
- Notifications: Configure email notifications to alert approvers of pending requests
- Dashboards: Build approval dashboards to help users track pending approvals
- Delegation: Use the delegation system during vacations or absences
Conclusion
The approval workflow system provides a flexible foundation for organizations to implement governance over their invoice processing. The system is designed to be extensible and can be adapted for other types of approvals beyond invoices in the future.