Index: openacs-4/packages/ecommerce/www/admin/orders/revenue-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/orders/revenue-postgresql.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/ecommerce/www/admin/orders/revenue-postgresql.xql 10 Jul 2001 20:33:53 -0000 1.1 +++ openacs-4/packages/ecommerce/www/admin/orders/revenue-postgresql.xql 23 Jul 2001 06:21:47 -0000 1.2 @@ -18,8 +18,20 @@ select to_char(shipment_date,'YYYY') as shipment_year, to_char(shipment_date,'Q') as shipment_quarter, coalesce(sum(bal_price_charged),0) as total_price_charged, -coalesce(sum(bal_shipping_charged + case when mv.shipment_id = (select min(s2.shipment_id) from ec_shipments s2 where s2.order_id=mv.order_id) then (select coalesce(o.shipping_charged else 0 end-coalesce(o.shipping_refunded,0) from ec_orders o where o.order_id=mv.order_id),0)),0) as total_shipping_charged, -coalesce(sum(bal_tax_charged + case when mv.shipment_id = (select min(s2.shipment_id) from ec_shipments s2 where s2.order_id=mv.order_id) then (select coalesce(o.shipping_tax_charged else 0 end-coalesce(o.shipping_tax_refunded,0) from ec_orders o where o.order_id=mv.order_id),0)),0) as total_tax_charged +coalesce( + sum(bal_shipping_charged + + case when mv.shipment_id = (select min(s2.shipment_id) from ec_shipments s2 where s2.order_id=mv.order_id) + then (select coalesce(o.shipping_charged,0) - coalesce(o.shipping_refunded,0) from ec_orders o where o.order_id=mv.order_id) + else 0 end + ) +,0) as total_shipping_charged, +coalesce( + sum(bal_tax_charged + + case when mv.shipment_id = (select min(s2.shipment_id) from ec_shipments s2 where s2.order_id=mv.order_id) + then (select coalesce(o.shipping_tax_charged,0) - coalesce(o.shipping_tax_refunded,0) from ec_orders o where o.order_id=mv.order_id) + else 0 end + ) +,0) as total_tax_charged from ec_items_money_view mv group by to_char(shipment_date,'YYYY'), to_char(shipment_date,'Q') order by to_char(shipment_date,'YYYY') || to_char(shipment_date,'Q')