      SELECT A
      USE DEBTOR INDEX DEBTOR
      select d
      use contrans
      REPLACE ALL REF WITH STR(DACCOUNT,4)+PRODUCT
      use contrans index contran2
      total on REF to &tempf2 fields qty
      use &tempf2
      SET RELATION TO STR(DACCOUNT,4) INTO DEBTOR
      COPY TO CONSIGN FIELDS DACCOUNT,PRODUCT,RETAIL,WSALE,QTY FOR QTY # 0 .AND. DEBTOR->ID # '    '


      USE CONSIGN
      go top
      set relation to product into product
      @ 1,0 say 'Account No. '+mkey
      @ 1,29 say setname
      @ 1,59 say debtor->name + space(20)+dtoc(date())
      @ 2,0 say 'Consignment'
      @ 3,0 say 'Summary ISBN      Product   Our      Your      Retail Wholesale'
      @ 4,0 say '                          Balance  Stock Count'
      store 6 to mentry
      do while str(daccount,4) = mkey .and. .not. eof()
            store product to mproduct
            @ mentry,0 say iif(msumm='Y','   '+e->isbn+' ',actdate + ' ' + action + str(number,5)) + ' '+product
            do case
            case qty > 0 .or. msumm = 'Y'
               @ mentry,26 say str(qty,4)
               store mtotal + qty to mtotal
            otherwise
               store mtotal + qty to mtotal
               @ mentry,33 say str(0-qty,4)
            endcase
            if minvnum = 0 .and. msumm = 'N'
               @ mentry,40 say str(mtotal,4)
            endif
            @ mentry,47 say str(retail,6,2)
            if debtor->exempt = 'Y'
               @ mentry,54 say str(wsale,8,2)
            else
               select e
               if .not. eof()
                  if taxcode = ' '
                     store str(category,3) to mkcat
                     select category
                     seek mkcat
                  endif
                  store taxcode to t
                  if setgst # ' '
                     store '0' to t
                  endif
                  select d
                  @ mentry,54 say str(wsale*(1+settax&t/100),8,2)
               else
                  select d
                  @ mentry,54 say str(wsale,8,2)
               endif
            endif
            select e
            if .not. eof()
               if mx = 'P'
                  @ mentry,64 say e->desc
               else
                  @ mentry,64 say substr(e->desc,1,16)
               endif
            else
               @ mentry,64 say '** Not on File'
            endif
            select d
            store mentry + 1 to mentry
            skip
            if product # mproduct
               if msumm = 'N' .and. minvnum = 0
                  @ mentry-1,44 say '*'
                  store mentry+1 to mentry
               endif
               store 0 to mtotal
            endif
            if macc # '   ' .and. product # macc
               go bottom
               skip
            endif
            if mentry > 20 .and. mx = 'V'
               store ' ' to mmx
               @ 21,0 say 'Hit new line to continue, X to exit ' get mmx picture '!'
               read
               if mmx = 'X'
                  exit
               endif
               store iif(msumm='Y',6,5) to mentry
               @ 5,0 clear
            endif
            if mentry=55 .and. mx = 'P'
               eject
               @ 1,0 say 'Account No. '+mkey
               @ 1,29 say setname
               @ 1,59 say debtor->name + space(20)+dtoc(date())
               @ 2,0 say 'Consignment'
               if msumm = 'Y'
                  @ 3,0 say 'Summary ISBN      Product   Our      Your      Retail Wholesale (incl.Sales Tax)'
                  @ 4,0 say '                          Balance  Stock Count'
                  store 6 to mentry
               else
                  @ 3,0 say '  Date     Number Product Debit Credit Balance Retail Wholesale'
                  store 5 to mentry
               endif
            endif
         enddo
         if mx = 'P'
            set print on
            ? savconoff
            ?? '** End of Report Debtor 3 run on '+dtoc(date())+' at '+time()
            set print off
            eject
            set device to screen
         endif
      endif
      if macc = '    '
         exit
      else
         clear typeahead
         store ' ' to mx
         @ 23,0 say 'TYPE V/P TO VIEW/PRINT MORE CONSIGNMENT HISTORY DETAILS ' get mx picture '!'
         read
         if mx # 'V' .and. mx # 'P'
            exit
         endif
      endif
   enddo
   @ 24,0
   select debtor
RETURN
