mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
fix: ignore expired non-carry forwarded allocation on calculating leaves taken
This commit is contained in:
@@ -431,7 +431,7 @@ def get_leave_details(employee, date):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_leave_balance_on(employee, leave_type, date, to_date=nowdate(), allocation_records=None, docname=None,
|
def get_leave_balance_on(employee, leave_type, date, to_date=nowdate(), allocation_records=None,
|
||||||
consider_all_leaves_in_the_allocation_period=False):
|
consider_all_leaves_in_the_allocation_period=False):
|
||||||
''' Returns leave balance till date and fetches expiry date based on to_date
|
''' Returns leave balance till date and fetches expiry date based on to_date
|
||||||
to calculate minimum remaining leave balance '''
|
to calculate minimum remaining leave balance '''
|
||||||
@@ -467,13 +467,17 @@ def get_remaining_leaves(allocation, leaves_taken, date, expiry):
|
|||||||
|
|
||||||
def get_leaves_taken(employee, leave_type, from_date, to_date):
|
def get_leaves_taken(employee, leave_type, from_date, to_date):
|
||||||
''' Returns leaves taken based on leave application/encashment '''
|
''' Returns leaves taken based on leave application/encashment '''
|
||||||
return frappe.db.get_value("Leave Ledger Entry", filters={
|
leaves = frappe.db.get_all("Leave Ledger Entry", filters={
|
||||||
'Employee':employee,
|
'Employee':employee,
|
||||||
'leave_type':leave_type,
|
'leave_type':leave_type,
|
||||||
'leaves': ("<", 0),
|
'leaves': ("<", 0),
|
||||||
'to_date':("<=", to_date),
|
'to_date':("<=", to_date),
|
||||||
'from_date': (">=", from_date)},
|
'from_date': (">=", from_date)},
|
||||||
fieldname=['SUM(leaves)'])
|
or_filters={
|
||||||
|
'is_expired': 0,
|
||||||
|
'is_carry_forward': 1
|
||||||
|
}, fields=['SUM(leaves) as leaves'])
|
||||||
|
return leaves[0]['leaves'] if leaves else None
|
||||||
|
|
||||||
def get_total_allocated_leaves(employee, leave_type, date):
|
def get_total_allocated_leaves(employee, leave_type, date):
|
||||||
filters= {
|
filters= {
|
||||||
|
|||||||
@@ -538,7 +538,6 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
self.assertEquals(leave_ledger_entry[1].leaves, -2)
|
self.assertEquals(leave_ledger_entry[1].leaves, -2)
|
||||||
|
|
||||||
def create_carry_forwarded_allocation(employee, leave_type):
|
def create_carry_forwarded_allocation(employee, leave_type):
|
||||||
|
|
||||||
# initial leave allocation
|
# initial leave allocation
|
||||||
leave_allocation = create_leave_allocation(
|
leave_allocation = create_leave_allocation(
|
||||||
leave_type="_Test_CF_leave_expiry",
|
leave_type="_Test_CF_leave_expiry",
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ def get_leave_encashment_records(allocation_list):
|
|||||||
employee,
|
employee,
|
||||||
leave_type,
|
leave_type,
|
||||||
encashable_days,
|
encashable_days,
|
||||||
from_date,
|
encashment_date
|
||||||
to_date
|
|
||||||
FROM `tabLeave Encashment`
|
FROM `tabLeave Encashment`
|
||||||
WHERE
|
WHERE
|
||||||
leave_type = %s
|
leave_type = %s
|
||||||
|
|||||||
Reference in New Issue
Block a user