Merge pull request #3829 from dottenbr/customer-taxid

Tax ID added and Customer Details description updated
diff --git a/README.md b/README.md
index 54a9f4c..d91136f 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@
 
 ### Full Install
 
-The Easy Way install script for bench will install all dependencies (e.g. MariaDB). See https://github.com/frappe/bench
+The Easy Way: our install script for bench will install all dependencies (e.g. MariaDB). See https://github.com/frappe/bench for more details.
 
 New passwords will be created for the ERPNext "Administrator" user, the MariaDB root user, and the frappe user (the script displays the passwords and saves them to ~/frappe_passwords.txt).
 
@@ -71,6 +71,6 @@
 
 Please note that it is not the goal of this policy to limit commercial activity around ERPNext. We encourage ERPNext-based businesses, and we would love to see hundreds of them.
 
-When in doubt about your use of the ERPNext name or logo, please contact the Frappe Technologies for clarification.
+When in doubt about your use of the ERPNext name or logo, please contact Frappe Technologies for clarification.
 
-(inspired from WordPress)
+(inspired by WordPress)
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index f0630ce..80d2435 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -192,8 +192,9 @@
 
 				if against_field in ["against_invoice", "against_voucher"]:
 					if (against_voucher[0] !=d.party or against_voucher[1] != d.account):
-						frappe.throw(_("Row {0}: Party / Account does not match with \
-							Customer / Debit To in {1}").format(d.idx, doctype))
+						frappe.throw(_("Row {0}: Party / Account does not match with {1} / {2} in {3} {4}")
+							.format(d.idx, field_dict.get(doctype)[0], field_dict.get(doctype)[1], 
+								doctype, d.get(against_field)))
 					else:
 						payment_against_voucher.setdefault(d.get(against_field), []).append(flt(d.get(dr_or_cr)))
 
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py
index eeb2bcf..98a8509 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.py
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py
@@ -11,7 +11,6 @@
 class POSProfile(Document):
 	def validate(self):
 		self.check_for_duplicate()
-		self.validate_expense_account()
 		self.validate_all_link_fields()
 
 	def check_for_duplicate(self):
@@ -26,11 +25,6 @@
 				msgprint(_("Global POS Profile {0} already created for company {1}").format(res[0][0],
 					self.company), raise_exception=1)
 
-	def validate_expense_account(self):
-		if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
-				and not self.expense_account:
-			msgprint(_("Expense Account is mandatory"), raise_exception=1)
-
 	def validate_all_link_fields(self):
 		accounts = {"Account": [self.cash_bank_account, self.income_account,
 			self.expense_account], "Cost Center": [self.cost_center],
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 6c67379..67f4a8e 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -746,7 +746,7 @@
 	def test_return_sales_invoice(self):
 		set_perpetual_inventory()
 		
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
 		
 		actual_qty_0 = get_qty_after_transaction()
 		
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 17fe922..8081459 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -11,8 +11,7 @@
 
 class StockAccountInvalidTransaction(frappe.ValidationError): pass
 
-def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True,
-		update_outstanding='Yes'):
+def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True, update_outstanding='Yes'):
 	if gl_map:
 		if not cancel:
 			gl_map = process_gl_map(gl_map, merge_entries)
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index 19050a4..b6b6ce5 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -46,6 +46,8 @@
 						+ '</b> / <span class="text-muted">' + __("Total Unpaid") + ": <b>"
 						+ format_currency(r.message.total_unpaid, r.message.company_currency[0])
 						+ '</b></span>');
+				} else {
+					cur_frm.dashboard.set_headline("");
 				}
 			}
 			cur_frm.dashboard.set_badge_count(r.message);
diff --git a/erpnext/change_log/current/stock_entry_additional_costs.md b/erpnext/change_log/current/stock_entry_additional_costs.md
new file mode 100644
index 0000000..ef03375
--- /dev/null
+++ b/erpnext/change_log/current/stock_entry_additional_costs.md
@@ -0,0 +1,2 @@
+- Additional Costs in Stock Entry **[Sponsored by PT. Ridho Sribumi Sejahtera]**
+	- Now additional costs like shipping charges, operating costs etc can be added in Stock Entry in item valuation
\ No newline at end of file
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index bb8c65b..915d294 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -11,7 +11,7 @@
 from erpnext.controllers.recurring_document import convert_to_recurring, validate_recurring_document
 from erpnext.controllers.sales_and_purchase_return import validate_return
 
-force_item_fields = ("item_name", "item_group", "barcode", "brand", "stock_uom")
+force_item_fields = ("item_group", "barcode", "brand", "stock_uom")
 
 class CustomerFrozen(frappe.ValidationError): pass
 
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 6156dcf..edaa151 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -80,9 +80,23 @@
 		if(doc.status!=="Quotation")
 			cur_frm.add_custom_button(__('Opportunity Lost'),
 				cur_frm.cscript['Declare Opportunity Lost'], "icon-remove", "btn-default");
-
-
 	}
+
+	var frm = cur_frm;
+	if(frm.perm[0].write && doc.docstatus==0) {
+		if(frm.doc.status==="Open") {
+			frm.add_custom_button("Close", function() {
+				frm.set_value("status", "Closed");
+				frm.save();
+			});
+		} else {
+			frm.add_custom_button("Reopen", function() {
+				frm.set_value("status", "Open");
+				frm.save();
+			});
+		}
+	}
+
 }
 
 cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
index eb770a8..46d7bb8 100644
--- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
+++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json
@@ -42,6 +42,15 @@
    "precision": ""
   }, 
   {
+   "default": "BOM", 
+   "fieldname": "backflush_raw_materials_based_on", 
+   "fieldtype": "Select", 
+   "label": "Backflush Raw Materials Based On", 
+   "options": "BOM\nMaterial Transferred for Manufacture", 
+   "permlevel": 0, 
+   "precision": ""
+  }, 
+  {
    "fieldname": "column_break_3", 
    "fieldtype": "Column Break", 
    "permlevel": 0, 
@@ -78,8 +87,8 @@
  "in_create": 0, 
  "in_dialog": 0, 
  "is_submittable": 0, 
- "issingle": 1, 
- "istable": 0, 
+ "issingle": 1,
+ "istable": 0,
  "modified": "2015-07-23 08:12:33.889753", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 657756d..04fcaa5 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -162,7 +162,7 @@
 	make_se: function(purpose) {
 		var me = this;
 		var max = (purpose === "Manufacture") ?
-			flt(this.frm.doc.qty) - flt(this.frm.doc.produced_qty) :
+			flt(this.frm.doc.material_transferred_for_manufacturing) - flt(this.frm.doc.produced_qty) :
 			flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing);
 
 		frappe.prompt({fieldtype:"Int", label: __("Qty for {0}", [purpose]), fieldname:"qty",
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index b79f8b6..023c43e 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -10,6 +10,9 @@
 from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
 from dateutil.relativedelta import relativedelta
 from erpnext.stock.doctype.item.item import validate_end_of_life
+from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError, NotInWorkingHoursError
+from erpnext.projects.doctype.time_log.time_log import OverlapError
+from erpnext.stock.doctype.stock_entry.stock_entry import get_additional_costs
 
 class OverProductionError(frappe.ValidationError): pass
 class StockOverProductionError(frappe.ValidationError): pass
@@ -17,9 +20,6 @@
 class ProductionNotApplicableError(frappe.ValidationError): pass
 class ItemHasVariantError(frappe.ValidationError): pass
 
-from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError, NotInWorkingHoursError
-from erpnext.projects.doctype.time_log.time_log import OverlapError
-
 form_grid_templates = {
 	"operations": "templates/form_grid/production_order_grid.html"
 }
@@ -356,7 +356,6 @@
 	stock_entry.company = production_order.company
 	stock_entry.from_bom = 1
 	stock_entry.bom_no = production_order.bom_no
-	stock_entry.additional_operating_cost = production_order.additional_operating_cost
 	stock_entry.use_multi_level_bom = production_order.use_multi_level_bom
 	stock_entry.fg_completed_qty = qty or (flt(production_order.qty) - flt(production_order.produced_qty))
 
@@ -365,6 +364,8 @@
 	else:
 		stock_entry.from_warehouse = production_order.wip_warehouse
 		stock_entry.to_warehouse = production_order.fg_warehouse
+		additional_costs = get_additional_costs(production_order, fg_qty=stock_entry.fg_completed_qty)
+		stock_entry.set("additional_costs", additional_costs)
 
 	stock_entry.get_items()
 	return stock_entry.as_dict()
diff --git a/erpnext/manufacturing/doctype/production_order/test_production_order.py b/erpnext/manufacturing/doctype/production_order/test_production_order.py
index 4d65337..eb26d29 100644
--- a/erpnext/manufacturing/doctype/production_order/test_production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/test_production_order.py
@@ -28,9 +28,9 @@
 
 		# add raw materials to stores
 		test_stock_entry.make_stock_entry(item_code="_Test Item",
-			target="Stores - _TC", qty=100, incoming_rate=100)
+			target="Stores - _TC", qty=100, basic_rate=100)
 		test_stock_entry.make_stock_entry(item_code="_Test Item Home Desktop 100",
-			target="Stores - _TC", qty=100, incoming_rate=100)
+			target="Stores - _TC", qty=100, basic_rate=100)
 
 		# from stores to wip
 		s = frappe.get_doc(make_stock_entry(pro_order.name, "Material Transfer for Manufacture", 4))
@@ -58,9 +58,9 @@
 		pro_doc = self.check_planned_qty()
 
 		test_stock_entry.make_stock_entry(item_code="_Test Item",
-			target="_Test Warehouse - _TC", qty=100, incoming_rate=100)
+			target="_Test Warehouse - _TC", qty=100, basic_rate=100)
 		test_stock_entry.make_stock_entry(item_code="_Test Item Home Desktop 100",
-			target="_Test Warehouse - _TC", qty=100, incoming_rate=100)
+			target="_Test Warehouse - _TC", qty=100, basic_rate=100)
 
 		s = frappe.get_doc(make_stock_entry(pro_doc.name, "Manufacture", 7))
 		s.insert()
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b2d8068..d12154b 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -188,3 +188,5 @@
 erpnext.patches.v5_4.notify_system_managers_regarding_wrong_tax_calculation
 erpnext.patches.v5_4.fix_invoice_outstanding
 execute:frappe.db.sql("update `tabStock Ledger Entry` set stock_queue = '[]' where voucher_type = 'Stock Reconciliation' and ifnull(qty_after_transaction, 0) = 0")
+erpnext.patches.v5_4.fix_missing_item_images
+erpnext.patches.v5_4.stock_entry_additional_costs
diff --git a/erpnext/patches/v5_4/fix_missing_item_images.py b/erpnext/patches/v5_4/fix_missing_item_images.py
new file mode 100644
index 0000000..d782cd1
--- /dev/null
+++ b/erpnext/patches/v5_4/fix_missing_item_images.py
@@ -0,0 +1,116 @@
+from __future__ import unicode_literals
+import frappe
+import os
+from frappe.utils import get_files_path
+from frappe.utils.file_manager import get_content_hash
+
+def execute():
+	files_path = get_files_path()
+
+	# get files that don't have attached_to_name but exist
+	unlinked_files = get_unlinked_files(files_path)
+	if not unlinked_files:
+		return
+
+	fixed_files = fix_files_for_item(files_path, unlinked_files)
+
+	# fix remaining files
+	for key, file_data in unlinked_files.items():
+		if key not in fixed_files:
+			rename_and_set_content_hash(files_path, unlinked_files, key)
+			frappe.db.commit()
+
+def fix_files_for_item(files_path, unlinked_files):
+	fixed_files = []
+
+	# make a list of files/something and /files/something to check in child table's image column
+	file_urls = [key for key in unlinked_files.keys()] + ["/" + key for key in unlinked_files.keys()]
+	file_item_code = get_file_item_code(file_urls)
+
+	for (file_url, item_code), children in file_item_code.items():
+		new_file_url = "/files/{0}".format(unlinked_files[file_url]["file_name"])
+
+		for row in children:
+			# print file_url, new_file_url, item_code, row.doctype, row.name
+
+			# replace image in these rows with the new file url
+			frappe.db.set_value(row.doctype, row.name, "image", new_file_url, update_modified=False)
+
+		# set it as attachment of this item code
+		file_data = frappe.get_doc("File Data", unlinked_files[file_url]["file"])
+		file_data.attached_to_doctype = "Item"
+		file_data.attached_to_name = item_code
+		file_data.save()
+
+		# set it as image in Item
+		if not frappe.db.get_value("Item", item_code, "image"):
+			frappe.db.set_value("Item", item_code, "image", new_file_url, update_modified=False)
+
+		rename_and_set_content_hash(files_path, unlinked_files, file_url)
+
+		fixed_files.append(file_url)
+
+		# commit
+		frappe.db.commit()
+
+	return fixed_files
+
+def rename_and_set_content_hash(files_path, unlinked_files, file_url):
+	# rename this file
+	old_filename = os.path.join(files_path, unlinked_files[file_url]["file"])
+	new_filename = os.path.join(files_path, unlinked_files[file_url]["file_name"])
+
+	if not os.path.exists(new_filename):
+		os.rename(old_filename, new_filename)
+
+	# set content hash if missing
+	file_data_name = unlinked_files[file_url]["file"]
+	if not frappe.db.get_value("File Data", file_data_name, "content_hash"):
+		with open(new_filename, "r") as f:
+			content_hash = get_content_hash(f.read())
+			frappe.db.set_value("File Data", file_data_name, "content_hash", content_hash)
+
+def get_unlinked_files(files_path):
+	# find files that have the same name as a File Data doc
+	# and the file_name mentioned in that File Data doc doesn't exist
+	# and it isn't already attached to a doc
+	unlinked_files = {}
+	files = os.listdir(files_path)
+	for file in files:
+		if not frappe.db.exists("File Data", {"file_name": file}):
+			file_data = frappe.db.get_value("File Data", {"name": file},
+				["file_name", "attached_to_doctype", "attached_to_name"], as_dict=True)
+
+			if (file_data
+				and file_data.file_name
+				and file_data.file_name not in files
+				and not file_data.attached_to_doctype
+				and not file_data.attached_to_name):
+
+				file_data["file"] = file
+				unlinked_files["files/{0}".format(file)] = file_data
+
+	return unlinked_files
+
+def get_file_item_code(file_urls):
+	# get a map of file_url, item_code and list of documents where file_url will need to be changed in image field
+	file_item_code = {}
+
+	doctypes = frappe.db.sql_list("""select name from `tabDocType` dt
+		where istable=1
+			and exists (select name from `tabDocField` df where df.parent=dt.name and df.fieldname='item_code')
+			and exists (select name from `tabDocField` df where df.parent=dt.name and df.fieldname='image')""")
+
+	for doctype in doctypes:
+		result = frappe.db.sql("""select name, image, item_code, '{0}' as doctype from `tab{0}`
+				where image in ({1})""".format(doctype, ", ".join(["%s"]*len(file_urls))),
+				file_urls, as_dict=True)
+
+		for r in result:
+			key = (r.image, r.item_code)
+			if key not in file_item_code:
+				file_item_code[key] = []
+
+			file_item_code[key].append(r)
+
+	return file_item_code
diff --git a/erpnext/patches/v5_4/stock_entry_additional_costs.py b/erpnext/patches/v5_4/stock_entry_additional_costs.py
new file mode 100644
index 0000000..e064690
--- /dev/null
+++ b/erpnext/patches/v5_4/stock_entry_additional_costs.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import flt
+
+def execute():
+	frappe.reload_doctype("Stock Entry")
+	frappe.reload_doctype("Stock Entry Detail")
+	frappe.reload_doctype("Landed Cost Taxes and Charges")
+	
+	frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se
+		set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount
+		where sed.parent = se.name 
+		and (se.purpose not in ('Manufacture', 'Repack') or ifnull(additional_operating_cost, 0)=0)
+	""")
+	
+	stock_entries = frappe.db.sql_list("""select name from `tabStock Entry` 
+		where purpose in ('Manufacture', 'Repack') and ifnull(additional_operating_cost, 0)!=0""")
+	
+	for d in stock_entries:
+		stock_entry = frappe.get_doc("Stock Entry", d)
+		stock_entry.append("additional_costs", {
+			"description": "Additional Operating Cost",
+			"amount": stock_entry.additional_operating_cost
+		})
+		
+		number_of_fg_items = len([t.t_warehouse for t in stock_entry.get("items") if t.t_warehouse])
+		
+		for d in stock_entry.get("items"):
+			d.valuation_rate = d.incoming_rate
+			
+			if d.bom_no or (d.t_warehouse and number_of_fg_items == 1):	
+				d.additional_cost = stock_entry.additional_operating_cost
+				
+			d.basic_rate = flt(d.valuation_rate) - flt(d.additional_cost)
+			d.basic_amount = flt(flt(d.basic_rate) *flt(d.transfer_qty), d.precision("basic_amount"))
+			
+		stock_entry.flags.ignore_validate = True
+		stock_entry.flags.ignore_validate_update_after_submit = True
+		stock_entry.save()
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 1f9a12b..ac0f636 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -46,6 +46,7 @@
 	cur_frm.dashboard.add_doctype_badge("Sales Order", "customer");
 	cur_frm.dashboard.add_doctype_badge("Delivery Note", "customer");
 	cur_frm.dashboard.add_doctype_badge("Sales Invoice", "customer");
+	cur_frm.dashboard.add_doctype_badge("Project", "customer");
 
 	return frappe.call({
 		type: "GET",
@@ -62,6 +63,8 @@
 						+ '</b> / <span class="text-muted">' + __("Unpaid") + ": <b>"
 						+ format_currency(r.message.total_unpaid, r.message["company_currency"][0])
 						+ '</b></span>');
+				} else {
+					cur_frm.dashboard.set_headline("");
 				}
 			}
 			cur_frm.dashboard.set_badge_count(r.message);
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index f82e2fb..fe68966 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -119,7 +119,8 @@
 		frappe.msgprint(_("Not permitted"), raise_exception=True)
 
 	out = {}
-	for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
+	for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note",
+		"Sales Invoice", "Project"]:
 		out[doctype] = frappe.db.get_value(doctype,
 			{"customer": customer, "docstatus": ["!=", 2] }, "count(*)")
 
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 5660d89..cf47de5 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -32,7 +32,7 @@
 			frappe.throw(_("Abbreviation cannot have more than 5 characters"))
 
 		if not self.abbr.strip():
-			frappe.throw(_("Abbr can not be blank or space"))
+			frappe.throw(_("Abbreviation is mandatory"))
 
 		self.previous_default_currency = frappe.db.get_value("Company", self.name, "default_currency")
 		if self.default_currency and self.previous_default_currency and \
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index eb80014..e41aab7 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -37,7 +37,7 @@
 		set_perpetual_inventory(0)
 		self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 0)
 
-		make_stock_entry(target="_Test Warehouse - _TC", qty=5, incoming_rate=100)
+		make_stock_entry(target="_Test Warehouse - _TC", qty=5, basic_rate=100)
 
 		stock_queue = json.loads(get_previous_sle({
 			"item_code": "_Test Item",
@@ -59,7 +59,7 @@
 		self.assertEqual(cint(frappe.defaults.get_global_default("auto_accounting_for_stock")), 1)
 		frappe.db.set_value("Item", "_Test Item", "valuation_method", "FIFO")
 
-		make_stock_entry(target="_Test Warehouse - _TC", qty=5, incoming_rate=100)
+		make_stock_entry(target="_Test Warehouse - _TC", qty=5, basic_rate=100)
 
 		stock_in_hand_account = frappe.db.get_value("Account", {"warehouse": "_Test Warehouse - _TC"})
 		prev_bal = get_balance_on(stock_in_hand_account)
@@ -85,7 +85,7 @@
 
 		# back dated incoming entry
 		make_stock_entry(posting_date=add_days(nowdate(), -2), target="_Test Warehouse - _TC",
-			qty=5, incoming_rate=100)
+			qty=5, basic_rate=100)
 
 		gl_entries = get_gl_entries("Delivery Note", dn.name)
 		self.assertTrue(gl_entries)
@@ -107,9 +107,9 @@
 	def test_delivery_note_gl_entry_packing_item(self):
 		set_perpetual_inventory()
 
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=10, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=10, basic_rate=100)
 		make_stock_entry(item_code="_Test Item Home Desktop 100",
-			target="_Test Warehouse - _TC", qty=10, incoming_rate=100)
+			target="_Test Warehouse - _TC", qty=10, basic_rate=100)
 
 		stock_in_hand_account = frappe.db.get_value("Account", {"warehouse": "_Test Warehouse - _TC"})
 		prev_bal = get_balance_on(stock_in_hand_account)
@@ -184,7 +184,7 @@
 	def test_sales_return_for_non_bundled_items(self):
 		set_perpetual_inventory()
 		
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
 		
 		actual_qty_0 = get_qty_after_transaction()
 		
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 510c0d1..9235bec 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -47,7 +47,7 @@
 
 	def test_template_cannot_have_stock(self):
 			item = self.get_item(10)
-			make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, incoming_rate=1)
+			make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, basic_rate=1)
 			item.has_variants = 1
 			self.assertRaises(ItemTemplateCannotHaveStock, item.save)
 
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 0433036..fd6f943 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -305,7 +305,7 @@
 
 	def set_missing_values(source, target):
 		target.purpose = source.material_request_type
-		target.run_method("get_stock_and_rate")
+		target.run_method("calculate_rate_and_amount")
 
 	doclist = get_mapped_doc("Material Request", source_name, {
 		"Material Request": {
diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py
index dcca3ce..99815dd 100644
--- a/erpnext/stock/doctype/material_request/test_material_request.py
+++ b/erpnext/stock/doctype/material_request/test_material_request.py
@@ -72,7 +72,7 @@
 						"doctype": "Stock Entry Detail",
 						"item_code": "_Test Item Home Desktop 100",
 						"parentfield": "items",
-						"incoming_rate": 100,
+						"basic_rate": 100,
 						"qty": qty1,
 						"stock_uom": "_Test UOM 1",
 						"transfer_qty": qty1,
@@ -84,7 +84,7 @@
 						"doctype": "Stock Entry Detail",
 						"item_code": "_Test Item Home Desktop 200",
 						"parentfield": "items",
-						"incoming_rate": 100,
+						"basic_rate": 100,
 						"qty": qty2,
 						"stock_uom": "_Test UOM 1",
 						"transfer_qty": qty2,
@@ -196,13 +196,13 @@
 			"qty": 27.0,
 			"transfer_qty": 27.0,
 			"s_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 		se_doc.get("items")[1].update({
 			"qty": 1.5,
 			"transfer_qty": 1.5,
 			"s_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 
 		# make available the qty in _Test Warehouse 1 before transfer
@@ -279,13 +279,13 @@
 			"qty": 60.0,
 			"transfer_qty": 60.0,
 			"s_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 		se_doc.get("items")[1].update({
 			"qty": 3.0,
 			"transfer_qty": 3.0,
 			"s_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 
 		# make available the qty in _Test Warehouse 1 before transfer
@@ -350,13 +350,13 @@
 			"transfer_qty": 60.0,
 			"s_warehouse": "_Test Warehouse - _TC",
 			"t_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 		se_doc.get("items")[1].update({
 			"qty": 3.0,
 			"transfer_qty": 3.0,
 			"s_warehouse": "_Test Warehouse 1 - _TC",
-			"incoming_rate": 1.0
+			"basic_rate": 1.0
 		})
 
 		# check for stopped status of Material Request
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 343d51a..5017964 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -80,9 +80,9 @@
 	def test_subcontracting(self):
 		from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
 		
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse 1 - _TC", qty=100, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse 1 - _TC", qty=100, basic_rate=100)
 		make_stock_entry(item_code="_Test Item Home Desktop 100", target="_Test Warehouse 1 - _TC", 
-			qty=100, incoming_rate=100)
+			qty=100, basic_rate=100)
 		
 		pr = make_purchase_receipt(item_code="_Test FG Item", qty=10, rate=500, is_subcontracted="Yes")
 		self.assertEquals(len(pr.get("supplied_items")), 2)
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 04ef935..e9fc134 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -10,7 +10,10 @@
 
 		this.frm.fields_dict.bom_no.get_query = function() {
 			return {
-				filters:{ 'docstatus': 1 }
+				filters:{
+					"docstatus": 1,
+					"is_active": 1
+				}
 			};
 		};
 
@@ -22,7 +25,8 @@
 			return {
 				"filters": {
 					"docstatus": 1,
-					"is_subcontracted": "Yes"
+					"is_subcontracted": "Yes",
+					"company": me.frm.doc.company
 				}
 			};
 		});
@@ -38,6 +42,14 @@
 					}
 				}
 			}
+			this.frm.set_query("difference_account", function() {
+				return {
+					"filters": {
+						"company": me.frm.doc.company,
+						"is_group": 0
+					}
+				};
+			});
 		}
 	},
 
@@ -122,11 +134,6 @@
 		var d = locals[cdt][cdn];
 		d.transfer_qty = flt(d.qty) * flt(d.conversion_factor);
 		refresh_field('items');
-		calculate_total(doc, cdt, cdn);
-	},
-
-	incoming_rate: function(doc, cdt, cdn) {
-		calculate_total(doc, cdt, cdn);
 	},
 
 	production_order: function() {
@@ -135,13 +142,29 @@
 
 		return frappe.call({
 			method: "erpnext.stock.doctype.stock_entry.stock_entry.get_production_order_details",
-			args: {production_order: this.frm.doc.production_order},
+			args: {production_order: me.frm.doc.production_order},
 			callback: function(r) {
 				if (!r.exc) {
-					me.frm.set_value(r.message);
+					$.each(["from_bom", "bom_no", "fg_completed_qty", "use_multi_level_bom"], function(i, field) {
+						me.frm.set_value(field, r.message[field]);
+					})
+					
 					if (me.frm.doc.purpose == "Material Transfer for Manufacture" && !me.frm.doc.to_warehouse)
 						me.frm.set_value("to_warehouse", r.message["wip_warehouse"]);
-					me.frm.set_value("from_bom", 1);
+					
+					
+					if (me.frm.doc.purpose == "Manufacture") {
+						if(r.message["additional_costs"].length) {
+							$.each(r.message["additional_costs"], function(i, row) {
+								me.frm.add_child("additional_costs", row);
+							})
+							refresh_field("additional_costs");
+						}
+						
+						if (!me.frm.doc.from_warehouse) me.frm.set_value("from_warehouse", r.message["wip_warehouse"]);
+						if (!me.frm.doc.to_warehouse) me.frm.set_value("to_warehouse", r.message["fg_warehouse"]);
+					}
+					me.get_items()
 				}
 			}
 		});
@@ -229,13 +252,20 @@
 	if(doc.purpose == "Material Receipt") {
 		cur_frm.set_value("from_bom", 0);
 	}
+	
+	// Addition costs based on purpose
+	cur_frm.toggle_display(["additional_costs", "total_additional_costs", "additional_costs_section"], 
+		doc.purpose!='Material Issue');
+	
+	cur_frm.fields_dict["items"].grid.set_column_disp("additional_cost", doc.purpose!='Material Issue');
 }
 
 cur_frm.fields_dict['production_order'].get_query = function(doc) {
 	return {
 		filters: [
 			['Production Order', 'docstatus', '=', 1],
-			['Production Order', 'qty', '>','`tabProduction Order`.produced_qty']
+			['Production Order', 'qty', '>','`tabProduction Order`.produced_qty'],
+			['Production Order', 'company', '=', cur_frm.doc.company]
 		]
 	}
 }
@@ -375,17 +405,4 @@
 
 cur_frm.cscript.posting_date = function(doc, cdt, cdn){
 	erpnext.get_fiscal_year(doc.company, doc.posting_date);
-}
-
-var calculate_total = function(doc, cdt, cdn){
-	var d = locals[cdt][cdn];
-	amount = flt(d.incoming_rate) * flt(d.transfer_qty)
-	frappe.model.set_value(cdt, cdn, 'amount', amount);
-	var total_amount = 0.0;
-	var items = doc.items || [];
-	for(var i=0;i<items.length;i++) {
-		total_amount += flt(items[i].amount);
-	}
-	doc.total_amount = total_amount;
-	refresh_field("total_amount");
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index 3c39d42..165c474 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -4,24 +4,49 @@
  "allow_rename": 0, 
  "autoname": "naming_series:", 
  "creation": "2013-04-09 11:43:55", 
+ "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "fields": [
   {
+   "allow_on_submit": 0, 
    "fieldname": "items_section", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "", 
+   "no_copy": 0, 
    "oldfieldtype": "Section Break", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col1", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "oldfieldtype": "Column Break", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "print_width": "50%", 
    "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0, 
    "width": "50%"
   }, 
   {
@@ -29,7 +54,9 @@
    "fieldname": "naming_series", 
    "fieldtype": "Select", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Series", 
    "no_copy": 1, 
    "oldfieldname": "naming_series", 
@@ -40,7 +67,9 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -48,6 +77,7 @@
    "fieldname": "purpose", 
    "fieldtype": "Select", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Purpose", 
@@ -60,7 +90,9 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -68,7 +100,9 @@
    "fieldname": "production_order", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
+   "in_list_view": 0, 
    "label": "Production Order", 
    "no_copy": 0, 
    "oldfieldname": "production_order", 
@@ -79,16 +113,31 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval:doc.purpose==\"Subcontract\"", 
    "fieldname": "purchase_order", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Purchase Order", 
+   "no_copy": 0, 
    "options": "Purchase Order", 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -96,7 +145,9 @@
    "fieldname": "delivery_note_no", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Delivery Note No", 
    "no_copy": 1, 
    "oldfieldname": "delivery_note_no", 
@@ -107,19 +158,30 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval:doc.purpose==\"Sales Return\"", 
    "fieldname": "sales_invoice_no", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Sales Invoice No", 
    "no_copy": 1, 
    "options": "Sales Invoice", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -127,7 +189,9 @@
    "fieldname": "purchase_receipt_no", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Purchase Receipt No", 
    "no_copy": 1, 
    "oldfieldname": "purchase_receipt_no", 
@@ -138,23 +202,50 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Subcontract\", \"Material Transfer for Manufacture\"], doc.purpose)", 
    "fieldname": "from_bom", 
    "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "From BOM", 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col2", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "oldfieldtype": "Column Break", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "print_width": "50%", 
    "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0, 
    "width": "50%"
   }, 
   {
@@ -163,6 +254,7 @@
    "fieldname": "posting_date", 
    "fieldtype": "Date", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
    "in_list_view": 0, 
    "label": "Posting Date", 
@@ -174,14 +266,18 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "posting_time", 
    "fieldtype": "Time", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Posting Time", 
    "no_copy": 1, 
    "oldfieldname": "posting_time", 
@@ -191,40 +287,50 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval: doc.from_bom && (doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")", 
    "fieldname": "sb1", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "", 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "from_bom", 
    "fieldname": "bom_no", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "BOM No", 
+   "no_copy": 0, 
    "options": "BOM", 
    "permlevel": 0, 
-   "read_only": 0
-  }, 
-  {
-   "depends_on": "from_bom", 
-   "fieldname": "additional_operating_cost", 
-   "fieldtype": "Currency", 
-   "label": "Additional Operating Cost", 
-   "no_copy": 1, 
-   "options": "Company:company:default_currency", 
-   "permlevel": 0, 
-   "read_only": 0
-  }, 
-  {
-   "fieldname": "cb1", 
-   "fieldtype": "Column Break", 
-   "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -233,7 +339,9 @@
    "fieldname": "fg_completed_qty", 
    "fieldtype": "Float", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "For Quantity", 
    "no_copy": 0, 
    "oldfieldname": "fg_completed_qty", 
@@ -243,18 +351,49 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "cb1", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "default": "1", 
    "depends_on": "from_bom", 
    "description": "Including items for sub assemblies", 
    "fieldname": "use_multi_level_bom", 
    "fieldtype": "Check", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Use Multi-Level BOM", 
+   "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -262,7 +401,9 @@
    "fieldname": "get_items", 
    "fieldtype": "Button", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Get Items", 
    "no_copy": 0, 
    "oldfieldtype": "Button", 
@@ -271,19 +412,35 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "section_break_12", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "from_warehouse", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Default Source Warehouse", 
@@ -296,19 +453,34 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "cb0", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "to_warehouse", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Default Target Warehouse", 
@@ -321,21 +493,37 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "sb0", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "options": "Simple", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "items", 
    "fieldtype": "Table", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Items", 
    "no_copy": 0, 
    "oldfieldname": "mtn_details", 
@@ -346,76 +534,254 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "description": "Get valuation rate and available stock at source/target warehouse on mentioned posting date-time. If serialized item, please press this button after entering serial nos.", 
    "fieldname": "get_stock_and_rate", 
    "fieldtype": "Button", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Get Stock and Rate", 
+   "no_copy": 0, 
    "oldfieldtype": "Button", 
    "options": "get_stock_and_rate", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "section_break_19", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "total_incoming_value", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Total Incoming Value", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "precision": "", 
-   "read_only": 1
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "column_break_22", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "total_outgoing_value", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Total Outgoing Value", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "precision": "", 
-   "read_only": 1
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "value_difference", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Total Value Difference (Out - In)", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "precision": "", 
-   "read_only": 1
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "description": "This will override Difference Account in Item", 
    "fieldname": "difference_account", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Difference Account", 
+   "no_copy": 0, 
    "options": "Account", 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "additional_costs_section", 
+   "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Additional Costs", 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "additional_costs", 
+   "fieldtype": "Table", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Additional Costs", 
+   "no_copy": 0, 
+   "options": "Landed Cost Taxes and Charges", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "total_additional_costs", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Total Additional Costs", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "fieldname": "fold", 
    "fieldtype": "Fold", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Subcontract\"], doc.purpose)", 
    "fieldname": "contact_section", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "", 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -423,7 +789,9 @@
    "fieldname": "supplier", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Supplier", 
    "no_copy": 1, 
    "oldfieldname": "supplier", 
@@ -434,7 +802,9 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -442,7 +812,9 @@
    "fieldname": "supplier_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Supplier Name", 
    "no_copy": 1, 
    "oldfieldname": "supplier_name", 
@@ -452,7 +824,9 @@
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -460,7 +834,9 @@
    "fieldname": "supplier_address", 
    "fieldtype": "Small Text", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Supplier Address", 
    "no_copy": 1, 
    "oldfieldname": "supplier_address", 
@@ -470,13 +846,28 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "column_break_39", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -484,7 +875,9 @@
    "fieldname": "customer", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Customer", 
    "no_copy": 1, 
    "oldfieldname": "customer", 
@@ -495,7 +888,9 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -503,7 +898,9 @@
    "fieldname": "customer_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Customer Name", 
    "no_copy": 1, 
    "oldfieldname": "customer_name", 
@@ -513,7 +910,9 @@
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -521,7 +920,9 @@
    "fieldname": "customer_address", 
    "fieldtype": "Small Text", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Customer Address", 
    "no_copy": 1, 
    "oldfieldname": "customer_address", 
@@ -531,33 +932,60 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "more_info", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "", 
+   "no_copy": 0, 
    "oldfieldtype": "Section Break", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "project_name", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
+   "in_list_view": 0, 
    "label": "Project Name", 
+   "no_copy": 0, 
    "oldfieldname": "project_name", 
    "oldfieldtype": "Link", 
    "options": "Project", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "remarks", 
    "fieldtype": "Text", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Remarks", 
    "no_copy": 1, 
    "oldfieldname": "remarks", 
@@ -567,30 +995,58 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col5", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
+   "print_hide": 0, 
    "print_width": "50%", 
    "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0, 
    "width": "50%"
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "total_amount", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Total Amount", 
+   "no_copy": 0, 
    "options": "Company:company:default_currency", 
    "permlevel": 0, 
-   "read_only": 1
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
    "fieldname": "company", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
+   "in_list_view": 0, 
    "label": "Company", 
    "no_copy": 0, 
    "oldfieldname": "company", 
@@ -601,25 +1057,38 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "fiscal_year", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Fiscal Year", 
+   "no_copy": 0, 
    "options": "Fiscal Year", 
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 0, 
-   "reqd": 1
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 1, 
    "fieldname": "select_print_heading", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Print Heading", 
    "no_copy": 0, 
    "oldfieldname": "select_print_heading", 
@@ -630,15 +1099,30 @@
    "read_only": 0, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "letter_head", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Letter Head", 
+   "no_copy": 0, 
    "options": "Letter Head", 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 0, 
@@ -647,6 +1131,7 @@
    "hidden": 0, 
    "ignore_user_permissions": 1, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Amended From", 
    "no_copy": 1, 
    "oldfieldname": "amended_from", 
@@ -657,16 +1142,30 @@
    "read_only": 1, 
    "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "credit_note", 
    "fieldtype": "Link", 
    "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Credit Note", 
+   "no_copy": 0, 
    "options": "Journal Entry", 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }
  ], 
  "hide_heading": 0, 
@@ -677,8 +1176,9 @@
  "in_dialog": 0, 
  "is_submittable": 1, 
  "issingle": 0, 
+ "istable": 0, 
  "max_attachments": 0, 
- "modified": "2015-07-22 18:47:20.328749", 
+ "modified": "2015-08-07 12:28:35.832492", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Entry", 
@@ -691,11 +1191,15 @@
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Stock User", 
+   "set_user_permissions": 0, 
    "share": 1, 
    "submit": 1, 
    "write": 1
@@ -707,41 +1211,55 @@
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Manufacturing User", 
+   "set_user_permissions": 0, 
    "share": 1, 
    "submit": 1, 
    "write": 1
   }, 
   {
    "amend": 1, 
+   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Manufacturing Manager", 
+   "set_user_permissions": 0, 
    "share": 1, 
    "submit": 1, 
    "write": 1
   }, 
   {
    "amend": 1, 
+   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": 0, 
+   "if_owner": 0, 
+   "import": 0, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
    "role": "Stock Manager", 
+   "set_user_permissions": 0, 
    "share": 1, 
    "submit": 1, 
    "write": 1
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 051d9fc..62f5b88 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -29,8 +29,7 @@
 	def onload(self):
 		if self.docstatus==1:
 			for item in self.get("items"):
-				item.update(get_available_qty(item.item_code,
-					item.s_warehouse))
+				item.update(get_available_qty(item.item_code, item.s_warehouse))
 
 	def validate(self):
 		self.pro_doc = None
@@ -46,14 +45,13 @@
 		self.validate_uom_is_integer("stock_uom", "transfer_qty")
 		self.validate_warehouse()
 		self.validate_production_order()
-		self.get_stock_and_rate()
 		self.validate_bom()
 		self.validate_finished_goods()
 		self.validate_with_material_request()
-		self.validate_valuation_rate()
-		self.set_total_incoming_outgoing_value()
-		self.set_total_amount()
 		self.validate_batch()
+		
+		self.set_actual_qty()
+		self.calculate_rate_and_amount()
 
 	def on_submit(self):
 		self.update_stock_ledger()
@@ -213,6 +211,88 @@
 			if fg_qty_already_entered >= qty:
 				frappe.throw(_("Stock Entries already created for Production Order ")
 					+ self.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
+		
+	def set_actual_qty(self):
+		allow_negative_stock = cint(frappe.db.get_value("Stock Settings", None, "allow_negative_stock"))
+		
+		for d in self.get('items'):
+			previous_sle = get_previous_sle({
+				"item_code": d.item_code,
+				"warehouse": d.s_warehouse or d.t_warehouse,
+				"posting_date": self.posting_date,
+				"posting_time": self.posting_time
+			})
+
+			# get actual stock at source warehouse
+			d.actual_qty = previous_sle.get("qty_after_transaction") or 0
+
+			# validate qty during submit
+			if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty:
+				frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}.
+					Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse,
+					self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty), NegativeStockError)
+
+	def calculate_rate_and_amount(self, force=False):
+		self.set_basic_rate(force)
+		self.distribute_additional_costs()
+		self.update_valuation_rate()
+		self.validate_valuation_rate()
+		self.set_total_incoming_outgoing_value()
+		self.set_total_amount()
+		
+	def set_basic_rate(self, force=False):
+		"""get stock and incoming rate on posting date"""
+		raw_material_cost = 0.0
+
+		for d in self.get('items'):
+			args = frappe._dict({
+				"item_code": d.item_code,
+				"warehouse": d.s_warehouse or d.t_warehouse,
+				"posting_date": self.posting_date,
+				"posting_time": self.posting_time,
+				"qty": d.s_warehouse and -1*flt(d.transfer_qty) or flt(d.transfer_qty),
+				"serial_no": d.serial_no,
+			})
+
+			# get basic rate
+			if not d.bom_no:
+				if not flt(d.basic_rate) or d.s_warehouse or force:
+					basic_rate = flt(get_incoming_rate(args), self.precision("basic_rate", d))
+					if basic_rate > 0:
+						d.basic_rate = basic_rate
+
+				d.basic_amount = flt(flt(d.transfer_qty) * flt(d.basic_rate), d.precision("basic_amount"))
+				if not d.t_warehouse:
+					raw_material_cost += flt(d.basic_amount)
+					
+		self.set_basic_rate_for_finished_goods(raw_material_cost)
+		
+	def set_basic_rate_for_finished_goods(self, raw_material_cost):
+		if self.purpose in ["Manufacture", "Repack"]:
+			number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
+			for d in self.get("items"):
+				if d.bom_no or (d.t_warehouse and number_of_fg_items == 1):
+					d.basic_rate = flt(raw_material_cost / flt(d.transfer_qty), d.precision("basic_rate"))
+					d.basic_amount = flt(flt(d.basic_rate) * flt(d.transfer_qty), d.precision("basic_amount"))
+					
+	def distribute_additional_costs(self):
+		if self.purpose == "Material Issue":
+			self.additional_costs = []
+			
+		self.total_additional_costs = sum([flt(t.amount) for t in self.get("additional_costs")])
+		total_basic_amount = sum([flt(t.basic_amount) for t in self.get("items") if t.t_warehouse])
+
+		for d in self.get("items"):
+			if d.t_warehouse and total_basic_amount:
+				d.additional_cost = (flt(d.basic_amount) / total_basic_amount) * self.total_additional_costs
+			else:
+				d.additional_cost = 0
+				
+	def update_valuation_rate(self):
+		for d in self.get("items"):
+			d.amount = flt(d.basic_amount + flt(d.additional_cost), d.precision("amount"))
+			d.valuation_rate = flt(flt(d.basic_rate) + flt(d.additional_cost) / flt(d.transfer_qty), 
+				d.precision("valuation_rate"))
 
 	def validate_valuation_rate(self):
 		if self.purpose in ["Manufacture", "Repack"]:
@@ -224,100 +304,22 @@
 					valuation_at_target += flt(d.amount)
 
 			if valuation_at_target + 0.001 < valuation_at_source:
-				frappe.throw(_("Total valuation ({0}) for manufactured or repacked item(s) can not be less than total valuation of raw materials ({1})").format(valuation_at_target,
-					valuation_at_source))
+				frappe.throw(_("Total valuation ({0}) for manufactured or repacked item(s) can not be less than total valuation of raw materials ({1})")
+					.format(valuation_at_target, valuation_at_source))
 
 	def set_total_incoming_outgoing_value(self):
 		self.total_incoming_value = self.total_outgoing_value = 0.0
 		for d in self.get("items"):
-			if d.s_warehouse:
-				self.total_incoming_value += flt(d.amount)
 			if d.t_warehouse:
+				self.total_incoming_value += flt(d.amount)
+			if d.s_warehouse:
 				self.total_outgoing_value += flt(d.amount)
 
-		self.value_difference = self.total_outgoing_value - self.total_incoming_value
+		self.value_difference = self.total_incoming_value - self.total_outgoing_value
 
 	def set_total_amount(self):
 		self.total_amount = sum([flt(item.amount) for item in self.get("items")])
 
-	def get_stock_and_rate(self, force=False):
-		"""get stock and incoming rate on posting date"""
-
-		raw_material_cost = 0.0
-
-		if not self.posting_date or not self.posting_time:
-			frappe.throw(_("Posting date and posting time is mandatory"))
-
-		allow_negative_stock = cint(frappe.db.get_value("Stock Settings", None, "allow_negative_stock"))
-
-		for d in self.get('items'):
-			d.transfer_qty = flt(d.transfer_qty)
-
-			args = frappe._dict({
-				"item_code": d.item_code,
-				"warehouse": d.s_warehouse or d.t_warehouse,
-				"posting_date": self.posting_date,
-				"posting_time": self.posting_time,
-				"qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty,
-				"serial_no": d.serial_no,
-			})
-
-			# get actual stock at source warehouse
-			d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0
-
-			# validate qty during submit
-			if d.docstatus==1 and d.s_warehouse and not allow_negative_stock and d.actual_qty < d.transfer_qty:
-				frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}.
-					Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse,
-					self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty), NegativeStockError)
-
-			# get incoming rate
-			if not d.bom_no:
-				if not flt(d.incoming_rate) or d.s_warehouse or force:
-					incoming_rate = flt(get_incoming_rate(args), self.precision("incoming_rate", d))
-					if incoming_rate > 0:
-						d.incoming_rate = incoming_rate
-
-				d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), d.precision("amount"))
-				if not d.t_warehouse:
-					raw_material_cost += flt(d.amount)
-
-
-		self.add_operation_cost(raw_material_cost, force)
-
-	def add_operation_cost(self, raw_material_cost, force):
-		"""Adds operating cost if Production Order is set"""
-		# set incoming rate for fg item
-		if self.purpose in ["Manufacture", "Repack"]:
-			number_of_fg_items = len([t.t_warehouse for t in self.get("items") if t.t_warehouse])
-			for d in self.get("items"):
-				if d.bom_no or (d.t_warehouse and number_of_fg_items == 1):
-					operation_cost_per_unit = self.get_operation_cost_per_unit(d.bom_no, d.qty)
-
-					d.incoming_rate = operation_cost_per_unit + (raw_material_cost / flt(d.transfer_qty))
-					d.amount = flt(flt(d.transfer_qty) * flt(d.incoming_rate), self.precision("transfer_qty", d))
-					break
-
-	def get_operation_cost_per_unit(self, bom_no, qty):
-		"""Returns operating cost from Production Order for given `bom_no`"""
-		operation_cost_per_unit = 0
-
-		if self.production_order:
-			if not getattr(self, "pro_doc", None):
-				self.pro_doc = frappe.get_doc("Production Order", self.production_order)
-			for d in self.pro_doc.get("operations"):
-				if flt(d.completed_qty):
-					operation_cost_per_unit += flt(d.actual_operating_cost) / flt(d.completed_qty)
-				else:
-					operation_cost_per_unit += flt(d.planned_operating_cost) / flt(self.pro_doc.qty)
-
-		# set operating cost from BOM if specified.
-		if not operation_cost_per_unit and bom_no:
-			bom = frappe.db.get_value("BOM", bom_no, ["operating_cost", "quantity"], as_dict=1)
-			operation_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
-
-		return operation_cost_per_unit + (flt(self.additional_operating_cost) / flt(qty))
-
 	def validate_purchase_order(self):
 		"""Throw exception if more raw material is transferred against Purchase Order than in
 		the raw materials supplied table"""
@@ -366,7 +368,7 @@
 
 	def update_stock_ledger(self):
 		sl_entries = []
-		for d in self.get('items'):
+		for d in self.get('items'):			
 			if cstr(d.s_warehouse) and self.docstatus == 1:
 				sl_entries.append(self.get_sl_entries(d, {
 					"warehouse": cstr(d.s_warehouse),
@@ -378,7 +380,7 @@
 				sl_entries.append(self.get_sl_entries(d, {
 					"warehouse": cstr(d.t_warehouse),
 					"actual_qty": flt(d.transfer_qty),
-					"incoming_rate": flt(d.incoming_rate)
+					"incoming_rate": flt(d.valuation_rate)
 				}))
 
 			# On cancellation, make stock ledger entry for
@@ -392,6 +394,32 @@
 				}))
 
 		self.make_sl_entries(sl_entries, self.amended_from and 'Yes' or 'No')
+		
+	def get_gl_entries(self, warehouse_account):
+		expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
+		
+		gl_entries = super(StockEntry, self).get_gl_entries(warehouse_account)
+		
+		for d in self.get("items"):
+			additional_cost = flt(d.additional_cost, d.precision("additional_cost"))
+			if additional_cost:			
+				gl_entries.append(self.get_gl_dict({
+					"account": expenses_included_in_valuation,
+					"against": d.expense_account,
+					"cost_center": d.cost_center,
+					"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
+					"credit": additional_cost
+				}))
+			
+				gl_entries.append(self.get_gl_dict({
+					"account": d.expense_account,
+					"against": expenses_included_in_valuation,
+					"cost_center": d.cost_center,
+					"remarks": self.get("remarks") or _("Accounting Entry for Stock"),
+					"credit": -1 * additional_cost # put it as negative credit instead of debit purposefully
+				}))
+
+		return gl_entries
 
 	def update_production_order(self):
 		def _validate_production_order(pro_doc):
@@ -442,7 +470,7 @@
 			'conversion_factor'		: 1,
 			'batch_no'				: '',
 			'actual_qty'			: 0,
-			'incoming_rate'			: 0
+			'basic_rate'			: 0
 		}
 		for d in [["Account", "expense_account", "default_expense_account"],
 			["Cost Center", "cost_center", "cost_center"]]:
@@ -490,13 +518,16 @@
 
 			ret = {
 				"actual_qty" : get_previous_sle(args).get("qty_after_transaction") or 0,
-				"incoming_rate" : get_incoming_rate(args)
+				"basic_rate" : get_incoming_rate(args)
 			}
 		return ret
 
 	def get_items(self):
 		self.set('items', [])
 		self.validate_production_order()
+		
+		if not self.posting_date or not self.posting_time:
+			frappe.throw(_("Posting date and posting time is mandatory"))
 
 		if not getattr(self, "pro_doc", None):
 			self.pro_doc = None
@@ -520,6 +551,12 @@
 					if self.to_warehouse and self.pro_doc:
 						for item in item_dict.values():
 							item["to_warehouse"] = self.pro_doc.wip_warehouse
+					self.add_to_stock_entry_detail(item_dict)
+					
+				elif self.production_order and self.purpose == "Manufacture" and \
+					frappe.db.get_single_value("Manufacturing Settings", "backflush_raw_materials_based_on")== "Material Transferred for Manufacture":
+					self.get_transfered_raw_materials()
+
 				else:
 					if not self.fg_completed_qty:
 						frappe.throw(_("Manufacturing Quantity is mandatory"))
@@ -530,15 +567,14 @@
 							item["from_warehouse"] = self.pro_doc.wip_warehouse
 
 						item["to_warehouse"] = self.to_warehouse if self.purpose=="Subcontract" else ""
-
-				# add raw materials to Stock Entry Detail table
-				self.add_to_stock_entry_detail(item_dict)
+					self.add_to_stock_entry_detail(item_dict)
 
 			# add finished goods item
 			if self.purpose in ("Manufacture", "Repack"):
 				self.load_items_from_bom()
 
-		self.get_stock_and_rate()
+		self.set_actual_qty()
+		self.calculate_rate_and_amount()
 
 	def load_items_from_bom(self):
 		if self.production_order:
@@ -568,12 +604,70 @@
 		from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
 
 		# item dict = { item_code: {qty, description, stock_uom} }
-		item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty, fetch_exploded = self.use_multi_level_bom)
+		item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty, 
+			fetch_exploded = self.use_multi_level_bom)
 
 		for item in item_dict.values():
 			item.from_warehouse = self.from_warehouse or item.default_warehouse
-
 		return item_dict
+		
+	def get_transfered_raw_materials(self):
+		transferred_materials = frappe.db.sql("""
+			select 
+				item_name, item_code, sum(qty) as qty, sed.t_warehouse as warehouse, 
+				description, stock_uom, expense_account, cost_center 
+			from `tabStock Entry` se,`tabStock Entry Detail` sed 
+			where 
+				se.name = sed.parent and se.docstatus=1 and se.purpose='Material Transfer for Manufacture' 
+				and se.production_order= %s and ifnull(sed.t_warehouse, '') != '' 
+			group by sed.item_code, sed.t_warehouse
+		""", self.production_order, as_dict=1)
+		
+		materials_already_backflushed = frappe.db.sql("""
+			select 
+				item_code, sed.s_warehouse as warehouse, sum(qty) as qty 
+			from 
+				`tabStock Entry` se, `tabStock Entry Detail` sed 
+			where 
+				se.name = sed.parent and se.docstatus=1 and se.purpose='Manufacture' 
+				and se.production_order= %s and ifnull(sed.s_warehouse, '') != '' 
+			group by sed.item_code, sed.s_warehouse
+		""", self.production_order, as_dict=1)
+		
+		backflushed_materials= {}
+		for d in materials_already_backflushed:
+			backflushed_materials.setdefault(d.item_code,[]).append({d.warehouse: d.qty})
+		
+		po_qty = frappe.db.sql("""select qty, produced_qty, material_transferred_for_manufacturing from
+			`tabProduction Order` where name=%s""", self.production_order, as_dict=1)[0]
+		manufacturing_qty = flt(po_qty.qty)
+		produced_qty = flt(po_qty.produced_qty)
+		trans_qty = flt(po_qty.material_transferred_for_manufacturing)
+		
+		for item in transferred_materials:
+			qty= item.qty
+			
+			if manufacturing_qty > (produced_qty + flt(self.fg_completed_qty)):
+				qty = (qty/trans_qty) * flt(self.fg_completed_qty)
+			
+			elif backflushed_materials.get(item.item_code):
+				for d in backflushed_materials.get(item.item_code):
+					if d.get(item.warehouse):
+						qty-= d.get(item.warehouse)
+				
+			if qty > 0:
+				self.add_to_stock_entry_detail({
+					item.item_code: {
+						"from_warehouse": item.warehouse,
+						"to_warehouse": "",
+						"qty": qty,
+						"item_name": item.item_name,
+						"description": item.description,
+						"stock_uom": item.stock_uom,
+						"expense_account": item.expense_account,
+						"cost_center": item.buying_cost_center,
+					}
+				})
 
 	def get_pending_raw_materials(self):
 		"""
@@ -639,7 +733,7 @@
 				se_child.s_warehouse = self.from_warehouse
 			if se_child.t_warehouse==None:
 				se_child.t_warehouse = self.to_warehouse
-
+				
 			# in stock uom
 			se_child.transfer_qty = flt(item_dict[d]["qty"])
 			se_child.conversion_factor = 1.00
@@ -667,12 +761,56 @@
 						if getdate(self.posting_date) > getdate(expiry_date):
 							frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
 
-
 @frappe.whitelist()
 def get_production_order_details(production_order):
-	res = frappe.db.sql("""select bom_no, use_multi_level_bom, wip_warehouse,
-		ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty,
-		(ifnull(additional_operating_cost, 0) / qty)*(ifnull(qty, 0) - ifnull(produced_qty, 0)) as additional_operating_cost
-		from `tabProduction Order` where name = %s""", production_order, as_dict=1)
-
-	return res and res[0] or {}
+	production_order = frappe.get_doc("Production Order", production_order)
+	pending_qty_to_produce = flt(production_order.qty) - flt(production_order.produced_qty)
+	
+	return {
+		"from_bom": 1,
+		"bom_no": production_order.bom_no,
+		"use_multi_level_bom": production_order.use_multi_level_bom,
+		"wip_warehouse": production_order.wip_warehouse,
+		"fg_warehouse": production_order.fg_warehouse,
+		"fg_completed_qty": pending_qty_to_produce,
+		"additional_costs": get_additional_costs(production_order, fg_qty=pending_qty_to_produce)
+	}
+	
+def get_additional_costs(production_order=None, bom_no=None, fg_qty=None):
+	additional_costs = []
+	operating_cost_per_unit = get_operating_cost_per_unit(production_order, bom_no)
+	if operating_cost_per_unit:
+		additional_costs.append({
+			"description": "Operating Cost as per Production Order / BOM",
+			"amount": operating_cost_per_unit * flt(fg_qty)
+		})
+	
+	if production_order and production_order.additional_operating_cost:
+		additional_operating_cost_per_unit = \
+			flt(production_order.additional_operating_cost) / flt(production_order.qty)
+			
+		additional_costs.append({
+			"description": "Additional Operating Cost",
+			"amount": additional_operating_cost_per_unit * flt(fg_qty)
+		})
+		
+	return additional_costs
+	
+def get_operating_cost_per_unit(production_order=None, bom_no=None):
+	operating_cost_per_unit = 0
+	if production_order:
+		if not bom_no:
+			bom_no = production_order.bom_no
+		
+		for d in production_order.get("operations"):
+			if flt(d.completed_qty):
+				operating_cost_per_unit += flt(d.actual_operating_cost) / flt(d.completed_qty)
+			else:
+				operating_cost_per_unit += flt(d.planned_operating_cost) / flt(production_order.qty)
+				
+	# Get operating cost from BOM if not found in production_order.
+	if not operating_cost_per_unit and bom_no:
+		bom = frappe.db.get_value("BOM", bom_no, ["operating_cost", "quantity"], as_dict=1)
+		operating_cost_per_unit = flt(bom.operating_cost) / flt(bom.quantity)
+		
+	return operating_cost_per_unit
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/test_records.json b/erpnext/stock/doctype/stock_entry/test_records.json
index f4d2044..f648b9e 100644
--- a/erpnext/stock/doctype/stock_entry/test_records.json
+++ b/erpnext/stock/doctype/stock_entry/test_records.json
@@ -8,7 +8,7 @@
     "cost_center": "_Test Cost Center - _TC",
     "doctype": "Stock Entry Detail",
     "expense_account": "Stock Adjustment - _TC",
-    "incoming_rate": 100,
+    "basic_rate": 100,
     "item_code": "_Test Item",
     "parentfield": "items",
     "qty": 50.0,
@@ -32,7 +32,7 @@
     "cost_center": "_Test Cost Center - _TC",
     "doctype": "Stock Entry Detail",
     "expense_account": "Stock Adjustment - _TC",
-    "incoming_rate": 100,
+    "basic_rate": 100,
     "item_code": "_Test Item",
     "parentfield": "items",
     "qty": 40.0,
@@ -57,7 +57,7 @@
     "cost_center": "_Test Cost Center - _TC",
     "doctype": "Stock Entry Detail",
     "expense_account": "Stock Adjustment - _TC",
-    "incoming_rate": 100,
+    "basic_rate": 100,
     "item_code": "_Test Item",
     "parentfield": "items",
     "qty": 45.0,
@@ -83,7 +83,7 @@
     "cost_center": "_Test Cost Center - _TC",
     "doctype": "Stock Entry Detail",
     "expense_account": "Stock Adjustment - _TC",
-    "incoming_rate": 100,
+    "basic_rate": 100,
     "item_code": "_Test Item",
     "parentfield": "items",
     "qty": 50.0,
@@ -97,7 +97,7 @@
     "cost_center": "_Test Cost Center - _TC",
     "doctype": "Stock Entry Detail",
     "expense_account": "Stock Adjustment - _TC",
-    "incoming_rate": 5000,
+    "basic_rate": 5000,
     "item_code": "_Test Item Home Desktop 100",
     "parentfield": "items",
     "qty": 1,
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index d283c3d..f00a235 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -36,12 +36,12 @@
 		create_stock_reconciliation(item_code="_Test Item 2", warehouse="_Test Warehouse - _TC",
 			qty=0, rate=100)
 
-		make_stock_entry(item_code=item_code, target=warehouse, qty=1, incoming_rate=10)
+		make_stock_entry(item_code=item_code, target=warehouse, qty=1, basic_rate=10)
 		sle = get_sle(item_code = item_code, warehouse = warehouse)[0]
 		self.assertEqual([[1, 10]], eval(sle.stock_queue))
 
 		# negative qty
-		make_stock_entry(item_code=item_code, source=warehouse, qty=2, incoming_rate=10)
+		make_stock_entry(item_code=item_code, source=warehouse, qty=2, basic_rate=10)
 		sle = get_sle(item_code = item_code, warehouse = warehouse)[0]
 
 		self.assertEqual([[-1, 10]], eval(sle.stock_queue))
@@ -53,12 +53,12 @@
 		self.assertEqual([[-2, 10]], eval(sle.stock_queue))
 
 		# move stock to positive
-		make_stock_entry(item_code=item_code, target=warehouse, qty=3, incoming_rate=20)
+		make_stock_entry(item_code=item_code, target=warehouse, qty=3, basic_rate=20)
 		sle = get_sle(item_code = item_code, warehouse = warehouse)[0]
 		self.assertEqual([[1, 20]], eval(sle.stock_queue))
 
 		# incoming entry with diff rate
-		make_stock_entry(item_code=item_code, target=warehouse, qty=1, incoming_rate=30)
+		make_stock_entry(item_code=item_code, target=warehouse, qty=1, basic_rate=30)
 		sle = get_sle(item_code = item_code, warehouse = warehouse)[0]
 
 		self.assertEqual([[1, 20],[1, 30]], eval(sle.stock_queue))
@@ -125,7 +125,7 @@
 		set_perpetual_inventory()
 
 		mr = make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC",
-			qty=50, incoming_rate=100)
+			qty=50, basic_rate=100)
 
 		stock_in_hand_account = frappe.db.get_value("Account", {"account_type": "Warehouse",
 			"warehouse": mr.get("items")[0].t_warehouse})
@@ -152,7 +152,7 @@
 		set_perpetual_inventory()
 
 		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC",
-			qty=50, incoming_rate=100)
+			qty=50, basic_rate=100)
 
 		mi = make_stock_entry(item_code="_Test Item", source="_Test Warehouse - _TC", qty=40)
 
@@ -217,9 +217,9 @@
 	def test_repack_no_change_in_valuation(self):
 		set_perpetual_inventory(0)
 
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
 		make_stock_entry(item_code="_Test Item Home Desktop 100", target="_Test Warehouse - _TC",
-			qty=50, incoming_rate=100)
+			qty=50, basic_rate=100)
 
 		repack = frappe.copy_doc(test_records[3])
 		repack.posting_date = nowdate()
@@ -238,15 +238,24 @@
 
 		set_perpetual_inventory(0)
 
-	def test_repack_with_change_in_valuation(self):
+	def test_repack_with_additional_costs(self):
 		set_perpetual_inventory()
 
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
-
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
 		repack = frappe.copy_doc(test_records[3])
 		repack.posting_date = nowdate()
 		repack.posting_time = nowtime()
-		repack.additional_operating_cost = 1000.0
+		
+		repack.set("additional_costs", [
+			{
+				"description": "Actual Oerating Cost",
+				"amount": 1000
+			},
+			{
+				"description": "additional operating costs",
+				"amount": 200
+			},
+		])
 		repack.insert()
 		repack.submit()
 
@@ -260,11 +269,13 @@
 			"voucher_no": repack.name, "item_code": "_Test Item Home Desktop 100"}, "stock_value_difference"))
 
 		stock_value_diff = flt(fg_stock_value_diff - rm_stock_value_diff, 2)
+		
+		self.assertEqual(stock_value_diff, 1200)
 
 		self.check_gl_entries("Stock Entry", repack.name,
 			sorted([
-				[stock_in_hand_account, stock_value_diff, 0.0],
-				["Stock Adjustment - _TC", 0.0, stock_value_diff],
+				[stock_in_hand_account, 1200, 0.0],
+				["Expenses Included In Valuation - _TC", 0.0, 1200.0]
 			])
 		)
 		set_perpetual_inventory(0)
@@ -291,10 +302,9 @@
 		gl_entries = frappe.db.sql("""select account, debit, credit
 			from `tabGL Entry` where voucher_type=%s and voucher_no=%s
 			order by account asc, debit asc""", (voucher_type, voucher_no), as_list=1)
-
+		
 		self.assertTrue(gl_entries)
 		gl_entries.sort(key=lambda x: x[0])
-
 		for i, gle in enumerate(gl_entries):
 			self.assertEquals(expected_gl_entries[i][0], gle[0])
 			self.assertEquals(expected_gl_entries[i][1], gle[1])
@@ -503,6 +513,8 @@
 		frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
 
 	def test_production_order(self):
+		from erpnext.manufacturing.doctype.production_order.production_order \
+			import make_stock_entry as _make_stock_entry
 		bom_no, bom_operation_cost = frappe.db.get_value("BOM", {"item": "_Test FG Item 2",
 			"is_default": 1, "docstatus": 1}, ["name", "operating_cost"])
 
@@ -514,22 +526,15 @@
 			"bom_no": bom_no,
 			"qty": 1.0,
 			"stock_uom": "_Test UOM",
-			"wip_warehouse": "_Test Warehouse - _TC"
+			"wip_warehouse": "_Test Warehouse - _TC",
+			"additional_operating_cost": 1000
 		})
 		production_order.insert()
 		production_order.submit()
 
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, incoming_rate=100)
+		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=50, basic_rate=100)
 
-		stock_entry = frappe.new_doc("Stock Entry")
-		stock_entry.update({
-			"purpose": "Manufacture",
-			"production_order": production_order.name,
-			"bom_no": bom_no,
-			"fg_completed_qty": "1",
-			"additional_operating_cost": 1000
-		})
-		stock_entry.get_items()
+		stock_entry = _make_stock_entry(production_order.name, "Manufacture", 1)
 
 		rm_cost = 0
 		for d in stock_entry.get("items"):
@@ -538,7 +543,7 @@
 
 		fg_cost = filter(lambda x: x.item_code=="_Test FG Item 2", stock_entry.get("items"))[0].amount
 		self.assertEqual(fg_cost, 
-			flt(rm_cost + bom_operation_cost + stock_entry.additional_operating_cost, 2))
+			flt(rm_cost + bom_operation_cost + production_order.additional_operating_cost, 2))
 
 
 	def test_variant_production_order(self):
@@ -610,7 +615,7 @@
 		"s_warehouse": args.from_warehouse or args.source,
 		"t_warehouse": args.to_warehouse or args.target,
 		"qty": args.qty,
-		"incoming_rate": args.incoming_rate,
+		"basic_rate": args.basic_rate,
 		"expense_account": args.expense_account or "Stock Adjustment - _TC",
 		"conversion_factor": 1.0,
 		"cost_center": "_Test Cost Center - _TC"
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index a373185..fe8a1b1 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -1,25 +1,58 @@
 {
+ "allow_copy": 0, 
+ "allow_import": 0, 
+ "allow_rename": 0, 
  "autoname": "hash", 
  "creation": "2013-03-29 18:22:12", 
+ "custom": 0, 
  "docstatus": 0, 
  "doctype": "DocType", 
  "fields": [
   {
+   "allow_on_submit": 0, 
    "fieldname": "barcode", 
    "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Barcode", 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "section_break_2", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "s_warehouse", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Source Warehouse", 
@@ -28,16 +61,38 @@
    "oldfieldtype": "Link", 
    "options": "Warehouse", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col_break1", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "t_warehouse", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Target Warehouse", 
@@ -46,240 +101,631 @@
    "oldfieldtype": "Link", 
    "options": "Warehouse", 
    "permlevel": 0, 
-   "read_only": 0
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "sec_break1", 
    "fieldtype": "Section Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "item_code", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 1, 
    "in_list_view": 1, 
    "label": "Item Code", 
+   "no_copy": 0, 
    "oldfieldname": "item_code", 
    "oldfieldtype": "Link", 
    "options": "Item", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
+   "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col_break2", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "qty", 
    "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 1, 
    "label": "Qty", 
+   "no_copy": 0, 
    "oldfieldname": "qty", 
    "oldfieldtype": "Currency", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 1
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "section_break_8", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "item_name", 
    "fieldtype": "Data", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Item Name", 
+   "no_copy": 0, 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 1
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "description", 
    "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 0, 
    "label": "Description", 
+   "no_copy": 0, 
    "oldfieldname": "description", 
    "oldfieldtype": "Text", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "print_width": "300px", 
    "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0, 
    "width": "300px"
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "column_break_10", 
    "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "image", 
    "fieldtype": "Attach", 
    "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Image", 
+   "no_copy": 0, 
    "permlevel": 0, 
    "precision": "", 
-   "print_hide": 1
+   "print_hide": 1, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "image_view", 
    "fieldtype": "Image", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Image View", 
+   "no_copy": 0, 
    "options": "image", 
    "permlevel": 0, 
-   "precision": ""
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "quantity_and_rate", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Quantity and Rate", 
-   "permlevel": 0
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
-   "fieldname": "incoming_rate", 
+   "allow_on_submit": 0, 
+   "fieldname": "basic_rate", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 1, 
-   "label": "Valuation Rate", 
+   "label": "Basic Rate (as per Stock UOM)", 
+   "no_copy": 0, 
    "oldfieldname": "incoming_rate", 
    "oldfieldtype": "Currency", 
    "options": "Company:company:default_currency", 
    "permlevel": 0, 
+   "print_hide": 1, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "basic_amount", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Basic Amount", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "fieldname": "additional_cost", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Additional Cost", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 1, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "fieldname": "amount", 
    "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Amount", 
+   "no_copy": 0, 
    "oldfieldname": "amount", 
    "oldfieldtype": "Currency", 
    "options": "Company:company:default_currency", 
    "permlevel": 0, 
-   "read_only": 1
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "valuation_rate", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Valuation Rate", 
+   "no_copy": 0, 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "fieldname": "col_break3", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "uom", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
    "in_list_view": 0, 
    "label": "UOM", 
+   "no_copy": 0, 
    "oldfieldname": "uom", 
    "oldfieldtype": "Link", 
    "options": "UOM", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 1
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "conversion_factor", 
    "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Conversion Factor", 
+   "no_copy": 0, 
    "oldfieldname": "conversion_factor", 
    "oldfieldtype": "Currency", 
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 1, 
-   "reqd": 1
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "stock_uom", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
    "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Stock UOM", 
+   "no_copy": 0, 
    "oldfieldname": "stock_uom", 
    "oldfieldtype": "Link", 
    "options": "UOM", 
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 1, 
+   "report_hide": 0, 
    "reqd": 1, 
-   "search_index": 0
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
+   "fieldname": "transfer_qty", 
+   "fieldtype": "Float", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "label": "Qty as per Stock UOM", 
+   "no_copy": 0, 
+   "oldfieldname": "transfer_qty", 
+   "oldfieldtype": "Currency", 
+   "permlevel": 0, 
+   "print_hide": 1, 
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "fieldname": "serial_no_batch", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Serial No / Batch", 
-   "permlevel": 0
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "serial_no", 
    "fieldtype": "Text", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Serial No", 
    "no_copy": 1, 
    "oldfieldname": "serial_no", 
    "oldfieldtype": "Text", 
    "permlevel": 0, 
+   "print_hide": 0, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col_break4", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "batch_no", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Batch No", 
+   "no_copy": 0, 
    "oldfieldname": "batch_no", 
    "oldfieldtype": "Link", 
    "options": "Batch", 
    "permlevel": 0, 
    "print_hide": 0, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "accounting", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Accounting", 
-   "permlevel": 0
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
    "fieldname": "expense_account", 
    "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Difference Account", 
+   "no_copy": 0, 
    "options": "Account", 
    "permlevel": 0, 
-   "print_hide": 1
+   "print_hide": 1, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col_break5", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "default": ":Company", 
    "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
    "fieldname": "cost_center", 
    "fieldtype": "Link", 
    "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Cost Center", 
+   "no_copy": 0, 
    "options": "Cost Center", 
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 0, 
-   "reqd": 0
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "more_info", 
    "fieldtype": "Section Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "More Info", 
-   "permlevel": 0
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
    "allow_on_submit": 1, 
    "fieldname": "actual_qty", 
    "fieldtype": "Float", 
+   "hidden": 0, 
    "ignore_user_permissions": 0, 
    "in_filter": 1, 
+   "in_list_view": 0, 
    "label": "Actual Qty (at source/target)", 
    "no_copy": 1, 
    "oldfieldname": "actual_qty", 
@@ -287,67 +733,107 @@
    "permlevel": 0, 
    "print_hide": 1, 
    "read_only": 1, 
+   "report_hide": 0, 
    "reqd": 0, 
-   "search_index": 1
+   "search_index": 1, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "description": "BOM No. for a Finished Good Item", 
    "fieldname": "bom_no", 
    "fieldtype": "Link", 
    "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "BOM No", 
    "no_copy": 0, 
    "options": "BOM", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 0
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "col_break6", 
    "fieldtype": "Column Break", 
-   "permlevel": 0
-  }, 
-  {
-   "fieldname": "transfer_qty", 
-   "fieldtype": "Float", 
-   "label": "Qty as per Stock UOM", 
-   "oldfieldname": "transfer_qty", 
-   "oldfieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "no_copy": 0, 
    "permlevel": 0, 
-   "print_hide": 1, 
-   "read_only": 1, 
-   "reqd": 1
+   "print_hide": 0, 
+   "read_only": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "description": "Material Request used to make this Stock Entry", 
    "fieldname": "material_request", 
    "fieldtype": "Link", 
    "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Material Request", 
    "no_copy": 1, 
    "options": "Material Request", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 1
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }, 
   {
+   "allow_on_submit": 0, 
    "fieldname": "material_request_item", 
    "fieldtype": "Link", 
    "hidden": 1, 
+   "ignore_user_permissions": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
    "label": "Material Request Item", 
    "no_copy": 1, 
    "options": "Material Request Item", 
    "permlevel": 0, 
    "print_hide": 1, 
-   "read_only": 1
+   "read_only": 1, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
   }
  ], 
+ "hide_heading": 0, 
+ "hide_toolbar": 0, 
  "idx": 1, 
+ "in_create": 0, 
+ "in_dialog": 0, 
+ "is_submittable": 0, 
+ "issingle": 0, 
  "istable": 1, 
- "modified": "2015-07-02 05:32:56.511570", 
+ "modified": "2015-08-07 13:21:23.840052", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Stock Entry Detail", 
  "owner": "Administrator", 
- "permissions": []
+ "permissions": [], 
+ "read_only": 0, 
+ "read_only_onload": 0
 }
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
index dde3386..fa2fa13 100644
--- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
@@ -82,13 +82,13 @@
 		from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
 
 		make_stock_entry(posting_date="2012-12-15", posting_time="02:00", item_code="_Test Item",
-			target="_Test Warehouse - _TC", qty=10, incoming_rate=700)
+			target="_Test Warehouse - _TC", qty=10, basic_rate=700)
 
 		make_stock_entry(posting_date="2012-12-25", posting_time="03:00", item_code="_Test Item",
 			source="_Test Warehouse - _TC", qty=15)
 
 		make_stock_entry(posting_date="2013-01-05", posting_time="07:00", item_code="_Test Item",
-			target="_Test Warehouse - _TC", qty=15, incoming_rate=1200)
+			target="_Test Warehouse - _TC", qty=15, basic_rate=1200)
 
 def create_stock_reconciliation(**args):
 	args = frappe._dict(args)
diff --git a/erpnext/templates/form_grid/stock_entry_grid.html b/erpnext/templates/form_grid/stock_entry_grid.html
index 1782b82..a2bf1df 100644
--- a/erpnext/templates/form_grid/stock_entry_grid.html
+++ b/erpnext/templates/form_grid/stock_entry_grid.html
@@ -1,6 +1,6 @@
 {% var visible_columns = row.get_visible_columns(["item_code",
 	"item_name", "amount", "stock_uom", "uom", "qty",
-	"s_warehouse", "t_warehouse", "incoming_rate"]);
+	"s_warehouse", "t_warehouse", "valuation_rate"]);
 %}
 
 {% if(!doc) { %}
@@ -43,7 +43,7 @@
 		<div class="col-sm-2 col-xs-2 text-right">
 			{%= doc.get_formatted("amount") %}
 			<div class="small text-muted">
-				{%= doc.get_formatted("incoming_rate") %}
+				{%= doc.get_formatted("valuation_rate") %}
 			</div>
 		</div>
 	</div>
diff --git a/erpnext/utilities/doctype/address/address.json b/erpnext/utilities/doctype/address/address.json
index 7cb8d82..a4d7a55 100644
--- a/erpnext/utilities/doctype/address/address.json
+++ b/erpnext/utilities/doctype/address/address.json
@@ -101,7 +101,7 @@
    "fieldtype": "Data", 
    "label": "Phone", 
    "permlevel": 0, 
-   "reqd": 1
+   "reqd": 0
   }, 
   {
    "fieldname": "fax", 
@@ -199,7 +199,7 @@
  "icon": "icon-map-marker", 
  "idx": 1, 
  "in_dialog": 0, 
- "modified": "2015-06-01 06:42:18.331818", 
+ "modified": "2015-08-10 19:42:18.331818", 
  "modified_by": "Administrator", 
  "module": "Utilities", 
  "name": "Address", 
diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py
index 52b94ae..3cb18ee 100644
--- a/erpnext/utilities/repost_stock.py
+++ b/erpnext/utilities/repost_stock.py
@@ -237,7 +237,7 @@
 
 			doc = frappe.get_doc(voucher_type, voucher_no)
 			if voucher_type=="Stock Entry" and doc.purpose in ["Manufacture", "Repack"]:
-				doc.get_stock_and_rate(force=1)
+				doc.calculate_rate_and_amount(force=1)
 			elif voucher_type=="Purchase Receipt" and doc.is_subcontracted == "Yes":
 				doc.validate()
 
diff --git a/sponsors.md b/sponsors.md
index 5f6c2f2..9b84487 100644
--- a/sponsors.md
+++ b/sponsors.md
@@ -29,5 +29,13 @@
 				For Sales / Purchase Return Enhancement <a href="https://github.com/frappe/erpnext/issues/3582">#3582</a>
 			</td>
 		</tr>
+		<tr>
+			<td style="width: 30%">
+				PT. Ridho Sribumi Sejahtera
+			</td>
+			<td>
+				For Additional Costs in Stock Entry <a href="https://github.com/frappe/erpnext/issues/3613">#3613</a>
+			</td>
+		</tr>
 	</tbody>
 </table>