 PROCEDURE prin_bill

*** Change Done On 24/04/98 For printing Multiple Bills/Sale Letter

PRIVATE sale_rec,resp,lcbill_amt,lcbill_amt2,lncredit_amt,lnnet_amt,lndebit_amt,lcrepnam

if ! empt(salemast.prininvflg)
	resp = 1
	do alert with 'Bill was Printed Successfully;;do you want to print this Bill ?',1,'\<No;\<Yes',resp
	if resp = 1
		retu .f.
	endif
endif
= get_oprin('SALES BILL Printing')
SELE salemast
lncredit_amt = clicramt(client_no)
sele salemast
= seek(salemast.client_no,'BOOKING','CLIENT_NO')
sale_rec = RECN()
SELECT booking
IF EMPTY(booking.hpa_name) AND ! EMPTY(booking.hpa_no)
	IF SEEK(booking.hpa_no,'HPAMAST','HPA_NO')
		REPLACE booking.hpa_name WITH hpamast.hpa_name
	ENDIF
ENDIF
SELECT salemast
GO (sale_rec)
SET ORDE TO ref_no IN vehicle
lndebit_amt = salemast.basic_amt + salemast.st_amt + salemast.st_sc_amt + salemast.insurance+salemast.rto_cust +  salemast.octroi + salemast.road_tax + salemast.crtm_amt + salemast.accessory + salemast.other + salemast.hpa_rto + salemast.opticalamt + salemast.spl_noamt
lcbill_amt2 = rwrd(abs(lndebit_amt - lncredit_amt))
lnnet_amt = lndebit_amt - lncredit_amt
if ! seek(salemast.ref_no,'VEHICLE','REF_NO')
	do err_msg with 'Vehicle Detail was not found while printing'
ELSE 
	IF ! SEEK(vehicle.modelcolno,'MODELCOL','MODELCOLNO')
		DO err_msg WITH 'Model cOLOUR Detail was not found while printing'
	ENDIF 		
	IF ! SEEK(vehicle.model_no,'MODEL','MODEL_NO')
		DO err_msg WITH 'Model Detail was not found while printing'
	ENDIF 
ENDIF 
IF EMPTY(gcsbilname)
	DO prinrepo WITH '','SALEBILL','','',1
ELSE
	lcrepnam = gcsbilname + '.FRX'
	IF ! FILE(lcrepnam)			
		MESSAGEBOX("Please copy REPORT file and try again ...","AUTOSOFT",0+64)
	ELSE 			
		DO prinrepo WITH '',gcSBILname,'','',1
	ENDIF 			
ENDIF
         
GO (sale_rec)

IF RLOC('SALEMAST')
	IF out_typ = 'PRINT (DOS)' OR out_typ = 'Modify & Print' OR out_typ = 'PRINT (WIN)'
		REPLACE salemast.prininvflg WITH 'Y'
	ENDIF
	UNLO IN salemast
ENDIF