*              ******** USETAX COMMAND FILE **********
* This file accepts inputs for supplier bills when the agency has bought
* an item without paying a use tax on it.
*      The item or items are added to the INVIOCES file (not Billings),
* then are used by the SalesTax program so that the Quarterly Sales Tax
* report can be prepared by the computer.
*
* A temporary file called GETBILLS is used for data entry, because the operator
* can decide to quit on an incomplete entry, which is marked for deletion.
* When the data is APPENDed to the POSTFILE, these entries are eliminated (the
* APPEND command does not transfer records marked for deletion).  An entry must
* include at least the name of a supplier and the amountof the bill.  If these
* are not BOTH supplied, the entry is flagged for correction or deletion.
*******************************************************************************


ERASE
@  5,20 SAY 'AGENCY USE-TAX PROCEEDURE'
?
USE B:PostFile
COPY STRUCTURE TO GETBILLS

USE GetBills
STORE 'Y' TO Bills
DO WHILE !(BILLS) <> 'F'
   APPEND BLANK
   STORE STR(#,5) TO Number
   REPLACE Client WITH 'OFC'
   STORE T TO Entering
   DO WHILE Entering
      ERASE
      @  1,0 SAY 'ENTER ONLY UNTAXED ITEMS NOT USED FOR CLIENT JOBS.'
      @  3,0 SAY '   RECORD NUMBER:' + Number
      @  4,0 SAY '          CLIENT:' + Client + ':'
      @  5,0 SAY '      JOB NUMBER' GET Job:Nmbr
      @  6,0 SAY '          AMOUNT' GET Amount
      @  7,0 SAY '     BILL NUMBER' GET Bill:Nmbr
      @  8,0 SAY '       BILL DATE' GET Bill:Date
      @  9,0 SAY '   SUPPLIER NAME' GET Name
      READ
      REPLACE Name WITH !(Name),Descrip WITH 'USE TAX ENTRY';
              Bill:Nmbr WITH !(Bill:Nmbr)
      @   7,17 SAY Bill:Nmbr
      @   9,17 SAY Name
      @  10,17 SAY Descrip

      STORE ' ' TO Getting
      IF Job:Nmbr <= 0 .OR. Job:Nmbr > 99
         @  12,0
         ? '          The JOB NUMBER entry is wrong!'
         ? '          Agency jobs are from 1 through 99.'
         ? '          F if FINISHED,'
         ACCEPT '       <Return> to change.' TO Getting
      ELSE
         IF Amount = 0 .OR. Name <= '    '
         ?
         ?
         ? '           AMOUNT or NAME missing.'
         ? '           F if FINISHED,'
         ACCEPT '        <Return> to change.' TO Getting
      ELSE
         @  12,5 SAY '     C to CHANGE,'
         @  13,5 SAY '     F if FINISHED,'
         ACCEPT '     <Return> to continue.' TO Bills
             IF !(Bills) = 'C'
                STORE T TO Entering
             ELSE
                STORE F TO Entering
             ENDIF
          ENDIF amount or name
       ENDIF client or job number

       IF !(Getting) = 'F'
          DELETE RECORD &Number
          STORE F TO Enteriing
          STORE 'F' TO Bills
       ENDIF
    ENDDO Entering
 ENDDO Bills

 COUNT FOR .NOT. * TO Any
 IF Any = 0
    ?
    ? '         No valid entries to add to the files.'
    ? '      <Return> to the menu.'
    WAIT
 ELSE

    RESTORE FROM B:CONSTANT
    STORE 'Bill:Date' TO Date
    DO DateTest

    * Checks names against a list of suppliers to catch spelling and
    * abbreviation inconsistencies.
    DO NameTest

    ERASE
    @  3,25 SAY ' *** DO NOT INTERRUPT ***'
    @  5,25 SAY ' UPDATING THE POSTING FILE'
    USE B:PostFile
    APPEND FROM GetBills

    * The following loop transfers the bills just entered into the INVOICES
    * file.  The amount of the bill is entered in the "Taxable" column.  The
    * job number is entered into the Invoice Number column.  Since invoices
    * have 5 digits, while job numbers are under 1000, we use this to separate
    * the two types of entries later in the SALESTAX.CMD file..IF < 1000 THEN..
    * PRIMARY and SECONDARY work areas are used to step through the GETBILLS
    * file one entry at a time.
    USE GetBills
    SELECT SECONDARY
    USE B:Invoices
    SELECT PRIMARY
    DO WHILE .NOT. EOF
       IF *
          SKIP
       ELSE
          SELECT SECONDARY
          APPEND BLANK
          REPLACE Inv:Nmbr WITH STR(Job:Nmbr,3), Inv:Date WITH Bill:Date,;
                  Taxable WITH Amount, Date:Rcd WITH 'USE TAX'
          SELECT PRIMARY
          SKIP
       ENDIF
    ENDDO
 ENDIF
USE
DELETE FILE GetBills
RELEASE ALL
RETURN
