	REMARK	***********************************************\
		*  A/P060.BAS ACCOUNTS PAYABLE CHECK WRITER   *\
		*       6/18/79               5:15 PM         *\
		***********************************************



	DIM W3$(7),W2(4),M$(5),P(6),W(5),G3(5),G2$(5),C(27),D(27),Y(2)
%INCLUDE CURSOR
	DATA "ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN"		REMARK	DATA TABLE USED IN CHECK AND DATE CALCULATIONS
	DATA "EIGHT","NINE","TEN","ELEVEN","TWELVE"
	DATA "THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN"
	DATA "SEVENTEEN","EIGHTEEN","NINETEEN","TWENTY"
	DATA "THIRTY","FORTY","FIFTY","SIXTY","SEVENTY"
	DATA "EIGHTY","NINETY"
	DATA "JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY"
	DATA "AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE GENINFO
%INCLUDE BINSEARC
%INCLUDE READVEND
%INCLUDE A/P-INFO



4000	A2=A1								REMARK	ROUTINE TO GENERATE ENGLISH VERSION OF CHECK AMOUNT.\
										AMOUNTS OVER $1000.00 PRINT ON FIRST LINE; BELOW THAT, ON THE SECOND.
	IF A1<1000  THEN PRINT:GOTO 4070
4040	N1=INT(A1/100000)						REMARK	HUNDRED-THOUSANDS
	PRINT TAB(5);"**";
	IF N1>99  THEN RETURN
	IF N1<>0  THEN GOSUB 4160:PRINT "HUNDRED ";:A1=A1-N1*100000
4050	N1=INT(A1/1000)							REMARK	THOUSANDS OF DOLLARS
	IF N1<>0 THEN GOSUB 4160:A1=A1-N1*1000
	PRINT "THOUSAND**"
4070	PRINT TAB(5);"**";						REMARK	HUNDREDS  "   "   "
	N1=INT(A1/100)
	IF N1<>0 THEN GOSUB 4160:PRINT "HUNDRED ";:A1=A1-N1*100
4080	N1=INT(A1)							REMARK	DOLLARS
	IF N1<>0 THEN GOSUB 4160:PRINT "DOLLARS ";:GOTO 4110
	IF INT(A2)>0 THEN PRINT "DOLLARS ";
4110	A1=A1-N1							REMARK	CALCULATE CENTS
	IF A2>=1  THEN PRINT "AND";
	IF A1=0  THEN PRINT " NO "; \
	ELSE PRINT A1*100;
	PRINT "CENTS**";
	RETURN 

4160	IF N1 >= 21 THEN 4161 						REMARK	ROUTINE TO CONVERT AMOUNT IN N1 TO ENGLISH LANGUAGE
	RESTORE
	FOR I%=1 TO N1:READ X0$:NEXT I%:GOTO 4180
4161	RESTORE
	FOR I%=1 TO INT(((N1-20)/10)+20)
	READ X0$
	NEXT I%
	PRINT X0$;
	A3=N1-INT(N1/10)*10
	IF A3=0 THEN PRINT" ";: RETURN
	PRINT "-";
	RESTORE
	FOR I%=1 TO A3
	READ X0$
	NEXT I%
4180	PRINT X0$;
	PRINT " ";
	RETURN 


4200	A1=A8:GOSUB 4400						REMARK	PRINT BODY OF CHECK
	A1=W5:GOSUB 4000						REMARK	GENERATE ENGLISH CHECK AMOUNT
4240	PRINT TAB(65);
	PRINT USING "**#######.##";W5					REMARK	PRINT CHECK WITH ASTERISK FILL
	PRINT:PRINT:PRINT:PRINT
4250	FOR I%=2 TO 5
	PRINT TAB(12);M$(I%)						REMARK	PRINT NAME/ADDRESS LINE OF PAYEE
	NEXT I%
	FOR I%=1 TO 9							REMARK	PRINT LINE FEEDS TO CHECK STUB PORTION
	PRINT
	NEXT I%
	RETURN 
4320	C6%=C6%+1							REMARK	SKIP TO BOTTOM OF THE CURRENT CHECK STUB.\
										IF LAST STUB PAGE, PRINT TOTALS.
	FOR I%=1 TO 14-C8%
	PRINT
	NEXT I%
	C8%=0
	IF C5%=0  THEN PRINT TAB(15);"TOTAL";TAB(33);: \
	PRINT USING MASKD$;W(1)+W(3)+W(4);W(2);: \
	PRINT TAB(65);: \
	PRINT USING MASKC$;W(5)
	PRINT:PRINT
	PRINT "   REG. NO.";W7;TAB(25);M$(2);TAB(53);"PAGE";C6%;"OF";C9%
	PRINT CHR$(12)
	RETURN 
4370	A1=A8:GOSUB 4400						REMARK	ROUTINE TO PRINT A DUMMY CHECK FOR MULTI-PAGE CHECKS.
	PRINT
	PRINT TAB(5);L1$;TAB(65);L1$;L1$
	PRINT:PRINT:PRINT:PRINT
	GOTO 4250
4400	X1=INT(A1/10000)						REMARK	PRINT DATE (STORED IN A1) IN ENGLISH, AND PRINT REGISTER #
	X2=INT((A1-X1*10000)/100)
	X3=INT(A1-(X1*100+X2)*100)
	RESTORE
	FOR I%=1 TO 27+X1
	READ X0$
	NEXT I%
	PRINT TAB(70-LEN(X0$));X0$;X2;" ";X3
	PRINT TAB(62);"REG. NO.";W7
	RETURN 
6000	MASKA$="######"
	MASKB$=" #######.##"
	MASKC$="$$######.##"
	MASKD$="$$######.## LESS $$####.## DISC"
	IF END #3 THEN 6180						REMARK	EXIT IF THE CHECK FILE IS EMPTY
	OPEN "G/I0F010.DAT" AS 1,"A/P0F110.DAT" RECL 162 AS 2,\
	"A/P0F030.DAT" RECL 86 AS 3, "A/P0F130.DAT" AS 4
	Y9=1:GOSUB 700							REMARK	READ GENERAL INFORMATION FILE
	X0=4:GOSUB 3310							REMARK	READ A/P INFORMATION FILE
	RECORD.COUNT=AP.VENDFILE.EXTENT
	Y9=2:Y2=Y9
6010	L1$="*VOID*"
	CHECKS%=0
	CONSOLE
6020	PRINT CLEAR.SCREEN$;"A/P CHECK WRITER"
	PRINT:PRINT:PRINT:PRINT
	PRINT "FIRST CHECK REG. #"
	PRINT "LAST CHECK REG. #"
6025	X1=339:X2=6:X3=0:X4=999999:GOSUB 345				REMARK	ENTER FIRST REGISTER # TO PRINT
	F=X0
	IF F=0  THEN 6180
	X1=403:X2=6:X3=F:X4=999999:GOSUB 345				REMARK	ENTER LAST REGISTER # TO PRINT
	E=X0
	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665			REMARK	ENTER '1' IF ENTRY OK; OTHERWISE, RE-PROMPT
	IF X0=0 THEN 6025
	IF END #3 THEN 6010
6050	CHECKS%=CHECKS%+1
	READ #3,CHECKS%;W1$,W7,W5,A8,W9					REMARK	READ CHECK HEADER RECORD
	IF W7 > E THEN 6010						REMARK	IF REGISTER # IS BEYOND RANGE, END PRINTING; RE-START
6060	IF W7 < F THEN CHECKS%=CHECKS%+W9:GOTO 6050			REMARK	IF REGISTER # IS BELOW RANGE, ADD DETAIL RECORD COUNT\
										TO FILE POINTER AND GET NEXT CHECK HEADER.
6065	XYZ$=W1$+"      "
	K$=LEFT$(XYZ$,6):GOSUB 1060					REMARK	SEARCH VENDOR FILE
	IF H=-1 OR VAR1=0 THEN \
		 M$(2)="*** VOID ***":M$(3)="":M$(4)="":M$(5)="":W5=0 \	REMARK	IF RECORD NOT FOUND, VOID THE CURRENT PAYEE & CHECK
	ELSE X0=L:GOSUB 3200						REMARK	IF FOUND, READ FROM A/P0F110.DAT
6080	CONSOLE
	X1=768:GOSUB 210
	PRINT "REG.  NUMBER";W7						REMARK	PRINT CURRENT REGISTER #, PAYEE AND CHECK AMOUNT
	PRINT M$(2);TAB(64)
	PRINT "AMOUNT";
	PRINT USING MASKB$;W5
	LPRINTER
6100	GOSUB 4200							REMARK	EXECUTE SUBROUTINE TO PRINT BODY OF CHECK
	FOR I%=1 TO 5
	W(I%)=0								REMARK	ZERO OUT CHECK TOTALS
	NEXT I%
	C5%=W9
	C8%=0:C6%=0
	C9%=INT((W9-1)/6)+1						REMARK	CALCULATE NUMBER OF PAGES AND DETAIL ITEMS TO PRINT\
										ON NEXT PAGE OF CHECK STUB
6130	IF C5%<7  THEN C4%=C5%:C5%=0 \
	ELSE C5%=C5%-6:C4%=6
6150	FOR B%=1 TO C4%
	CHECKS%=CHECKS%+1
	READ #3,CHECKS%; W2$,W1%,D8,W0,W2(1),W2(2),W2(3),W2(4)		REMARK	READ CHECK DETAIL RECORD
	C8%=C8%+1
	PRINT TAB(3);
	X0=D8:GOSUB 680.5						REMARK	PRINT INVOICE DATE ON DETAIL RECORD
	PRINT TAB(15);
	PRINT USING MASKA$;W0;						REMARK	PRINT INVOICE NUMBER
	PRINT TAB(25);W2$;TAB(35);					REMARK	PRINT PURCHASE ORDER REFERENCE
	IF W2(2) <> 0 THEN PRINT USING MASKD$;W2(1)+W2(3)+W2(4),W2(2);	REMARK	PRINT AMT, DISCOUNT (IF DISCOUNT <> 0) 
	PRINT TAB(65);
	PRINT USING MASKC$;W2(1)+W2(2)+W2(3)+W2(4);			REMARK	PRINT TOTAL AMOUNT
	FOR I%=1TO 4
	W(I%)=W(I%)+W2(I%)						REMARK	ADD DETAIL AMOUNTS TO CHECK TOTAL
	W(5)=W(5)+W2(I%)
	NEXT I%
	IF W1%=5  THEN PRINT " DB";					REMARK	IF DEBIT MEMO, PRINT "DB"
	IF W1%=4  THEN PRINT " CR";					REMARK	IF CREDIT MEMO, PRINT "CR"
	PRINT 
	NEXT B%
	GOSUB 4320
	IF C5%=0  THEN 6050
	GOSUB 4370							REMARK	IF MORE PAGES TO PRINT, PRINT A DUMMY CHECK AND SKIP TO STUB
	GOTO 6130
6180	PRINT CLEAR.SCREEN$;"A/P CHECK WRITER LOADING MENU"
	CHAIN "A/P000"
