fix: ledger entries creation
This commit is contained in:
parent
7cc6a67c18
commit
ded33a7e2e
@ -136,8 +136,8 @@ class LeaveAllocation(Document):
|
||||
if flt(leaves) > 0:
|
||||
args = dict(
|
||||
leaves=leaves * -1,
|
||||
from_date=self.to_date,
|
||||
to_date=self.to_date,
|
||||
from_date=self.from_date,
|
||||
to_date=self.from_date,
|
||||
is_carry_forward=0,
|
||||
is_expired=1
|
||||
)
|
||||
|
@ -431,22 +431,24 @@ def get_leave_details(employee, date):
|
||||
return ret
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_leave_balance_on(employee, leave_type, from_date, to_date=nowdate(), allocation_records=None, docname=None,
|
||||
def get_leave_balance_on(employee, leave_type, date, to_date=nowdate(), allocation_records=None, docname=None,
|
||||
consider_all_leaves_in_the_allocation_period=False):
|
||||
''' Returns leave balance till date and fetches expiry date based on to_date
|
||||
to calculate minimum remaining leave balance '''
|
||||
|
||||
if allocation_records == None:
|
||||
allocation_records = get_leave_allocation_records(from_date, employee).get(employee, frappe._dict())
|
||||
allocation_records = get_leave_allocation_records(date, employee).get(employee, frappe._dict())
|
||||
allocation = allocation_records.get(leave_type, frappe._dict())
|
||||
|
||||
end_date = allocation.to_date if consider_all_leaves_in_the_allocation_period else from_date
|
||||
expiry = get_allocation_expiry(employee, leave_type, to_date, from_date)
|
||||
end_date = allocation.to_date if consider_all_leaves_in_the_allocation_period else date
|
||||
expiry = get_allocation_expiry(employee, leave_type, to_date, date)
|
||||
|
||||
leaves_taken = get_leaves_taken(employee, leave_type, allocation.from_date, end_date)
|
||||
|
||||
return get_remaining_leaves(allocation, leaves_taken, from_date, expiry)
|
||||
return get_remaining_leaves(allocation, leaves_taken, date, expiry)
|
||||
|
||||
def get_remaining_leaves(allocation, leaves_taken, date, expiry):
|
||||
''' Returns leaves remaining after comparing with remaining days for allocation expiry '''
|
||||
''' Returns minimum leaves remaining after comparing with remaining days for allocation expiry '''
|
||||
def _get_remaining_leaves(allocated_leaves, end_date):
|
||||
remaining_leaves = flt(allocated_leaves) + flt(leaves_taken)
|
||||
|
||||
|
@ -22,6 +22,7 @@ def generate_allocation_ledger_entries(allocation_list):
|
||||
|
||||
for allocation in allocation_list:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Allocation', 'transaction_name': allocation.name}):
|
||||
allocation.update(dict(doctype="Leave Allocation"))
|
||||
leave_allocation = LeaveAllocation(allocation)
|
||||
leave_allocation.create_leave_ledger_entry()
|
||||
|
||||
@ -33,6 +34,7 @@ def generate_application_leave_ledger_entries(allocation_list):
|
||||
|
||||
for record in leave_applications:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Application', 'transaction_name': record.name}):
|
||||
record.update(dict(doctype="Leave Application"))
|
||||
leave_application = LeaveApplication(record)
|
||||
leave_application.create_leave_ledger_entry()
|
||||
|
||||
@ -44,6 +46,7 @@ def generate_encashment_leave_ledger_entries(allocation_list):
|
||||
|
||||
for record in leave_encashments:
|
||||
if not frappe.db.exists("Leave Ledger Entry", {'transaction_type': 'Leave Encashment', 'transaction_name': record.name}):
|
||||
record.update(dict(doctype="Leave Encashment"))
|
||||
leave_encashment = LeaveEncashment(record)
|
||||
leave_encashment.create_leave_ledger_entry()
|
||||
|
||||
@ -89,7 +92,7 @@ def get_leaves_application_records(allocation_list):
|
||||
from_date >= %s
|
||||
AND leave_type = %s
|
||||
AND employee = %s
|
||||
""", (allocation.from_date, allocation.leave_type, allocation.employee))
|
||||
""", (allocation.from_date, allocation.leave_type, allocation.employee), as_dict=1)
|
||||
return leave_applications
|
||||
|
||||
def get_leave_encashment_records(allocation_list):
|
||||
@ -108,5 +111,5 @@ def get_leave_encashment_records(allocation_list):
|
||||
leave_type = %s
|
||||
AND employee = %s
|
||||
AND encashment_date >= %s
|
||||
""", (allocation.leave_type, allocation.employee, allocation.from_date))
|
||||
""", (allocation.leave_type, allocation.employee, allocation.from_date), as_dict=1)
|
||||
return leave_encashments
|
Loading…
x
Reference in New Issue
Block a user