Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/index.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/index.tcl	4 Aug 2005 23:33:17 -0000	1.2
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/index.tcl	5 Aug 2005 12:23:34 -0000	1.3
@@ -69,7 +69,10 @@
 	    label "[_ dotlrn-ecommerce.Total_Amount]"
 	    html { align right }
 	    display_template {
-		@orders.pretty_total@
+		<if @orders.price_to_display@ gt 0>@orders.pretty_total@<br /></if>
+		<if @orders.refund_price@ gt 0>
+		Refund: @orders.pretty_refund@
+		</if>
 	    }
 	    aggregate sum
 	    aggregate_label "[_ dotlrn-ecommerce.Total_1]:"
@@ -125,15 +128,15 @@
 	}
     }
 
-db_multirow -extend { order_url section_url pretty_total pretty_balance person_url } orders orders [subst {
+db_multirow -extend { order_url section_url pretty_total pretty_balance person_url pretty_refund } orders orders [subst {
     select o.order_id, o.confirmed_date, o.order_state, ec_total_price(o.order_id) as price_to_display, o.user_id as purchasing_user_id, u.first_names, u.last_name, count(*) as n_items, person__name(o.user_id), t.method, s.section_id as _section_id, s.section_name, s.course_id, 
 
     case when t.method = 'invoice' then
     ec_total_price(o.order_id) - ec_order_gift_cert_amount(o.order_id) - 
     (select coalesce(sum(amount), 0)
      from dotlrn_ecommerce_transaction_invoice_payments
-     where order_id = o.order_id)
-    else 0 end as balance
+     where order_id = o.order_id) + ec_total_refund(o.order_id)
+    else 0 end as balance, ec_total_refund(o.order_id) as refund_price
 
     from ec_orders o
     join ec_items i using (order_id)
@@ -145,7 +148,7 @@
     
     [template::list::filter_where_clauses -and -name orders]
     
-    group by o.order_id, o.confirmed_date, o.order_state, ec_total_price(o.order_id), o.user_id, u.first_names, u.last_name, o.in_basket_date, t.method, s.section_name, s.section_id, s.course_id, o.authorized_date, balance
+    group by o.order_id, o.confirmed_date, o.order_state, ec_total_price(o.order_id), o.user_id, u.first_names, u.last_name, o.in_basket_date, t.method, s.section_name, s.section_id, s.course_id, o.authorized_date, balance, refund_price
 
     order by o.in_basket_date desc
 }] {
@@ -164,6 +167,7 @@
     set order_state [string totitle $order_state]
     set section_url [export_vars -base ../one-section { {section_id $_section_id} }]
     set person_url [export_vars -base ../one-user { {user_id $purchasing_user_id} }]
+    set pretty_refund [ec_pretty_price $refund_price]
 }
 
 if { [info exists section_id] } {