	REMARK	*****************************************\
		*  P/R310.BAS   OVERHEAD DISTRIBUTION   *\
		*    3/23/79                  4:30 PM   *\
		*****************************************

%INCLUDE CURSOR

	DIM W(2),W1(2),W2(14),W2$(2),G2$(5),G3(5)
	DEF FNR(A1)=INT(A1*100+.5)/100					REMARK  ROUNDING FUNCTION
	GOTO 6000

%INCLUDE SUBS1
%INCLUDE GENINFO

6000	MASKA$="######.##"						REMARK  SET UP PRINT MASKS
	MASKB$="##.##"
	MASKC$="######.## (##.##%)"
	MASKD$="###.##"
 	Y8=1 
	Y9=2
	OPEN "JOB0F100.DAT" RECL 160 AS 1,"G/I0F010.DAT" RECL 200 AS 2,\REMARK  OPEN JOB, GENERAL INFOMATION AND CRT MASK FILES
	"CRT" RECL 1100 AS 19
	GOSUB 700							REMARK  READ GENERAL INFORMATION FILE
	X0=13:GOSUB 260							REMARK  GET CRT MASK 13
6020	X1=64:GOSUB 210
	PRINT "WORKING..."
	IF JOB.RECORDS=0 THEN X2$="FILE IS EMPTY":GOSUB 615:\
	GOTO 6225
6035	FOR K%=1 TO JOB.RECORDS
	READ #1,K%;W(1),W(2)						REMARK  READ JOB FILE
	IF W(2)=0 THEN\
	READ #1,K%;W(1),W(2),W1$,W1(1),W1(2),W2$(1),W2$(2):GOTO 6065	REMARK  IF HEADER RECORD ENCOUNTERED, READ IT IN
	READ #1,K%;W(1),W(2),W2(1),W2(2),W2(3),W2(4),W2(5),\		REMARK  READ DETAIL RECORD IF W(2) IS POSITIVE
	W2(6),W2(7),W2(8),W2(9),W2(10),W2(11),W2(12),W2(13),W2(14)
	IF W2(3)=-1 THEN 6065						REMARK  IF DETAIL RECORD WAS DELETED, SKIP IT

	J2=J2+W2(3)							REMARK  ADD MONTHLY COST-2 FOR ALL JOBS INTO J2

 	IF W2$(2)<>"1" THEN J=J+W2(3)					REMARK  ADD COST-2 FOR ALL NON-PAYROLL OVERHEAD JOBS

 	IF W2$(2)="0" THEN J0=J0+W2(3)					REMARK  ADD COST-2 FOR ALL PAYROLL OVERHEAD JOBS
6065	NEXT K%


	X1=270:GOSUB 210:PRINT USING MASKA$; J2;			REMARK  DISPLAY TOTAL OVERHEAD
	X1=8:GOSUB 215:PRINT USING MASKA$; J2-J;			REMARK  SUBTRACT NON-PAYROLL OVERHEAD
	X1=5:GOSUB 215:PRINT USING MASKA$; J;				REMARK  DISPLAY TOTAL PAYROLL COSTS FOR PERIOD

	X1=408:X2=5:X3=0:X4=99.99:GOSUB 345				REMARK  ENTER TAXES AND INSURANCE PERCENTAGE OF PAYROLL
	R1=X0
	X1=472:X2=5:X3=0:X4=99.99:GOSUB 345				REMARK  ENTER VACATION AND HOLIDAY PAY PERCENTAGE
	R2=X0 
	R3=R1+R2							REMARK  ADD AND DISPLAY TOTAL PERCENTAGE

	X1=536:GOSUB 210
	PRINT USING MASKB$; R3;
	X1=8:GOSUB 215
	PRINT USING MASKA$; FNR(R3/100*J);


	X1=665:X2=9:X3=0:X4=999999.99:GOSUB 345				REMARK  ENTER GENERAL OFFICE OVERHEAD AMOUNT
	O1=X0
 	IF O1>0 THEN R4=O1/J*100 ELSE R4=0				REMARK  CONVERT AMOUNT TO PERCENT OF TOTAL PAYROLL
	X1=680:GOSUB 210:PRINT USING MASKB$; FNR(R4)			REMARK  PRINT PERCENTAGE
	PRINT
	X1=26:GOSUB 215:PRINT USING MASKA$; J0				REMARK  DISPLAY PERSONNEL OVERHEAD PAY

	X1=26:GOSUB 215:PRINT USING MASKC$; FNR(J0*R3/100); FNR(R3)	REMARK  DISPLAY PAYROLL OVERHEAD

	X1=26:GOSUB 215:PRINT USING MASKC$; FNR(J0*R4/100); FNR(R4)	REMARK  DISPLAY GENERAL OFFICE OVERHEAD

	J1=J0+FNR(J0*R3/100)+FNR(J0*R4/100)				REMARK  CALCULATE AND DISPLAY TOTAL PERSONNEL OVERHEAD
	X1=26:GOSUB 215:PRINT USING MASKA$; J1;

 	IF J1>0 THEN R5=J1/(J-J0)*100 ELSE R5=0				REMARK  CALCULATE AND DISPLAY PERSONNEL OHD PERCENT
	X1=6:GOSUB 215:PRINT USING MASKD$; FNR(R5);
	X1=11:GOSUB 215:PRINT USING MASKD$; FNR(R5)+FNR(R4)+FNR(R3)	REMARK  DISPLAY TOTAL OVERHEAD PERCENT


	PRINT CURSOR.HOME$
	PRINT
	PRINT "KEY RETURN TO BEGIN; CTRL-C TO EXIT"
6160	IF CONSTAT%=0 THEN GOTO 6160					REMARK  AWAIT OPERATOR CUE BEFORE STARTING PROCESSING
	A%=CONCHAR%
	IF A%=03H\
	THEN\
	X2$="PROGRAM ABORTED":GOSUB 615:\				REMARK  FLASH TERMINATION MESSAGE IF CTRL-C HIT
	GOTO 9000
	IF A% <>0DH THEN GOTO 6160					REMARK  EXECUTE PROGRAM ONLY IF <RETURN> WAS HIT


	PRINT "WORKING...DO NOT INTERRUPT";
	FOR K%=1 TO JOB.RECORDS
	READ #1,K%;W(1),W(2)
	IF W(2)=0 THEN \
	READ #1,K%;W(1),W(2),W1$,W2(1),W2(2),W2$(1),W2$(2):GOTO 6225	REMARK  READ HEADER RECORD

	READ #1,K%;W(1),W(2),W2(1),W2(2),W2(3),W2(4),W2(5),\		REMARK  IF W(2) IS POSITIVE, READ JIB DETAIL RECORD
	W2(6),W2(7),W2(8),W2(9),W2(10),W2(11),W2(12),W2(13),W2(14)

	IF W2(3)=-1 OR W2$(2)="1" THEN 6225				REMARK  IF JOB RECORD WAS DELETED OR IS NOT TO HAVE\
									        OVERHEAD DISTRIBUTED TO IT, GET NEXT RECORD

	W2(4)=0:W2(5)=0:W2(6)=0:W2(7)=0					REMARK  INITIALIZE ALL MONTHLY OVERHEAD AMOUNTS				
 	W2(4)=FNR(R3/100*W2(3))						REMARK  CALCULATE PAYROLL OVERHEAD BASED ON COST-2
 	W2(5)=FNR(R4/100*W2(3))
 	IF W2$(2)<>"0"\
	THEN\
	W2(6)=FNR(R5/100*W2(3)):W2(14)=W2(14)+W2(7)			REMARK  ADD PERSONNEL AND MISCELLANEOUS OVERHEAD\
									        FOR ANY USER-DEFINED COST CENTER

 	W2(7)=0
 	W2(11)=W2(11)+W2(4) 						REMARK  ADD ALL MONTHLY OVERHEAD TO J-T-D OVERHEAD
	W2(12)=W2(12)+W2(5) 
	W2(13)=W2(13)+W2(6)


6220	PRINT #1,K%;W(1),W(2),W2(1),W2(2),W2(3),W2(4),W2(5),\		REMARK  RE-WRITE DETAIL RECORD WITH DITRIBUTED COSTS
	W2(6),W2(7),W2(8),W2(9),W2(10),W2(11),W2(12),W2(13),W2(14)

6225	NEXT K%



9000	PRINT CLEAR.SCREEN$;						REMARK  END OF PROGARM -- CLOSE FILES, CHAIN MENU
	PRINT"OVERHEAD DISTRIBUTION EXITING"
	CHAIN "P/R000"
