
	REMARK	#########################################################
	REMARK	#	A/R TRANSACTION FILE MAINTENANCE   (A/R070)	#
	REMARK	#		VERS. OF 3.00 PM	3/5/79		#
	REMARK	#########################################################

	DIM L4(2),D(13),Y(2),M$(5),R$(10),R1(10),R2(10)
%INCLUDE CURSOR
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE BINSEARC
%INCLUDE A/R-INV
%INCLUDE READCUST
%INCLUDE A/R-INFO
%INCLUDE A/RTAX
	DATA "INVOICE","CR MEMO","DB MEMO","NEW","INV BILLING"
	DATA "INV PAYMENT","PROG PAYMENT","DELETE","MODIFY"


.673	Z0=X1								REMARK	ENTER & DISPLAY DATE:  ALLOW ZERO DATE
	GOSUB 210
	PRINT "          ";
	X2=6
	X3=0
	X4=123199
	GOSUB 345							REMARK	ENTER THAT DATE
	IF X0=0 THEN X0$="000000"
	IF LEN(X0$)<5 THEN X1=Z0:GOTO .673
.6735	IF LEN(X0$) < 6 THEN X0$="0"+X0$:GOTO .6735
	IF MID$(X0$,1,2)>="00" AND MID$(X0$,1,2)<="12"\
	AND MID$(X0$,3,2)>="00" AND MID$(X0$,3,2) <="31" THEN .675
	X2$="OUT OF RANGE":GOSUB 615:X1=Z0:GOTO .673
.675	X0=VAL(X0$)
.680	GOSUB 210
.6805	X0$=STR$(X0)
.6806	IF LEN(X0$)<6 THEN X0$="0"+X0$:GOTO .6806
.681	PRINT LEFT$(X0$,2);"/";MID$(X0$,3,2);"/";RIGHT$(X0$,2);
	RETURN


4000	D(3)=INT((D(1)*R1(L6+1))+.5)/100				REMARK	COMPUTE SALES TAX AND INVOICE TOTAL
	D(4)=D(3)+D(2)+D(1)
	X1=704:GOSUB 210
	GOSUB 5440							REMARK	REDISPLAY INVOICE AMOUNTS AND TOTAL
4020	D(7)=D(4)-D(6)							REMARK	COMPUTE INVOICE BALANCE
	IF L4(2)<>0 THEN D(7)=D(7)-D(8)
	IF L4(1)=0 THEN D(7)=0						REMARK	IF BILL DATE IS ZERO, INVOICE BALANCE IS ZERO
4060	X1=320:GOSUB 210
	I1%=5:I2%=7:GOSUB 4320						REMARK	DISPLAY INVOICE PAYMENT AND BALANCE
	RETURN 


4080	D(11)=D(8)-D(10)						REMARK	COMPUTE PROGRESS BALANCE
	IF L4(2)=0 THEN D(11)=0						REMARK	ZERO PROGRESS BALANCE IF PROGRESS DUE DATE IS ZERO
	X1=640:GOSUB 210
	I1%=8:I2%=11:GOSUB 4320						REMARK	DISPLAY PROGRESS BILLING FIELDS
	RETURN 

									REMARK	CHECK FOR INCONSISTENCIES BETWEEN FIELDS
4120	IF D(7)<0 THEN 4220						REMARK	NEGATIVE INVOICE BALANCE ILLEGAL
	IF D(11)<0 THEN 4220						REMARK	NEGATIVE PROGRESS BALANCE ILLEGAL
	IF L4(1)<>0 THEN 4140						REMARK	IF BILL DATE IS ZERO...
	IF D(4)<>0 THEN 4220						REMARK	INVOICE PAYMENT MUST BE ZERO
	IF D(5)<>0 THEN 4220						REMARK	AND INVOICE BALANCE MUST BE ZERO
	GOTO 4160
4140	IF D(4)=0 THEN 4220						REMARK	IF BILL DATE IS NON-ZERO\
										INVOICE AMOUNT MUST BE NON-ZERO
4160	IF L4(2)<>0 THEN 4180						REMARK	IF PROGRESS DUE DATE IS ZERO...
	IF D(8)<>0 THEN 4220						REMARK	PROGRESS BILLING AMOUNT MUST BE ZERO
	IF D(9)<>0 THEN 4220						REMARK	AND PROGRESS BALANCE MUST BE ZERO
	GOTO 4200
4180	IF D(8)=0 THEN 4220						REMARK	IF PROGRESS DUE DATE IS NON-ZERO,\
										PROGRESS BILLING AMOUNT MUST BE NON-ZERO

									REMARK	DETERMINE TRANSACTION'S FATE
4200	X2=1:X3=1:X4=4:X2$="ENTER ACTION: 1=RECORD, 2=MORE CHANGES, 3=CANCEL,"
	X2$=X2$+" 4=VOID TRANS":GOSUB 665
	RETURN 

4220	FOR I%=1 TO 2							REMARK	FLASH NASTY MESSAGE ON SCREEN
	X2$="DATE OR AMOUNT FIELD MISSING OR NEGATIVE BALANCE":GOSUB 615
	NEXT I%
	X0=2
	RETURN 


4320	FOR I%=I1% TO I2%						REMARK	DISPLAY TRANSACTION FIELDS I1% THROUGH I2%
	X1=50:GOSUB 215
	PRINT USING MASKB$;D(I%)
	NEXT I%
	RETURN 

5000	GOSUB 5260							REMARK	DISPLAY CUSTOMER DATA
	X1=265:GOSUB 210
	PRINT W1$;TAB(12);M$(2);TAB(40);
	X1=12:GOSUB 215
	PRINT USING MASKA$;L1
	RETURN 

									REMARK	BRANCH TO ENTER VALUE FOR FIELD "F%"
5020	ON F% GOTO 5040,5060,5080,5100,5120,5140,5160,5180,5200,5220,5240,5250

5040	RETURN								REMARK	TRANSACTION TYPE CAN'T CHANGE 

5060	X1=403:X2=12:X3=0:X4=0:GOSUB 345				REMARK	ENTER CUSTOMER ORDER NUMBER
	L1$=X0$
	RETURN 

5080	X1=462:X2=6:X3=0:X4=999999:GOSUB 345				REMARK	ENTER JOB NUMBER
	L2=X0
	RETURN 

5100	X1=526:X2=6:X3=0:X4=0:GOSUB 345					REMARK	ENTER JOB DESCRIPTION
	L2$=X0$
	RETURN 

5120	X1=590:GOSUB .673						REMARK	ENTER BILL DATE
	L4(1)=X0
	RETURN 

5140	X1=652:X2=1:X3=0:X4=9:GOSUB 345					REMARK	ENTER TAX CODE
	L6=X0
	GOSUB 5400							REMARK	DISPLAY TAX CODE DESCRIPTION AND RATE
	D(13)=0
	IF L6>0 THEN 5420
	X1=718:X2=8:X3=-99999.9:X4=99999.9:GOSUB 345			REMARK	FOR TAX CODE ZERO, ENTER G/L ACCOUNT NUMBER
	D(13)=X0
	RETURN 

5160	X1=787:X2=10:X3=0:X4=9999999.99:GOSUB 345			REMARK	ENTER INVOICE AMOUNT
	D(1)=X0
	RETURN 

5180	X1=851:X2=10:X3=0:X4=9999999.99:GOSUB 345			REMARK	ENTER SHIPPING/TRAVEL AMOUNT
	D(2)=X0
	RETURN 

5200	X1=369:X2=11:X3=-9999999.99:X4=9999999.99:GOSUB 345		REMARK	ENTER INVOICE PAYMENT AMOUNT
	X1=363:GOSUB 210
	D(6)=D(6)-D(5)+ABS(X0)
	D(5)=ABS(X0)
	IF X0>=0 OR B=2 THEN PRINT "     ";:D(12)=0 \
	ELSE PRINT "BY CM";:D(12)=1
	RETURN 

5220	X1=628:GOSUB .673						REMARK	ENTER PROGRESS DUE DATE
	L4(2)=X0
	RETURN 

5240	X1=690:X2=10:X3=0:X4=9999999.99:GOSUB 345			REMARK	ENTER PROGRESS BILLING AMOUNT
	D(8)=X0
	RETURN 

5250	X1=754:X2=10:X3=0:X4=9999999.99:GOSUB 345			REMARK	ENTER PROGRESS PAYMENT
	D(10)=D(10)-D(9)+X0						REMARK	ADJUST PAYMENT TOTAL
	D(9)=X0
	RETURN 


5260	X1=16:GOSUB 210							REMARK	DISPLAY TRANSACTION OPERATION DESCRIPTION
	PRINT "FILE MAINTENANCE";
	RETURN 


5280	X1=9:GOSUB 215							REMARK	DISPLAY CURRENT TRANSACTION VALUES
	PRINT B;
	RESTORE
	FOR I%=1 TO B
	READ X0$
	NEXT I%
	PRINT X0$
	X1=20:GOSUB 215
	PRINT L1$
	X1=15:GOSUB 215
	PRINT USING MASKA$;L2
	X1=15:GOSUB 215
	PRINT L2$
	X1=15:GOSUB 215
	X0=L4(1):GOSUB 680.5
	PRINT 
	X1=12:GOSUB 215
	PRINT L6;
	GOSUB 5400
	IF L6=0 THEN X1=15:GOSUB 215:PRINT USING MASKC$;D(13); \
	ELSE GOSUB 5420
	GOSUB 5440
	GOSUB 4060
	PRINT 
	X1=53:GOSUB 215
	X0=L4(2):GOSUB 680.5
	PRINT 
	I1%=8:I2%=11:GOSUB 4320
	RETURN 


5400	X1=654:GOSUB 210						REMARK	DISPLAY TAX CODE DESCRIPTION AND RATE
	PRINT USING MASKD$;R$(L6+1),R1(L6+1)
	RETURN 

5420	X1=718:GOSUB 210						REMARK	DISPLAY TAX CODE'S G/L ACCOUNT NUMBER
	PRINT USING MASKC$;R2(L6+1);
	RETURN 

5440	FOR I%=1 TO 4							REMARK	DISPLAY INVOICE AMOUNT, SHIPPING, TAX, AND TOTAL
	PRINT 
	X1=19:GOSUB 215
	PRINT USING MASKB$;D(I%);
	NEXT I%
	RETURN 



									REMARK	START OF MAIN PROGRAM
6000	MASKA$="######"
	MASKB$=" #######.##"
	MASKC$=" #####.#"
	MASKD$="/      / ##.##%"
	OPEN "A/R0F020.DAT" RECL 226 AS 1,"A/R0F110.DAT" RECL 162 AS 2, \
	"A/R0F120.DAT" RECL 226 AS 3,"A/R0F130.DAT" AS 4, \
	"A/R0F030.DAT" AS 5,"CRT" RECL 1100 AS 19
	FILE.NO=4:GOSUB 3.14						REMARK	RETRIEVE A/R EXTENT INFORMATION
	A1=5:GOSUB 3700							REMARK	RETRIEVE A/R TAX CODE INFORMATION
6020	X0=15:GOSUB 260							REMARK	DISPLAY TRANSACTION ENTRY OPERATION SELECTION MASK
	GOSUB 5260							REMARK	DISPLAY PROGRAM TITLE
6040	X2=3:X3=0:X4=999:X2$="ENTER RECORD NO. TO CHANGE (0 TO END)"	REMARK	ENTER NUMBER OF TRANSACTION TO CHANGE
	GOSUB 665
	IF X0=0 THEN 6540						REMARK	END PROGRAM ON ZERO RECORD NO.
	IF X0>AR.TRANFILE.EXTENT THEN 6040
	FILE.NO=1:REC.NO%=X0:GOSUB 3400					REMARK	RETRIEVE TRANSACTION DATA
	IF C2>9 THEN X2$="TRANSACTION IS VOID":GOSUB 615:GOTO 6040
	RECORD.COUNT=AR.CUSTFILE.EXTENT
	Y2=2
	XYZ$=W1$+"      "
	K$=LEFT$(XYZ$,6)
	GOSUB 1060							REMARK	LOCATE CUSTOMER DATA
	IF H=-1 OR VAR1=0 THEN M$(2)="NOT ON CUSTOMER FILE" \
	ELSE Y9=2:X0=L:GOSUB 3225					REMARK	RETRIEVE CUSTOMER DATA
	GOSUB 5000							REMARK	DISPLAY CUSTOMER DATA
	GOSUB 5280							REMARK	DISPLAY TRANSACTION DATA
6240	IF C2=5 THEN 6260						REMARK	IF TRANSACTION OPERATION IS DELETE, DON'T ALLOW CHANGES
	X2=2:X3=0:X4=12:X2$="ENTER FIELD TO CHANGE (0=NONE)":GOSUB 665	REMARK	ALLOW CHANGES TO FIELDS
	IF X0=0 THEN 6260
	F%=X0
	IF C2=4 AND F%<>12 THEN 6240
	IF C2=3 AND F%<>9 THEN 6240
	GOSUB 5020							REMARK	ENTER VALUE FOR CHOSEN FIELD
	IF F%<5 THEN 6240
	GOSUB 4000							REMARK	COMPUTE SALES TAX AND INVOICE TOTAL
	IF F%>9 THEN GOSUB 4080						REMARK	COMPUTE PROGRESS BALANCE
	GOTO 6240

6260	GOSUB 4120							REMARK	CHECK FOR CONSISTENCY
	IF X0=2 THEN 6240						REMARK	ACTION CODE 2 = MORE CHANGES
	IF X0=3 THEN X2$="LAST CHANGES IGNORED":GOSUB 615:GOTO 6020	REMARK	ACTION CODE 3 = IGNORE CHANGES
	IF X0=4 THEN C2=C2+10: \					REMARK	ACTION CODE 4 = VOID TRANSACTION
		X2$="LAST TRANSACTION VOIDED": \
		GOSUB 615: GOTO 6360
	IF D(5)=0 OR B>1 THEN D(12)=0					REMARK	CHECK FOR PAYMENT BY CREDIT MEMO
	X2$="RECORDED":GOSUB 615
6360	GOSUB 3450							REMARK	UPDATE TRANSACTION FILE
	GOTO 6020


									REMARK	END PROGRAM AND RELOAD MENU
6540	PRINT CLEAR.SCREEN$;"A/R TRANSACTION FILE MAINTENANCE LOADING MENU"
	CHAIN"A/P000"
