error fixed in leave calculation
This commit is contained in:
parent
fb37157163
commit
db3728955b
@ -38,10 +38,11 @@ class DocType:
|
|||||||
|
|
||||||
# ************************************************ utilities *************************************************
|
# ************************************************ utilities *************************************************
|
||||||
|
|
||||||
# -------------------
|
|
||||||
# get total holidays
|
|
||||||
# -------------------
|
# -------------------
|
||||||
def get_holidays(self):
|
def get_holidays(self):
|
||||||
|
"""
|
||||||
|
get total holidays
|
||||||
|
"""
|
||||||
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2, `tabEmployee` e1 where e1.name = '%s' and h1.parent = h2.name and e1.holiday_list = h2.name and h1.holiday_date between '%s' and '%s'"% (self.doc.employee, self.doc.from_date, self.doc.to_date))
|
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2, `tabEmployee` e1 where e1.name = '%s' and h1.parent = h2.name and e1.holiday_list = h2.name and h1.holiday_date between '%s' and '%s'"% (self.doc.employee, self.doc.from_date, self.doc.to_date))
|
||||||
if not tot_hol:
|
if not tot_hol:
|
||||||
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between '%s' and '%s' and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s"% (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year))
|
tot_hol = sql("select count(*) from `tabHoliday List Detail` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between '%s' and '%s' and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s"% (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year))
|
||||||
@ -52,9 +53,16 @@ class DocType:
|
|||||||
# get total leave days
|
# get total leave days
|
||||||
# ---------------------
|
# ---------------------
|
||||||
def get_total_leave_days(self):
|
def get_total_leave_days(self):
|
||||||
|
"""
|
||||||
|
Calculates total leave days based on input and holidays
|
||||||
|
"""
|
||||||
|
ret = {'total_leave_days' : 0.5}
|
||||||
|
if not self.doc.half_day:
|
||||||
tot_days = date_diff(self.doc.to_date, self.doc.from_date) + 1
|
tot_days = date_diff(self.doc.to_date, self.doc.from_date) + 1
|
||||||
holidays = self.get_holidays()
|
holidays = self.get_holidays()
|
||||||
ret = {'total_leave_days':flt(tot_days)-flt(holidays)}
|
ret = {
|
||||||
|
'total_leave_days' : flt(tot_days)-flt(holidays)
|
||||||
|
}
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +72,7 @@ class DocType:
|
|||||||
# validate to date
|
# validate to date
|
||||||
# -----------------
|
# -----------------
|
||||||
def validate_to_date(self):
|
def validate_to_date(self):
|
||||||
if (getdate(self.doc.to_date) < getdate(self.doc.from_date)):
|
if self.doc.from_date and self.doc.to_date and (getdate(self.doc.to_date) < getdate(self.doc.from_date)):
|
||||||
msgprint("To date cannot be before from date")
|
msgprint("To date cannot be before from date")
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
@ -79,7 +87,7 @@ class DocType:
|
|||||||
# validate balance leaves
|
# validate balance leaves
|
||||||
# ------------------------
|
# ------------------------
|
||||||
def validate_balance_leaves(self):
|
def validate_balance_leaves(self):
|
||||||
if not self.is_lwp():
|
if self.doc.from_date and self.doc.to_date and not self.is_lwp():
|
||||||
bal = self.get_leave_balance()
|
bal = self.get_leave_balance()
|
||||||
tot_leaves = self.get_total_leave_days()
|
tot_leaves = self.get_total_leave_days()
|
||||||
bal, tot_leaves = bal, tot_leaves
|
bal, tot_leaves = bal, tot_leaves
|
||||||
|
Loading…
x
Reference in New Issue
Block a user