fix(compensatory leave request): Create leave ledger entry on submit/cancel (#19476)

* fix: allow creation of leave ledger entry

* feat(compensatory-leave-request): create leave ledger entry on submit

* style: add descriptive comments

* test: allow creation of leave period based on company

* fix(leave-allocation): check name of leave allocation for determining overlap

* fix: validate new leaves allocated before updating leave allocation

* test: compensatory leave request creation

* fix: skip leave entries for non expired leave allocation

* test: creation of leave ledger entry on creation of compensatory leave request

* fix: minor changes

* fix: fetch leave approver defined in employee in leave application

* fix: attendance creation and leave balance calculation

* test: create leave period for the compensatory off

* style: add descriptive method name

* test: updation of leave allocation on submit

* fix: remove db_set from compensatory off
This commit is contained in:
Mangesh-Khairnar
2019-12-09 14:27:38 +05:30
committed by Anurag Mishra
parent 317bf5a321
commit 4350846f1e
8 changed files with 205 additions and 89 deletions

View File

@@ -321,11 +321,11 @@ def allocate_earned_leaves():
if new_allocation == allocation.total_leaves_allocated:
continue
allocation.db_set("total_leaves_allocated", new_allocation, update_modified=False)
create_earned_leave_ledger_entry(allocation, earned_leaves, today)
create_additional_leave_ledger_entry(allocation, earned_leaves, today)
def create_earned_leave_ledger_entry(allocation, earned_leaves, date):
''' Create leave ledger entry based on the earned leave frequency '''
allocation.new_leaves_allocated = earned_leaves
def create_additional_leave_ledger_entry(allocation, leaves, date):
''' Create leave ledger entry for leave types '''
allocation.new_leaves_allocated = leaves
allocation.from_date = date
allocation.unused_leaves = 0
allocation.create_leave_ledger_entry()
@@ -389,6 +389,7 @@ def get_sal_slip_total_benefit_given(employee, payroll_period, component=False):
def get_holidays_for_employee(employee, start_date, end_date):
holiday_list = get_holiday_list_for_employee(employee)
holidays = frappe.db.sql_list('''select holiday_date from `tabHoliday`
where
parent=%(holiday_list)s