function get_it2

PARAMETERS sele_criteria,mwarranty,mservice_typ,pcrate_flg,pcGodown_no,plChk_Stock


PRIVATE lcGodown_no,llChk_stock
STORE ' ' TO lcGodown_no
STORE .f. to llChk_stock
IF PARAMETERS() > 3
	lcGodown_no = pcGodown_no
ENDIF
IF PARAMETERS() > 4
	llChk_stock = plChk_Stock
ENDIF 
IF lastkey() = 5
	IF recn() = 1
		retu -1
	ELSE 
		RETURN 
	ENDIF 
ENDIF 
if empt(item_no) and recn() > 1
	keyb '{CTRL+Q}'
	scan rest while ! empt(item_no)
		msr_no = sr_no
		scat memv blank
		gath memv
		repl sr_no with msr_no
	ends		
	retu .T.
else
	if empt(item_no) and recn() = 1
		if lastkey() = 5
			retu - 1
		else	
			do alert with '!!! ATTENTION !!!;First Item info is blank'
			retu .F.
		endif	
	endif	
endif	
private m.item,m.item_no,mrate,mbalance,mitemtype

m.item_no = tmpissue.item_no
mrate = 0
m.item = item
mitemtype = ''
mbalance = 0
llEnteredInBrowse = .f.
IF get_it(m.item_no,m.item,mbalance,mrate,mitemtype,sele_criteria)
	IF llEnteredInBrowse 
		KEYBOARD '{ENTER}'
	ENDIF 
ELSE 
	sele tmpissue
	RETURN 
ENDIF 
sele tmpissue
repl tmpissue.item with m.item ;
	tmpissue.item_no with m.item_no ;
	tmpissue.itemtype with mitemtype ;
    tmpissue.rate with iif(empt(rate),itemmast.rate,rate) ;
	tmpissue.st_rt with itemmast.st_rt ;
	tmpissue.cst_rt WITH itemmast.cst_rt ;
	tmpissue.itvat_rate WITH st_rt 
	IF gcaddivatflg = "Y"	
		REPLACE tmpissue.itavat_rt with ITEMMAST.ADDIVATRT	
	ENDIF 
do CASE  
	CASE tmpissue.itemtype = 'C'
		repl tmpissue.oil_rt with iif(mwarranty = 'Y' OR pcrate_flg = "P",itemmast.rate,itemmast.salerate)
		repl tmpissue.spare_rt with 0
		REPLACE tmpissue.accessoryr WITH 0
	CASE tmpissue.itemtype = 'A'
		repl tmpissue.accessoryr with iif(mwarranty = 'Y' OR pcrate_flg = "P",itemmast.rate,itemmast.salerate)
		repl tmpissue.spare_rt with 0
		REPLACE tmpissue.oil_rt WITH 0
	CASE tmpissue.itemtype = 'L'	
		repl tmpissue.labour_rt with iif(empt(labour_rt),itemmast.labour_rt,labour_rt)
		if mservice_typ = 'P'
		endif	
		repl tmpissue.spare_rt with 0
		REPLACE tmpissue.accessoryr WITH 0
		REPLACE tmpissue.oil_rt WITH 0		
	OTHERWISE 
		repl tmpissue.spare_rt with iif(inli(mwarranty,'C','D'),roun(rate*(100 + moverhead)/100,2),itemmast.salerate)
		repl tmpissue.labour_rt with iif(empt(labour_rt),iif(mwarranty = 'Y',0,itemmast.labour_rt),labour_rt)
		repl tmpissue.oil_rt with 0
ENDCASE
IF pcrate_flg = "P" AND tmpissue.itemtype <> 'C'
	REPLACE tmpissue.spare_rt WITH itemmast.rate
ENDIF
IF llChk_stock = .T. and ! EMPTY(tmpissue.item_no)
	IF gcnegative_flg = 'N'
		PRIVATE lctmpItemNo
		lctmpItemNo = PADR(ALLTRIM(tmpissue.item_no),LEN(itemmast.item_no))
		IF SEEK(lctmpItemNo,'ITEMMAST','ITEM_NO')
			IF ITEMMAST.itemtype <> 'L'
				IF SEEK(lcGodown_no + lctmpItemNo,'GODOWN_I','GODOITEM')
					IF GODOWN_I.BALANCE - tmpissue.QTY < 0
						DO err_msg WITH 'AS PER COMPUTER STOCK OF ITEM NO. : ' + lctmpItemNo + ' IN godown no. : ' + lcgodown_no + CHR(13) + ' is : ' + STR(godown_i.balance,10,2) + CHR(13) + 'your entered qty is : ' + STR(tmpissue.QTY,10,2) + CHR(13) + 'NEGATIVE stock is not allowed'
						REPLACE qty WITH 0
						RETURN .f.
					ENDIF
				ELSE 
					INSERT INTO (godown_i) ;
						(item_no,godown_no) ;
					VALUES ;
						(lctmpItemNo,pcGodown_no)
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF


RETURN