field hide/unhide for pos
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
index 14a53c4..ec8f291 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
@@ -13,8 +13,8 @@
 // On Load
 // -------
 cur_frm.cscript.onload = function(doc,dt,dn) {
-  if(!doc.customer && doc.debit_to) get_field(dt, 'debit_to', dn).print_hide = 0;
-  if (doc.__islocal) {
+	if(!doc.customer && doc.debit_to) get_field(dt, 'debit_to', dn).print_hide = 0;
+	if (doc.__islocal) {
 		if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
 		if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
 		if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
@@ -22,8 +22,8 @@
 		//for previously created sales invoice, set required field related to pos
 		if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
 
- 	    hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
-  }
+ 			hide_field(['customer_address', 'contact_person', 'customer_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
+	}
 }
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
@@ -48,10 +48,25 @@
 // Hide Fields
 // ------------
 cur_frm.cscript.hide_fields = function(doc, cdt, cdn) {
-  if(cint(doc.is_pos) == 1)
-    hide_field(['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items']);
-  else
-    unhide_field(['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items']);
+	par_flds	=['project_name', 'due_date', 'posting_time', 'sales_order_main', 'delivery_note_main', 'Get Items', 'company', 'is_opening', 'currency', 'conversion_rate', 'price_list_name', 'cash_bank_account', 'source', 'cancel_reason', 'total_advance', 'gross_profit', 'gross_profit_percent', 'Get Advances Received', 'advance_adjustment_details', 'sales_partner', 'commission_rate', 'total_commission', 'Repair Outstanding Amt'];
+	
+	ch_flds = {'entries': ['income_account', 'warehouse', 'cost_center', 'sales_order', 'delivery_note']}
+	
+	if(cint(doc.is_pos) == 1) {
+		hide_field(par_flds);	
+		for(t in ch_flds) {
+			for(f in ch_flds[t]) {
+				cur_frm.fields_dict[t].grid.set_column_disp(ch_flds[t][f], false);
+			}
+		}
+	} else {
+		unhide_field(par_flds);
+		for (t in ch_flds) {
+			for (f in ch_flds[t]) {
+				cur_frm.fields_dict[t].grid.set_column_disp(ch_flds[t][f], true);
+			}
+		}
+	}
 }
 
 
@@ -59,53 +74,53 @@
 // -------
 cur_frm.cscript.refresh = function(doc, dt, dn) {
 
-  // Show / Hide button
-  cur_frm.clear_custom_buttons();
+	// Show / Hide button
+	cur_frm.clear_custom_buttons();
 
-  if(doc.docstatus==1) {
-    cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
-    cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
-    unhide_field('Repair Outstanding Amt');
+	if(doc.docstatus==1) {
+		cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
+		cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
+		unhide_field('Repair Outstanding Amt');
 
-    if(doc.is_pos==1 && doc.update_stock!=1)
-      cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
+		if(doc.is_pos==1 && doc.update_stock!=1)
+			cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
 
-    if(doc.outstanding_amount!=0)
-      cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript['Make Bank Voucher']);
-  }
-  else
-    hide_field('Repair Outstanding Amt');
-  cur_frm.cscript.is_opening(doc, dt, dn);
-  cur_frm.cscript.hide_fields(doc, cdt, cdn);
+		if(doc.outstanding_amount!=0)
+			cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript['Make Bank Voucher']);
+	}
+	else
+		hide_field('Repair Outstanding Amt');
+	cur_frm.cscript.is_opening(doc, dt, dn);
+	cur_frm.cscript.hide_fields(doc, cdt, cdn);
 }
 
 //fetch retail transaction related fields
 //--------------------------------------------
 cur_frm.cscript.is_pos = function(doc,dt,dn){
-  cur_frm.cscript.hide_fields(doc, cdt, cdn);
-  if(doc.is_pos == 1){
-    if (!doc.company) {
-      msgprint("Please select company to proceed");
-      doc.is_pos = 0;
-      refresh_field('is_pos');
-    }
-    else {
-      var callback = function(r,rt){
-        cur_frm.refresh();
-      }
-      $c_obj(make_doclist(dt,dn),'set_pos_fields','',callback);
-    }
-  }
+	cur_frm.cscript.hide_fields(doc, cdt, cdn);
+	if(doc.is_pos == 1){
+		if (!doc.company) {
+			msgprint("Please select company to proceed");
+			doc.is_pos = 0;
+			refresh_field('is_pos');
+		}
+		else {
+			var callback = function(r,rt){
+				cur_frm.refresh();
+			}
+			$c_obj(make_doclist(dt,dn),'set_pos_fields','',callback);
+		}
+	}
 }
 
 
 cur_frm.cscript.warehouse = function(doc, cdt , cdn) {
-  var d = locals[cdt][cdn];
-  if (!d.item_code) {alert("please enter item code first"); return};
-  if (d.warehouse) {
-    arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
-    get_server_fields('get_actual_qty',arg,'entries',doc,cdt,cdn,1);
-  }
+	var d = locals[cdt][cdn];
+	if (!d.item_code) {alert("please enter item code first"); return};
+	if (d.warehouse) {
+		arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.warehouse +"'}";
+		get_server_fields('get_actual_qty',arg,'entries',doc,cdt,cdn,1);
+	}
 }
 
 
@@ -113,57 +128,57 @@
 //Customer
 cur_frm.cscript.customer = function(doc,dt,dn) {
 
-  var callback = function(r,rt) {
-      var doc = locals[cur_frm.doctype][cur_frm.docname];
-      get_server_fields('get_debit_to','','',doc, dt, dn, 0);
-      cur_frm.refresh();
-  }
+	var callback = function(r,rt) {
+			var doc = locals[cur_frm.doctype][cur_frm.docname];
+			get_server_fields('get_debit_to','','',doc, dt, dn, 0);
+			cur_frm.refresh();
+	}
 
-  if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
-  if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
+	if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
 }
 
 cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
-  if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
+	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
 }
 
 cur_frm.fields_dict.customer_address.on_new = function(dn) {
-  locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
-  locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+	locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+	locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
 }
 
 cur_frm.fields_dict.contact_person.on_new = function(dn) {
-  locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
-  locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
+	locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
+	locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
 }
 
 cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
-  return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+	return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
 }
 
 cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
-  return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
+	return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
 }
 
 
 // Set Due Date = posting date + credit days
 cur_frm.cscript.debit_to = function(doc,dt,dn) {
 
-  var callback2 = function(r,rt) {
-      var doc = locals[cur_frm.doctype][cur_frm.docname];
-      cur_frm.refresh();
-  }
+	var callback2 = function(r,rt) {
+			var doc = locals[cur_frm.doctype][cur_frm.docname];
+			cur_frm.refresh();
+	}
 
-  var callback = function(r,rt) {
-      var doc = locals[cur_frm.doctype][cur_frm.docname];
-      if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
-      if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
-      cur_frm.refresh();
-  }
+	var callback = function(r,rt) {
+			var doc = locals[cur_frm.doctype][cur_frm.docname];
+			if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
+			if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+			cur_frm.refresh();
+	}
 
-  if(doc.debit_to && doc.posting_date){
-    get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,callback);
-  }
+	if(doc.debit_to && doc.posting_date){
+		get_server_fields('get_cust_and_due_date','','',doc,dt,dn,1,callback);
+	}
 }
 
 
@@ -172,15 +187,15 @@
 //-------------------------------------------------
 
 cur_frm.cscript.paid_amount = function(doc,dt,dn){
-  doc.outstanding_amount = flt(doc.grand_total) - flt(doc.paid_amount) - flt(doc.write_off_amount);
-  refresh_field('outstanding_amount');
+	doc.outstanding_amount = flt(doc.grand_total) - flt(doc.paid_amount) - flt(doc.write_off_amount);
+	refresh_field('outstanding_amount');
 }
 
 
 //---- get customer details ----------------------------
 cur_frm.cscript.project_name = function(doc,cdt,cdn){
 	$c_obj(make_doclist(doc.doctype, doc.name),'pull_project_customer','', function(r,rt){
-	  refresh_many(['customer', 'customer_name','customer_address', 'territory']);
+		refresh_many(['customer', 'customer_name','customer_address', 'territory']);
 	});
 }
 
@@ -188,26 +203,26 @@
 //----------------------------------------------
 cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
 
-  cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
-  acc = '';
-  cc = '';
+	cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
+	acc = '';
+	cc = '';
 
-  for(var i = 0; i<cl.length; i++) {
+	for(var i = 0; i<cl.length; i++) {
 
-    if (cl[i].idx == 1){
-      acc = cl[i].income_account;
-      cc = cl[i].cost_center;
-    }
-    else{
-      if (! cl[i].income_account) { cl[i].income_account = acc; refresh_field('income_account', cl[i].name, 'entries');}
-      if (! cl[i].cost_center)  {cl[i].cost_center = cc;refresh_field('cost_center', cl[i].name, 'entries');}
-    }
-  }
+		if (cl[i].idx == 1){
+			acc = cl[i].income_account;
+			cc = cl[i].cost_center;
+		}
+		else{
+			if (! cl[i].income_account) { cl[i].income_account = acc; refresh_field('income_account', cl[i].name, 'entries');}
+			if (! cl[i].cost_center)	{cl[i].cost_center = cc;refresh_field('cost_center', cl[i].name, 'entries');}
+		}
+	}
 }
 
 cur_frm.cscript.is_opening = function(doc, dt, dn) {
-  hide_field('aging_date');
-  if (doc.is_opening == 'Yes') unhide_field('aging_date');
+	hide_field('aging_date');
+	if (doc.is_opening == 'Yes') unhide_field('aging_date');
 }
 
 /* **************************** TRIGGERS ********************************** */
@@ -221,11 +236,11 @@
 
 // Get Items based on SO or DN Selected
 cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
-  var callback = function(r,rt) {
-	  unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
-	  cur_frm.refresh();
-  }
-  get_server_fields('pull_details','','',doc, dt, dn,1,callback);
+	var callback = function(r,rt) {
+		unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
+		cur_frm.refresh();
+	}
+	get_server_fields('pull_details','','',doc, dt, dn,1,callback);
 }
 
 
@@ -233,7 +248,7 @@
 // Allocated Amount in advances table
 // -----------------------------------
 cur_frm.cscript.allocated_amount = function(doc,cdt,cdn){
-  cur_frm.cscript.calc_adjustment_amount(doc,cdt,cdn);
+	cur_frm.cscript.calc_adjustment_amount(doc,cdt,cdn);
 }
 
 //Make Delivery Note Button
@@ -241,18 +256,18 @@
 
 cur_frm.cscript['Make Delivery Note'] = function() {
 
-  var doc = cur_frm.doc
-  n = createLocal('Delivery Note');
-  $c('dt_map', args={
-    'docs':compress_doclist([locals['Delivery Note'][n]]),
-    'from_doctype':doc.doctype,
-    'to_doctype':'Delivery Note',
-    'from_docname':doc.name,
-    'from_to_list':"[['Receivable Voucher','Delivery Note'],['RV Detail','Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
-    }, function(r,rt) {
-       loaddoc('Delivery Note', n);
-    }
-  );
+	var doc = cur_frm.doc
+	n = createLocal('Delivery Note');
+	$c('dt_map', args={
+		'docs':compress_doclist([locals['Delivery Note'][n]]),
+		'from_doctype':doc.doctype,
+		'to_doctype':'Delivery Note',
+		'from_docname':doc.name,
+		'from_to_list':"[['Receivable Voucher','Delivery Note'],['RV Detail','Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
+		}, function(r,rt) {
+			 loaddoc('Delivery Note', n);
+		}
+	);
 }
 
 
@@ -260,7 +275,7 @@
 // Make Bank Voucher Button
 // -------------------------
 cur_frm.cscript['Make Bank Voucher'] = function(doc, dt, dn) {
-  cur_frm.cscript.make_jv(cur_frm.doc);
+	cur_frm.cscript.make_jv(cur_frm.doc);
 }
 
 
@@ -269,101 +284,101 @@
 // Debit To
 // ---------
 cur_frm.fields_dict.debit_to.get_query = function(doc) {
-  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
+	return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
 }
 
 // Cash/bank account
 //------------------
 cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
-  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
+	return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "No" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
 }
 
 // Write off account
 //------------------
 cur_frm.fields_dict.write_off_account.get_query = function(doc) {
-  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
+	return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.is_pl_account = "Yes" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'
 }
 
 // Write off cost center
 //-----------------------
 cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
-  return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company_name="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
+	return 'SELECT `tabCost Center`.name FROM `tabCost Center` WHERE `tabCost Center`.group_or_ledger="Ledger" AND `tabCost Center`.docstatus!=2 AND `tabCost Center`.company_name="'+doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s"'
 }
 
 //project name
 //--------------------------
 cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
-  var cond = '';
-  if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
-  return repl('SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND %(cond)s `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
+	var cond = '';
+	if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
+	return repl('SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND %(cond)s `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
 }
 
 //Territory
 //-----------------------------
 cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
-  return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"  ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';
+	return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"	ORDER BY	`tabTerritory`.`name` ASC LIMIT 50';
 }
 
 // Income Account in Details Table
 // --------------------------------
 cur_frm.fields_dict.entries.grid.get_field("income_account").get_query = function(doc) {
-  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
+	return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"';
 }
 
 // warehouse in detail table
 //----------------------------
 cur_frm.fields_dict['entries'].grid.get_field('warehouse').get_query= function(doc, cdt, cdn) {
-  var d = locals[cdt][cdn];
-  return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
+	var d = locals[cdt][cdn];
+	return "SELECT `tabBin`.`warehouse`, `tabBin`.`actual_qty` FROM `tabBin` WHERE `tabBin`.`item_code` = '"+ d.item_code +"' AND ifnull(`tabBin`.`actual_qty`,0) > 0 AND `tabBin`.`warehouse` like '%s' ORDER BY `tabBin`.`warehouse` DESC LIMIT 50";
 }
 
 // Cost Center in Details Table
 // -----------------------------
 cur_frm.fields_dict.entries.grid.get_field("cost_center").get_query = function(doc) {
-  return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY  `tabCost Center`.`name` ASC LIMIT 50';
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY	`tabCost Center`.`name` ASC LIMIT 50';
 }
 
 // Sales Order
 // -----------
 cur_frm.fields_dict.sales_order_main.get_query = function(doc) {
-  if (doc.customer)
-    return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.`customer` =  "' + doc.customer + '" and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
-  else
-    return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
+	if (doc.customer)
+		return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.`customer` =	"' + doc.customer + '" and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
+	else
+		return 'SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "' + doc.company + '" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_billed,0) < 100 and `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50';
 }
 
 // Delivery Note
 // --------------
 cur_frm.fields_dict.delivery_note_main.get_query = function(doc) {
-  if (doc.customer)
-    return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.`customer` =  "' + doc.customer + '" and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
-  else
-    return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
+	if (doc.customer)
+		return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.`customer` =	"' + doc.customer + '" and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
+	else
+		return 'SELECT DISTINCT `tabDelivery Note`.`name` FROM `tabDelivery Note` WHERE `tabDelivery Note`.company = "' + doc.company + '" and `tabDelivery Note`.`docstatus` = 1 and ifnull(`tabDelivery Note`.per_billed,0) < 100 and `tabDelivery Note`.%(key)s LIKE "%s" ORDER BY `tabDelivery Note`.`name` DESC LIMIT 50';
 }
 
 
 
 cur_frm.cscript.income_account = function(doc, cdt, cdn){
-  var d = locals[cdt][cdn];
-  if(d.income_account){
-    var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
-    for(var i = 0; i < cl.length; i++){
-      if(!cl[i].income_account) cl[i].income_account = d.income_account;
-    }
-  }
-  refresh_field(cur_frm.cscript.fname);
+	var d = locals[cdt][cdn];
+	if(d.income_account){
+		var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
+		for(var i = 0; i < cl.length; i++){
+			if(!cl[i].income_account) cl[i].income_account = d.income_account;
+		}
+	}
+	refresh_field(cur_frm.cscript.fname);
 }
 
 
 cur_frm.cscript.cost_center = function(doc, cdt, cdn){
-  var d = locals[cdt][cdn];
-  if(d.cost_center){
-    var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
-    for(var i = 0; i < cl.length; i++){
-      if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
-    }
-  }
-  refresh_field(cur_frm.cscript.fname);
+	var d = locals[cdt][cdn];
+	if(d.cost_center){
+		var cl = getchildren('RV Detail', doc.name, cur_frm.cscript.fname, doc.doctype);
+		for(var i = 0; i < cl.length; i++){
+			if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
+		}
+	}
+	refresh_field(cur_frm.cscript.fname);
 }
 
 /* **************************************** Utility Functions *************************************** */
@@ -371,49 +386,49 @@
 // Details Calculation
 // --------------------
 cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
-  var doc = locals[doc.doctype][doc.name];
-  var el = getchildren('Advance Adjustment Detail',doc.name,'advance_adjustment_details');
-  var total_adjustment_amt = 0
-  for(var i in el) {
-      total_adjustment_amt += flt(el[i].allocated_amount)
-  }
-  doc.total_advance = flt(total_adjustment_amt);
-  doc.outstanding_amount = flt(doc.grand_total) - flt(total_adjustment_amt) - flt(doc.paid_amount) - flt(doc.write_off_amount);
-  refresh_many(['total_advance','outstanding_amount']);
+	var doc = locals[doc.doctype][doc.name];
+	var el = getchildren('Advance Adjustment Detail',doc.name,'advance_adjustment_details');
+	var total_adjustment_amt = 0
+	for(var i in el) {
+			total_adjustment_amt += flt(el[i].allocated_amount)
+	}
+	doc.total_advance = flt(total_adjustment_amt);
+	doc.outstanding_amount = flt(doc.grand_total) - flt(total_adjustment_amt) - flt(doc.paid_amount) - flt(doc.write_off_amount);
+	refresh_many(['total_advance','outstanding_amount']);
 }
 
 
 // Make Journal Voucher
 // --------------------
 cur_frm.cscript.make_jv = function(doc, dt, dn) {
-  var jv = LocalDB.create('Journal Voucher');
-  jv = locals['Journal Voucher'][jv];
-  jv.voucher_type = 'Bank Voucher';
+	var jv = LocalDB.create('Journal Voucher');
+	jv = locals['Journal Voucher'][jv];
+	jv.voucher_type = 'Bank Voucher';
 
-  jv.company = doc.company;
-  jv.remark = repl('Payment received against invoice %(vn)s for %(rem)s', {vn:doc.name, rem:doc.remarks});
-  jv.fiscal_year = doc.fiscal_year;
+	jv.company = doc.company;
+	jv.remark = repl('Payment received against invoice %(vn)s for %(rem)s', {vn:doc.name, rem:doc.remarks});
+	jv.fiscal_year = doc.fiscal_year;
 
-  // debit to creditor
-  var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
-  d1.account = doc.debit_to;
-  d1.credit = doc.outstanding_amount;
-  d1.against_invoice = doc.name;
+	// debit to creditor
+	var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
+	d1.account = doc.debit_to;
+	d1.credit = doc.outstanding_amount;
+	d1.against_invoice = doc.name;
 
 
-  // credit to bank
-  var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
-  d1.debit = doc.outstanding_amount;
+	// credit to bank
+	var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
+	d1.debit = doc.outstanding_amount;
 
-  loaddoc('Journal Voucher', jv.name);
+	loaddoc('Journal Voucher', jv.name);
 }
 
 
 /****************** Get Accounting Entry *****************/
 cur_frm.cscript['View Ledger Entry'] = function(){
-  var callback = function(report){
-    report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
-    report.dt.run();
-  }
-  loadreport('GL Entry','General Ledger', callback);
+	var callback = function(report){
+		report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
+		report.dt.run();
+	}
+	loadreport('GL Entry','General Ledger', callback);
 }
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
index f2f9eaf..2f3b48d 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
@@ -5,16 +5,17 @@
 	{
 		'creation': '2010-08-08 17:09:18',
 		'docstatus': 0,
-		'modified': '2011-06-20 13:02:04',
+		'modified': '2011-10-10 12:29:26',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1309508839',
+		'_last_update': '1317986484',
 		'change_log': '1. Change in pull_details method dt.-26-06-2009',
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'module': 'Accounts',
 		'name': '__common__',
@@ -24,7 +25,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s worth %(currency)s %(grand_total_export)s due on %(due_date)s | %(outstanding_amount)s outstanding',
-		'version': 356
+		'version': 359
 	},
 
 	# These values are common for all DocField
@@ -58,7 +59,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 1,
 		'role': 'Accounts Manager',
 		'submit': 0,
@@ -71,7 +71,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 0,
 		'role': 'Accounts Manager',
 		'submit': 1,
@@ -84,7 +83,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 0,
 		'role': 'Accounts User',
 		'submit': 1,
@@ -97,7 +95,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 1,
 		'role': 'Accounts User',
 		'submit': 0,
@@ -106,18 +103,21 @@
 
 	# DocPerm
 	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'match': 'customer',
 		'permlevel': 0,
-		'role': 'Customer'
+		'role': 'Customer',
+		'submit': 0,
+		'write': 0
 	},
 
 	# DocField
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Basic Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -128,7 +128,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 2,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 0,
@@ -143,7 +142,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'naming_series',
 		'fieldtype': 'Select',
-		'idx': 3,
 		'label': 'Series',
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
@@ -159,7 +157,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_pos',
 		'fieldtype': 'Check',
-		'idx': 4,
 		'label': 'Is POS',
 		'oldfieldname': 'is_pos',
 		'oldfieldtype': 'Check',
@@ -174,7 +171,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'update_stock',
 		'fieldtype': 'Check',
-		'idx': 5,
 		'label': 'Update Stock',
 		'oldfieldname': 'update_stock',
 		'oldfieldtype': 'Check',
@@ -189,7 +185,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'debit_to',
 		'fieldtype': 'Link',
-		'idx': 6,
 		'in_filter': 1,
 		'label': 'Debit To',
 		'oldfieldname': 'debit_to',
@@ -209,7 +204,6 @@
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 7,
 		'label': 'Customer',
 		'no_copy': 0,
 		'oldfieldname': 'customer',
@@ -225,7 +219,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_address',
 		'fieldtype': 'Link',
-		'idx': 8,
 		'label': 'Customer Address',
 		'options': 'Address',
 		'permlevel': 0,
@@ -237,7 +230,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_person',
 		'fieldtype': 'Link',
-		'idx': 9,
 		'label': 'Contact Person',
 		'options': 'Contact',
 		'permlevel': 0,
@@ -249,7 +241,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 10,
 		'label': 'Name',
 		'oldfieldname': 'customer_name',
 		'oldfieldtype': 'Data',
@@ -261,7 +252,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'address_display',
 		'fieldtype': 'Small Text',
-		'idx': 11,
 		'label': 'Address',
 		'permlevel': 1
 	},
@@ -271,7 +261,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_display',
 		'fieldtype': 'Small Text',
-		'idx': 12,
 		'label': 'Contact',
 		'permlevel': 1
 	},
@@ -281,7 +270,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_mobile',
 		'fieldtype': 'Text',
-		'idx': 13,
 		'label': 'Mobile No',
 		'permlevel': 1
 	},
@@ -291,7 +279,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_email',
 		'fieldtype': 'Text',
-		'idx': 14,
 		'label': 'Contact Email',
 		'permlevel': 1,
 		'print_hide': 1
@@ -302,7 +289,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 15,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0
 	},
@@ -315,7 +301,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'voucher_date',
 		'fieldtype': 'Date',
-		'idx': 16,
 		'in_filter': 1,
 		'label': 'Voucher Date',
 		'no_copy': 1,
@@ -334,7 +319,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'due_date',
 		'fieldtype': 'Date',
-		'idx': 17,
 		'in_filter': 1,
 		'label': 'Due Date',
 		'no_copy': 1,
@@ -353,7 +337,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'posting_date',
 		'fieldtype': 'Date',
-		'idx': 18,
 		'in_filter': 1,
 		'label': 'Posting Date',
 		'no_copy': 1,
@@ -370,7 +353,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'posting_time',
 		'fieldtype': 'Time',
-		'idx': 19,
 		'label': 'Posting Time',
 		'no_copy': 1,
 		'oldfieldname': 'posting_time',
@@ -385,7 +367,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'amendment_date',
 		'fieldtype': 'Date',
-		'idx': 20,
 		'label': 'Amendment Date',
 		'no_copy': 1,
 		'oldfieldname': 'amendment_date',
@@ -399,8 +380,8 @@
 		'doctype': 'DocField',
 		'fieldname': 'amended_from',
 		'fieldtype': 'Link',
-		'idx': 21,
 		'label': 'Amended From',
+		'no_copy': 1,
 		'oldfieldname': 'amended_from',
 		'oldfieldtype': 'Link',
 		'options': 'Receivable Voucher',
@@ -413,7 +394,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'mode_of_payment',
 		'fieldtype': 'Select',
-		'idx': 22,
 		'label': 'Mode of Payment',
 		'oldfieldname': 'mode_of_payment',
 		'oldfieldtype': 'Select',
@@ -426,7 +406,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'territory',
 		'fieldtype': 'Link',
-		'idx': 23,
 		'in_filter': 1,
 		'label': 'Territory',
 		'options': 'Territory',
@@ -441,14 +420,12 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_group',
 		'fieldtype': 'Link',
-		'idx': 24,
 		'in_filter': 1,
 		'label': 'Customer Group',
 		'options': 'Customer Group',
 		'permlevel': 0,
 		'print_hide': 1,
-		'reqd': 1,
-		'search_index': 1
+		'search_index': 0
 	},
 
 	# DocField
@@ -456,7 +433,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 25,
 		'label': 'Items',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -467,7 +443,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'price_list_name',
 		'fieldtype': 'Select',
-		'idx': 26,
 		'label': 'Price List',
 		'oldfieldname': 'price_list_name',
 		'oldfieldtype': 'Select',
@@ -484,7 +459,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_order_main',
 		'fieldtype': 'Link',
-		'idx': 27,
 		'label': 'Sales Order',
 		'oldfieldname': 'sales_order_main',
 		'oldfieldtype': 'Link',
@@ -500,7 +474,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'delivery_note_main',
 		'fieldtype': 'Link',
-		'idx': 28,
 		'label': 'Delivery Note',
 		'oldfieldname': 'delivery_note_main',
 		'oldfieldtype': 'Link',
@@ -513,7 +486,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 29,
 		'label': 'Get Items',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -525,7 +497,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 30,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -535,7 +506,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'currency',
 		'fieldtype': 'Select',
-		'idx': 31,
 		'label': 'Currency',
 		'oldfieldname': 'currency',
 		'oldfieldtype': 'Select',
@@ -551,7 +521,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'conversion_rate',
 		'fieldtype': 'Currency',
-		'idx': 32,
 		'label': 'Conversion Rate',
 		'oldfieldname': 'conversion_rate',
 		'oldfieldtype': 'Currency',
@@ -564,7 +533,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 33,
 		'permlevel': 0
 	},
 
@@ -575,7 +543,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'entries',
 		'fieldtype': 'Table',
-		'idx': 34,
 		'label': 'Entries',
 		'oldfieldname': 'entries',
 		'oldfieldtype': 'Table',
@@ -588,7 +555,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 35,
 		'label': 'Re-Calculate Values',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -598,11 +564,25 @@
 
 	# DocField
 	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'permlevel': 0,
+		'width': '50%'
+	},
+
+	# DocField
+	{
 		'description': 'Will be calculated automatically when you enter the details',
 		'doctype': 'DocField',
 		'fieldname': 'net_total',
 		'fieldtype': 'Currency',
-		'idx': 36,
 		'label': 'Net Total*',
 		'oldfieldname': 'net_total',
 		'oldfieldtype': 'Currency',
@@ -615,7 +595,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 37,
 		'label': 'Rates HTML',
 		'oldfieldtype': 'HTML',
 		'options': '* Rates in standard currency',
@@ -625,20 +604,11 @@
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 38,
-		'permlevel': 0
-	},
-
-	# DocField
-	{
 		'colour': 'White:FFF',
 		'depends_on': 'eval:doc.is_pos==1',
 		'doctype': 'DocField',
 		'fieldname': 'cash_bank_account',
 		'fieldtype': 'Link',
-		'idx': 39,
 		'label': 'Cash/Bank Account',
 		'oldfieldname': 'cash_bank_account',
 		'oldfieldtype': 'Link',
@@ -654,7 +624,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'paid_amount',
 		'fieldtype': 'Currency',
-		'idx': 40,
 		'label': 'Paid Amount',
 		'oldfieldname': 'paid_amount',
 		'oldfieldtype': 'Currency',
@@ -667,7 +636,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 41,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -679,7 +647,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'write_off_account',
 		'fieldtype': 'Link',
-		'idx': 42,
 		'label': 'Write Off Account',
 		'options': 'Account',
 		'permlevel': 0,
@@ -693,7 +660,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'write_off_cost_center',
 		'fieldtype': 'Link',
-		'idx': 43,
 		'label': 'Write Off Cost Center',
 		'options': 'Cost Center',
 		'permlevel': 0,
@@ -707,7 +673,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'write_off_amount',
 		'fieldtype': 'Currency',
-		'idx': 44,
 		'label': 'Write Off Amount',
 		'permlevel': 0,
 		'print_hide': 1
@@ -717,7 +682,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 45,
 		'label': 'Taxes',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -728,7 +692,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'charge',
 		'fieldtype': 'Link',
-		'idx': 46,
 		'label': 'Charge',
 		'oldfieldname': 'charge',
 		'oldfieldtype': 'Link',
@@ -741,7 +704,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 47,
 		'label': 'Get Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -756,7 +718,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges',
 		'fieldtype': 'Table',
-		'idx': 48,
 		'label': 'Taxes1',
 		'oldfieldname': 'other_charges',
 		'oldfieldtype': 'Table',
@@ -767,21 +728,7 @@
 	# DocField
 	{
 		'doctype': 'DocField',
-		'fieldname': 'other_charges_total',
-		'fieldtype': 'Currency',
-		'idx': 49,
-		'label': 'Total Charges',
-		'oldfieldname': 'other_charges_total',
-		'oldfieldtype': 'Currency',
-		'permlevel': 1,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 50,
 		'label': 'Calculate Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -792,8 +739,19 @@
 	# DocField
 	{
 		'doctype': 'DocField',
+		'fieldname': 'other_charges_total',
+		'fieldtype': 'Currency',
+		'label': 'Total Charges',
+		'oldfieldname': 'other_charges_total',
+		'oldfieldtype': 'Currency',
+		'permlevel': 1,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 51,
 		'label': 'Other Charges Calculation',
 		'oldfieldtype': 'HTML',
 		'permlevel': 0,
@@ -805,7 +763,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 52,
 		'label': 'Terms',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -816,7 +773,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'tc_name',
 		'fieldtype': 'Link',
-		'idx': 53,
 		'label': 'Select Terms',
 		'oldfieldname': 'tc_name',
 		'oldfieldtype': 'Link',
@@ -830,7 +786,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 54,
 		'label': 'Get Terms',
 		'oldfieldtype': 'Button',
 		'options': 'get_tc_details',
@@ -844,7 +799,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 55,
 		'label': 'Terms HTML',
 		'oldfieldtype': 'HTML',
 		'options': 'You can add Terms and Notes that will be printed in the Transaction',
@@ -857,7 +811,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'terms',
 		'fieldtype': 'Text Editor',
-		'idx': 56,
 		'label': 'Term Details',
 		'oldfieldname': 'terms',
 		'oldfieldtype': 'Text Editor',
@@ -869,7 +822,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 57,
 		'label': 'More Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -881,7 +833,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 58,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -895,7 +846,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_opening',
 		'fieldtype': 'Select',
-		'idx': 59,
 		'in_filter': 1,
 		'label': 'Is Opening',
 		'oldfieldname': 'is_opening',
@@ -912,7 +862,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'aging_date',
 		'fieldtype': 'Date',
-		'idx': 60,
 		'label': 'Aging Date',
 		'oldfieldname': 'aging_date',
 		'oldfieldtype': 'Date',
@@ -927,7 +876,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'letter_head',
 		'fieldtype': 'Select',
-		'idx': 61,
 		'label': 'Letter Head',
 		'oldfieldname': 'letter_head',
 		'oldfieldtype': 'Select',
@@ -941,7 +889,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'source',
 		'fieldtype': 'Select',
-		'idx': 62,
 		'label': 'Source',
 		'oldfieldname': 'source',
 		'oldfieldtype': 'Select',
@@ -957,7 +904,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'campaign',
 		'fieldtype': 'Link',
-		'idx': 63,
 		'label': 'Campaign',
 		'oldfieldname': 'campaign',
 		'oldfieldtype': 'Link',
@@ -973,7 +919,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'select_print_heading',
 		'fieldtype': 'Link',
-		'idx': 64,
 		'label': 'Select Print Heading',
 		'no_copy': 1,
 		'oldfieldname': 'select_print_heading',
@@ -992,7 +937,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'project_name',
 		'fieldtype': 'Link',
-		'idx': 65,
 		'in_filter': 1,
 		'label': 'Project Name',
 		'oldfieldname': 'project_name',
@@ -1008,7 +952,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 66,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0
 	},
@@ -1018,7 +961,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Link',
-		'idx': 67,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
@@ -1035,7 +977,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 68,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'no_copy': 0,
@@ -1055,7 +996,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'cancel_reason',
 		'fieldtype': 'Data',
-		'idx': 69,
 		'label': 'Cancel Reason',
 		'oldfieldname': 'cancel_reason',
 		'oldfieldtype': 'Data',
@@ -1068,7 +1008,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'remarks',
 		'fieldtype': 'Small Text',
-		'idx': 70,
 		'label': 'Remarks',
 		'no_copy': 1,
 		'oldfieldname': 'remarks',
@@ -1083,7 +1022,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 71,
 		'label': 'Totals',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1095,7 +1033,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 72,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1108,7 +1045,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total',
 		'fieldtype': 'Currency',
-		'idx': 73,
 		'in_filter': 1,
 		'label': 'Grand Total',
 		'oldfieldname': 'grand_total',
@@ -1124,7 +1060,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total',
 		'fieldtype': 'Currency',
-		'idx': 74,
 		'label': 'Rounded Total',
 		'oldfieldname': 'rounded_total',
 		'oldfieldtype': 'Currency',
@@ -1139,7 +1074,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words',
 		'fieldtype': 'Data',
-		'idx': 75,
 		'label': 'In Words',
 		'oldfieldname': 'in_words',
 		'oldfieldtype': 'Data',
@@ -1152,7 +1086,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'total_advance',
 		'fieldtype': 'Currency',
-		'idx': 76,
 		'label': 'Total Advance',
 		'oldfieldname': 'total_advance',
 		'oldfieldtype': 'Currency',
@@ -1166,7 +1099,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'outstanding_amount',
 		'fieldtype': 'Currency',
-		'idx': 77,
 		'label': 'Outstanding Amount',
 		'no_copy': 1,
 		'oldfieldname': 'outstanding_amount',
@@ -1180,7 +1112,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 78,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1192,7 +1123,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total_export',
 		'fieldtype': 'Currency',
-		'idx': 79,
 		'label': 'Grand Total (Export)',
 		'oldfieldname': 'grand_total_export',
 		'oldfieldtype': 'Currency',
@@ -1206,7 +1136,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total_export',
 		'fieldtype': 'Currency',
-		'idx': 80,
 		'label': 'Rounded Total (Export)',
 		'oldfieldname': 'rounded_total_export',
 		'oldfieldtype': 'Currency',
@@ -1221,7 +1150,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words_export',
 		'fieldtype': 'Data',
-		'idx': 81,
 		'label': 'In Words (Export)',
 		'oldfieldname': 'in_words_export',
 		'oldfieldtype': 'Data',
@@ -1234,7 +1162,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'gross_profit',
 		'fieldtype': 'Currency',
-		'idx': 82,
 		'label': 'Gross Profit',
 		'oldfieldname': 'gross_profit',
 		'oldfieldtype': 'Currency',
@@ -1247,7 +1174,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'gross_profit_percent',
 		'fieldtype': 'Currency',
-		'idx': 83,
 		'label': 'Gross Profit (%)',
 		'oldfieldname': 'gross_profit_percent',
 		'oldfieldtype': 'Currency',
@@ -1260,7 +1186,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 84,
 		'label': 'Advances',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1271,7 +1196,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 85,
 		'label': 'Get Advances Received',
 		'oldfieldtype': 'Button',
 		'options': 'get_advances',
@@ -1284,7 +1208,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'advance_adjustment_details',
 		'fieldtype': 'Table',
-		'idx': 86,
 		'label': 'Advance Adjustment Detail',
 		'oldfieldname': 'advance_adjustment_details',
 		'oldfieldtype': 'Table',
@@ -1297,7 +1220,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 87,
 		'label': 'Sales Team',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1309,7 +1231,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 88,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1321,7 +1242,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_partner',
 		'fieldtype': 'Link',
-		'idx': 89,
 		'in_filter': 1,
 		'label': 'Sales Partner',
 		'oldfieldname': 'sales_partner',
@@ -1337,7 +1257,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'commission_rate',
 		'fieldtype': 'Currency',
-		'idx': 90,
 		'label': 'Commission Rate (%)',
 		'oldfieldname': 'commission_rate',
 		'oldfieldtype': 'Currency',
@@ -1352,7 +1271,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'total_commission',
 		'fieldtype': 'Currency',
-		'idx': 91,
 		'label': 'Total Commission',
 		'oldfieldname': 'total_commission',
 		'oldfieldtype': 'Currency',
@@ -1366,7 +1284,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 92,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1378,7 +1295,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_team',
 		'fieldtype': 'Table',
-		'idx': 93,
 		'label': 'Sales Team1',
 		'oldfieldname': 'sales_team',
 		'oldfieldtype': 'Table',
@@ -1392,7 +1308,6 @@
 		'allow_on_submit': 1,
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 94,
 		'label': 'Repair Outstanding Amt',
 		'oldfieldtype': 'Button',
 		'options': 'repair_rv_outstanding',
@@ -1406,7 +1321,6 @@
 		'fieldname': 'against_income_account',
 		'fieldtype': 'Small Text',
 		'hidden': 1,
-		'idx': 95,
 		'label': 'Against Income Account',
 		'no_copy': 1,
 		'oldfieldname': 'against_income_account',