-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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: Leave Encashment calculations #31062
fix: Leave Encashment calculations #31062
Conversation
Also, I don't know if this is how it should be. The Encashment threshold days setting seems to be adding some functionality that should work exactly opposite to what it's doing right now maybe? As per docs and functionality: Which organization has a threshold above which you can encash? Like if you have 15 leaves, you cannot encash 5 but you can encash 10? Expected (Maybe): Shouldn't it be like; you can only encash up to 5 leaves because 5 is the threshold. Currently, it's very confusing for the user. cc: @nabinhait |
Codecov Report
@@ Coverage Diff @@
## develop #31062 +/- ##
===========================================
- Coverage 63.04% 62.94% -0.10%
===========================================
Files 986 986
Lines 67343 67345 +2
===========================================
- Hits 42457 42392 -65
- Misses 24886 24953 +67
|
- incorrect leave balance and encashable days in encashment
3c707fb
to
3c3b26f
Compare
Will look into this in a separate PR. |
(cherry picked from commit 34e238c)
# [13.31.0](v13.30.0...v13.31.0) (2022-05-26) ### Bug Fixes * Account currency validation for first transaction ([228f10b](228f10b)) * Add party account validation for journal entry ([7f853b1](7f853b1)) * always update item_name for stock entry (backport [#31068](#31068)) ([#31071](#31071)) ([f519dc6](f519dc6)) * change project's actual_start_date fieldtype from Data to Date (backport [#31085](#31085)) ([#31135](#31135)) ([8c2f203](8c2f203)) * Chart data for monthly periodicity in Cash Flow report ([#31039](#31039)) ([f14e9b7](f14e9b7)) * corrective job card creation (backport [#31083](#31083)) ([#31084](#31084)) ([c17c260](c17c260)) * don't capture payments with invoice_id as donations ([168a9d4](168a9d4)) * employee advance status update on return via additional salary ([d59c3d2](d59c3d2)) * Handle missing HSN Codes ([ce3a21e](ce3a21e)) * Healthcare module accounting test cases ([09a42a1](09a42a1)) * **India:** Async issue in company address trigger ([2ea3318](2ea3318)) * **india:** error while parsing e-invoice ([#31061](#31061)) ([1461d66](1461d66)) * **india:** eway bill cancel api is disabled ([#31060](#31060)) ([95491e1](95491e1)) * Job Card excess transfer behaviour (backport [#31054](#31054)) ([#31096](#31096)) ([3984f04](3984f04)) * Leave Encashment calculations (backport [#31062](#31062)) ([#31091](#31091)) ([ba76b64](ba76b64)) * Loan Doc query in Bank Reconciliation Statement ([611d1af](611d1af)) * Loan repayment entries for payroll payable account ([ea6d754](ea6d754)) * multiple entries for same payment term ([90b1147](90b1147)) * Party account validation in JV ([d10c2e5](d10c2e5)) * payments duplicate on pos closing entry (backport [#30976](#30976)) ([#31005](#31005)) ([0efbabe](0efbabe)) * **pos:** paid amount calculation for multicurrency invoice ([#31122](#31122)) ([98eb7da](98eb7da)) * remove bad default for Membership From Date ([34928d2](34928d2)) * Remove validation from Journal Entry ([4ca6cdc](4ca6cdc)) * replace document states with list settings ([78e9e66](78e9e66)) * timesheet fetching in sales invoice ([216c32f](216c32f)) * Use directly <a> and style it as button instead of using button ([0ab9fc0](0ab9fc0)) ### Features * **Employee Advance:** add 'Returned' and 'Partly Claimed and Returned' status ([42e7a86](42e7a86)) ### Reverts * Revert "fix: Add party account validation for journal entry" ([9d43a90](9d43a90))
Problem:
The Leave Balance calculation in Leave Encashment is incorrect:
get_leave_allocation
doesn't fetchallocation.from_date
:erpnext/erpnext/hr/doctype/leave_encashment/leave_encashment.py
Lines 128 to 136 in 9fb7b49
but
from_date
is being accessed inget_unused_leaves
for getting encashable leave balance which is None:erpnext/erpnext/hr/doctype/leave_encashment/leave_encashment.py
Lines 107 to 111 in 9fb7b49
Also, the above formula is not correct for calculating leave balance. It's subtracting unused leaves from allocated leaves. Instead, it should remove used leaves from leaves allocated to get the encashable balance. So if 10 leaves are allocated 6 leaves are used, balance should be 4 but this does 10 - 4 = 6. 🤷🏻♀️
This feature seems to be broken since the time it was introduced. It also has a test but the test was incorrect causing no failures.
Fix:
Fetch
from_date
in the queryChange the leave balance calculation formula to:
Subtract the leaves taken from leaves allocated to get the balance leaves that can be encashed.
Closes #28020, Closes #23448, Closes #24706