fixed hr issues
This commit is contained in:
parent
0c18b18b84
commit
dbffc2d8d0
@ -59,48 +59,15 @@ class DocType:
|
||||
msgprint("Employee's attendance already marked.")
|
||||
raise Exception
|
||||
|
||||
#validation - leave_type is mandatory for status absent/ half day else not required to entered.
|
||||
def validate_status(self):
|
||||
if self.doc.status == 'Present' and self.doc.leave_type:
|
||||
msgprint("You can not enter leave type for attendance status 'Present'")
|
||||
raise Exception
|
||||
|
||||
elif (self.doc.status == 'Absent' or self.doc.status == 'Half Day') and not self.doc.leave_type:
|
||||
msgprint("Please enter leave type for attendance status 'Absent'")
|
||||
raise Exception
|
||||
|
||||
#check for already record present in leave transaction for same date
|
||||
def check_leave_record(self):
|
||||
if self.doc.status == 'Present':
|
||||
chk = sql("select name from `tabLeave Transaction` where employee=%s and (from_date <= %s and to_date >= %s) and status = 'Submitted' and leave_transaction_type = 'Deduction' and docstatus!=2", (self.doc.employee, self.doc.att_date, self.doc.att_date))
|
||||
chk = sql("select name from `tabLeave Application` where employee=%s and (from_date <= %s and to_date >= %s) and docstatus!=2", (self.doc.employee, self.doc.att_date, self.doc.att_date))
|
||||
if chk:
|
||||
msgprint("Leave Application created for employee "+self.doc.employee+" whom you are trying to mark as 'Present' ")
|
||||
raise Exception
|
||||
|
||||
#For absent/ half day record - check for leave balances of the employees
|
||||
def validate_leave_type(self):
|
||||
if not self.doc.status =='Present' and self.doc.leave_type not in ('Leave Without Pay','Compensatory Off'):
|
||||
#check for leave allocated to employee from leave transaction
|
||||
ret = sql("select name from `tabLeave Transaction` where employee = '%s' and leave_type = '%s' and leave_transaction_type = 'Allocation' and fiscal_year = '%s'"%(self.doc.employee,self.doc.leave_type,self.doc.fiscal_year))
|
||||
|
||||
#if leave allocation is present then calculate leave balance i.e. sum(allocation) - sum(deduction)
|
||||
if ret:
|
||||
q1 = 'SUM(CASE WHEN leave_transaction_type = "Allocation" THEN total_leave ELSE 0 END)-SUM(CASE WHEN leave_transaction_type = "Deduction" THEN total_leave ELSE 0 END)'
|
||||
q2 = "select %s from `tabLeave Transaction` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1"
|
||||
|
||||
res = sql(q2%(q1,self.doc.employee,self.doc.leave_type,self.doc.fiscal_year))
|
||||
|
||||
if res:
|
||||
if self.doc.status == 'Absent' and flt(res[0][0]) < 1:
|
||||
msgprint("%s balances are insufficient to cover a day absence, please select other leave type."%self.doc.leave_type)
|
||||
raise Exception
|
||||
if self.doc.status == 'Half Day' and flt(res[0][0]) < 0.5:
|
||||
msgprint("%s balances are insufficient to cover a half day absence, please select other leave type."%self.doc.leave_type)
|
||||
raise Exception
|
||||
|
||||
else:
|
||||
msgprint("Leave Allocation for employee %s not done.\n You can allocate leaves from HR -> Leave Transaction OR HR -> Leave Control Panel."%self.doc.employee)
|
||||
raise Exception
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"% self.doc.fiscal_year)
|
||||
@ -129,7 +96,6 @@ class DocType:
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
self.validate_att_date()
|
||||
#self.validate_leave_type()
|
||||
self.validate_duplicate_record()
|
||||
#self.validate_status()
|
||||
self.check_leave_record()
|
||||
|
@ -29,7 +29,6 @@ cur_frm.cscript.onload = function(doc, dt, dn){
|
||||
//=======================================================================
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn){
|
||||
if((!doc.__islocal) && (doc.is_active == 'Yes')){
|
||||
cur_frm.add_custom_button('Make IT Checklist', cur_frm.cscript['Make IT Checklist']);
|
||||
cur_frm.add_custom_button('Make Salary Slip', cur_frm.cscript['Make Salary Slip']);
|
||||
|
||||
get_field(doc.doctype, 'employee', doc.name).permlevel = 1;
|
||||
@ -37,16 +36,6 @@ cur_frm.cscript.refresh = function(doc, dt, dn){
|
||||
}
|
||||
}
|
||||
|
||||
// Make IT checklist
|
||||
//=======================================================================
|
||||
cur_frm.cscript['Make IT Checklist']=function(){
|
||||
var itc = LocalDB.create('IT Checklist');
|
||||
itc = locals['IT Checklist'][itc];
|
||||
itc.employee = cur_frm.doc.employee;
|
||||
itc.fiscal_year = sys_defaults.fiscal_year;
|
||||
itc.is_cheklist_active='Yes';
|
||||
loaddoc('IT Checklist', itc.name);
|
||||
}
|
||||
|
||||
// Make Salry Slip
|
||||
//=======================================================================
|
||||
|
@ -143,7 +143,7 @@ def delete_search_criteria():
|
||||
def change_report_module():
|
||||
reports = {'itemwise_receipt_details': 'Stock'}
|
||||
for k in reports:
|
||||
sql("update `tabSearch Criteria` set module = %s where name = %s", (reports[k], k))
|
||||
webnotes.conn.sql("update `tabSearch Criteria` set module = %s where name = %s", (reports[k], k))
|
||||
|
||||
def rename_in_db(ren_data, data_type, is_doctype):
|
||||
for d in ren_data:
|
||||
|
Loading…
Reference in New Issue
Block a user