Merge branch 'shf_rename' of github.com:webnotes/erpnext into shf_rename
diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py
index 0d0c23c..ba06995 100644
--- a/erpnext/hr/doctype/attendance/attendance.py
+++ b/erpnext/hr/doctype/attendance/attendance.py
@@ -59,48 +59,15 @@
       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 @@
   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()
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index cd8b115..937ada7 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -8,11 +8,11 @@
 # 
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 # GNU General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.	If not, see <http://www.gnu.org/licenses/>.
 
 # Please edit this list and import only required elements
 import webnotes
@@ -34,126 +34,126 @@
 
 
 class DocType:
-  def __init__(self, doc, doclist=[]):
-    self.doc = doc
-    self.doclist = doclist
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
 
-  def get_employee_name(self):
-    emp_dtl = sql("select employee_name,company_email from `tabEmployee` where name=%s", self.doc.employee)
-    emp_nm = emp_dtl and emp_dtl[0][0] or ''
-    self.doc.employee_name = emp_nm
-    self.doc.email_id = emp_dtl and emp_dtl[0][1] or ''
+	def get_employee_name(self):
+		emp_dtl = sql("select employee_name,company_email from `tabEmployee` where name=%s", self.doc.employee)
+		emp_nm = emp_dtl and emp_dtl[0][0] or ''
+		self.doc.employee_name = emp_nm
+		self.doc.email_id = emp_dtl and emp_dtl[0][1] or ''
 
-    return cstr(emp_nm)  
-  
-  def get_approver_lst(self):
-    approver_lst =[]
-    approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
-    if approver_lst1:
-      approver_lst=approver_lst1
-    else:
-      approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
-    return approver_lst
+		return cstr(emp_nm)	
+	
+	def get_approver_lst(self):
+		approver_lst =[]
+		approver_lst1 = get_obj('Authorization Control').get_approver_name(self.doc.doctype,0,self)
+		if approver_lst1:
+			approver_lst=approver_lst1
+		else:
+			approver_lst = [x[0] for x in sql("select distinct name from `tabProfile` where enabled=1 and name!='Administrator' and name!='Guest' and docstatus!=2")]
+		return approver_lst
 
-  def set_approver(self):
-    ret={}
-    approver_lst =[]
-    emp_nm = self.get_employee_name()
-    approver_lst = self.get_approver_lst()    
-    ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
-    return ret
+	def set_approver(self):
+		ret={}
+		approver_lst =[]
+		emp_nm = self.get_employee_name()
+		approver_lst = self.get_approver_lst()		
+		ret = {'app_lst':"\n" + "\n".join(approver_lst), 'emp_nm':cstr(emp_nm)}
+		return ret
 
-  def update_voucher(self):
-    sql("delete from `tabExpense Claim Detail` where parent = '%s'"%self.doc.name)
-    for d in getlist(self.doclist, 'expense_voucher_details'):
-      if not d.expense_type or not d.claim_amount:
-        msgprint("Please remove the extra blank row added")
-        raise Exception
-      d.save(1)
-    if self.doc.total_sanctioned_amount:
-      set(self.doc,'total_sanctioned_amount',self.doc.total_sanctioned_amount)
-    if self.doc.remark:
-      set(self.doc, 'remark', self.doc.remark)
-  
-  def approve_voucher(self):
-    for d in getlist(self.doclist, 'expense_voucher_details'):
-      if not d.sanctioned_amount:
-        msgprint("Please add 'Sanctioned Amount' for all expenses")
-        return cstr('Incomplete')
-    
-    if not self.doc.total_sanctioned_amount:
-      msgprint("Please calculate total sanctioned amount using button 'Calculate Total Amount'")
-      return cstr('No Amount')
-    self.update_voucher()
-    
-    set(self.doc, 'approval_status', 'Approved')    
-    # on approval notification
-    #get_obj('Notification Control').notify_contact('Expense Claim Approved', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
+	def update_voucher(self):
+		sql("delete from `tabExpense Claim Detail` where parent = '%s'"%self.doc.name)
+		for d in getlist(self.doclist, 'expense_voucher_details'):
+			if not d.expense_type or not d.claim_amount:
+				msgprint("Please remove the extra blank row added")
+				raise Exception
+			d.save(1)
+		if self.doc.total_sanctioned_amount:
+			set(self.doc,'total_sanctioned_amount',self.doc.total_sanctioned_amount)
+		if self.doc.remark:
+			set(self.doc, 'remark', self.doc.remark)
+	
+	def approve_voucher(self):
+		for d in getlist(self.doclist, 'expense_voucher_details'):
+			if not d.sanctioned_amount:
+				msgprint("Please add 'Sanctioned Amount' for all expenses")
+				return cstr('Incomplete')
+		
+		if not self.doc.total_sanctioned_amount:
+			msgprint("Please calculate total sanctioned amount using button 'Calculate Total Amount'")
+			return cstr('No Amount')
+		self.update_voucher()
+		
+		set(self.doc, 'approval_status', 'Approved')		
+		# on approval notification
+		#get_obj('Notification Control').notify_contact('Expense Claim Approved', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
 
-    return cstr('Approved')
-  
-  def reject_voucher(self):
-    
-    if self.doc.remark:
-      set(self.doc, 'remark', self.doc.remark)   
-    set(self.doc, 'approval_status', 'Rejected')    
+		return cstr('Approved')
+	
+	def reject_voucher(self):
+		
+		if self.doc.remark:
+			set(self.doc, 'remark', self.doc.remark)	 
+		set(self.doc, 'approval_status', 'Rejected')		
 
-    # on approval notification
-    #get_obj('Notification Control').notify_contact('Expense Claim Rejected', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
+		# on approval notification
+		#get_obj('Notification Control').notify_contact('Expense Claim Rejected', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.employee_name)
 
-    return cstr('Rejected')
-  
-  def validate_curr_exp(self):
-    for d in getlist(self.doclist, 'expense_voucher_details'):
-      if flt(d.sanctioned_amount) > 0:
-        if self.doc.approval_status == 'Draft':
-          msgprint("Sanctioned amount can be added by Approver person only for submitted Expense Claim")
-          raise Exception
-        elif self.doc.approval_status == 'Submitted' and session['user'] != self.doc.exp_approver:
-          msgprint("Sanctioned amount can be added only by expense voucher Approver")
-          raise Exception
-  
-  def validate_fiscal_year(self):
-    fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
-    ysd=fy and fy[0][0] or ""
-    yed=add_days(str(ysd),365)
-    if str(self.doc.posting_date) < str(ysd) or str(self.doc.posting_date) > str(yed):
-      msgprint("Posting Date is not within the Fiscal Year selected")
-      raise Exception
-    
-  def validate(self):
-    self.validate_curr_exp()
-    self.validate_fiscal_year()
-  
-  def on_update(self):
-    set(self.doc, 'approval_status', 'Draft')
-  
-  def validate_exp_details(self):
-    if not getlist(self.doclist, 'expense_voucher_details'):
-      msgprint("Please add expense voucher details")
-      raise Exception
-    
-    if not self.doc.total_claimed_amount:
-      msgprint("Please calculate Total Claimed Amount")
-      raise Exception
-    
-    if not self.doc.exp_approver:
-      msgprint("Please select Expense Claim approver")
-      raise Exception
-  
-  def validate_approver(self):
-    app_lst = self.get_approver_lst()
-    if self.doc.exp_approver and self.doc.exp_approver not in app_lst:
-      msgprint("Approver "+self.doc.exp_approver+" is not authorized to approve this expense voucher. Please select another approver")
-      valid_app = 'No'
-    else:
-      valid_app = 'Yes'
-    ret = {'app_lst':("\n" + "\n".join(app_lst)), 'valid_approver':valid_app}
-    return ret
-  
-  def on_submit(self):
-    self.validate_exp_details()
-    set(self.doc, 'approval_status', 'Submitted')
-  
-  def on_cancel(self):
-    set(self.doc, 'approval_status', 'Cancelled')
+		return cstr('Rejected')
+	
+	def validate_curr_exp(self):
+		for d in getlist(self.doclist, 'expense_voucher_details'):
+			if flt(d.sanctioned_amount) > 0:
+				if self.doc.approval_status == 'Draft':
+					msgprint("Sanctioned amount can be added by Approver person only for submitted Expense Claim")
+					raise Exception
+				elif self.doc.approval_status == 'Submitted' and session['user'] != self.doc.exp_approver:
+					msgprint("Sanctioned amount can be added only by expense voucher Approver")
+					raise Exception
+	
+	def validate_fiscal_year(self):
+		fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
+		ysd=fy and fy[0][0] or ""
+		yed=add_days(str(ysd),365)
+		if str(self.doc.posting_date) < str(ysd) or str(self.doc.posting_date) > str(yed):
+			msgprint("Posting Date is not within the Fiscal Year selected")
+			raise Exception
+		
+	def validate(self):
+		self.validate_curr_exp()
+		self.validate_fiscal_year()
+	
+	def on_update(self):
+		set(self.doc, 'approval_status', 'Draft')
+	
+	def validate_exp_details(self):
+		if not getlist(self.doclist, 'expense_voucher_details'):
+			msgprint("Please add expense voucher details")
+			raise Exception
+		
+		if not self.doc.total_claimed_amount:
+			msgprint("Please calculate Total Claimed Amount")
+			raise Exception
+		
+		if not self.doc.exp_approver:
+			msgprint("Please select Expense Claim approver")
+			raise Exception
+	
+	def validate_approver(self):
+		app_lst = self.get_approver_lst()
+		if self.doc.exp_approver and self.doc.exp_approver not in app_lst:
+			msgprint("Approver "+self.doc.exp_approver+" is not authorized to approve this expense voucher. Please select another approver")
+			valid_app = 'No'
+		else:
+			valid_app = 'Yes'
+		ret = {'app_lst':("\n" + "\n".join(app_lst)), 'valid_approver':valid_app}
+		return ret
+	
+	def on_submit(self):
+		self.validate_exp_details()
+		set(self.doc, 'approval_status', 'Submitted')
+	
+	def on_cancel(self):
+		set(self.doc, 'approval_status', 'Cancelled')
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js
index eaba16b..2cfab81 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.js
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.js
@@ -29,7 +29,6 @@
 //=======================================================================
 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 @@
   }
 }
 
-// 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
 //=======================================================================
diff --git a/erpnext/hr/search_criteria/monthly_salary_register/monthly_salary_register.py b/erpnext/hr/search_criteria/monthly_salary_register/monthly_salary_register.py
index 998b927..bbf6fb0 100644
--- a/erpnext/hr/search_criteria/monthly_salary_register/monthly_salary_register.py
+++ b/erpnext/hr/search_criteria/monthly_salary_register/monthly_salary_register.py
@@ -43,8 +43,8 @@
   for d1 in li:
     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']]))
-    ded_ret=convert_to_lists(sql("select d_type,d_amount from `tabSS Deduction 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 `tabSalary Slip Deduction` where parent = '%s'"%r[col_idx['ID']]))
     
 
     for e in earn_ret:
@@ -78,7 +78,7 @@
   for r in res:
    
     lst0 = '%s'%lst[0]
-    total_ear += r[col_idx[lst0]]
+    total_ear += flt(r[col_idx[lst0]])
     
   total.append(total_ear) 
   
@@ -87,7 +87,7 @@
   total_ded = 0
   for r in res:
     lst0 = '%s'%lst[0]
-    total_ded += r[col_idx[lst0]]
+    total_ded += flt(r[col_idx[lst0]])
     
   total.append(total_ded) 
 
diff --git a/erpnext/patches/jan_mar_2012/rename_dt.py b/erpnext/patches/jan_mar_2012/rename_dt.py
index e53daf4..693fd77 100644
--- a/erpnext/patches/jan_mar_2012/rename_dt.py
+++ b/erpnext/patches/jan_mar_2012/rename_dt.py
@@ -129,7 +129,7 @@
 			'periodic_sales_summary', 'monthly_despatched_trend', 'sales', 'sales_order',
 			'sales_order1', 'sales_agentwise_commission', 'test_report', 
 			'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("""
 		DELETE FROM `tabSearch Criteria`
@@ -143,7 +143,7 @@
 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: