Index: openacs-4/packages/ecommerce/www/admin/orders/items-return-4-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/orders/items-return-4-oracle.xql,v
diff -u -r1.3 -r1.3.2.1
--- openacs-4/packages/ecommerce/www/admin/orders/items-return-4-oracle.xql 26 May 2002 04:36:50 -0000 1.3
+++ openacs-4/packages/ecommerce/www/admin/orders/items-return-4-oracle.xql 17 Oct 2002 02:53:51 -0000 1.3.2.1
@@ -123,4 +123,71 @@
+
+
+ select * from (
+ select transaction_id as charged_transaction_id, marked_date
+ from ec_financial_transactions
+ where order_id = :order_id
+ and transaction_type = 'charge'
+ and (transaction_amount - :refund_amount) < 0.01
+ and (transaction_amount - :refund_amount) > 0
+ and refunded_amount is null
+ and marked_date is not null
+ and failed_p = 'f'
+ order by transaction_id)
+ where rownum=1
+
+
+
+
+
+ select * from (
+ select transaction_id as charged_transaction_id, (transaction_amount - nvl(refunded_amount, 0)) as unrefunded_amount, marked_date
+ from ec_financial_transactions
+ where order_id = :order_id
+ and transaction_type = 'charge'
+ and (transaction_amount - nvl(refunded_amount, 0)) > 0.01
+ and marked_date is not null
+ and failed_p = 'f'
+ order by (transaction_amount - nvl(refunded_amount, 0)) desc
+ )
+ where rownum=1
+
+
+
+
+
+ update ec_financial_transactions
+ set refunded_amount = nvl(refunded_amount, 0) + :refund_amount
+ where transaction_id = :charged_transaction_id
+
+
+
+
+
+ update ec_financial_transactions
+ set refunded_amount = coalesce(refunded_amount, 0) + :unrefunded_amount
+ where transaction_id = :charged_transaction_id
+
+
+
+
+
+ insert into ec_financial_transactions
+ (transaction_id, refunded_transaction_id, order_id, refund_id, creditcard_id, transaction_amount, transaction_type, inserted_date, to_be_captured_date)
+ values
+ (:refund_transaction_id, :charged_transaction_id, :order_id, :refund_id, :creditcard_id, :refund_amount, 'refund', sysdate, to_date(:scheduled_hour,'YYYY-MM-DD HH12:MI:SSAM'))
+
+
+
+
+
+ insert into ec_financial_transactions
+ (transaction_id, refunded_transaction_id, order_id, refund_id, creditcard_id, transaction_amount, transaction_type, inserted_date, to_be_captured_date)
+ values
+ (:refund_transaction_id, :charged_transaction_id, :order_id, :refund_id, :creditcard_id, :unrefunded_amount, 'refund', sysdate, to_date(:scheduled_hour,'YYYY-MM-DD HH12:MI:SSAM'))
+
+
+
Index: openacs-4/packages/ecommerce/www/admin/orders/items-return-4-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ecommerce/www/admin/orders/items-return-4-postgresql.xql,v
diff -u -r1.3 -r1.3.2.1
--- openacs-4/packages/ecommerce/www/admin/orders/items-return-4-postgresql.xql 26 May 2002 04:36:50 -0000 1.3
+++ openacs-4/packages/ecommerce/www/admin/orders/items-return-4-postgresql.xql 17 Oct 2002 02:53:51 -0000 1.3.2.1
@@ -171,4 +171,68 @@
+
+
+ select transaction_id as charged_transaction_id, marked_date
+ from ec_financial_transactions
+ where order_id = :order_id
+ and transaction_type = 'charge'
+ and (transaction_amount - :refund_amount) < 0.01::numeric
+ and (transaction_amount - :refund_amount) > 0::numeric
+ and refunded_amount is null
+ and marked_date is not null
+ and failed_p = 'f'
+ order by transaction_id
+ limit 1
+
+
+
+
+
+ select transaction_id as charged_transaction_id, (transaction_amount - coalesce(refunded_amount, 0)) as unrefunded_amount, marked_date
+ from ec_financial_transactions
+ where order_id = :order_id
+ and transaction_type = 'charge'
+ and (transaction_amount - coalesce(refunded_amount, 0)) > 0.01::numeric
+ and marked_date is not null
+ and failed_p = 'f'
+ order by (transaction_amount - coalesce(refunded_amount, 0)) desc
+ limit 1
+
+
+
+
+
+ update ec_financial_transactions
+ set refunded_amount = coalesce(refunded_amount, 0) + :refund_amount
+ where transaction_id = :charged_transaction_id
+
+
+
+
+
+ update ec_financial_transactions
+ set refunded_amount = coalesce(refunded_amount, 0) + :unrefunded_amount
+ where transaction_id = :charged_transaction_id
+
+
+
+
+
+ insert into ec_financial_transactions
+ (transaction_id, refunded_transaction_id, order_id, refund_id, creditcard_id, transaction_amount, transaction_type, inserted_date, to_be_captured_date)
+ values
+ (:refund_transaction_id, :charged_transaction_id, :order_id, :refund_id, :creditcard_id, :refund_amount, 'refund', sysdate, :scheduled_hour)
+
+
+
+
+
+ insert into ec_financial_transactions
+ (transaction_id, refunded_transaction_id, order_id, refund_id, creditcard_id, transaction_amount, transaction_type, inserted_date, to_be_captured_date)
+ values
+ (:refund_transaction_id, :charged_transaction_id, :order_id, :refund_id, :creditcard_id, :unrefunded_amount, 'refund', sysdate, :scheduled_hour)
+
+
+