= get_pdt('OUTPUT VAT REPORT (SALES)')
IF out_typ = 'Cancel'
	do alert with '!!! ATTENTION !!!;Report generation will be terminated'
	do cls_menu
	RETURN 
ENDIF 
DO wait_msg
WAIT WINDOW '!!! WAIT !!! Gathering data using SQL...' NOWAIT 

SELECT SALEMAST.CHALLAN_NO, SALEMAST.CHALLAN_DT, SALEMAST.BILL_NO, SALEMAST.BILL_DT,;
	SALEMAST.CUST_NO, SALEMAST.BILL_AMT,SALEMAST.TYPEOFSALE, SALEMAST.VATBASIC,;
	 SALEMAST.FORM_TYPE,SALEMAST.VAT_AMT,SALEMAST.CST_AMT,;
	LEDGER.ACCOUNT,;
	CUST_ID.TINNO ;
	FROM SALEMAST, LEDGER, CUST_ID ;
	WHERE BETW(SALEMAST.BILL_DT,DATE1,DATE2) ;
		AND SALEMAST.CUST_NO = LEDGER.ACCOUNT_NO ;
		AND SALEMAST.CUST_NO = client.client_NO ;		
	ORDER BY BILL_DT, BILL_NO;
	INTO CURSOR QUERY
SELECT QUERY

WAIT CLEAR 
IF _TALLY > 0
	WAIT WINDOW '!!! WAIT !!! Generating Report ...' NOWAIT 
	DEACTIVATE WINDOW WAIT 	
	do prinrepo with '','OUTPUTRG'," "," ",0,.F.
	
	USE IN query 
ELSE 
	DEACTIVATE WINDOW wait
	do err_beep
	do alert with '!!! ATTENTION !!!;No Purchase Info. found for the period : ' + dtoc(date1) + ' to ' + dtoc(date2)
ENDIF 
do cls_menu	
