Merge branch 'unicode' of github.com:webnotes/erpnext into unicode
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js
index adcb4cf..eabb476 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.js
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.js
@@ -27,23 +27,23 @@
 		for(var i = 0; i<val.length; i++){
 			val[i].sanctioned_amount ='';
 		}
-		//doc.total_claimed_amount = '';
 		doc.total_sanctioned_amount = '';
 		refresh_many(['sanctioned_amount', 'total_sanctioned_amount']);
 	}
 }
 
 cur_frm.cscript.refresh = function(doc,cdt,cdn){
-	if((user == doc.exp_approver && doc.approval_status == 'Submitted') || doc.docstatus == 0) unhide_field('calculate_total_amount');
-	else hide_field('calculate_total_amount');
-	
-	if(user == doc.exp_approver && doc.approval_status == 'Submitted')	unhide_field(['update_voucher', 'approve', 'reject']);
-
-	else hide_field(['update_voucher', 'approve', 'reject']);
-
-	
-	if(user == doc.exp_approver && doc.approval_status == 'Submitted') set_field_permlevel('remark', 0);
-	else set_field_permlevel('remark', 1);
+	hide_field('calculate_total_amount');
+	if(user == doc.exp_approver && doc.approval_status == 'Submitted'){
+		unhide_field(['update_voucher', 'approve', 'reject', 'calculate_total_amount']);
+		cur_frm.fields_dict['expense_voucher_details'].grid.set_column_disp('sanctioned_amount', true);
+		set_field_permlevel('remark', 0);
+	} else {
+		hide_field(['update_voucher', 'approve', 'reject']);
+		cur_frm.fields_dict['expense_voucher_details'].grid.set_column_disp('sanctioned_amount', false);
+		set_field_permlevel('remark', 1);
+	}
+	if (doc.docstatus == 0) unhide_field('calculate_total_amount');
 }
 
 cur_frm.cscript.employee = function(doc,cdt,cdn){
@@ -63,27 +63,21 @@
 		var val = getchildren('Expense Claim Detail', doc.name, 'expense_voucher_details', doc.doctype);
 		var total_claim =0;
 		for(var i = 0; i<val.length; i++){
+			if(!doc.claim_amount) val[i].sanctioned_amount = val[i].claim_amount;
 			total_claim = flt(total_claim)+flt(val[i].claim_amount);
+			refresh_field('sactioned_amount', val[i].name, 'expense_voucher_details'); 
 		}
 		doc.total_claimed_amount = flt(total_claim);
 		refresh_field('total_claimed_amount');
-		
-		$c_obj(make_doclist(doc.doctype, doc.name),'validate_approver','', function(r,rt){
-			if(r.message){
-				if(r.message['valid_approver'] == 'No'){
-					doc.exp_approver ='';
-				}
-				wn.meta.get_docfield(doc.doctype, 'exp_approver' , doc.name).options = '';
-				wn.meta.get_docfield(doc.doctype, 'exp_approver' , doc.name).options = r.message['app_lst'];
-				refresh_field('exp_approver');
-			}
-		});
 	}
 	else if(doc.approval_status == 'Submitted'){
 		var val = getchildren('Expense Claim Detail', doc.name, 'expense_voucher_details', doc.doctype);
 		var total_sanctioned = 0;
 		for(var i = 0; i<val.length; i++){
+			if(!doc.claim_amount) val[i].sanctioned_amount = val[i].claim_amount;
 			total_sanctioned = flt(total_sanctioned)+flt(val[i].sanctioned_amount);
+			refresh_field('sactioned_amount', val[i].name, 'expense_voucher_details'); 
+			
 		}
 		doc.total_sanctioned_amount = flt(total_sanctioned);
 		refresh_field('total_sanctioned_amount');
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index ef5c8b3..ee02dc3 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -99,20 +99,8 @@
 			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)
-
 		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)
@@ -123,7 +111,6 @@
 			raise Exception
 		
 	def validate(self):
-		self.validate_curr_exp()
 		self.validate_fiscal_year()
 	
 	def on_update(self):
@@ -141,17 +128,7 @@
 		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')
diff --git a/erpnext/patches/july_2012/bin_permission.py b/erpnext/patches/july_2012/bin_permission.py
new file mode 100644
index 0000000..e1d0ea6
--- /dev/null
+++ b/erpnext/patches/july_2012/bin_permission.py
@@ -0,0 +1,3 @@
+def execute():
+	import webnotes
+	webnotes.conn.sql("update `tabDocPerm` set permlevel = 0 where parent = 'Bin'")
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index e560973..14d56a0 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -525,4 +525,8 @@
 		'patch_module': 'patches.july_2012',
 		'patch_file': 'blog_guest_permission',
 	},
-]
+	{
+		'patch_module': 'patches.july_2012',
+		'patch_file': 'bin_permission',
+	},
+]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/bin/bin.txt b/erpnext/stock/doctype/bin/bin.txt
index 7956e67..158dbde 100644
--- a/erpnext/stock/doctype/bin/bin.txt
+++ b/erpnext/stock/doctype/bin/bin.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-03-27 14:36:27',
+		'creation': '2012-05-15 12:15:04',
 		'docstatus': 0,
-		'modified': '2012-03-27 14:36:27',
+		'modified': '2012-07-31 17:23:42',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -26,7 +26,7 @@
 		'section_style': u'Simple',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 115
+		'version': 1
 	},
 
 	# These values are common for all DocField
@@ -36,7 +36,7 @@
 		'parent': u'Bin',
 		'parentfield': u'fields',
 		'parenttype': u'DocType',
-		'permlevel': 1
+		'permlevel': 0
 	},
 
 	# These values are common for all DocPerm
@@ -46,6 +46,7 @@
 		'parent': u'Bin',
 		'parentfield': u'permissions',
 		'parenttype': u'DocType',
+		'permlevel': 0,
 		'read': 1
 	},
 
@@ -58,28 +59,24 @@
 	# DocPerm
 	{
 		'doctype': u'DocPerm',
-		'permlevel': 1,
 		'role': u'Sales Manager'
 	},
 
 	# DocPerm
 	{
 		'doctype': u'DocPerm',
-		'permlevel': 1,
 		'role': u'Sales User'
 	},
 
 	# DocPerm
 	{
 		'doctype': u'DocPerm',
-		'permlevel': 1,
 		'role': u'Purchase Manager'
 	},
 
 	# DocPerm
 	{
 		'doctype': u'DocPerm',
-		'permlevel': 1,
 		'role': u'Purchase User'
 	},
 
@@ -89,7 +86,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': u'DocPerm',
-		'permlevel': 1,
 		'role': u'Material User',
 		'submit': 0,
 		'write': 0
@@ -101,7 +97,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': u'DocPerm',
-		'permlevel': 0,
 		'role': u'Material Manager',
 		'submit': 0,
 		'write': 0
@@ -162,7 +157,7 @@
 		'doctype': u'DocField',
 		'fieldname': u'actual_qty',
 		'fieldtype': u'Currency',
-		'in_filter': 0,
+		'in_filter': 1,
 		'label': u'Actual Quantity',
 		'oldfieldname': u'actual_qty',
 		'oldfieldtype': u'Currency',
diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
index 9935e46..8b51b5c 100644
--- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
@@ -83,13 +83,17 @@
 		for d in getlist(obj.doclist, fname):
 			is_stock_item = get_value('Item', d.item_code, 'is_stock_item')
 			ar_required = get_value('Item', d.item_code, 'has_serial_no')
-			if cstr(d.serial_no).strip():
+			
+			# [bug fix] need to strip serial nos of all spaces and new lines for validation
+			serial_no = cstr(d.serial_no).strip()
+			
+			if serial_no:
 				if is_stock_item != 'Yes':
 					msgprint("Serial No is not required for non-stock item: %s" % d.item_code, raise_exception=1)
 				elif ar_required != 'Yes':
 					msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" + d.item_code + \
 						', otherwise please remove serial no', raise_exception=1)
-			elif ar_required == 'Yes' and not d.serial_no:
+			elif ar_required == 'Yes' and not serial_no:
 				msgprint("Serial no is mandatory for item: "+ d.item_code, raise_exception = 1)
 
 			# validate rejected serial nos