Merge branch 'develop' into debit-credit-opening-invoice-tool
diff --git a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py
index ee73cca..5278d8b 100644
--- a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py
+++ b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py
@@ -195,88 +195,91 @@
 
 def create_records():
 	# create a new loyalty Account
-	if frappe.db.exists("Account", "Loyalty - _TC"):
-		return
-
-	frappe.get_doc({
-		"doctype": "Account",
-		"account_name": "Loyalty",
-		"parent_account": "Direct Expenses - _TC",
-		"company": "_Test Company",
-		"is_group": 0,
-		"account_type": "Expense Account",
-	}).insert()
+	if not frappe.db.exists("Account", "Loyalty - _TC"):
+		frappe.get_doc({
+			"doctype": "Account",
+			"account_name": "Loyalty",
+			"parent_account": "Direct Expenses - _TC",
+			"company": "_Test Company",
+			"is_group": 0,
+			"account_type": "Expense Account",
+		}).insert()
 
 	# create a new loyalty program Single tier
-	frappe.get_doc({
-		"doctype": "Loyalty Program",
-		"loyalty_program_name": "Test Single Loyalty",
-		"auto_opt_in": 1,
-		"from_date": today(),
-		"loyalty_program_type": "Single Tier Program",
-		"conversion_factor": 1,
-		"expiry_duration": 10,
-		"company": "_Test Company",
-		"cost_center": "Main - _TC",
-		"expense_account": "Loyalty - _TC",
-		"collection_rules": [{
-			'tier_name': 'Silver',
-			'collection_factor': 1000,
-			'min_spent': 1000
-		}]
-	}).insert()
-
-	# create a new customer
-	frappe.get_doc({
-		"customer_group": "_Test Customer Group",
-		"customer_name": "Test Loyalty Customer",
-		"customer_type": "Individual",
-		"doctype": "Customer",
-		"territory": "_Test Territory"
-	}).insert()
-
-	# create a new loyalty program Multiple tier
-	frappe.get_doc({
-		"doctype": "Loyalty Program",
-		"loyalty_program_name": "Test Multiple Loyalty",
-		"auto_opt_in": 1,
-		"from_date": today(),
-		"loyalty_program_type": "Multiple Tier Program",
-		"conversion_factor": 1,
-		"expiry_duration": 10,
-		"company": "_Test Company",
-		"cost_center": "Main - _TC",
-		"expense_account": "Loyalty - _TC",
-		"collection_rules": [
-			{
+	if not frappe.db.exists("Loyalty Program","Test Single Loyalty"):
+		frappe.get_doc({
+			"doctype": "Loyalty Program",
+			"loyalty_program_name": "Test Single Loyalty",
+			"auto_opt_in": 1,
+			"from_date": today(),
+			"loyalty_program_type": "Single Tier Program",
+			"conversion_factor": 1,
+			"expiry_duration": 10,
+			"company": "_Test Company",
+			"cost_center": "Main - _TC",
+			"expense_account": "Loyalty - _TC",
+			"collection_rules": [{
 				'tier_name': 'Silver',
 				'collection_factor': 1000,
-				'min_spent': 10000
-			},
-			{
-				'tier_name': 'Gold',
-				'collection_factor': 1000,
-				'min_spent': 19000
-			}
-		]
-	}).insert()
+				'min_spent': 1000
+			}]
+		}).insert()
+
+	# create a new customer
+	if not frappe.db.exists("Customer","Test Loyalty Customer"):
+		frappe.get_doc({
+			"customer_group": "_Test Customer Group",
+			"customer_name": "Test Loyalty Customer",
+			"customer_type": "Individual",
+			"doctype": "Customer",
+			"territory": "_Test Territory"
+		}).insert()
+
+	# create a new loyalty program Multiple tier
+	if not frappe.db.exists("Loyalty Program","Test Multiple Loyalty"):
+		frappe.get_doc({
+			"doctype": "Loyalty Program",
+			"loyalty_program_name": "Test Multiple Loyalty",
+			"auto_opt_in": 1,
+			"from_date": today(),
+			"loyalty_program_type": "Multiple Tier Program",
+			"conversion_factor": 1,
+			"expiry_duration": 10,
+			"company": "_Test Company",
+			"cost_center": "Main - _TC",
+			"expense_account": "Loyalty - _TC",
+			"collection_rules": [
+				{
+					'tier_name': 'Silver',
+					'collection_factor': 1000,
+					'min_spent': 10000
+				},
+				{
+					'tier_name': 'Gold',
+					'collection_factor': 1000,
+					'min_spent': 19000
+				}
+			]
+		}).insert()
 
 	# create an item
-	item = frappe.get_doc({
-		"doctype": "Item",
-		"item_code": "Loyal Item",
-		"item_name": "Loyal Item",
-		"item_group": "All Item Groups",
-		"company": "_Test Company",
-		"is_stock_item": 1,
-		"opening_stock": 100,
-		"valuation_rate": 10000,
-	}).insert()
+	if not frappe.db.exists("Item", "Loyal Item"):
+		frappe.get_doc({
+			"doctype": "Item",
+			"item_code": "Loyal Item",
+			"item_name": "Loyal Item",
+			"item_group": "All Item Groups",
+			"company": "_Test Company",
+			"is_stock_item": 1,
+			"opening_stock": 100,
+			"valuation_rate": 10000,
+		}).insert()
 
 	# create item price
-	frappe.get_doc({
-		"doctype": "Item Price",
-		"price_list": "Standard Selling",
-		"item_code": item.item_code,
-		"price_list_rate": 10000
-	}).insert()
+	if not frappe.db.exists("Item Price", {"price_list": "Standard Selling", "item_code": "Loyal Item"}):
+		frappe.get_doc({
+			"doctype": "Item Price",
+			"price_list": "Standard Selling",
+			"item_code": "Loyal Item",
+			"price_list_rate": 10000
+		}).insert()
diff --git a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
index aa6a388..8de54d5 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
+++ b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
@@ -45,7 +45,7 @@
 		frappe.set_user("Administrator")
 		frappe.db.sql("delete from `tabPOS Profile`")
 
-def init_user_and_profile():
+def init_user_and_profile(**args):
 	user = 'test@example.com'
 	test_user = frappe.get_doc('User', user)
 
@@ -53,7 +53,7 @@
 	test_user.add_roles(*roles)
 	frappe.set_user(user)
 
-	pos_profile = make_pos_profile()
+	pos_profile = make_pos_profile(**args)
 	pos_profile.append('applicable_for_users', {
 		'default': 1,
 		'user': user
diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
index ba68df7..1669ca4 100644
--- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
@@ -139,7 +139,8 @@
 			frappe.throw(_("At least one mode of payment is required for POS invoice."))
 
 	def validate_change_account(self):
-		if frappe.db.get_value("Account", self.account_for_change_amount, "company") != self.company:
+		if self.change_amount and self.account_for_change_amount and \
+			frappe.db.get_value("Account", self.account_for_change_amount, "company") != self.company:
 			frappe.throw(_("The selected change account {} doesn't belongs to Company {}.").format(self.account_for_change_amount, self.company))
 
 	def validate_change_amount(self):
diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
index e08af95..c179360 100644
--- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
@@ -8,6 +8,7 @@
 from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
 from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
 from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
+from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
 
 class TestPOSInvoice(unittest.TestCase):
 	def test_timestamp_change(self):
@@ -222,29 +223,29 @@
 		from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
 		from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
 
-		se = make_serialized_item(company='_Test Company with perpetual inventory',
-			target_warehouse="Stores - TCP1", cost_center='Main - TCP1', expense_account='Cost of Goods Sold - TCP1')
+		se = make_serialized_item(company='_Test Company',
+			target_warehouse="Stores - _TC", cost_center='Main - _TC', expense_account='Cost of Goods Sold - _TC')
 
 		serial_nos = get_serial_nos(se.get("items")[0].serial_no)
 
-		pos = create_pos_invoice(company='_Test Company with perpetual inventory', debit_to='Debtors - TCP1',
-			account_for_change_amount='Cash - TCP1', warehouse='Stores - TCP1', income_account='Sales - TCP1',
-			expense_account='Cost of Goods Sold - TCP1', cost_center='Main - TCP1',
+		pos = create_pos_invoice(company='_Test Company', debit_to='Debtors - _TC',
+			account_for_change_amount='Cash - _TC', warehouse='Stores - _TC', income_account='Sales - _TC',
+			expense_account='Cost of Goods Sold - _TC', cost_center='Main - _TC',
 			item=se.get("items")[0].item_code, rate=1000, do_not_save=1)
 
 		pos.get("items")[0].serial_no = serial_nos[0]
-		pos.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - TCP1', 'amount': 1000})
+		pos.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 1000})
 
 		pos.insert()
 		pos.submit()
 
-		pos2 = create_pos_invoice(company='_Test Company with perpetual inventory', debit_to='Debtors - TCP1',
-			account_for_change_amount='Cash - TCP1', warehouse='Stores - TCP1', income_account='Sales - TCP1',
-			expense_account='Cost of Goods Sold - TCP1', cost_center='Main - TCP1',
+		pos2 = create_pos_invoice(company='_Test Company', debit_to='Debtors - _TC',
+			account_for_change_amount='Cash - _TC', warehouse='Stores - _TC', income_account='Sales - _TC',
+			expense_account='Cost of Goods Sold - _TC', cost_center='Main - _TC',
 			item=se.get("items")[0].item_code, rate=1000, do_not_save=1)
 
 		pos2.get("items")[0].serial_no = serial_nos[0]
-		pos2.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - TCP1', 'amount': 1000})
+		pos2.append("payments", {'mode_of_payment': 'Bank Draft', 'account': '_Test Bank - _TC', 'amount': 1000})
 
 		self.assertRaises(frappe.ValidationError, pos2.insert)
 
@@ -286,7 +287,7 @@
 
 		after_redeem_lp_details = get_loyalty_program_details_with_points(inv.customer, company=inv.company, loyalty_program=inv.loyalty_program)
 		self.assertEqual(after_redeem_lp_details.loyalty_points, 9)
-	
+
 	def test_merging_into_sales_invoice_with_discount(self):
 		from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile
 		from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import merge_pos_invoices
@@ -295,7 +296,7 @@
 		test_user, pos_profile = init_user_and_profile()
 		pos_inv = create_pos_invoice(rate=300, additional_discount_percentage=10, do_not_submit=1)
 		pos_inv.append('payments', {
-			'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 300
+			'mode_of_payment': 'Cash', 'account': 'Cash - _TC', 'amount': 270
 		})
 		pos_inv.submit()
 
@@ -309,9 +310,9 @@
 
 		pos_inv.load_from_db()
 		rounded_total = frappe.db.get_value("Sales Invoice", pos_inv.consolidated_invoice, "rounded_total")
-		self.assertEqual(rounded_total, 3500)
+		self.assertEqual(rounded_total, 3470)
 		frappe.set_user("Administrator")
-	
+
 	def test_merging_into_sales_invoice_with_discount_and_inclusive_tax(self):
 		from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile
 		from erpnext.accounts.doctype.pos_invoice_merge_log.pos_invoice_merge_log import merge_pos_invoices
@@ -361,7 +362,7 @@
 		if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"):
 			frappe.db.set_value("Selling Settings", "Selling Settings", "validate_selling_price", 1)
 
-		make_stock_entry(item_code="_Test Item", target="_Test Warehouse - _TC", qty=1, basic_rate=300)
+		make_purchase_receipt(item_code="_Test Item", warehouse="_Test Warehouse - _TC", qty=1, rate=300)
 		frappe.db.sql("delete from `tabPOS Invoice`")
 		test_user, pos_profile = init_user_and_profile()
 		pos_inv = create_pos_invoice(rate=300, do_not_submit=1)
@@ -413,8 +414,6 @@
 	pos_inv.is_pos = 1
 	pos_inv.pos_profile = args.pos_profile or pos_profile.name
 
-	pos_inv.set_missing_values()
-
 	if args.posting_date:
 		pos_inv.set_posting_time = 1
 	pos_inv.posting_date = args.posting_date or frappe.utils.nowdate()
@@ -428,6 +427,8 @@
 	pos_inv.conversion_rate = args.conversion_rate or 1
 	pos_inv.account_for_change_amount = args.account_for_change_amount or "Cash - _TC"
 
+	pos_inv.set_missing_values()
+
 	pos_inv.append("items", {
 		"item_code": args.item or args.item_code or "_Test Item",
 		"warehouse": args.warehouse or "_Test Warehouse - _TC",
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 158799c..7c8ae6c 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -651,12 +651,12 @@
 		make_subcontracted_item(item_code)
 
 		po = create_purchase_order(item_code=item_code, qty=1,
-			is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC")
+			is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC", include_exploded_items=1)
 
 		name = frappe.db.get_value('BOM', {'item': item_code}, 'name')
 		bom = frappe.get_doc('BOM', name)
 
-		exploded_items = sorted([d.item_code for d in bom.exploded_items])
+		exploded_items = sorted([d.item_code for d in bom.exploded_items if not d.get('sourced_by_supplier')])
 		supplied_items = sorted([d.rm_item_code for d in po.supplied_items])
 		self.assertEquals(exploded_items, supplied_items)
 
@@ -664,7 +664,7 @@
 			is_subcontracted="Yes", supplier_warehouse="_Test Warehouse 1 - _TC", include_exploded_items=0)
 
 		supplied_items1 = sorted([d.rm_item_code for d in po1.supplied_items])
-		bom_items = sorted([d.item_code for d in bom.items])
+		bom_items = sorted([d.item_code for d in bom.items if not d.get('sourced_by_supplier')])
 
 		self.assertEquals(supplied_items1, bom_items)
 
diff --git a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py
index 019cefc..ea38129 100644
--- a/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/test_request_for_quotation.py
@@ -9,7 +9,7 @@
 from frappe.utils import nowdate
 from erpnext.stock.doctype.item.test_item import make_item
 from erpnext.templates.pages.rfq import check_supplier_has_docname_access
-from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation
+from erpnext.buying.doctype.request_for_quotation.request_for_quotation import make_supplier_quotation_from_rfq
 from erpnext.buying.doctype.request_for_quotation.request_for_quotation import create_supplier_quotation
 from erpnext.crm.doctype.opportunity.test_opportunity import make_opportunity
 from erpnext.crm.doctype.opportunity.opportunity import make_request_for_quotation as make_rfq
@@ -22,7 +22,7 @@
 		self.assertEqual(rfq.get('suppliers')[1].quote_status, 'Pending')
 
 		# Submit the first supplier quotation
-		sq = make_supplier_quotation(rfq.name, rfq.get('suppliers')[0].supplier)
+		sq = make_supplier_quotation_from_rfq(rfq.name, for_supplier=rfq.get('suppliers')[0].supplier)
 		sq.submit()
 
 		# No Quote first supplier quotation
@@ -37,10 +37,10 @@
 	def test_make_supplier_quotation(self):
 		rfq = make_request_for_quotation()
 
-		sq = make_supplier_quotation(rfq.name, rfq.get('suppliers')[0].supplier)
+		sq = make_supplier_quotation_from_rfq(rfq.name, for_supplier=rfq.get('suppliers')[0].supplier)
 		sq.submit()
 
-		sq1 = make_supplier_quotation(rfq.name, rfq.get('suppliers')[1].supplier)
+		sq1 = make_supplier_quotation_from_rfq(rfq.name, for_supplier=rfq.get('suppliers')[1].supplier)
 		sq1.submit()
 
 		self.assertEqual(sq.supplier, rfq.get('suppliers')[0].supplier)
@@ -62,7 +62,7 @@
 
 		rfq = make_request_for_quotation(supplier_data=supplier_wt_appos)
 
-		sq = make_supplier_quotation(rfq.name, supplier_wt_appos[0].get("supplier"))
+		sq = make_supplier_quotation_from_rfq(rfq.name, for_supplier=supplier_wt_appos[0].get("supplier"))
 		sq.submit()
 
 		frappe.form_dict = frappe.local("form_dict")
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index 86757df..b7aca79 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -11,7 +11,7 @@
 from erpnext.exceptions import InvalidCurrency
 from erpnext.stock.doctype.material_request.material_request import make_request_for_quotation
 from erpnext.buying.doctype.request_for_quotation.request_for_quotation import \
-			 make_supplier_quotation as make_quotation_from_rfq
+			 make_supplier_quotation_from_rfq
 
 def work():
 	frappe.set_user(frappe.db.get_global('demo_purchase_user'))
@@ -44,7 +44,7 @@
 				rfq = frappe.get_doc('Request for Quotation', rfq.name)
 
 				for supplier in rfq.suppliers:
-					supplier_quotation = make_quotation_from_rfq(rfq.name, supplier.supplier)
+					supplier_quotation = make_supplier_quotation_from_rfq(rfq.name, for_supplier=supplier.supplier)
 					supplier_quotation.save()
 					supplier_quotation.submit()
 
diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py
index 76dc942..6df7bc8 100644
--- a/erpnext/hr/doctype/holiday_list/holiday_list.py
+++ b/erpnext/hr/doctype/holiday_list/holiday_list.py
@@ -1,3 +1,4 @@
+
 # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 # License: GNU General Public License v3. See license.txt
 
@@ -32,7 +33,7 @@
 
 
 	def validate_days(self):
-		if self.from_date > self.to_date:
+		if getdate(self.from_date) > getdate(self.to_date):
 			throw(_("To Date cannot be before From Date"))
 
 		for day in self.get("holidays"):
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index eface4d..3239478 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -207,7 +207,6 @@
 		supplied_items = sorted([d.rm_item_code for d in po.supplied_items])
 		self.assertEquals(bom_items, supplied_items)
 
-
 def get_default_bom(item_code="_Test FG Item 2"):
 	return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1})
 
diff --git a/erpnext/payroll/doctype/salary_slip/test_salary_slip.py b/erpnext/payroll/doctype/salary_slip/test_salary_slip.py
index 37cd89a..7fe4165 100644
--- a/erpnext/payroll/doctype/salary_slip/test_salary_slip.py
+++ b/erpnext/payroll/doctype/salary_slip/test_salary_slip.py
@@ -347,8 +347,7 @@
 
 		# create additional salary of 150000
 		frappe.db.sql("""delete from `tabSalary Slip` where employee=%s""", (employee))
-		data["additional-1"] = create_additional_salary(employee, payroll_period, 50000)
-		data["additional-2"] = create_additional_salary(employee, payroll_period, 100000)
+		data["additional-1"] = create_additional_salary(employee, payroll_period, 150000)
 		data["deducted_dates"] = create_salary_slips_for_payroll_period(employee,
 			salary_structure.name, payroll_period)
 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index bfdddbb..a094e6c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -577,8 +577,9 @@
 						# if barcode is getting updated , the row name has to reset.
 						# Delete previous old row doc and re-enter row as if new to reset name in db.
 						item_barcode.set("__islocal", True)
+						item_barcode_entry_name = item_barcode.name
 						item_barcode.name = None
-						frappe.delete_doc("Item Barcode", item_barcode.name)
+						frappe.delete_doc("Item Barcode", item_barcode_entry_name)
 
 	def validate_warehouse_for_reorder(self):
 		'''Validate Reorder level table for duplicate and conditional mandatory'''
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index cbd5e33..109731a 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -471,7 +471,7 @@
 		item_doc = frappe.get_doc('Item', item_code)
 		new_barcode = item_doc.append('barcodes')
 		new_barcode.update(barcode_properties_list[0])
-		self.assertRaises(frappe.DuplicateEntryError, item_doc.save)
+		self.assertRaises(frappe.UniqueValidationError, item_doc.save)
 
 		# Add invalid barcode - should cause InvalidBarcode
 		item_doc = frappe.get_doc('Item', item_code)
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 1e7153e..74a06d8 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -181,17 +181,14 @@
 
 		#stock raw materials in a warehouse before transfer
 		make_stock_entry(target="_Test Warehouse - _TC",
-			item_code="_Test Item Home Desktop 100", qty=1, basic_rate=100)
-		make_stock_entry(target="_Test Warehouse - _TC",
 			item_code = "Test Extra Item 1", qty=1, basic_rate=100)
 		make_stock_entry(target="_Test Warehouse - _TC",
-			item_code = "_Test Item", qty=1, basic_rate=100)
-
+			item_code = "_Test FG Item", qty=1, basic_rate=100)
 		rm_items = [
 			{
 				"item_code": item_code,
 				"rm_item_code": po.supplied_items[0].rm_item_code,
-				"item_name": "_Test Item",
+				"item_name": "_Test FG Item",
 				"qty": po.supplied_items[0].required_qty,
 				"warehouse": "_Test Warehouse - _TC",
 				"stock_uom": "Nos"
@@ -203,14 +200,6 @@
 				"qty": po.supplied_items[1].required_qty,
 				"warehouse": "_Test Warehouse - _TC",
 				"stock_uom": "Nos"
-			},
-			{
-				"item_code": item_code,
-				"rm_item_code": po.supplied_items[2].rm_item_code,
-				"item_name": "_Test Item Home Desktop 100",
-				"qty": po.supplied_items[2].required_qty,
-				"warehouse": "_Test Warehouse - _TC",
-				"stock_uom": "Nos"
 			}
 		]
 		rm_item_string = json.dumps(rm_items)
diff --git a/erpnext/translations/ar.csv b/erpnext/translations/ar.csv
index f586a44..01a135d 100644
--- a/erpnext/translations/ar.csv
+++ b/erpnext/translations/ar.csv
@@ -316,12 +316,12 @@
 Auto Material Requests Generated,إنشاء طلب مواد تلقائي,
 Auto Repeat,تكرار تلقائي,
 Auto repeat document updated,تكرار تلقائي للمستندات المحدثة,
-Automotive,سيارات,
+Automotive,سيارات,متحرك بطاقة ذاتية
 Available,متاح,
-Available Leaves,المغادارت المتوفرة,
+Available Leaves,المغادارت والاجازات المتاحة,
 Available Qty,الكمية المتاحة,
 Available Selling,المبيعات المتاحة,
-Available for use date is required,مطلوب متاح لتاريخ الاستخدام,
+Available for use date is required,مطلوب تاريخ متاح للاستخدام,
 Available slots,الفتحات المتاحة,
 Available {0},متاح {0},
 Available-for-use Date should be after purchase date,يجب أن يكون التاريخ متاحًا بعد تاريخ الشراء,
@@ -331,16 +331,16 @@
 Avg. Buying Price List Rate,متوسط قائمة أسعار الشراء,
 Avg. Selling Price List Rate,متوسط قائمة أسعار البيع,
 Avg. Selling Rate,متوسط معدل البيع,
-BOM,فاتورة المواد,
-BOM Browser,BOM متصفح,
-BOM No,رقم قائمة المواد,
-BOM Rate,سعر قائمة المواد,
-BOM Stock Report,تقرير مخزون فاتورة المواد,
+BOM,قائمة مكونات المواد,
+BOM Browser,قائمة مكونات المواد متصفح,
+BOM No,رقم قائمة مكونات المواد,
+BOM Rate,سعر او معدل قائمة مكونات المواد,
+BOM Stock Report,تقرير مخزون قائمة مكونات المواد,
 BOM and Manufacturing Quantity are required,مطلوب، قائمة مكونات المواد و كمية التصنيع,
-BOM does not contain any stock item,فاتورة الموارد لا تحتوي على أي صنف مخزون,
-BOM {0} does not belong to Item {1},قائمة المواد {0} لا تنتمي إلى الصنف {1},
-BOM {0} must be active,فاتورة المواد {0} يجب أن تكون نشطة\n<br>\nBOM {0} must be active,
-BOM {0} must be submitted,فاتورة المواد {0} يجب أن تكون مسجلة\n<br>\nBOM {0} must be submitted,
+BOM does not contain any stock item,قائمة مكونات المواد لا تحتوي على أي صنف مخزون,
+BOM {0} does not belong to Item {1},قائمة مكونات المواد {0} لا تنتمي إلى الصنف {1},
+BOM {0} must be active,قائمة مكونات المواد {0} يجب أن تكون نشطة\n<br>\nBOM {0} must be active,
+BOM {0} must be submitted,قائمة مكونات المواد {0} يجب أن تكون مسجلة\n<br>\nBOM {0} must be submitted,
 Balance,الموازنة,
 Balance (Dr - Cr),الرصيد (مدين - دائن),
 Balance ({0}),الرصيد ({0}),
@@ -389,23 +389,23 @@
 Bill No,رقم الفاتورة,
 Bill of Materials,فاتورة المواد,
 Bill of Materials (BOM),قوائم المواد,
-Billable Hours,ساعات للفوترة,
-Billed,توصف,
+Billable Hours,ساعات قابلة للفوترة,
+Billed,تمت الفوترة,
 Billed Amount,القيمة المقدم فاتورة بها,
 Billing,الفواتير,
-Billing Address,عنوان تقديم الفواتير,
+Billing Address,العنوان الذي ترسل به الفواتير,
 Billing Address is same as Shipping Address,عنوان الفواتير هو نفس عنوان الشحن,
 Billing Amount,قيمة الفواتير,
-Billing Status,الحالة الفواتير,
+Billing Status,حالة الفواتير,
 Billing currency must be equal to either default company's currency or party account currency,يجب أن تكون عملة الفوترة مساوية لعملة الشركة الافتراضية أو عملة حساب الطرف,
 Bills raised by Suppliers.,فواتير حولت من قبل الموردين.,
 Bills raised to Customers.,فواتير حولت للزبائن.,
 Biotechnology,التكنولوجيا الحيوية,
 Birthday Reminder,تذكير عيد ميلاد,
 Black,أسود,
-Blanket Orders from Costumers.,أوامر بطانية من العملاء.,
+Blanket Orders from Costumers.,أوامر شراء شاملة من العملاء.,
 Block Invoice,حظر الفاتورة,
-Boms,قوائم المواد,
+Boms,قوائم مكونات المواد,
 Bonus Payment Date cannot be a past date,لا يمكن أن يكون تاريخ الدفع المكافأ تاريخًا سابقًا,
 Both Trial Period Start Date and Trial Period End Date must be set,يجب تعيين كل من تاريخ بدء الفترة التجريبية وتاريخ انتهاء الفترة التجريبية,
 Both Warehouse must belong to same Company,يجب أن ينتمي المستودع إلى نفس الشركة\n<br>\nBoth Warehouse must belong to same Company,
@@ -504,9 +504,9 @@
 Cash or Bank Account is mandatory for making payment entry,الحساب النقدي أو البنكي مطلوب لعمل مدخل بيع <br>Cash or Bank Account is mandatory for making payment entry,
 Cashier Closing,إغلاق أمين الصندوق,
 Casual Leave,أجازة عادية,
-Category,فئة,
+Category,فئة,صنف
 Category Name,اسم التصنيف,
-Caution,الحذر,
+Caution,الحذر,تحذير
 Central Tax,الضريبة المركزية,
 Certification,شهادة,
 Cess,سيس,
@@ -627,7 +627,7 @@
 Cost Centers,مراكز التكلفة,
 Cost Updated,تم تحديث التكلفة\n<br>\nCost Updated,
 Cost as on,التكلفة كما في,
-Cost of Delivered Items,تكلفة البنود المسلمة,
+Cost of Delivered Items,تكلفة السلع والمواد المسلمة,
 Cost of Goods Sold,تكلفة البضاعة المباعة,
 Cost of Issued Items,تكلفة المواد المصروفة,
 Cost of New Purchase,تكلفة الشراء الجديد,
@@ -1300,7 +1300,7 @@
 Integrated Tax,ضريبة متكاملة,
 Inter-State Supplies,اللوازم بين الدول,
 Interest Amount,مبلغ الفائدة,
-Interests,الإهتمامات,
+Interests,الإهتمامات او الفوائد,
 Intern,المتدرب,
 Internet Publishing,نشر على شبكة الإنترنت,
 Intra-State Supplies,اللوازم داخل الدولة,
@@ -1421,13 +1421,13 @@
 Lab Tests and Vital Signs,اختبارات المختبر وعلامات حيوية,
 Lab result datetime cannot be before testing datetime,لا يمكن أن يكون تاريخ نتيجة المختبر سابقا لتاريخ الفحص,
 Lab testing datetime cannot be before collection datetime,لا يمكن أن يكون وقت اختبار المختبر قبل تاريخ جمع البيانات,
-Label,ملصق,
+Label,ملصق,'طابع
 Laboratory,مختبر,
 Language Name,اسم اللغة,
 Large,كبير,
 Last Communication,آخر الاتصالات,
 Last Communication Date,تاريخ الاتصال الأخير,
-Last Name,اسم العائلة,
+Last Name,اسم العائلة او اللقب,
 Last Order Amount,قيمة آخر طلب,
 Last Order Date,تاريخ أخر أمر بيع,
 Last Purchase Price,سعر الشراء الأخير,