Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename

This commit is contained in:
Rushabh Mehta
2012-04-16 13:35:53 +05:30
5 changed files with 125 additions and 170 deletions

View File

@@ -59,48 +59,15 @@ class DocType:
msgprint("Employee's attendance already marked.") msgprint("Employee's attendance already marked.")
raise Exception 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 #check for already record present in leave transaction for same date
def check_leave_record(self): def check_leave_record(self):
if self.doc.status == 'Present': 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: if chk:
msgprint("Leave Application created for employee "+self.doc.employee+" whom you are trying to mark as 'Present' ") msgprint("Leave Application created for employee "+self.doc.employee+" whom you are trying to mark as 'Present' ")
raise Exception 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): def validate_fiscal_year(self):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"% self.doc.fiscal_year) 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): def validate(self):
self.validate_fiscal_year() self.validate_fiscal_year()
self.validate_att_date() self.validate_att_date()
#self.validate_leave_type()
self.validate_duplicate_record() self.validate_duplicate_record()
#self.validate_status() #self.validate_status()
self.check_leave_record() self.check_leave_record()

View File

@@ -29,7 +29,6 @@ cur_frm.cscript.onload = function(doc, dt, dn){
//======================================================================= //=======================================================================
cur_frm.cscript.refresh = function(doc, dt, dn){ cur_frm.cscript.refresh = function(doc, dt, dn){
if((!doc.__islocal) && (doc.is_active == 'Yes')){ 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']); cur_frm.add_custom_button('Make Salary Slip', cur_frm.cscript['Make Salary Slip']);
get_field(doc.doctype, 'employee', doc.name).permlevel = 1; 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 // Make Salry Slip
//======================================================================= //=======================================================================

View File

@@ -43,8 +43,8 @@ for r in res:
for d1 in li: for d1 in li:
d2 = '%s'%d1 d2 = '%s'%d1
earn_ret=convert_to_lists(sql("select e_type,e_amount from `tabSS Earning Detail` where parent = '%s'"%r[col_idx['ID']])) earn_ret=convert_to_lists(sql("select e_type,e_amount from `tabSalary Slip Earning` where parent = '%s'"%r[col_idx['ID']]))
ded_ret=convert_to_lists(sql("select d_type,d_amount from `tabSS Deduction Detail` where parent = '%s'"%r[col_idx['ID']])) ded_ret=convert_to_lists(sql("select d_type,d_amount from `tabSalary Slip Deduction` where parent = '%s'"%r[col_idx['ID']]))
for e in earn_ret: for e in earn_ret:
@@ -78,7 +78,7 @@ for lst in earn_type_lst:
for r in res: for r in res:
lst0 = '%s'%lst[0] lst0 = '%s'%lst[0]
total_ear += r[col_idx[lst0]] total_ear += flt(r[col_idx[lst0]])
total.append(total_ear) total.append(total_ear)
@@ -87,7 +87,7 @@ for lst in ded_type_lst:
total_ded = 0 total_ded = 0
for r in res: for r in res:
lst0 = '%s'%lst[0] lst0 = '%s'%lst[0]
total_ded += r[col_idx[lst0]] total_ded += flt(r[col_idx[lst0]])
total.append(total_ded) total.append(total_ded)

View File

@@ -129,7 +129,7 @@ def delete_search_criteria():
'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order', 'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order',
'sales_order1', 'sales_agentwise_commission', 'test_report', 'sales_order1', 'sales_agentwise_commission', 'test_report',
'territory_wise_sales_-_target_vs_actual_', 'territory_wise_sales_-_target_vs_actual_',
'pending_po_items_to_bill1', 'pending_po_items_to_receive1')""") 'pending_po_items_to_bill1', 'pending_po_items_to_receive1', 'expense_vouchers', 'pending_expense_vouchers')""")
webnotes.conn.sql(""" webnotes.conn.sql("""
DELETE FROM `tabSearch Criteria` DELETE FROM `tabSearch Criteria`
@@ -143,7 +143,7 @@ def delete_search_criteria():
def change_report_module(): def change_report_module():
reports = {'itemwise_receipt_details': 'Stock'} reports = {'itemwise_receipt_details': 'Stock'}
for k in reports: 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): def rename_in_db(ren_data, data_type, is_doctype):
for d in ren_data: for d in ren_data: