FUNCTION get_pitWithVat

PARAMETERS minsurance,sele_criteria,rate_flg

if lastkey() = 5
	if recn() = 1
		RETURN 
*		retu -1
	else
		RETURN 
	endif
endif
if empt(item_no) and recn() > 1
	scan rest while ! empt(item_no)
		msr_no = sr_no
		scat memv blank
		gath memv
		repl sr_no with msr_no
	ends		
	keyb '{CTRL+W}'
	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,lcold_itemno
m.item_no = tmpissue.item_no
IF ! EMPTY(gcItemSeperator)
	IF ALLTRIM(gcItemSeperator) $ m.item_no
		m.item_no = LEFT(m.item_no,AT(ALLTRIM(gcItemSeperator),m.item_no) - 1)
	ENDIF 
	m.item_no = padr(alltrim(m.item_no),len(tmpissue.item_no))
ELSE 
	m.item_no = padr(alltrim(m.item_no),len(tmpissue.item_no))
ENDIF 

lcold_itemno = m.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
SELECT tmpissue
REPLACE item WITH m.item ;
	item_no with m.item_no ;
	itemtype with mitemtype ;
	tmpIssue.itVatRt WITH itemMast.st_rt ;
	tmpIssue.itAVatRt WITH itemMast.addiVatRt
IF gcitpurwithtax = 'Y' then
  REPLACE purst_rt WITH itemmast.purst_rt;
       	 purcst_rt WITH itemmast.purcst_rt
ENDIF 
IF empt(rate) or ! rate_flg OR m.item_no <> lcold_itemno
	repl rate with itemmast.rate
ENDIF
DO calItAmount
