* **********  COSTMENU.CMD COMMAND FILE ***************
*    This is one level down from the ACCOUNTS.CMD control module.
*    Selections are refinements that relate to costs for client-related
*    jobs or agency overhead.
*         The main database is called COSTBASE.DBF and is kept on disk B.
*    Costs are not entered directly into the COSTBASE, however, because this
*    leads to data contamination and all sorts of problems fixing the errors.
*    Instead, supplier bills and agency time sheets are posted into an interim
*    file called POSTFILE.DBF.  In here, they can be reviewed and edited as
*    necessary.
*         When all the cost entries are confirmed as being correct, they are
*    transferred to the COSTBASE by using the "update proceedure",
*    (selection 6 below).
******************************************************************************

STORE T TO Posting
DO WHILE Posting
   ERASE
   @    2,20 SAY '     1> UNTAXED ITEMS USED BY AGENCY'
   @    4,20 SAY '     2> ENTER SUPPLIER BILLS'
   @    6,20 SAY '     3> ENTER EMPLOYEE TIME SHEETS'
   @    8,20 SAY '     4> EDIT THE POSTFILE'
   @   10,20 SAY '     5> REVIEW/PRINT THE POSTFILE'
   @   12,20 SAY '     6> UPDATE THE COSTBASE'
   @   14,20 SAY '     7> WIPE OUT DELETED RECORDS IN POSTFILE'
   @   16,20 SAY '          <RETURN>'
   WAIT TO Action
   ERASE

   IF Action = '1'
      ERASE
      @  4,10 SAY 'This program accepts bills for items that the agency bought'
      ? '          without paying sales tax, but will use internally, rather'
      ? '          than for a job that will be billed to a client.  This would'
      ? '          include equipment bought out of state and locally bought'
      ? '          materials NOT used in client jobs and NOT taxed.'
      ? "               Use job #'S  1 - 99 for these bills."
      ? '                  DO NOT ENTER ANY OTHER BILLS!'
      ?
      ? 'Do you want to continue (Y or N)?'
      WAIT TO GoAhead
      IF !(GoAhead) = 'Y'
         DO UseTax
      ELSE
         RELEASE ALL
      ENDIF
   ELSE
      IF Action = '2'
         ERASE
         @  4,10 SAY '   CHECK ALL BILLS BEFORE ENTERING THEM.'
         ? '          If any of the bills are for items used by the agency'
         ? '          but sales tax was not paid, select OPTION 1 from the'
         ? '          entry menu.  '
         ? "             Use job #'s greater than 100 for these bills."
         ? '                    <Return> to continue.'
         ?              
         WAIT
         DO CostBills
      ELSE
         IF Action = '3'
            DO CostTime
         ELSE
            IF Action = '4'
               STORE "Y" TO Changing
               DO WHILE !(Changing)='Y'
                  USE B:PostFile
                  IF EOF
                     ? 'There are no entries in the POSTING file.'
                     ? '<Return> to continue.'
                     WAIT
                     STORE "N" TO Changing
                  ELSE
                     GO BOTTOM
                     ERASE
                     @  3,10 SAY 'EDITING BILLS ENTERED.'
                     @  5,10 SAY 'There are '+STR(#,5)+' file entries.'
                     @  6,10 SAY 'Which entry do you want to EDIT?'
                     ACCEPT TO Number
                     IF VAL(Number) <= 0 .OR. VAL(Number) > #
                        ?
                        ?
                        ?  'Out of range: do you want to continue (Y or N)?'
                        WAIT TO Changing
                     ELSE
                        Edit &Number
                        REPLACE Name WITH !(Name), Descrip WITH !(Descrip),;
                           Client WITH !(Client), Bill:Nmbr WITH !(Bill:Nmbr)
                        ?
                        ? 'Do you want to edit any other entries (Y or N)?'
                        WAIT TO Changing
                     ENDIF
                  ENDIF
               ENDDO Changing
               RELEASE All
            ELSE
               IF Action = '5'
                  STORE 'Y' TO Reviewing
                  DO WHILE !(Reviewing) = 'Y'
                     USE B:PostFile
                     COUNT FOR .NOT. * TO Any
                     IF Any = 0
                        ? 'No unposted entries in the POSTING file.'
                        ? '<Return> to continue.'
                        WAIT
                        STORE "N" TO Reviewing
                     ELSE
                        ERASE
                        ? 'THERE ARE '+STR(Any,5)+' unposted entries.'
                        ? 'Do you want to print them, too (Y or N)?'
                        WAIT TO Output

                        IF !(Output) = 'Y'
                           SET PRINT ON
                        ENDIF
                        ? '            JOB    NAME                 DESCRIP';
                          +'TION           AMOUNT  DATE   NUMBER'
                        ?
                        STORE 'OFF' TO Condition
                        STORE '0' TO Number
                        DO PRINTOUT

                        ? "That's all the unposted entries."
                        ? 'Want to see them again (Y or N)?'
                        ? '(To see deleted records, choose "Edit".)'
                        WAIT TO Reviewing
                     ENDIF
                  ENDDO Reviewing
                  RELEASE ALL
               ELSE
                  IF Action = '6'
                     DO CostUpda  
                  ELSE
                     IF Action = '7'
                        ? 'This destroys all DELETED records in the POSTFILE.'
                        ? 'Do you want to do this (Y or N)?'
                        WAIT TO Wipeout
                        IF !(Wipeout) = 'Y'
                           USE B:PostFile
                           PACK
                        ENDIF
                        RELEASE ALL
                     ELSE
                        RELEASE ALL
                        RETURN
                     ENDIF 7
                  ENDIF 6
               ENDIF 5
            ENDIF 4
         ENDIF 3
      ENDIF 2
   ENDIF 1
   STORE T TO Posting
ENDDO Posting

