Skip to content

Update logic to update Weekly Status based on per day-priority status#669

Merged
niraj2477 merged 1 commit intodevelopfrom
feat/priority-based-weekly-status-updates
Jul 2, 2025
Merged

Update logic to update Weekly Status based on per day-priority status#669
niraj2477 merged 1 commit intodevelopfrom
feat/priority-based-weekly-status-updates

Conversation

@Siddhantsingh1230
Copy link
Copy Markdown
Collaborator

@Siddhantsingh1230 Siddhantsingh1230 commented Jul 1, 2025

Description

This PR refactors the update_weekly_status_of_timesheet utility to use a per-day priority-based approach for determining the overall weekly approval status.

Previously, the weekly status was derived based on the total count of timesheets, which led to inaccurate results when users created multiple timesheets on the same day.

For example:
A user creates 1 timesheet each for Monday to Wednesday and 2 timesheets on Thursday, resulting in 5 timesheets.
If the employee's working days are also 5, the system considers the quota met and marks the week as "Approved" once these are approved by the manager.
However, the user is then unable to add a timesheet on Friday, which is a valid working day.

To resolve this:
We now evaluate daily statuses based on the highest priority status among all timesheets for a given day.
Weekly status is derived from the distribution of these daily statuses, ensuring accurate and fair handling of timesheet approvals.
This approach eliminates issues arising from multiple timesheets on the same day and respects the actual working day count for the employee.

Relevant Technical Choices

  • Refactors update_weekly_status_of_timesheet to derive weekly status based on highest-priority status per working day, preventing issues from multiple timesheets on the same day.

Testing Instructions

  • Go to NPMS
  • Add Timesheets
  • Send them for approval
  • Normal Workflow should not break

Additional Information:

Priority of status are as followed
Rejected > Approval Pending > Approved > Not Submitted

Screenshot/Screencast

N/A

Checklist

  • I have carefully reviewed the code before submitting it for review.
  • This code is adequately covered by unit tests to validate its functionality.
  • I have conducted thorough testing to ensure it functions as intended.
  • A member of the QA team has reviewed and tested this PR (To be checked by QA or code reviewer)

@niraj2477 niraj2477 changed the title [WIP] Update logic to update Weekly Status based on per day-priority status Update logic to update Weekly Status based on per day-priority status Jul 2, 2025
@niraj2477 niraj2477 closed this Jul 2, 2025
@niraj2477 niraj2477 reopened this Jul 2, 2025
@niraj2477
Copy link
Copy Markdown
Collaborator

closed/opened to re-run the test

@niraj2477 niraj2477 marked this pull request as ready for review July 2, 2025 05:02
@niraj2477 niraj2477 merged commit 13ea4a2 into develop Jul 2, 2025
11 of 14 checks passed
@Siddhantsingh1230 Siddhantsingh1230 deleted the feat/priority-based-weekly-status-updates branch August 7, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants