* FILL.CMD 
* WRITTEN BY MICHAEL Lynn 5/16/83  revised 8/3/83   
ERASE
SELECT SECONDARY
@  1, 3 SAY 'ENTER PURCHASE ORDER # IF NEEDED' GET mpur PICTURE '!!!!!!!!!!!'
@  2, 3 SAY 'INVOICE NUMBER' GET mnum PICTURE '9999'
@ 20, 3 SAY 'ENTER AN ITEM NUMBER OF T TO COMPLETE ENTRY'
READ
   DO WHILE z<13
STORE '          ' to snum

IF z=12
@ 16, 3 Say 'THIS IS THE LAST ITEM WHICH CAN BE'
@ 17, 8 SAY 'ENTERED ON THIS INVOICE'
ENDIF

IF z>9
STORE '2' TO e
ELSE
STORE '1' TO e
ENDIF

STORE STR(z,&e) TO A
STORE '@ '+STR(2+z,2)+',' TO B

&B 3 SAY 'ENTER CATALOGUE NUMBER OF ITEM &A' GET snum PICTURE '!!!!!!!!!!'
READ
FIND &snum
IF # <> 0
   STORE catnum to Mcat&A
   STORE descr to mdescr&A
   STORE price to Mprice&A
   REPLACE quantity with quantity -1
   REPLACE sold WITH sold +1
else
   IF snum ='T'
   STORE 12 + z TO z
   ELSE
   @ 14,5 SAY 'ITEM NOT IN DATABASE'
   @ 15,5 SAY 'RE-TRY OR EXIT AND APPEND ITEM'
   SET CONSOLE OFF
   WAIT
   SET CONSOLE ON
   @ 14,0
   @ 15,0
   LOOP
   ENDIF
ENDIF
STORE Z+1 TO Z
   ENDDO

ERASE
SET FORMAT TO SCREEN
@  1, 0 SAY "INVOICE NUMBER:"
@  1,15 SAY mnum
@  1,30 SAY date()
@  2, 0 SAY "NAME:"
@  2, 6 SAY TRIM(p.first)+' '+p.last
@  3, 0 SAY "=========================================="
@  4, 0 SAY mdescr1
@  4,32 GET mprice1
@  5, 0 SAY mdescr2
@  5,32 GET mprice2
@  6, 0 SAY mdescr3
@  6,32 GET mprice3
@  7, 0 SAY mdescr4
@  7,32 GET mprice4
@  8, 0 SAY mdescr5
@  8,32 GET mprice5
@  9, 0 SAY mdescr6
@  9,32 GET mprice6
@ 10, 0 SAY mdescr7
@ 10,32 GET mprice7
@ 11, 0 SAY mdescr8
@ 11,32 GET mprice8
@ 12, 0 SAY mdescr9
@ 12,32 GET mprice9
@ 13, 0 SAY mdescr10
@ 13,32 GET mprice10
@ 14, 0 SAY mdescr11
@ 14,32 GET mprice11
@ 15, 0 SAY mdescr12
@ 15,32 GET mprice12
@ 16, 0 SAY "PURCHASE ORDER NUMBER:" GET mpur 
@ 17, 0 SAY "=========================================="
READ

STORE mprice1+mprice2+mprice3+mprice4+mprice5+mprice6+mprice7+mprice8;
+mprice9+mprice10+mprice11+mprice12 TO msub

ERASE
@ 1, 5 SAY "YOUR PRINTER SHOULD BE ON!"
@ 3, 5 SAY "ENTER A Y TO GIVE DISCOUNT ON ORDER"
SET CONSOLE OFF
WAIT TO disc
SET CONSOLE ON
STORE !(disc) TO disc
   IF disc ='Y'
   @ 5, 5 SAY "ENTER AMOUNT OF DISCOUNT IN %" GET mdisc PICTURE '99'
   READ
   STORE mdisc*.01 TO xdisc
   STORE xdisc*msub TO xdisc
   ENDIF
RELEASE disc

@ 7, 5 SAY "ENTER ONE OF THE FOLLOWING"
@ 8, 5 SAY "Y - FOR REGULAR POSTAGE CHARGE"
@ 9, 5 SAY "S - TO USE A SPECIAL PERCENTAGE"
@ 10, 5 SAY "N - TO CHARGE NO POSTAGE"
SET CONSOLE OFF
WAIT TO post
SET CONSOLE ON
STORE !(post) TO post

DO CASE
  CASE POST ='Y'
  IF msub < 19.99
    STORE 1.00 TO mpost
  ELSE
    STORE msub*.05 TO mpost
  ENDIF

  CASE POST ='S'
  @ 11, 5 SAY "ENTER % RATE FOR POSTAGE CHARGE" GET mpost PICTURE '99'
  READ
  STORE mpost*.01 TO mpost
  STORE msub*mpost TO mpost

  OTHERWISE
  STORE 0 TO mpost

ENDCASE
RELEASE post

SELE PRIM
IF state = 'MI'
STORE T TO mtax
ELSE
STORE F TO mtax
ENDIF

@ 13, 5 SAY "ENTER Y IF ORDER HAS BEEN PREPAID" GET mpaid PICTURE '!'
READ

STORE (msub-xdisc)+mpost to mtotal

SELE SECO
USE INVOICE INDEX INDNUM
APPEND BLANK

REPLACE num WITH Mnum,catnum1 WITH mcat1,price1 WITH mprice1
REPLACE catnum2 WITH mcat2,price2 WITH mprice3,catnum3 WITH mcat3
REPLACE price3 WITH mprice3,catnum4 WITH mcat4,price4 WITH mprice4
REPLACE catnum5 WITH mcat5,price5 WITH mprice5,catnum6 WITH mcat6
REPLACE price6 WITH mprice6,catnum7 WITH mcat7,price7 WITH mprice7
REPLACE catnum8 WITH mcat8,price8 WITH mprice8,catnum9 WITH mcat9
REPLACE price9 WITH mprice9,catnum10 WITH mcat10,price10 WITH mprice10
REPLACE catnum11 WITH mcat11,price11 WITH mprice11,catnum12 WITH mcat12
REPLACE price12 WITH mprice12
REPLACE disc WITH mdisc
REPLACE s.last WITH p.last
REPLACE s.first WITH p.first
REPLACE date WITH date()
REPLACE tax WITH mtax,total WITH mtotal

  IF mpaid = Y
  REPLACE paid WITH Y
  ELSE
  REPLACE paid WITH F
  ENDIF

SET EJECT OFF
SET FORMAT TO PRINT
SET MARGIN TO   0
RELEASE print
@  8,50 SAY "INVOICE NUMBER:"
@  8,66 SAY mnum USING '9999'
IF company =' '
@ 14,12 SAY TRIM(p.first)+' '+p.last
@ 14,52 SAY 'SAME'
@ 15,12 SAY p.address
@ 16,12 SAY TRIM(p.city)+', '+p.state+' '+p.zipcode
ELSE
@ 14,12 SAY TRIM(p.first)+' '+p.last
@ 14,52 SAY 'SAME'
@ 15,12 SAY p.company
@ 16,12 SAY p.address
@ 17,12 SAY TRIM(p.city)+', '+p.state+' '+p.zipcode
ENDIF
@ 20,10 SAY 'ML'

IF mpur <> ' '
@ 20,13 SAY mpur 
ENDIF

@ 20,25 SAY 'SPEC 4TH CLASS'

IF mpaid = Y
@ 20,44 SAY 'Y'
ELSE
@ 20,58 SAY 'NET/30'
ENDIF
@ 20,72 SAY DATE()
@ 20,82 SAY '1'

STORE 1 TO z

  DO WHILE z<13

   IF z>9
   STORE '2' TO e
   ELSE
   STORE '1' TO e
   ENDIF            
                   
STORE STR(z,&e) TO a
STORE '@ '+STR(24+z,2)+',' TO b

IF mcat&a <> ' '
&b 3 SAY '1'
&b 17 SAY mcat&a
&b 28 SAY mdescr&a
&b 72 SAY mprice&a
ENDIF
STORE z+1 TO z
ENDDO

IF mdisc > 0
@ 45,30 SAY "DISCOUNT"
@ 45,69 SAY mdisc USING '99'
@ 45,75 SAY xdisc USING '$999.99'
ENDIF

IF mpaid = Y
@ 47,35 SAY "*********"
@ 48,35 SAY "*P A I D*"
@ 49,35 SAY "*P A I D*"
@ 50,35 SAY "*P A I D*"
@ 51,35 SAY "*********"
ENDIF

@ 53,30 SAY "Thank you for your order"
@ 54,30 SAY "========================"

IF mpost > 0
@ 61,75 SAY mpost USING '$999.99'
ENDIF

@ 64,75 SAY mtotal USING '$999.99'
EJECT
SET FORMAT TO SCREEN
STORE mnum + 1 TO mnum
STORE '          'to snum
STORE 1 to Z
STORE 000.00 to mpost
STORE 000.00 to msub
STORE F to mtax
STORE F to mpaid
STORE 00 to mdisc
STORE 000.00 to xdisc
STORE '           ' TO mpur
store '          ' to mcat1
store '          ' to mcat2
store '          ' to mcat3
store '          ' to mcat4
store '          ' to mcat5
store '          ' to mcat6
store '          ' to mcat7
store '          ' to mcat8
store '          ' to mcat9
store '          ' to mcat10
store '          ' to mcat11
store '          ' to mcat12
store 000.00 to mprice1
store 000.00 to mprice2
store 000.00 to mprice3
store 000.00 to mprice4
store 000.00 to mprice5
store 000.00 to mprice6
store 000.00 to mprice7
store 000.00 to mprice8
store 000.00 to mprice9
store 000.00 to mprice10
store 000.00 to mprice11
store 000.00 to mprice12
store '                       ' to mdescr1
store '                       ' to mdescr2
store '                       ' to mdescr3
store '                       ' to mdescr4
store '                       ' to mdescr5
store '                       ' to mdescr6
store '                       ' to mdescr7
store '                       ' to mdescr8
store '                       ' to mdescr9
store '                       ' to mdescr10
store '                       ' to mdescr11
store '                       ' to mdescr12
store '           ' to LLL
store '           ' to FFF
SAVE TO B:NUM
RETURN
