CalcOrdTotal Function
Expand/Collapse source code of procedure CalcOrdTotal Source Code
  LPARAMETERS tcOrderID
  *-- Returns total of order, after discount
  *-- Assumes orders table is open and positioned on desired record
  LOCAL lyOrderTotal, ;
        llClose,;
        liSelect

  IF !USED("order_line_items")
    USE tastrade!order_line_items IN 0
    llClose = .T.
  ENDIF
  liSelect = SELECT()
  SELECT order_line_items

  lnOldRecNo = IIF(EOF(), 0, RECNO())
  SUM (unit_price * quantity) - ;
    (orders.discount * .01) * (unit_price * quantity) ;
    FOR order_id = tcOrderID ;
    TO lyOrderTotal 

  IF lnOldRecNo <> 0
    GO lnOldRecNo IN order_line_items
  ENDIF

  IF llClose
    USE IN order_line_items
  ENDIF

  SELECT (m.liSelect)
  RETURN lyOrderTotal