compile subroutine WIN_QUOTE_NUM_VALID(ConvType, DataIo, Branch, ReturnedValue)
begin condition
pre:
post:
end condition

$insert logical
$insert quote_equ
$insert msg_equates
declare function msg, get_property, set_property
equ valid$         to 0    ;* successful
equ invalid_msg$   to 1    ;* bad data       -   print error message window
equ invalid_conv$  to 2    ;* bad conversion -          "         "
equ invalid_nomsg$ to 3    ;* bad but do not print the error message window
equ CrLf$          to char(13):char(10)
* this validates the quote number in windows like order and annual contracts
ReturnedValue = DataIo       
status() = Valid$              
*
begin case
   case ConvType = 'ICONV'
      CustNo = get_property( @window:'.CUST_NO', 'TEXT' )
      QuoteRec =  xlate( 'QUOTE', DataIo, '', 'X' )
      if @window = 'CAR' then
	      if QuoteRec<quote_cust_no$> = CustNo else
	          MsgInfo = ''
	          MsgInfo<mtext$> = DataIo:' is not a Quote for ':oconv( CustNo, '[XLATE_CONV,COMPANY*CO_NAME]' ):'...':CrLf$:'Press [SF2] to view OPEN quotes for this customer.' 
	          MsgInfo<micon$> = 'H'
	          Void = msg( '', MsgInfo )
	          status() = invalid_nomsg$
	      end         
      end else
         if @window = 'ORDER' and DataIo = 999 then
            * THIS IS TO ALLOW ENTRY OF A LINE ITEM FOR BACK FREIGHT CHARGE ON A QUOTE
            * THIS IS IN THE QUOTE_OLD TABLE AND NOT IN THE QUOTE TABLE PER STEPHANIE
            * POSAVEK - ALSO CHECKS FOR 999 IN THE ORDER WRITE EVENT
         end else
		      if QuoteRec<quote_status$> = 'O' and QuoteRec<quote_cust_no$> = CustNo else
		          MsgInfo = ''
		          MsgInfo<mtext$> = DataIo:' is not an OPEN Quote for ':oconv( CustNo, '[XLATE_CONV,COMPANY*CO_NAME]' ):'...':CrLf$:'Press [SF2] to view OPEN quotes for this customer.' 
		          MsgInfo<micon$> = 'H'
		          Void = msg( '', MsgInfo )
		          status() = invalid_nomsg$
		      end
		   end
	  end
   case ConvType = 'OCONV'
      * no output
      ReturnedValue = DataIo
   case otherwise$
      ReturnedValue = ''
      status() = invalid_conv$
end case
return

