Index: openacs-4/packages/ecommerce/tcl/ecommerce-state-changes-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/tcl/ecommerce-state-changes-procs-postgresql.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/ecommerce/tcl/ecommerce-state-changes-procs-postgresql.xql 29 Jan 2002 00:11:46 -0000 1.6 +++ openacs-4/packages/ecommerce/tcl/ecommerce-state-changes-procs-postgresql.xql 26 May 2002 04:36:50 -0000 1.7 @@ -1,121 +1,94 @@ - postgresql7.1 + + postgresql + 7.1 + - - + + + select ec_reinst_gift_cert_on_order (:order_id) + + -select ec_reinst_gift_cert_on_order (:order_id) + + + update ec_orders + set order_state = 'authorized', authorized_date = current_timestamp + where order_id = :order_id + + - - + + + insert into ec_shipments + (shipment_id, order_id, shipment_date, expected_arrival_date, carrier, shippable_p, last_modified, last_modifying_user, modified_ip_address) + select :shipment_id, :order_id, current_timestamp, current_timestamp, 'none', 'f', current_timestamp, user_id, :peeraddr from ec_orders where order_id = :order_id + + - - - - select ec_order_cost(:order_id) - - + + + update ec_orders + set order_state='confirmed', confirmed_date=current_timestamp + where order_id=:order_id + + - - - - update ec_orders set order_state=:new_state, authorized_date=current_timestamp where order_id=:order_id - - - - - - - update ec_financial_transactions set authorized_date=current_timestamp where transaction_id=:transaction_id - - - - - - - update ec_orders set order_state='confirmed', confirmed_date=current_timestamp where order_id=:order_id - - - - - - + + select ec_order_cost(:order_id) - - + + - - - + + insert into ec_financial_transactions - (transaction_id, order_id, transaction_amount, transaction_type, inserted_date) - values - (:transaction_id, :order_id, :total_amount, 'charge', current_timestamp) - - + (transaction_id, order_id, transaction_amount, transaction_type, inserted_date) + values + (:transaction_id, :order_id, :total_amount, 'charge', current_timestamp) + + - - - - - select gift_certificate_id - from ec_gift_certificates_approved - where user_id=:user_id - and current_timestamp - expires < 0 - and amount_remaining_p = 't' - order by expires - - - - - - - - select ec_gift_certificate_balance(:user_id) - - - - - - + + select ec_order_amount_owed(:order_id) - - + + - - - - select gift_certificate_amount_left(:gift_certificate_id) - - + + + select gift_certificate_id, gift_certificate_amount_left(gift_certificate_id) as amount_available + from ec_gift_certificates_approved + where user_id = :user_id + and current_timestamp - expires < 0 + and amount_remaining_p = 't' + and gift_certificate_amount_left(gift_certificate_id) > 0 + order by expires + + - - - + + insert into ec_gift_certificate_usage (gift_certificate_id, order_id, amount_used, used_date) - VALUES + values (:gift_certificate_id, :order_id, - least(:gift_certificate_amount_left,:amount_owed), current_timestamp) - - - + least(:amount_available, :amount_owed), current_timestamp) + + - - - + + select ec_gift_certificate_balance(:user_id) - - + + - - - + + select ec_order_amount_owed(:order_id) - - + + -