*      ************ DEPTRANS COMMAND FILE  **************
* Applies deposits from the GetDep file against the matching invoices in the
* Invoices file as payments are received against them.
***********************************************************************

GO TOP
ERASE
DO WHILE .NOT. EOF
   STORE STR(#,5) TO Number
   @  6,20 SAY 'RECORD NUMBER  '+Number
   ? CHR(7) + CHR(27) + CHR(74)
   * ring bell,erase to end of page(ESC J = CHR(27)+CHR(74))

   IF Inv:Nmbr=' ' .OR. *
      SKIP
   ELSE
      @  7,20 SAY 'INVOICE NUMBER ' +Inv:Nmbr
      STORE Inv:Nmbr TO Key

      SELECT SECONDARY
      USE B:Invoices INDEX B:Invoices
      FIND &Key
      STORE T TO Again
      STORE 'T' TO Decision
      IF # = 0
         DO WHILE Again
            @  9,15 SAY 'THIS INVOICE NUMBER IS NOT IN THE INVOICE FILE. '
            @ 11,15 SAY '     E to EDIT it.                              '
            @ 12,15 SAY '     C to CONTINUE.                              '
            ?
            ? CHR(7)
            WAIT TO Decision

            IF !(Decision) = 'E'
               SELECT PRIMARY
               EDIT &Number
               SELECT SECONDARY
               STORE F TO Again
            ELSE
               IF !(Decision) = 'C'
                  STORE F TO Again
               ELSE
                  STORE T TO Again
               ENDIF C
            ENDIF E
         ENDDO
      ELSE
         REPLACE Amt:Rcd WITH (Amt:Rcd + Deposit), Date:Rcd WITH Dep:Date
      ENDIF 0
      SELECT PRIMARY

      * We do not skip to the next record if the record was edited.  This
      * allows us to run the edited record through the process again.
      IF !(Decision) <> 'E'
         SKIP
      ENDIF
   ENDIF no invoice number or record deleted
ENDDO the transfer
