Skip to content

Payroll adjustments api 478#504

Merged
codeZe-us merged 6 commits into
SafeVault:devfrom
auracule007:payroll-adjustments-api-478
Jun 1, 2026
Merged

Payroll adjustments api 478#504
codeZe-us merged 6 commits into
SafeVault:devfrom
auracule007:payroll-adjustments-api-478

Conversation

@auracule007
Copy link
Copy Markdown
Contributor

Summary #478

This PR implements the Payroll Bonuses and Deductions API for active payroll drafts.

It adds a new payroll draft database model and introduces an adjustments endpoint that lets an authenticated organization user apply one-time bonuses or custom deductions to a specific employee within an active payroll draft. When an adjustment is submitted, the API updates the employee payload, recalculates the employee’s netPay, recalculates the draft totalAmount, and persists the updated draft record.

This gives payroll managers a way to make last-minute draft payroll changes while keeping both employee-level and draft-level totals in sync.

Type of Change

  • Feature
  • Bug Fix
  • Refactoring
  • Documentation
  • Tests
  • Infrastructure / CI

Linked Issues

Fixes #478

Key Changes

  • Added payroll_draft_status enum with active, processed, and cancelled states.
  • Added payroll_drafts table to store draft payroll payloads, draft status, organization ownership, and total amount.
  • Added database migration for the payroll draft table and indexes.
  • Added POST /api/v1/payroll/[draftId]/adjustments for applying payroll adjustments.
  • Added PATCH /api/v1/payroll/[draftId]/adjustments for adding or removing payroll adjustments.
  • Added request validation for draftId, employeeId, adjustment type, amount, action, and optional reason.
  • Restricted updates to active payroll drafts owned by the authenticated user’s organization.
  • Recalculated the target employee’s netPay after applying bonuses or deductions.
  • Recalculated the payroll draft totalAmount after employee payload updates.
  • Returned clear error responses for invalid payloads, missing organization access, inactive/missing drafts, missing employees, and invalid removal amounts.

Checklist

  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new linting/type-checking warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the documentation accordingly.

Screenshots / Recordings

Not applicable. This is a backend API/database change.

Closes #478

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@auracule007 is attempting to deploy a commit to the vestroll's projects Team on Vercel.

A member of the Team first needs to authorize it.

@auracule007
Copy link
Copy Markdown
Contributor Author

@codeZe-us Please review this PR. points to dev branch

@github-actions github-actions Bot added size/xl and removed size/l labels Jun 1, 2026
@github-actions github-actions Bot added size/l and removed size/xl labels Jun 1, 2026
@codeZe-us codeZe-us self-requested a review June 1, 2026 23:24
@codeZe-us codeZe-us merged commit 8977b46 into SafeVault:dev Jun 1, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants