'RCVD - quick view of O/S balances for identifying bank receipts

external   X_path _SWIP_Crystal() Xreppath remove() vloadif() vunloadif() dpath	Background() progress()
external   popuplist()

public	ptstr

global	DirectReceipts() OS_Balances() t1 t2 x



MAIN
	repaint off
	single-step off
	Background()
	t1="OS˙Balances"
	t2="˙BACS˙rcvd"
' 	while true
    		x=popuplist(10,43,13,t2&t1,"",1,0)
' 		if x=-1
' 			exit while
' 		end if
    		if ptstr=t1
	 		OS_Balances()
	     else
			DirectReceipts()
	    	end if
		Background()
' 	end while
END MAIN


FUNCTION OS_Balances()
  	remove(X_path|"X_osbals.*")
  	vloadif(dpath|"cust_ord.vws")
	order change physical
  	progress(15,10," Finding balances ",0)
  	data query execute "posbal.dfq" index "osbals.idx"
	order sort now dictionary "rcvd" fields "[Balance_Due]" descending

  	vunloadif("X_osbals.vws")
  	data query execute "not_del.dfq" Smart4 X_path|"X_osbals" fields\
	"[Job_Nr;CustOrd_Name;Date_Of_Order;Invoice_Total;Invoice_Date;Balance_Due]"
  	_SWIP_Crystal(Xreppath|"X_osbals1","S",0,1,"")
	file unload all
END FUNCTION ' OS_Balances()


FUNCTION DirectReceipts()
  	remove(X_path|"Xdirrcpt.*")
  	vloadif(dpath|"dir_rcpt.vw")
	order change physical
  	progress(15,10," Finding recent receipts at bank ",0)
	data query execute "dir_rcpt.dfq" index "dir_rcpt.idx"

' days([Date_Of_Receipt])>=(days(today)-30)
' and
' [Method_Of_Payment]="Direct"
' and
' not (deleted)

	vunloadif("X_dirrcp.vws")
  	remove(X_path|"X_dirrcp.*")
  	data query execute "not_del.dfq" Smart4 X_path|"X_dirrcp" fields\
"[Date_Of_Receipt;Job_Nr;CustOrd_Name;Amount_Received;Posted;Banked;Delivery_Address_1;Receipt_Nr]"
  	_SWIP_Crystal(Xreppath|"Xdirrcpt","S",0,1,"")
	file unload all
END FUNCTION ' DirectReceipts()

