C     .TITLE ACOUNT
C
C   4 JAN 73 - COUNT OUTPUT LINES FOR TIDIER LISTING
C   1 NOV 72 - RENAME FROM 'SUPPLY' TO LIST ACCOUNT DATA
C  24 AUG 72 - ADD MULTI-FILE CAPABILITY
C  12 JUN 72 - PAUL HENDERSON
C
C  PROGRAM TO HELP WITH THE SUPPLIES ACCOUNT BALANCING
C
C  .DAT SLOTS USED:
C
C     3 - INPUT OF ACCOUNT FILES
C     4 - KEYBOARD INPUT & COMMAND
C
      LOGICAL FOUND,ADD,CHANGE,MORE,SEARCH
      REAL INVOIC,LOOK(3),NEW,EXIT
      DIMENSION FILEIN(2),TMPFIL(2),ANS(5)
      DIMENSION F16(6)
      COMMON /MONEY/ALLCOM,POCOM,ALLSUM,POSUM,ALSPNT,POSPNT
      COMMON /ITEMS/SUPLIR(5),REQNO(2),PO,DATISS(2),GUESS,COMMIT
      COMMON /GET/INVOIC(2),DATRCV(3),AMOUNT,SPENT
      EQUIVALENCE (LOOK(1),REQNO(1))
      DATA FILEIN(1),FILEIN(2)/5HFUNDS,4H SRC/
      DATA TMPFIL(1),TMPFIL(2)/5HTMPFI,4H LST/
C  F16 ""ACCOUNT"   OR EXIT"
      DATA F16(1),F16(2),F16(3)/4H(22H,5H"ACCO,4HUNT"/
      DATA F16(4),F16(5),F16(6)/4H  OR,5H  EXI,2HT)/
C
      DATA SPACE/1H /,YES/1HY/,NEW/2HNE/,P/1HP/,R/1HR/,EXIT/4HEXIT/
C
C  FORMAT STATEMENTS
C
1     FORMAT(I1,2X5A5,3F9.2)
2     FORMAT(1XI1,2X5A5,3F9.2)
3     FORMAT(5A5)
4     FORMAT(F9.2)
5     FORMAT(1X5A5,3F9.2)
6     FORMAT(/////22H ASSIGN PDE TO .DAT 10///)
7     FORMAT (A2,A5)
11    FORMAT (3X5A5,1X2A5,3XA5,3X2A5,2F9.2)
12    FORMAT (1H ,81X2A5,3X3A5,2F9.2)
13    FORMAT (31X20HTHIS PURCHASE ORDER:,5X19HAMOUNT INVOICED = $,
     *F9.2,5X30HPAID BY FINANCIAL SERVICES = $,F9.2//)
14    FORMAT (////3X13H ACCOUNT 081-,A4,3H-01//
     *10X20H TOTAL COMMITTED = $,F9.2/
     *10X20H TOTAL  INVOICED = $,F9.2/
     *10X20H TOTAL  PAID OUT = $,F9.2/)
  15  FORMAT (1H1)
C
C  PROGRAM STARTS HERE
C
C  F16: ""ACCOUNT"   OR   EXIT"
20    WRITE (4,F16)
      READ (4,3) ANS
      IF (ANS(1).EQ.EXIT) STOP 7
21    FILEIN(1)=ANS(1)
      TMPFIL(1)=ANS(1)
      ALLCOM=0.
      ALLSUM=0.
      ALSPNT=0.
      CALL FSTAT (3,FILEIN,FOUND)
      CALL ENTER (6,TMPFIL)
      IF (.NOT.FOUND) GO TO 100
      CALL SEEK (3,FILEIN)
C
 300  LINCNT=0
301   READ(3,1) LINE,SUPLIR
      IF (LINE.EQ.5) GO TO 100
      READ(3,1) LINE,REQNO,PO,DATISS,GUESS,COMMIT
      WRITE (6,11) SUPLIR,REQNO,PO,DATISS,GUESS,COMMIT
      LINCNT=LINCNT+1
C
31    POCOM=COMMIT
      ALLCOM=ALLCOM+COMMIT
      IF (ABS(POCOM).LT.0.05) POCOM=GUESS
      POSUM=0.
      POSPNT=0.
70    READ(3,1) LINE,INVOIC,DATRCV,AMOUNT,SPENT
      IF (LINE.EQ.4) GO TO 90
      WRITE (6,12) INVOIC,DATRCV,AMOUNT,SPENT
      LINCNT=LINCNT+1
80    POSUM=POSUM+AMOUNT
      ALLSUM=ALLSUM+AMOUNT
      POSPNT=POSPNT+SPENT
      ALSPNT=ALSPNT+SPENT
      POCOM=POCOM-AMOUNT
      ALLCOM=ALLCOM-AMOUNT
      GO TO 70
C
90    WRITE (6,13) POSUM,POSPNT
      LINCNT=LINCNT+3
      IF (LINCNT.LT.50) GO TO 301
      WRITE (6,15)
      GO TO 300
C
100   WRITE (6,14) FILEIN(1),ALLCOM,ALLSUM,ALSPNT
      CALL CLOSE (6)
      GO TO 20
      END
