
	REMARK	**********************************************
	REMARK	*  ACCOUNTS PAYABLE TRANSACTION F/M PROGRAM  *
	REMARK	*   (A/P120.BAS)      VERS OF 3 PM  6/27/78  *
	REMARK	**********************************************

	DIM C(27),D(27),W$(5),M$(5),A3$(10),P(6),Y(2)
%INCLUDE CURSOR
	DATA "INVOICE"," "," ","CR MEMO","DB MEMO","NEW","DELETE","MODIFY"
	MASKA$=" ######.##"
	MASKB$="######"
	MASKC$="######.#     #######.##  "
	MASKD$="##)     ######       #######.##"
	DEF FNR(Z9)=(INT(ABS(Z9)*100+.5)/100)*SGN(Z9)			REMARK	ROUND TO NEAREST CENT
	DEF FND(Z9)=FNR(Z9)*SGN(D2)					REMARK	USED IN G/L AND JOB POSTING VERIFICATIONS
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE BINSEARC
%INCLUDE READINV
%INCLUDE WRITEINV
%INCLUDE READVEND
%INCLUDE A/P-INFO
.314	RETURN								REMARK	THESE LINE NUMBERS FOR G/L SUBROUTINES
10.60	RETURN


5010	IF F=0 OR F>9 THEN GOTO 5040					REMARK	BRANCH TO ENTER VALUE OF FIELD "F"
	ON F GOTO 5040,5050,5060,5070,5080,5090,5100,5110,5120

5040	X1=462:X2=8:X3=0:X4=0:GOSUB 345					REMARK	ENTER PURCHASE ORDER NO.
	W2$=X0$
	RETURN 

5050	X1=526:X2=2:X3=0:X4=0:GOSUB 345					REMARK	ENTER BUYER
	W3$=X0$
	RETURN 

5060	X1=590:X2=6:X3=0:X4=999999:GOSUB 345				REMARK	ENTER CHECK REGISTER NO.
	D(25)=X0
	RETURN 

5070	X1=654:GOSUB 673						REMARK	ENTER INVOICE DATE
	PRINT
	D(23)=X0
	RETURN 

5080	X1=718:GOSUB 673						REMARK	ENTER AGE DATE
	PRINT
	D(24)=X0
	RETURN 

5090	IF W1%=4 THEN 5150						REMARK	ENTER INVOICE OR DEBIT MEMO AMOUNT
	X1=430:X2=9:X3=0:X4=999999.99:GOSUB 345
	C(23)=X0
	X1=429:GOSUB 210
	PRINT USING MASKA$;C(23)
	GOSUB 5140
	RETURN 

5100	X1=498:X2=5:X3=0:X4=100:GOSUB 345				REMARK	ENTER DISCOUNT RATE
	X1=493:GOSUB 210
	C(27)=X0
	PRINT USING MASKA$;C(27)
	GOSUB 5140
	RETURN 

5110	X1=622:X2=9:X3=0:X4=999999.99:GOSUB 345				REMARK	ENTER FREIGHT AMOUNT
	C(25)=FNR(X0)
	X1=621:GOSUB 210
	PRINT USING MASKA$;C(25)
	GOSUB 5140
	RETURN 

5120	X1=686:X2=9:X3=0:X4=999999.99:GOSUB 345				REMARK	ENTER TAX AMOUNT
	C(26)=FNR(X0)
	X1=685:GOSUB 210
	PRINT USING MASKA$;C(26)
	GOSUB 5140
	RETURN 

5140	C(24)=-1*FNR((C(23)*C(27))/100)					REMARK	RECALCULATE AND DISPLAY DISCOUNT AMOUNT
	X1=557:GOSUB 210
	PRINT USING MASKA$;C(24)
	GOTO 5215

5150	X1=494:X2=9:X3=-1*C(24):X4=999999.99:GOSUB 345			REMARK	ENTER CREDIT MEMO AMOUNT
	C(23)=FNR(X0)
	X1=494:GOSUB 210
	PRINT USING MASKA$;C(23)
	GOTO 5230

									REMARK	DISPLAY TRANSACTION MASK AND VALUES
5200	IF W1%=4 THEN 5220						REMARK	CREDIT MEMO TRANSACTIONS AT LINE 5220
	X0=2:GOSUB 260
	GOSUB 5375
	GOSUB 5250
	X1=493:GOSUB 210
	PRINT USING MASKA$;C(27)
	FOR A1%=24 TO 26
	PRINT LEFT$(X9$,45);						REMARK	PRINT NON-DESTRUCTIVE SPACES
	PRINT USING MASKA$;C(A1%)
	NEXT A1%
5215	X1=749:GOSUB 210
	PRINT USING MASKA$;C(23)+C(24)+C(25)+C(26)
	N1=1
	RETURN 

									REMARK	DISPLAY CREDIT MEMO TRANSACTIONS
5220	X0=13:GOSUB 260							REMARK	GET CRT MASK #13
	GOSUB 5375
	GOSUB 5250
	X1=558:GOSUB 210
	PRINT USING MASKA$;C(24)
	X1=622:GOSUB 210
	PRINT USING MASKA$;C(25)
5230	X1=686:GOSUB 210
	PRINT USING MASKA$;C(23)+C(24)
	N1=1
	RETURN 


5250	X1=266:GOSUB 210						REMARK	DISPLAY TRANSACTION DATA
	PRINT W1$
	X1=7:GOSUB 215
	PRINT M$(2)
	X1=15:GOSUB 215
	PRINT USING MASKB$;W0
	X1=15:GOSUB 215
	PRINT W2$
	IF W1%=4 THEN X1=494 \
	ELSE X1=429
	GOSUB 210
	PRINT USING MASKA$;C(23)
	X1=526:GOSUB 210
	PRINT W3$
	X1=15:GOSUB 215
	PRINT USING MASKB$;D(25)
	X1=15:GOSUB 215
	X0=D(23):GOSUB 680.5:PRINT
	X1=15:GOSUB 215
	X0=D(24):GOSUB 680.5:PRINT
	RETURN 


5375	PRINT CURSOR.HOME$;"A/P TRANSACTION F/M     "			REMARK	DISPLAY PROGRAM TITLE
	RETURN

5410	IF I%>11 THEN 5450
	X1=(I%-1)*64+326:X2=7:X3=0:X4=99999.9:GOSUB 345			REMARK	ENTER G/L DISTRIBUTION
	D(I%)=X0
	IF X0=0 THEN 5445
	GOTO 5440							REMARK	BYPASS THIS SECTION UNLESS G/L PROGRAMS INSTALLED

5420	Y2=5
	K1=X0
	GOSUB 10.60
	IF H=-1 THEN X2$="INVALID G/L NUMBER":GOSUB 615:GOTO 5410
5440	X1=(I%-1)*64+338:X2=10:X3=-999999.99:X4=999999.99:GOSUB 345	REMARK	ENTER DISTRIBUTION AMOUNT
	X0=FNR(X0)
5445	D1=D1+X0-C(I%)							REMARK	ACCUMULATE G/L AMOUNT TO TOTAL \
										AND DISPLAY ACCOUNT AND AMOUNT
	C(I%)=X0
	X1=(I%-1)*64+325:GOSUB 210
	PRINT USING MASKC$;D(I%),C(I%)
	RETURN 

5450	X1=(I%-12)*64+358:X2=6:X3=0:X4=999999:GOSUB 345			REMARK	ENTER JOB NUMBER
	D(I%)=X0
	IF X0<>0 THEN \							REMARK	ENTER DISTRIBUTION AMOUNT
		X1=(I%-12)*64+371:X2=10:X3=-999999.99:X4=999999.99:GOSUB 345:\
		X0=FNR(X0)
	D2=D2+X0-C(I%)							REMARK	ACCUMULATE JOB AMOUNT TO TOTAL
	C(I%)=X0
	X1=(I%-12)*64+350:GOSUB 210
	PRINT USING MASKD$;I%,D(I%),C(I%)				REMARK	DISPLAY ACCOUNT AND AMOUNT
	RETURN 

5460	IF W1%=4 THEN D0=C(23)\						REMARK	CALCULATE TOTALS
	ELSE D0=C(23)+C(24)+C(25)+C(26)
	IF FND(D1)<>D2 THEN 5465
	IF D1+D2<>FNR(D0)+FND(D0) THEN 5465
	PRINT CURSOR.HOME$;
	PRINT:PRINT:PRINT
	PRINT TAB(64);
	IF N1<=1 THEN RETURN
	N1=0
	GOTO 5460

5465	IF N1=1 THEN \							REMARK	ROUTINE TO CORRECT OUT-OF-BALANCE DISTRIBUTION
		N1=2:\
		GOSUB 5520:\
		F=0
5470	IF D1<>D0 THEN 5480
	X0=39:X0$="JOB":X2=D0-D2:GOSUB 5490				REMARK	USE SUBROUTINES TO CORRECT JOB TOTALS
	IF D2 <> FND(D0) THEN 5470
	PRINT CURSOR.HOME$;
	PRINT:PRINT:PRINT
	PRINT TAB(64)
	GOTO 5460

5480	X0=6:X0$="G/L":X2=D0-D1:GOSUB 5490				REMARK	USE SUBROUTINES TO CORRECT G/L TOTALS
	IF D1<>D0  THEN 5480
	GOTO 5460

5490	IF X2=0 THEN RETURN						REMARK	THIS SUBROUTINE DISPLAYS G/L OR \
										JOB POSTING DISCREPANCY AMOUNTS
	X1=192:GOSUB 210
	PRINT TAB(X0);X0$;" DIST OFF";
	PRINT USING MASKA$;X2;TAB(64)
	N1=2
	GOSUB 5950
	RETURN 


5520	IF N1+F=5  THEN RETURN						REMARK	REDISPLAY G/L AND JOB DISTRIBUTION MASK AND TOTALS
	X0=3:GOSUB 260
	GOSUB 5375
	X1=320:GOSUB 210
	FOR I%=1 TO 11
	X1=6:GOSUB 215
	IF D(I%)=0 THEN X1=26:GOSUB 215\
	ELSE\
	PRINT USING MASKC$;D(I%),C(I%);
	IF D(I%+11)>0 THEN PRINT USING MASKD$; I%+11,D(I%+11),C(I%+11)\
	ELSE PRINT
	NEXT I%
	IF F=3  THEN 5950
	RETURN 

5550	X0%=RECORD.NUMBER.ENTERED%
	FILE.NO=2:GOSUB 3000						REMARK	GET TRANSACTION RECORD FROM A/P0F020
	D1=C(1)+C(2)+C(3)+C(4)+C(5)+C(6)+C(7)+C(8)+C(9)+C(10)+C(11)
	D2=C(12)+C(13)+C(14)+C(15)+C(16)+C(17)+C(18)+C(19)+C(20)+C(21)+C(22)
	IF W1%=4 THEN F1=6 \
	ELSE F1=9
	RECORD.COUNT=AP.VENDFILE.EXTENT
	Y2=1
	XYZ$=W1$+"      "
	K$=LEFT$(W1$,6)
	GOSUB 1060
	IF H=-1 OR VAR1=0 THEN M$(2)="NOT ON FILE" \
	ELSE Y9=1:X0=L:GOSUB 3200					REMARK	LOAD VENDOR INFORMATION
	RETURN
	
5590	FILE.NO=2
	X0%=RECORD.NUMBER.ENTERED%
	GOSUB 3050							REMARK	WRITE TRANSACTION RCD TO A/P0F020
	X2$="RECORDED":GOSUB 615
	RETURN

5700	X2$="LAST CHANGES IGNORED"					REMARK	IGNORE LAST ENTERED CHANGES
	GOSUB 615
	RETURN 

5800	X2$="LAST TRANSACTION VOIDED"					REMARK	VOID LAST TRANSACTION
	GOSUB 615
	W2%=W2%+10
	FILE.NO=2
	X0%=RECORD.NUMBER.ENTERED%					REMARK	SET W2% TO LOGICALLY DELETE THIS RECORD \
										BY ADDING 10 TO CURRENT VALUE...
	GOSUB 3050							REMARK	SAVE RECORD ON A/P0F020
	RETURN 

5900	X2=1:X3=0:X4=F1:X2$="ENTER FIELD TO CHANGE(0=NONE)":GOSUB 665	REMARK	ALLOW CHANGES TO FIELDS ON THE INVOICE SCREEN
	F=X0
	IF F=0 THEN RETURN
	GOSUB 5010
	GOTO 5900

5950	X2=2:X3=0:X4=22:X2$="ENTER FIELD TO CHANGE(0=NONE)":GOSUB 665	REMARK	ALLOW CHANGES TO G/L AND JOB DISTRIBUTION FIELDS
	IF X0=0 THEN RETURN
	I%=X0
	GOSUB 5410
	IF N1=2 THEN RETURN
	GOTO 5950


									REMARK	START OF MAIN PROGRAM
6000	OPEN "A/P0F110.DAT" RECL 162 AS 1				REMARK	OPEN VENDOR FILE
	OPEN "A/P0F020.DAT" RECL 580 AS 2				REMARK	OPEN TRANSACTION FILE
	OPEN "A/P0F130.DAT" AS 4					REMARK	OPEN A/P INFORMATION FILE
	OPEN "CRT" RECL 1100 AS 19
	X0=4
	GOSUB 3310							REMARK	GET A/P GENERAL INFORMATION
	GOTO 6160							REMARK	SKIP OPENING G/L FILE FOR NOW
	OPEN "G/L0F110.DAT" RECL 157 AS 5
	OPEN "G/L0F130.DAT" AS 6
	FILE.NO%=6:GOSUB .314
6160	PRINT CLEAR.SCREEN$;
	GOSUB 5375							REMARK	DISPLAY PROGRAM IDENTIFICATION
	X0=0
	X2=3:X3=0:X4=TRANSACTION.RCD.COUNT%:\
	X2$="ENTER RECORD NO. TO CHANGE (0 TO END)":GOSUB 665		REMARK	ENTER NUMBER OF TRANSACTION TO CHANGE
	IF X0=0 THEN GOTO 6400						REMARK	END PROGRAM ON 0 ENTRY
	RECORD.NUMBER.ENTERED%=X0
	F=0
	GOSUB 5550							REMARK	RETRIEVE TRANSACTION
	IF W2%>9 THEN X2$="TRANSACTION IS VOID":GOSUB 615: GOTO 6160
	GOSUB 5200							REMARK	DISPLAY TRANSACTION
	GOSUB 5900							REMARK	ALLOW CHANGES TO INVOICE SCREEN FIELDS
6380	GOSUB 5460							REMARK	CALCULATE TOTAL
	X0=11:GOSUB 260							REMARK	GET THE ACTION CODE MASK FROM CRT FILE
	GOSUB 5375							REMARK	DISPLAY PROGRAM IDENTIFICATION
	X1=140:X2=1:X3=1:X4=5:GOSUB 345					REMARK	ENTER ACTION CODE
	F=X0

	IF F=1 THEN GOSUB 5590:GOTO 6160				REMARK	WRITE THE TRANSACTION RCD

	IF F=2 THEN GOSUB 5200:GOSUB 5900:GOTO 6380			REMARK	DISPLAY TRANSACTION DATA AND ALLOW CHANGES

	IF F=3 THEN GOSUB 5520:N1=1:GOTO 6380				REMARK	DISPLAY G/L & JOB DATA AND RETURN TO ACTION CODE MASK

	IF F=4 THEN GOSUB 5800:GOTO 6160				REMARK	VOID TRANSACTION AND GO BACK TO VENDOR NUMBER ENTRY

	IF F=5 THEN GOSUB 5700:GOTO 6160				REMARK	IGNORE LAST CHANGES


6400	PRINT CLEAR.SCREEN$;"A/P TRANSACTION F/M LOADING MENU"		REMARK	END PROGRAM AND RE-LOAD MENU
	CHAIN "A/P000"
