33 lines
1.7 KiB
Markdown
33 lines
1.7 KiB
Markdown
|
|
# Walkthrough - Overtime Delegation API Implementation
|
||
|
|
|
||
|
|
I have implemented the backend API for Overtime Delegation as requested. This API allows superiors to delegate overtime tasks to multiple subordinates across a range of dates.
|
||
|
|
|
||
|
|
## Changes Made
|
||
|
|
|
||
|
|
### 1. Delegation Service
|
||
|
|
- **File**: [delegation-overtime-services.js](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/ess_api/ess_api/app/services/delegation-overtime-services.js)
|
||
|
|
- **Method**: `insertOvertimeDelegation`
|
||
|
|
- **Logic**:
|
||
|
|
- Accepts a payload with employees, date range, and times.
|
||
|
|
- Generates a unique `idplanning` for tracking the batch.
|
||
|
|
- Calculates the duration for the overtime.
|
||
|
|
- Performs a batch `INSERT` into the `trx_multi_ovt` table.
|
||
|
|
- Includes tracking fields: `nik_delegator`, `time_stamp_delegator`, `nik_delegate`, `name_delegate`, and `time_stamp_delegate`.
|
||
|
|
|
||
|
|
### 2. Delegation Routes
|
||
|
|
- **File**: [delegation-routes.js](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/ess_api/ess_api/app/routes/delegation-routes.js)
|
||
|
|
- **Endpoint**: `POST /api/delegations/overtime/insert`
|
||
|
|
- **Middleware**: Secured with `jwtAuth.verifyToken`.
|
||
|
|
|
||
|
|
### 3. Server Integration
|
||
|
|
- **File**: [server.js](file:///home/itc43/Documents/HOKBEN_PROJECT/ESS%20PROJECT/ess_api/ess_api/server.js)
|
||
|
|
- **Action**: Registered the new delegation routes.
|
||
|
|
|
||
|
|
## Verification
|
||
|
|
- The API is now ready to be consumed by the UI.
|
||
|
|
- The batch insertion logic ensures that multiple records are created efficiently.
|
||
|
|
- Tracking fields are populated to allow auditing of who delegated to whom.
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
- Update the Flutter UI (`OvertimeDelegationPage`) to call this new API endpoint when the "Submit Delegasi" button is pressed.
|