You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calculating payroll deductions, duplicate entries appear in the results for employees with specific deduction assignments.
I'm not sure if this behavior is intended, but I believe each deduction should be applied only once.
Additionally, there is another issue: when creating a deduction and specifying it for a particular employee, the Include_all_active_employees boolean is automatically set to True in the database by default.
Use distinct querysets in both calculate_pre_tax_deduction and calculate_post_tax_deduction to prevent TypeErrors when merging non-unique querysets with unique querysets.
The text was updated successfully, but these errors were encountered:
unreal0901
changed the title
Duplicated Deductions in Payroll Calculation and QuerySet Merge Error
Duplicated Deductions in Payroll Calculation
Mar 1, 2025
We acknowledge the problem of duplicate deduction entries and the unexpected behavior of the Include_all_active_employees field. Your detailed explanation and proposed solution are greatly appreciated.
We'll review the suggested fixes, including the use of .distinct() across querysets and the approach to merge deductions by IDs. This will help ensure accurate payroll calculations and prevent TypeErrors.
We'll update you once the fix is implemented. Thank you for contributing to improving Horilla!
Environment
Issue Description
When calculating payroll deductions, duplicate entries appear in the results for employees with specific deduction assignments.
I'm not sure if this behavior is intended, but I believe each deduction should be applied only once.
Additionally, there is another issue: when creating a deduction and specifying it for a particular employee, the
Include_all_active_employees
boolean is automatically set toTrue
in the database by default.Files
payroll -> methods -> payslip_calc.py
Url
Steps to Reproduce
Debug Output
The output shows the same deduction (ID: 8) appearing multiple times in the final result.
Proposed Solution
Fix duplicate deductions
.distinct()
when combining querysets:Fix queryset merge errors
.distinct()
to both installment querysets:Ensure consistent use of
.distinct()
.distinct()
across all relevant querysets.calculate_pre_tax_deduction
andcalculate_post_tax_deduction
to prevent TypeErrors when merging non-unique querysets with unique querysets.The text was updated successfully, but these errors were encountered: