	REMARK	********************************************\
		*    A/P050.BAS  CHECK REGISTER PROGRAM    *\
		*      6/18/79             5:00  PM        *\
		********************************************


	DIM W(5),W5(6),W3$(7),W2(4),M$(5),P(6),G2$(5),G3(5),Y(2)
%INCLUDE CURSOR
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE GENINFO
%INCLUDE BINSEARC
%INCLUDE READVEND
%INCLUDE A/P-INFO


825	REMARK     *********     TOP OF FORM AND REPORT HEADINGS SUBROUTINE     *********
	IF LINE.COUNT% <55 AND PAGE.COUNT%>0  THEN RETURN		REMARK	IF NOT TOP OF NEW PAGE, OR FIRST PAGE, RETURN.
	PAGE.COUNT%=PAGE.COUNT%+1
	PRINT CHR$(12);TAB((A1-LEN(G2$(1)))/2);G2$(1);TAB(A1);"DATE ";
	X0=G3(1):GOSUB 680.5						REMARK	PRINT REPORT DATE FROM GENERAL INFORMATION FILE.

	PRINT 
	PRINT TAB((A1-LEN(X4$))/2);X4$;TAB(A1);"PAGE";PAGE.COUNT%
	PRINT
	PRINT TAB(8);"DATE    INV NO.  DESCRIPTION    AMOUNT   DISCOUNT";
	PRINT "    FREIGHT      TAXES    NET AMT      CHECK NO."	REMARK	PRINT REPORT HEADINGS
         
	PRINT
	LINE.COUNT%=6
	IF W(5) > 0\							REMARK	IF TOP-OF-PAGE WAS REACHED WHILE PRINTING CHECK DETAIL,
	THEN\								REMARK	THEN PRINT A MESSAGE TO THAT EFFECT ON THE NEW PAGE.
	PRINT USING MASKD$;W7,:\
	PRINT W1$;"   CONTINUED":\
	LINE.COUNT%=LINE.COUNT%+1
	RETURN 




5000	REMARK	**********       PRINT CHECK HEADER INFORMATION     **********
	X4$="A/P CHECK REGISTER":A1=90:GOSUB 825
	PRINT USING MASKD$;W7						REMARK	PRINT CHECK REGISTER NUMBER
	PRINT W1$;"   ";M$(2);TAB(55);"DATE ";				REMARK	PRINT VENDOR NUMBER, NAME
	X0=A8:GOSUB 680.5						REMARK	PRINT CHECK DATE
	PRINT TAB(95);"----------"
	LINE.COUNT%=LINE.COUNT%+1
	RETURN 




5040	REMARK	**********     PRINT CHECK TOTALS     **********
	PRINT TAB(10);
	PRINT USING MASKC$;W9;						REMARK	PRINT NUMBER OF ITEMS ON CHECK
	PRINT " ITEM";
	IF W9>1  THEN PRINT"S";
	FOR I%=1 TO 5
	IF W(I%)=0 THEN 5080
	PRINT TAB(24+(I%*11));
	PRINT USING MASKB$;W(I%);					REMARK	PRINT CHECK TOTALS
	W5(I%)=W5(I%)+W(I%)
	W(I%)=0
5080	NEXT I%
	PRINT:PRINT
	LINE.COUNT%=LINE.COUNT%+2
	RETURN 



6000	MASKA$="######"
	MASKB$=" #######.##"
	MASKC$="##"
	MASKD$="REGISTER  ######  "
	IF END #3 THEN 6440						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, "A/P0F030.PST" AS 5
	READ #5;W8
	Y9=1:GOSUB 700							REMARK	OPEN AND READ GENERAL INFORMATION FILE
	X0=4:GOSUB 3310							REMARK	GET A/P INFORMATION FILE
	CLOSE 1,4
	DELETE 5
	RECORD.COUNT=AP.VENDFILE.EXTENT
	Y9=2:Y2=Y9
	Y1=3
6020	CONSOLE
	LINE.COUNT%=66
	PAGE.COUNT%=0
	PRINT CLEAR.SCREEN$;"A/P CHECK REGISTER"
	PRINT:PRINT:PRINT:PRINT"FIRST CHECK REG. #"
	PRINT "LAST CHECK REG. #"
6060	X1=275:X2=6:X3=0:X4=999999:GOSUB 345				REMARK	ENTER FIRST CHECK REGISTER NUMBER
	IF X0=0 THEN 6440						REMARK	IF FIRST CHECK REGISTER NUMBER IS ZERO,\
										EXIT THE PROGRAM.
	F=X0
	X1=339:X2=6:X3=F:X4=999999:GOSUB 345				REMARK	ENTER LAST CHECK REGISTER NUMBER TO INCLUDE
	E=X0
6080	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665
	IF X0 <> 1 THEN 6060						REMARK	IF '1' WAS NOT ENTERED (I.E., INCORRECT ENTRY),\
										THEN RE-START ENTRY OF CHECK REGISTER NUMBERS.
	LPRINTER WIDTH 131
	CHECKS%=0
	IF END #3 THEN 6360						REMARK	IF END OF CHECK FILE, BRANCH TO TOTALS
6120	CHECKS%=CHECKS%+1
	READ #3,CHECKS%; W1$,W7,W5,A8,W9				REMARK	READ CHECK HEADER RECORD
	IF W7 > E THEN 6360						REMARK	IF REGISTER NUMBER IS PAST PRINT RANGE,\
										THEN BRANCH TO THE TOTALS ROUTINE.
	IF W7 < F \							REMARK	IF REGISTER NUMBER IS BELOW RANGE,
	THEN\								REMARK	ADVANCE FILE POINTER TO NEXT CHECK HEADER RECORD.
	CHECKS%=CHECKS%+W9:GOTO 6120

6125	XYZ$=W1$+"      "
	K$=LEFT$(XYZ$,6)
	GOSUB 1060							REMARK	SEARCH FOR VENDOR RECORD
	IF H = -1 OR VAR1=0 THEN M$(2)="NOT ON FILE" \			REMARK	IF RECORD NOT FOUND, SET VENDOR NAME TO ERROR MESSAGE.
	ELSE X0=L:GOSUB 3200
	GOSUB 5000
6240	FOR B%=1 TO W9
	CHECKS%=CHECKS%+1
	READ #3,CHECKS%; W2$,W1%,D8,W0,W2(1),W2(2),W2(3),W2(4)		REMARK	READ CHECK DETAIL RECORD
	X4$="A/P CHECK REGISTER":A1=90:GOSUB 825			REMARK	PRINT REPORT HEADING IF FIRST RECORD OR END OF PAGE.

6250	PRINT TAB(7);
	X0 = D8:GOSUB 680.5
	PRINT TAB(17);
	PRINT USING MASKA$;W0;						REMARK	PRINT INVOICE NUMBER
6260	PRINT TAB(26);W2$;
	FOR J% = 1 TO 4
	IF W2(J%) = 0 THEN 6280
	PRINT TAB(24+J%*11);
	PRINT USING MASKB$;W2(J%);					REMARK	PRINT DETAIL AMOUNT FIELD
	W(J%) = W(J%)+W2(J%)						REMARK	ADD DETAIL AMOUNTS TO CHECK TOTALS
	W(5) = W(5)+W2(J%)
6280	NEXT J%
	PRINT TAB(79);
	PRINT USING MASKB$;W2(1)+W2(2)+W2(3)+W2(4);
	IF W1% = 4  THEN PRINT " CR";					REMARK	IF CREDIT MEMO, PRINT "CR"
	PRINT 
	LINE.COUNT%=LINE.COUNT%+1
	NEXT B%
	GOSUB 5040
	GOTO 6120
6360	PRINT:PRINT:PRINT "TOTALS";
	FOR I%=1 TO 5
	PRINT TAB(24+(I%*11));
	PRINT USING MASKB$;W5(I%);					REMARK	PRINT CHECK REGISTER TOTALS
	NEXT I%
	PRINT 
6380	PRINT:PRINT:PRINT"G/L P0STINGS OF LATEST CHECK RUN"
	PRINT "TOTAL AMOUNT ";
	PRINT USING MASKB$;W8;
6420	PRINT "  POSTED TO CASH & A/P"
	GOTO 6020
6440	CONSOLE

	PRINT CLEAR.SCREEN$;"A/P CHECK REGISTER LOADING MENU"
	CHAIN "A/P000"
