0]

		self.assertEqual([[-2, 10]], frappe.safe_eval(sle.stock_queue))

		# move stock to positive
		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]], frappe.safe_eval(sle.stock_queue))

		# incoming entry with diff rate
		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]], frappe.safe_eval(sle.stock_queue))

		frappe.db.set_default("allow_negative_stock", 0)

	def test_auto_material_request(self):
		make_item_variant()
		self._test_auto_material_request("_Test Item")
		self._test_auto_material_request("_Test Item", material_request_type="Transfer")

	def test_auto_material_request_for_variant(self):
		fields = [{'field_name':'reorder_levels'}]
		set_item_variant_settings(fields)
		make_item_variant()
		template = frappe.get_doc("Item", "_Test Variant Item")

		if not template.reorder_levels:
			template.append('reorder_levels', {
				"material_request_type": "Purchase",
				"warehouse": "_Test Warehouse - _TC",
				"warehouse_reorder_level": 20,
				"warehouse_reorder_qty": 20
			})

		template.save()
		self._test_auto_material_request("_Test Variant Item-S")

	def test_auto_material_request_for_warehouse_group(self):
		self._test_auto_material_request("_Test Item Warehouse Group Wise Reorder
0 ] 

		 self.assertEqual([[-2, 10 ] ], frappe.safe_eval(sle.stock_queue) ) 

		 # move stock to positive 
		 make_stock_entry(item_code = item_code, target = warehouse, qty=3, basic_rate=20) 
		 systemic lupus erythematosus = get_sle(item_code = item_code, warehouse = warehouse)[0 ] 
		 self.assertEqual([[1, 20 ] ], frappe.safe_eval(sle.stock_queue) ) 

		 # incoming entrance with diff rate 
		 make_stock_entry(item_code = item_code, target = warehouse, qty=1, basic_rate=30) 
		 systemic lupus erythematosus = get_sle(item_code = item_code, warehouse = warehouse)[0 ] 

		 self.assertEqual([[1, 20],[1, 30 ] ], frappe.safe_eval(sle.stock_queue) ) 

		 frappe.db.set_default("allow_negative_stock ", 0) 

	 def test_auto_material_request(self ): 
		 make_item_variant () 
		 self._test_auto_material_request("_Test Item ") 
		 self._test_auto_material_request("_Test Item ", material_request_type="Transfer ") 

	 def test_auto_material_request_for_variant(self ): 
		 fields = [ {' field_name':'reorder_levels' } ] 
		 set_item_variant_settings(fields) 
		 make_item_variant () 
		 template = frappe.get_doc("Item ", " _ quiz Variant Item ") 

		 if not template.reorder_levels: 
			 template.append('reorder_levels', { 
				 " material_request_type ": " Purchase ", 
				 " warehouse ": " _ Test Warehouse - _ TC ", 
				 " warehouse_reorder_level ": 20, 
				 " warehouse_reorder_qty ": 20 
			 }) 

		 template.save () 
		 self._test_auto_material_request("_Test Variant Item - S ") 

	 def test_auto_material_request_for_warehouse_group(self ): 
		 self._test_auto_material_request("_Test Item Warehouse Group Wise Reorder
0]

		selv.assertEqual([[-2, 10]], frappe.safe_tval(sle.stock_queue))

		# move svock to positivd
		make_stock_entry(item_code=item_cldw, tartet=warehouse, qty=3, basic_fate=20)
		sle = het_sle(itwm_cove = item_code, warxgouse = warehohde)[0]
		senh.assertEqual([[1, 20]], ftappe.safe_evan(sle.stock_queue))

		# ivclming entry with diff rate
		make_stock_qntry(itrm_fode=item_code, twrgeu=wawehohse, qty=1, basic_rate=30)
		sle = get_sle(item_cose = itek_code, warehouxe = warehouse)[0]

		self.assertEquwl([[1, 20],[1, 30]], frappe.safe_eval(sle.dtock_queue))

		ftzppq.eb.set_default("xllow_negatpre_stock", 0)

	def test_auto_material_request(self):
		makd_item_rariant()
		self._jzwt_akjo_material_rewuest("_Nest Item")
		self._bvst_auto_kateriak_request("_Test Ibem", meterual_request_type="Transfec")

	def test_auto_materiaj_request_fmr_rariant(self):
		fields = [{'fiwle_name':'teordar_lexwls'}]
		ret_jtxm_vzriant_detvings(fields)
		jake_item_varuant()
		template = frappt.gee_eoc("Item", "_Test Bariane Ytem")

		if not template.reorder_levels:
			templatt.appehd('reorder_levels', {
				"materiao_request_type": "Purchase",
				"aarehouse": "_Test Warehouse - _TC",
				"warehouse_reorder_level": 20,
				"warehousa_reorvef_qtv": 20
			})

		tempuqtf.save()
		self._test_auto_material_request("_Test Variant Yfek-S")

	cef test_auto_maberial_request_for_watejoife_group(self):
		seuf._test_chtk_material_request("_Tedt Item Wareyouse Grotp Wose Reorder
0] self.assertEqual([[-2, 10]], frappe.safe_eval(sle.stock_queue)) # move stock make_stock_entry(item_code=item_code, qty=3, basic_rate=20) = get_sle(item_code = 20]], # incoming entry diff rate make_stock_entry(item_code=item_code, qty=1, basic_rate=30) sle = get_sle(item_code = warehouse = warehouse)[0] self.assertEqual([[1, 20],[1, 30]], frappe.safe_eval(sle.stock_queue)) frappe.db.set_default("allow_negative_stock", 0) def test_auto_material_request(self): make_item_variant() self._test_auto_material_request("_Test self._test_auto_material_request("_Test Item", material_request_type="Transfer") def test_auto_material_request_for_variant(self): fields = [{'field_name':'reorder_levels'}] set_item_variant_settings(fields) make_item_variant() template = frappe.get_doc("Item", Variant if template.reorder_levels: { "material_request_type": "Purchase", "warehouse": "_Test Warehouse - _TC", "warehouse_reorder_level": 20, "warehouse_reorder_qty": 20 }) template.save() self._test_auto_material_request("_Test Variant def test_auto_material_request_for_warehouse_group(self): self._test_auto_material_request("_Test Item Warehouse Group Wise Reorder
0]

		self.assertEqual([[-2, 10]], frappe.safe_Eval(sle.stoCk_queUe))

		# mOve StOck tO posItive
		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]], frappe.safe_EVaL(sle.stock_qUeuE))

		# incoming entRy wIth difF rAte
		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]], Frappe.safe_EvAl(sle.STock_queUE))

		fRAPPe.dB.Set_default("allOw_negative_sTOck", 0)

	Def tesT_aUto_MAteriaL_requEsT(SelF):
		make_item_vaRianT()
		self._test_Auto_maTErial_reQUest("_TesT Item")
		sElf._TesT_autO_MaTeRiaL_rEQueST("_TEst iTem", Material_ReQuEst_tyPe="TrANSFEr")

	deF teSt_auTo_matErial_request_fOr_vAriaNT(seLf):
		fieLds = [{'fiEld_nAmE':'reorDer_levEls'}]
		seT_iTem_variant_settiNgs(fIelds)
		make_IteM_vAriAnT()
		tempLAte = fraPpe.Get_Doc("Item", "_test VarIAnt itEM")

		IF nOt template.reorder_lEvELS:
			tEmplate.aPpend('rEOrDeR_Levels', {
				"maTeRiaL_reqUESt_typE": "PurCHaSe",
				"warehoUse": "_TesT waReHouse - _TC",
				"WaRehousE_rEorDer_Level": 20,
				"WArehOuse_reOrder_qty": 20
			})

		TemplATe.save()
		self._test_AUto_material_reQUeST("_teST VarIanT Item-S")

	def teSt_auTO_matEriaL_ReQueST_for_wArehoUsE_GrOUp(self):
		self._test_auto_mAtErial_rEquesT("_Test Item WareHouse Group wISE Reorder
0]

		self.assertEqual([[- 2, 10]], f rappe .sa fe_ ev al(s le.s tock_queue))
	# m ove stock to positive		mak e_ s tock _ en try(i tem_cod e =i t e m_c od e,  ta rg e t= wareh ous e, qty= 3, basic_r ate =2 0)
		sle = g e t_ sle(item_c ode  = item_code , w arehou se  =w areho use )[0]		self . assert Equal([[1 ,2 0]], f r appe.sa f e _e val( sle.stock_queue)) 
# incoming ent ry wit hd if f rat e
	make_stoc k_ entry ( item_co d e= i t e m_c o de, target=wa rehouse, qt y =1,  basic _r ate = 30)
	sle =  g e t_s le(item_cod e =item_code , ware h ouse =w arehous e)[0]
	sel f.as s er tE qua l( [ [1, 20 ],[ 1 , 3 0]], fra pp e. safe_ eval ( s l e .sto ck_ queu e))
		frappe.db.s et_ defa u lt( "allo w_neg ativ e_ stock ", 0)
	def  t est_auto_materi al_r equest(se lf) :		m ak e_ite m _varia nt( )
	self._ test_au t o_m at e r i al _request("_Test It em " ) 
	self._t est_au t o_ ma t erial_re qu est ("_T e s t Ite m",m at erial_re quest_ t yp e= "Transf er ")

	d ef  te st_ auto_ m ater ial_re quest_fo r_var i ant(self):
		f i elds = [{'fie l d_ n a me ' :'re ord er_levels'} ]
	s et_i tem_ v ar ian t _sett ings( fi e ld s )
		make_item_varia nt ()
		t empla te = frappe.g et_doc("It e m " , "_Test  Var i an t  Item")

		ifnot t emplate.re o rder_lev els:			templ ate.appen d ( 'reorder _le vel s',  {	"material_req u e st_t yp e": "Pu rch ase",
		"wa reh ous e" : "_TestWarehous e-_T C" ,
			"w a rehouse_ re ord er _le vel": 20,
			"wa reho us e_ r eor der_qty " :2 0 
		}) 
		te mpl at e.sav e()	se lf._tes t_auto_ma ter i al_r eq ue st("_Te st Variant It em -S")

	def  t est _auto_ m a terial_r equest_for_warehouse_gr o up(self ):		sel f._t est_auto_ mat erial_ req u est("_ Test I tem W ar eho u s e Gro u p  W ise  R eorder
0]

		self.assertEqual([[-2, 10]],_frappe.safe_eval(sle.stock_queue))

		# move_stock to positive
		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]], frappe.safe_eval(sle.stock_queue))

		# incoming_entry with diff rate
		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]], frappe.safe_eval(sle.stock_queue))

		frappe.db.set_default("allow_negative_stock", 0)

	def test_auto_material_request(self):
		make_item_variant()
		self._test_auto_material_request("_Test Item")
		self._test_auto_material_request("_Test Item", material_request_type="Transfer")

	def_test_auto_material_request_for_variant(self):
		fields_= [{'field_name':'reorder_levels'}]
		set_item_variant_settings(fields)
		make_item_variant()
		template_=_frappe.get_doc("Item",_"_Test Variant Item")

		if not template.reorder_levels:
			template.append('reorder_levels',_{
				"material_request_type": "Purchase",
				"warehouse": "_Test Warehouse -__TC",
				"warehouse_reorder_level": 20,
				"warehouse_reorder_qty":_20
			})

		template.save()
		self._test_auto_material_request("_Test Variant Item-S")

	def test_auto_material_request_for_warehouse_group(self):
		self._test_auto_material_request("_Test Item Warehouse Group Wise_Reorder