Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Salary Structure Assignment: Preview Salary Slip): Calculation of earnings whose formula is dependent on deductions and so on #2088

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

krantheman
Copy link
Member

@krantheman krantheman commented Aug 16, 2024

Ticket: https://support.frappe.io/helpdesk/tickets/20134

First of all, let it be known that I do not like working on the payroll codebase.

Now that that is out of the way, if the formula of an earning component is dependent on a deduction component, it does not get updated in the salary slip preview. Consequently, other components that are dependent on the un-updated one do not get updated either, and so on.

Salary Structure:

image

Salary Slip Preview (Base = 4,58,433):

image

Special Allowance isn't updated, as it does not get Provident Fund and Gratuity values. It should be 3504 - (1800 + 919) = 785

Solution

  • Recursively updating the components whose formulae are dependent on updated components (starting with earnings dependent on deductions)
  • Calculating gross and base gross pay twice
    • After calculating earnings
    • After calculating deductions
  • Updating deductions after final gross pay calculation in case it is dependent on it

@krantheman krantheman marked this pull request as ready for review August 16, 2024 11:28
@ruchamahabal
Copy link
Member

ruchamahabal commented Aug 28, 2024

First of all, let it be known that I do not like working on the payroll codebase.

Same 🤝. It needs a rewrite.

This approach needs to be optimized but maybe during/after the rewrite.

@ruchamahabal
Copy link
Member

LGTM

@ruchamahabal ruchamahabal merged commit 84dd3e0 into frappe:develop Aug 28, 2024
7 checks passed
ruchamahabal added a commit that referenced this pull request Aug 28, 2024
…2088

fix(Salary Structure Assignment: Preview Salary Slip): Calculation of earnings whose formula is dependent on deductions and so on (backport #2088)
@krantheman krantheman deleted the fix-salary-slip-preview branch August 29, 2024 08:24
ruchamahabal added a commit to ruchamahabal/hrms that referenced this pull request Aug 31, 2024
- sanitize condition & formula fields in structure doc reference to avoid accidental reference to unsanitized fields across functions

regression: frappe#2088
ruchamahabal added a commit to ruchamahabal/hrms that referenced this pull request Aug 31, 2024
- sanitize condition & formula fields in structure doc reference to avoid accidental reference to unsanitized fields across functions

regression: frappe#2088
mergify bot pushed a commit that referenced this pull request Aug 31, 2024
- sanitize condition & formula fields in structure doc reference to avoid accidental reference to unsanitized fields across functions

regression: #2088
(cherry picked from commit 3057298)
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.

2 participants