	REMARK	***************************************\
		*  P/R220.BAS  941A QUARTERLY REPORT  *\
		*    5/21/79             9:43 AM      *\
		***************************************

%INCLUDE CURSOR

	DIM S1(8),F1(6),B(9),P1(3),S(96),R1(2),R2(5),R$(5),G2$(5),G3(5)
	RESTORE
	DATA "GROSS EARNINGS","TAXABLE EARNINGS","SUBJECT TO F.U.T."
	DATA "SUBJECT TO F.I.C.A.","SUBJECT TO S.D.I.","F.U.T."
	DATA "F.I.C.A.","S.D.I.","NO. OF EMPLOYEES"
	DEF FNR(I8)=INT(I8*100+.5)/100					REMARK  ROUNDING FUNCTION
	GOTO 6000

%INCLUDE SUBS1
%INCLUDE GENINFO
%INCLUDE MSTRIN

5000	PRINT								REMARK  PRINT AND CLEAR 941A PAGE TOTALS
	PRINT TAB(21);
	PRINT USING A$;P1(1),P1(1),P1(2),P1(3)				REMARK  PRINT PAGE TOTALS
	FOR I7%=1 TO 3
	P1(I7%)=0							REMARK  CLEAR PAGE TOTAL
	NEXT I7%
	RETURN 

5030	IF C-A>=I2 THEN  A1=0						REMARK  CALCULATE HOW MUCH OF GROSS PAY IS TAXABLE,\
									        MODIFIED BY CUTOFF STORED IN I2
	IF C>=I2 THEN A1=I2-C+A ELSE A1=A

	RETURN 

6000	A$="## EMPLOYEES ## EMPLOYEES      ########.##  ########.##"	REMARK  SET UP PRINT MASKS
	B$="########.##"
	C$="  ######"
	D$=" ########.##  ########.##"
	E$="####"

	OPEN "P/R0F060.DAT" AS 1					REMARK  OPEN FEDERAL TAX FILE
	READ #1;F1(1),F1(2),F1(3),F1(4),F1(5),F1(6)			REMARK  READ TAX TABLES IN
	OPEN "P/R0F070.DAT" AS 2					REMARK  OPEN STATE TAX FILE
	READ #2;S1$,S1(1),S1(2),S1(3),S1(4),S1(5),S1(6),S1(7),S1(8)	REMARK  READ STATE TAX TABLES IN

	CLOSE 1,2
	OPEN "P/R0F110.DAT" RECL 1150 AS 1				REMARK  OPEN EMPLOYEE MASTER FILE
6010	CONSOLE
	PRINT CLEAR.SCREEN$;"FEDERAL QUARTERLY 941A"			REMARK  DISPLAY PROGRAM I.D. AND ENTRY MASK
	PRINT "ENTER START EMPLOYEE NUMBER OF ZERO TO EXIT"
	PRINT:PRINT:PRINT "START EMPLOYEE NUMBER"
	PRINT "END EMPLOYEE NUMBER"
	X1=279:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER STARTING EMPLOYEE NUMBER

	IF X0=0 THEN\							REMARK  IF START EMPLOYEE IS ZERO,
	PRINT CLEAR.SCREEN$;"941A LOADING MENU":\			REMARK  ABORT PROGRAM AND LOAD THE MENU
	CHAIN "P/R000"
	E1=X0

6020	X1=343:X2=3:X3=E1:X4=999:GOSUB 345				REMARK  ENTER ENDING EMPLOYEE NUMBER
	E2=X0
	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665			REMARK  VERIFY ENTRY: '1'=O.K.; '0'=RETRY
	IF X0<>1 THEN  6010

	FOR A%=1 TO 3
	P1(A%)=0							REMARK  CLEAR PAGE TOTAL
	NEXT A%
	FOR A%=1 TO 9
	B(A%)=0								REMARK  CLEAR GRAND TOTALS
	NEXT A%
	B1=0
	RESTORE 

	Y9=4:OPEN "G/I0F010.DAT" RECL 200 AS Y9				REMARK  OPEN GENERAL INFORMATION FILE
	GOSUB 700							REMARK  READ GENERAL INFORMATION FILE
	CLOSE Y9
	LPRINTER							REMARK  SELECT PRINTER AS OUTPUT DEVICE
	IF E1 > MSTR.RECORDS THEN GOTO 6010				REMARK  IF INVALID EMPLOYEE RANGE, RE-ENTER
	IF E2 > MSTR.RECORDS THEN E2=MSTR.RECORDS
	FOR J%=E1 TO E2
	X0=J%
	GOSUB 745							REMARK  READ EMPLOYEE MASTER RECORD
	IF Q$="E" THEN 6100
	IF S(1)<E1 OR S(59)=0 THEN GOTO 6090				REMARK  IF NO Q-T-D PAY, SKIP THIS EMPLOYEE
	B(1)=B(1)+S(59)							REMARK  ADD TOTAL PAY TO TOTAL Q-T-D PAY
	A=S(59)-S(60)							REMARK  CALCULATE TAXABLE Q-T-D PAY
	B(2)=B(2)+A							REMARK  ADD TO 941A TOTALS
	B(9)=B(9)+1							REMARK  INCREMENT TOTAL EMPLOYEES LISTED
	C=S(35)-S(36)							REMARK  CALCULATE Y-T-D TAXABLE PAY
	I2=S1(8)
	GOSUB 5030							REMARK  CALCULATE TOTAL TAXABLE PAY
	B1=B1+A1							REMARK  ADD TO TOTAL SUBJECT TO S.U.I
	I2=F1(2):GOSUB 5030						
	B(3)=B(3)+A1							REMARK  ADD TO TOTAL FUT EMPLOYER
	I2=F1(4):GOSUB 5030
	B(4)=B(4)+A1							REMARK  ADD TO TOTAL FICA EMPLOYER
	I2=F1(6):GOSUB 5030
	B.0=A1								REMARK  CALCULATE FICA EMPLOYEE WAGES
	I2=S1(6):GOSUB 5030						REMARK  CALCULATE SDI EMPLOYER WAGES
	B(5)=B(5)+A1
	GOSUB 6200							REMARK  PRINT 941A DETAIL ON FORM
6090	NEXT J%
6100	IF LINE.COUNT%>43 THEN  6110
	FOR I3%=LINE.COUNT% TO 43
	PRINT
	NEXT I3%
6110	GOSUB 5000							REMARK  PRINT 941A TOTALS FOR LAST PAGE
6120	CONSOLE
	X2=1:X3=0:X4=1:X2$="READY TO PRINT SUMMARY?":GOSUB 665		REMARK  VERIFY ENTRY:'1'=READY; '0'=NOT READY
	IF X0<>1 THEN  6120
	LPRINTER							REMARK  SELECT PRINTER AS OUTPUT DEVICE
	PRINT:PRINT
	PRINT "QUARTERLY TOTALS"
	PRINT 
6130	B(6)=FNR(B(3)*F1(1)/10000)					REMARK  CALCULATE ESTIMATED FEDERAL UNEMPLOYMENT TAX
	B(7)=FNR(B(4)*F1(3)/10000)					REMARK  CALCULATE ESTIMATED EMPLOYEE FICA TAXES
	B(8)=FNR(B(5)*S1(5)/10000)					REMARK  CALCULATE ESTIMATED SDI TAXES
	FOR I3%=1 TO 8
	READ A2$							REMARK  READ SUMMARY DESCRIPTIONS FROM DATA TABLE
	PRINT A2$;TAB(20);
	PRINT USING B$;B(I3%)						REMARK  PRINT DESCRIPTION AND AMOUNT
	PRINT 
6150	NEXT I3%
	PRINT "SUBJECT TO S.U.I.";TAB(20);
	PRINT USING B$;B1						REMARK  PRINT S.U.I. TAXABLE EARNINGS
	PRINT 
	PRINT "S.U.I.";TAB(20);
	PRINT USING B$;FNR(B1*S1(7)/10000)				REMARK  PRINT ESTIMATED S.U.I. TAX
	PRINT 
	READ A5$
	PRINT A5$;TAB(20);
	PRINT USING C$;B(9)						REMARK  PRINT NUMBER OF EMPLOYEES IN THIS REPORT
6170	GOTO 6010

6200	IF LINE.COUNT%>44 OR P=0 THEN GOTO 6250				REMARK  PRINT EMPLOYEE DETAIL ON 941A REPORT
6210	PRINT TAB(7);
	X0=R1(1):GOSUB 760.5						REMARK  PRINT SOCIAL SECURITY NUMBER
	PRINT TAB(22);R$(1);TAB(51);					REMARK  PRINT  EMPLOYEE NAME
	PRINT USING D$;B.0,A						REMARK  PRINT FICA WAGES AND Q-T-D TAXABLE PAY
6230	LINE.COUNT%=LINE.COUNT%+1
	P1(1)=P1(1)+1							REMARK  INCREMENT NUMBER OF EMPLOYEES THIS PAGE
	P1(2)=P1(2)+B.0							REMARK  ADD TO TOTAL FICA WAGES THIS PAGE
	P1(3)=P1(3)+A							REMARK  ADD TO TOTAL Q-T-D TAXABLE PAY THIS PAGE
	IF LINE.COUNT%<44 THEN  RETURN
	GOSUB 5000							REMARK  PRINT AND CLEAR PAGE TOTALS
6250	IF P>1 THEN PRINT CHR$(12);					REMARK  IF FIRST PAGE, DON'T DO A FORM FEED
6251	PRINT:PRINT
	P=P+1
	PRINT TAB(10);G2$(5);TAB(54);					REMARK  PRINT COMPANY'S FEDERAL & STATE ID NUMBERS
	X0=G3(1):GOSUB 680.5						REMARK  PRINT REPORT DATE
	PRINT TAB(71);
	PRINT USING E$;P						REMARK  PRINT PAGE NUMBER
6270	FOR I3%=1TO 4
	PRINT TAB(10);G2$(I3%)						REMARK  PRINT COMPANY NAME AND ADDRESS
	NEXT I3%
	FOR I%=1 TO 6:PRINT:NEXT I%					REMARK  PRINT LINE FEEDS TO DETAIL SECTION
	LINE.COUNT%=1
	GOTO 6210
