Index: openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.adp 14 Aug 2005 05:00:14 -0000 1.1 @@ -0,0 +1,84 @@ +

Financial Transactions

+ + +
+ + This order was paid by invoice. + + + + TOTAL: <%=[ec_pretty_price $total_price]%> +
+ Balance: <%=[ec_pretty_price [expr $total_price - $invoice_payment_sum + $total_refunds]]%> +
+
+ + + +
This order was fully paid by scholarship. + + +
This order was partially paid by scholarship. + + +
    + +
  • Date: @funds.grant_date@, Fund: @funds.title@, Amount Granted: @funds.grant_amount@, Amount Used: @funds.amount_used@
  • +
    +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " + +
IDDateCreditcard Last 4AmountTypeTo Be CapturedAuth DateMark DateRefund DateFailed
@financial_transactions.transaction_id@@financial_transactions.inserted_date@@financial_transactions.creditcard_last_four@@financial_transactions.transaction_amount@@financial_transactions.transaction_type@@financial_transactions.to_be_captured_p@@financial_transactions.authorized_date@@financial_transactions.marked_date@@financial_transactions.refunded_date@@financial_transactions.failed_p@
+
+ + +
This order was fully paid by check.
+
+ +
No credit card transactions
+
+
\ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/lib/financial-transactions.tcl 14 Aug 2005 05:00:14 -0000 1.1 @@ -0,0 +1,100 @@ +# packages/dotlrn-ecommerce/lib/financial-transactions.tcl +# +# Financial transactions chunk +# +# @author Roel Canicula (roelmc@pldtdsl.net) +# @creation-date 2005-08-14 +# @arch-tag: f154b8f3-d746-4d57-9ab5-49ca9d5d9a95 +# @cvs-id $Id: financial-transactions.tcl,v 1.1 2005/08/14 05:00:14 roelc Exp $ + +foreach required_param {order_id} { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} +foreach optional_param {} { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +set transaction_counter 0 + +# Check for payment methods +set method [db_string method { + select method, internal_account + from dotlrn_ecommerce_transactions + where order_id = :order_id +} -default cc] + +if { [db_0or1row scholarship { + select 1 + where exists (select * + from ec_gift_certificate_usage + where order_id = :order_id + and exists (select * + from scholarship_fund_grants + where ec_gift_certificate_usage.gift_certificate_id = gift_certificate_id)) +}] } { + set method scholarship +} + +set total_price [db_string total_price {select ec_total_price(:order_id)} -default 0] +set total_refunds [db_string total_refunds {select ec_total_refund(:order_id)} -default 0] + +switch $method { + + "invoice" { + # List invoice payments + set invoice_payment_sum 0 + db_multirow invoice_payments invoice_payments { + select amount, to_char(payment_date, 'Month dd, yyyy hh:miam') as pretty_payment_date, method as invoice_method + from dotlrn_ecommerce_transaction_invoice_payments + where order_id = :order_id + order by payment_date + } { + set amount [ec_pretty_price $amount] + set invoice_method [ad_decode $invoice_method cc "Credit Card" internal_account "Internal Account" check "Check" cash "Cash" lockbox "Lock Box" "Credit Card"] + set invoice_payment_sum [expr $invoice_payment_sum + $amount] + } + + } + "scholarship" { + set gc_amount [db_string gc_amount {select ec_order_gift_cert_amount(:order_id)} -default 0] + + db_multirow funds funds { + select f.title, u.amount_used, g.grant_amount, to_char(g.grant_date, 'Month dd, yyyy hh:miam') as grant_date + from ec_gift_certificate_usage u, scholarship_fund_grants g, scholarship_fundi f + where u.gift_certificate_id = g.gift_certificate_id + and g.fund_id = f.fund_id + and u.order_id = :order_id + and not u.amount_used is null + + order by g.grant_date + } { + set grant_amount [ec_pretty_price $grant_amount] + set amount_used [ec_pretty_price $amount_used] + + } + } +} + +db_multirow financial_transactions financial_transactions_select " + select t.transaction_id, t.inserted_date, t.transaction_amount, t.transaction_type, t.to_be_captured_p, t.authorized_date, + t.marked_date, t.refunded_date, t.failed_p, c.creditcard_last_four + from ec_financial_transactions t, ec_creditcards c + where t.creditcard_id=c.creditcard_id + and t.order_id=:order_id + order by transaction_id" { + + incr transaction_counter + set inserted_date [ec_nbsp_if_null [ec_formatted_full_date $inserted_date]] + set transaction_amount [ec_pretty_price $transaction_amount] + set transaction_type [ec_decode $transaction_type "charge" "authorization to charge" "intent to refund"] + set to_be_captured_p [ec_nbsp_if_null [ec_decode $transaction_type "refund" "Yes" [ec_decode $to_be_captured_p "t" "Yes" "f" "No" ""]]] + + set authorized_date [ec_nbsp_if_null [ec_formatted_full_date $authorized_date]] + set marked_date [ec_nbsp_if_null [ec_formatted_full_date $marked_date]] + set refunded_date [ec_nbsp_if_null [ec_formatted_full_date $refunded_date]] + set failed_p [ec_nbsp_if_null [ec_decode $failed_p "t" "Yes" "f" "No" ""]] +} Index: openacs-4/packages/dotlrn-ecommerce/lib/refunds.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/refunds.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/lib/refunds.adp 14 Aug 2005 05:00:14 -0000 1.1 @@ -0,0 +1,28 @@ +

Returns

+ +
+ + + + + + + + Refund ID: @refunds.refund_id@
+ Date: @refunds.refund_date@
+ Amount: @refunds.refund_amount@
+ Refunded by: @refunds.first_names@ @refunds.last_name@
+ Reason: @refunds.refund_reasons@ +
    + + +
  • Quantity @refunds.quantity@: @refunds.product_name@
  • + +
+
+ + No Returns Have Been Made + + +
+ Index: openacs-4/packages/dotlrn-ecommerce/lib/refunds.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/refunds.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn-ecommerce/lib/refunds.tcl 14 Aug 2005 05:00:14 -0000 1.1 @@ -0,0 +1,32 @@ +# packages/dotlrn-ecommerce/lib/refunds.tcl +# +# Refunds +# +# @author Roel Canicula (roelmc@pldtdsl.net) +# @creation-date 2005-08-14 +# @arch-tag: a2801cc7-9b21-4cf9-80b2-66d9f2a42425 +# @cvs-id $Id: refunds.tcl,v 1.1 2005/08/14 05:00:14 roelc Exp $ + +foreach required_param {order_id} { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} +foreach optional_param {} { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +db_multirow refunds refunds_select { + select r.refund_id, r.refund_date, r.refunded_by, r.refund_reasons, r.refund_amount, u.first_names, u.last_name, p.product_name, p.product_id, i.price_name, i.price_charged, count(*) as quantity + from ec_refunds r, cc_users u, ec_items i, ec_products p + where r.order_id=:order_id + and r.refunded_by=u.user_id + and i.refund_id=r.refund_id + and p.product_id=i.product_id + group by r.refund_id, r.refund_date, r.refunded_by, r.refund_reasons, r.refund_amount, u.first_names, u.last_name, p.product_name, p.product_id, i.price_name, i.price_charged +} { + set refund_date [ec_formatted_full_date $refund_date] + set refund_amount [ec_pretty_price $refund_amount] +} \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/one.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/one.tcl 10 Aug 2005 21:30:05 -0000 1.5 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/ecommerce/one.tcl 14 Aug 2005 05:00:14 -0000 1.6 @@ -228,156 +228,15 @@ Base shipping charged [ec_pretty_price $shipping_charged] [ec_decode $shipping_method "pickup" "(Pickup)" "no shipping" "(No Shipping)" ""] - - -

Financial Transactions

" + " -set table_header " - - - - - - - - - - - - - " +set financial_transactions [template::adp_compile -string {}] +# Hack to not display ds stuff even if it's enabled, demo purposes +regsub -all {\[::ds_show_p\]} $financial_transactions 0 financial_transactions -set transaction_counter 0 - -# Check for payment methods -set method [db_string method { - select method, internal_account - from dotlrn_ecommerce_transactions - where order_id = :order_id -} -default cc] - -if { [db_0or1row scholarship { - select 1 - where exists (select * - from ec_gift_certificate_usage - where order_id = :order_id - and exists (select * - from scholarship_fund_grants - where ec_gift_certificate_usage.gift_certificate_id = gift_certificate_id)) -}] } { - set method scholarship -} - -set total_price [db_string total_price {select ec_total_price(:order_id)} -default 0] -set total_refunds [db_string total_refunds {select ec_total_refund(:order_id)} -default 0] - -switch $method { - - "invoice" { - # List invoice payments - doc_body_append "
This order was paid by invoice." - - set invoice_payment_sum 0 - doc_body_append "
    Payments" - db_foreach invoice_payments { - select amount, to_char(payment_date, 'Month dd, yyyy hh:miam') as pretty_payment_date, method as invoice_method - from dotlrn_ecommerce_transaction_invoice_payments - where order_id = :order_id - order by payment_date - } { - doc_body_append "
  • Date: $pretty_payment_date, Amount: [ec_pretty_price $amount], Via: [ad_decode $invoice_method cc "Credit Card" internal_account "Internal Account" check "Check" cash "Cash" lockbox "Lock Box" "Credit Card"]
  • " - set invoice_payment_sum [expr $invoice_payment_sum + $amount] - } - - if { $invoice_payment_sum == 0 } { - doc_body_append "
  • No payments have been made
  • " - } - - if { $invoice_payment_sum < $total_price } { - doc_body_append "
  • Add Payment
  • " - } - - doc_body_append [subst {
- - TOTAL: [ec_pretty_price $total_price] -
- Balance: [ec_pretty_price [expr $total_price - $invoice_payment_sum + $total_refunds]] -
}] - } - "scholarship" { - set gc_amount [db_string gc_amount {select ec_order_gift_cert_amount(:order_id)} -default 0] - - if { $gc_amount == $total_price } { - doc_body_append "
This order was fully paid by scholarship." - } else { - doc_body_append "
This order was partially paid by scholarship." - } - - doc_body_append "
    " - db_foreach funds { - select f.title, u.amount_used, g.grant_amount, to_char(g.grant_date, 'Month dd, yyyy hh:miam') as grant_date - from ec_gift_certificate_usage u, scholarship_fund_grants g, scholarship_fundi f - where u.gift_certificate_id = g.gift_certificate_id - and g.fund_id = f.fund_id - and u.order_id = :order_id - - order by g.grant_date - } { - doc_body_append "
  • Date: $grant_date, Fund: $title, Amount Granted: [ec_pretty_price $grant_amount], Amount Used: [ec_pretty_price $amount_used]
  • " - } - doc_body_append "
" - - doc_body_append "
" - } -} - -db_foreach financial_transactions_select " - select t.transaction_id, t.inserted_date, t.transaction_amount, t.transaction_type, t.to_be_captured_p, t.authorized_date, - t.marked_date, t.refunded_date, t.failed_p, c.creditcard_last_four - from ec_financial_transactions t, ec_creditcards c - where t.creditcard_id=c.creditcard_id - and t.order_id=:order_id - order by transaction_id" { - - if { $transaction_counter == 0 } { - doc_body_append $table_header - } - doc_body_append " -
- - - - - - - - - - - " - incr transaction_counter -} - -if { $transaction_counter != 0 } { - doc_body_append "
IDDateCreditcard Last 4AmountTypeTo Be CapturedAuth DateMark DateRefund DateFailed
$transaction_id[ec_nbsp_if_null [ec_formatted_full_date $inserted_date]]$creditcard_last_four[ec_pretty_price $transaction_amount][ec_decode $transaction_type "charge" "authorization to charge" "intent to refund"][ec_nbsp_if_null [ec_decode $transaction_type "refund" "Yes" [ec_decode $to_be_captured_p "t" "Yes" "f" "No" ""]]][ec_nbsp_if_null [ec_formatted_full_date $authorized_date]][ec_nbsp_if_null [ec_formatted_full_date $marked_date]][ec_nbsp_if_null [ec_formatted_full_date $refunded_date]][ec_nbsp_if_null [ec_decode $failed_p "t" "Yes" "f" "No" ""]]
" -} else { - - # Check if this was payed via another method - switch $method { - cash - - lockbox - - check { - doc_body_append "
This order was fully paid by ${method}.
" - } - cc { - doc_body_append "
No credit card transactions
" - } - invoice - - scholarship {} - } -} - doc_body_append " +[eval $financial_transactions] +

Shipments

" @@ -428,46 +287,14 @@ } doc_body_append " -
+
" -

Returns

+set refunds [template::adp_compile -string {}] +# Hack to not display ds stuff even if it's enabled, demo purposes +regsub -all {\[::ds_show_p\]} $refunds 0 refunds -
" +doc_body_append "[eval $refunds]" -set old_refund_id 0 - -db_foreach refunds_select " - select r.refund_id, r.refund_date, r.refunded_by, r.refund_reasons, r.refund_amount, u.first_names, u.last_name, p.product_name, p.product_id, i.price_name, i.price_charged, count(*) as quantity - from ec_refunds r, cc_users u, ec_items i, ec_products p - where r.order_id=:order_id - and r.refunded_by=u.user_id - and i.refund_id=r.refund_id - and p.product_id=i.product_id - group by r.refund_id, r.refund_date, r.refunded_by, r.refund_reasons, r.refund_amount, u.first_names, u.last_name, p.product_name, p.product_id, i.price_name, i.price_charged" { - if { $refund_id != $old_refund_id } { - if { $old_refund_id != 0 } { - doc_body_append "" - } - doc_body_append " - Refund ID: $refund_id
- Date: [ec_formatted_full_date $refund_date]
- Amount: [ec_pretty_price $refund_amount]
- Refunded by: $first_names $last_name
- Reason: $refund_reasons -
    " - } - doc_body_append "
  • Quantity $quantity: $product_name
  • " - set old_refund_id $refund_id -} - -if { $old_refund_id == 0 } { - doc_body_append "No Returns Have Been Made" -} else { - doc_body_append "
" -} - -doc_body_append "
" - if { $order_state != "void" } { doc_body_append "

Actions