Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-3.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-3.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-3.tcl 3 Aug 2005 22:45:46 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-3.tcl 5 Aug 2005 02:52:53 -0000 1.2
@@ -200,7 +200,27 @@
# Request the credit card number to be re-entered if it is no longer
# on file, yet there is money to refund.
-if { [empty_string_p $creditcard_number] && $cash_amount_to_refund > 0 } {
+# Only ask for credit card info if credit card was used in purchase
+
+set method [db_string method {
+ select method
+ from dotlrn_ecommerce_transactions
+ where order_id = :order_id
+} -default cc]
+
+if { $method == "invoice" } {
+ if { [db_0or1row cc_transaction_in_invoice {
+ select 1
+ where exists (select *
+ from dotlrn_ecommerce_transaction_invoice_payments
+ where order_id = :order_id
+ and method = 'cc')
+ }] } {
+ set method cc
+ }
+}
+
+if { [empty_string_p $creditcard_number] && $cash_amount_to_refund > 0 && $method == "cc" } {
append doc_body "
Please re-enter the credit card number of the card used for this order:
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4-postgresql.xql 3 Aug 2005 22:45:46 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4-postgresql.xql 5 Aug 2005 02:52:53 -0000 1.2
@@ -49,7 +49,7 @@
- select transaction_id as charged_transaction_id, to_char(marked_date, 'yyyy-mm-dd hh24:mi::ss') as marked_date
+ select transaction_id as charged_transaction_id, to_char(marked_date, 'yyyy-mm-dd hh24:mi:ss') as marked_date
from ec_financial_transactions
where order_id = :order_id
and transaction_type = 'charge'
@@ -82,7 +82,7 @@
- select transaction_id as charged_transaction_id, (transaction_amount - coalesce(refunded_amount, 0)) as unrefunded_amount, marked_date
+ select transaction_id as charged_transaction_id, (transaction_amount - coalesce(refunded_amount, 0)) as unrefunded_amount, to_char(marked_date, 'yyyy-mm-dd hh24:mi:ss') as marked_date
from ec_financial_transactions
where order_id = :order_id
and transaction_type = 'charge'
@@ -173,7 +173,7 @@
- select transaction_id as charged_transaction_id, marked_date
+ select transaction_id as charged_transaction_id, to_char(marked_date, 'yyyy-mm-dd hh24:mi:ss') as marked_date
from ec_financial_transactions
where order_id = :order_id
and transaction_type = 'charge'
@@ -189,7 +189,7 @@
- select transaction_id as charged_transaction_id, (transaction_amount - coalesce(refunded_amount, 0)) as unrefunded_amount, marked_date
+ select transaction_id as charged_transaction_id, (transaction_amount - coalesce(refunded_amount, 0)) as unrefunded_amount, to_char(marked_date, 'yyyy-mm-dd hh24:mi:ss') as marked_date
from ec_financial_transactions
where order_id = :order_id
and transaction_type = 'charge'
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.tcl 3 Aug 2005 22:45:46 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.tcl 5 Aug 2005 02:52:53 -0000 1.2
@@ -44,6 +44,24 @@
creditcard_last_four:optional
}
+set method [db_string method {
+ select method
+ from dotlrn_ecommerce_transactions
+ where order_id = :order_id
+} -default cc]
+
+if { $method == "invoice" } {
+ if { [db_0or1row cc_transaction_in_invoice {
+ select 1
+ where exists (select *
+ from dotlrn_ecommerce_transaction_invoice_payments
+ where order_id = :order_id
+ and method = 'cc')
+ }] } {
+ set method cc
+ }
+}
+
# The customer service rep must be logged on and have admin
# privileges.
@@ -77,7 +95,7 @@
# Check if money needs to be refunded and if the credit card number is
# still on file.
-if { [expr $cash_amount_to_refund] > 0 } {
+if { [expr $cash_amount_to_refund] > 0 && $method == "cc" } {
# Make sure that all the credit card information is there.
@@ -146,10 +164,12 @@
# 2. Put records into ec_refunds, individual items, the order, and
# ec_financial_transactions
-db_dml update_cc_number_incctable "
- update ec_creditcards
+if { $method == "cc" } {
+ db_dml update_cc_number_incctable "
+ update ec_creditcards
set creditcard_number=:creditcard_number
where creditcard_id=:creditcard_id"
+}
db_dml insert_new_ec_refund "
insert into ec_refunds
(refund_id, order_id, refund_amount, refund_date, refunded_by, refund_reasons)
@@ -206,7 +226,7 @@
# in parts and the customer returned items from various shipments.
set refund_amount $cash_amount_to_refund
-while { $refund_amount > 0 } {
+while { $refund_amount > 0 && $method == "cc" } {
# See if the refund matches a single charge transaction. The
# test < 0.01 is needed for reasons of rounding errors.
@@ -258,9 +278,8 @@
(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)"
-
+
# Record the amount that was refunded of the charge transaction.
-
db_dml record_refunded_amount "
update ec_financial_transactions
set refunded_amount = coalesce(refunded_amount, 0) + :refund_amount
@@ -436,7 +455,7 @@
# 4. Try to do the refund(s)
-if {$cash_amount_to_refund > 0} {
+if {$cash_amount_to_refund > 0 && $method == "cc" } {
set page_title "Refund results"
set results_explanation ""
db_foreach select_unrefund_transactions "
Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.xql 3 Aug 2005 22:45:46 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/items-return-4.xql 5 Aug 2005 02:52:53 -0000 1.2
@@ -95,7 +95,7 @@
- select transaction_id, transaction_amount, refunded_transaction_id, to_be_captured_date
+ select transaction_id, transaction_amount, refunded_transaction_id, to_char(to_be_captured_date, 'yyyy-mm-dd hh24:mi:ss') as to_be_captured_date
from ec_financial_transactions
where order_id = :order_id
and transaction_type = 'refund'