Index: openacs-4/packages/invoices/www/invoice-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-ae.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/invoices/www/invoice-ae.tcl 26 Oct 2005 12:00:38 -0000 1.9 +++ openacs-4/packages/invoices/www/invoice-ae.tcl 27 Oct 2005 17:24:39 -0000 1.10 @@ -437,7 +437,7 @@ } } - ad_returnredirect [export_vars -base invoice-list {organization_id}] + ad_returnredirect "/contacts/$organization_id/" ad_script_abort } Index: openacs-4/packages/invoices/www/offer-ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-ae.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/invoices/www/offer-ae.adp 26 Oct 2005 14:26:21 -0000 1.4 +++ openacs-4/packages/invoices/www/offer-ae.adp 27 Oct 2005 17:24:39 -0000 1.5 @@ -59,11 +59,13 @@ price = form["item_price."+i].value item_amount = form["amount_sum."+i].value item_rebate = form["item_rebate."+i].value + item_total = 0. + new_total = 0. item_total = Math.round( (1*item_amount) * (100-item_rebate) ) /100; - new_units = Math.round( (1*units) * (100+credit_percent) / 10 ) / 10; - new_amount = Math.round( 100* (1*new_units) * (1*price) ) /100; + new_units = formatCurrency( Math.round( (1.*units) * (100. + (1.*credit_percent)) / 10. ) / 10. ); + new_amount = formatCurrency( Math.round( 100* (1*new_units) * (1.*price) ) /100. ); new_total = Math.round( (1*new_amount) * (100-item_rebate) ) /100; credit = credit + new_total - item_total; Index: openacs-4/packages/invoices/www/offer-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-ae.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/invoices/www/offer-ae.tcl 26 Oct 2005 14:54:18 -0000 1.8 +++ openacs-4/packages/invoices/www/offer-ae.tcl 27 Oct 2005 17:24:39 -0000 1.9 @@ -116,10 +116,6 @@ set list_id [iv::price_list::get_list_id -organization_id $organization_id] db_multirow pricelist all_prices {} -if {$_offer_id && !$has_submit} { - # new offer - db_1row credit_percent {} -} ad_form -name iv_offer_form -action offer-ae -mode $mode -has_submit $has_submit -has_edit $has_edit -export {organization_id return_url} -form { {offer_id:key} @@ -199,8 +195,9 @@ } if {![empty_string_p $_credit_percent] && $_credit_percent > 0} { + set _credit_percent [format "%.1f" $_credit_percent] ad_form -extend -name iv_offer_form -form { - {credit_percent:float {label "[_ invoices.iv_offer_credit_percent]"} {html {size 5 maxlength 10 onChange calculateTotalAmount()}} {help_text "[_ invoices.iv_offer_credit_percent_help]"} {after_html {%}}} + {credit_percent:float {label "[_ invoices.iv_offer_credit_percent]"} {html {size 5 maxlength 10 onChange calculateTotalAmount()}} {help_text "[_ invoices.iv_offer_credit_percent_help]"} {value $_credit_percent} {after_html {%}}} {credit_sum:float,optional {label "[_ invoices.iv_offer_credit_sum]"} {html {size 10 maxlength 10 disabled t}} {help_text "[_ invoices.iv_offer_credit_sum_help]"} {after_html $currency}} } } else { @@ -221,6 +218,7 @@ # edit or display existing offer set i 0 set amount_sum 0. + set total_credit 0. db_foreach offer_items {} -column_array item { incr i @@ -230,6 +228,12 @@ set item(rebate) [format "%.1f" $item(rebate)] set item(category) [lang::util::localize [category::get_name $item(category_id)]] + # calculate credit from this item + set item_credit [format "%.1f" [expr $item(item_units) * (1+ ($_credit_percent / 100.))]] + set item_credit [format "%.2f" [expr $item_credit * $item(price_per_unit)]] + set item_credit [format "%.2f" [expr (1. - ($item(rebate) / 100.)) * $item_credit]] + set total_credit [expr $total_credit + $item_credit - $item(amount_total)] + set item_name "$item(category): $item(item_units) x $item(price_per_unit) $currency = $item(amount_sum) $currency" if {$item(rebate) > 0} { append item_name " - $item(rebate)% [_ invoices.iv_offer_item_rebate] = $item(amount_total) $currency" @@ -486,7 +490,6 @@ set offer_nr [db_nextval iv_offer_seq] set amount_sum "0.00" set amount_total "0.00" - set credit_percent [format "%.1f" $_credit_percent] set credit_sum "0.00" # get this from organization_id @@ -512,8 +515,8 @@ if {$amount_total == 0} { set amount_total $amount_sum } - set amount_total [format "%.2f" $amount_total] + set credit_sum $total_credit if {$has_submit} { set amount_sum [format "%.2f" $amount_sum_] Index: openacs-4/packages/invoices/www/offer-ae.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-ae.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/invoices/www/offer-ae.xql 26 Oct 2005 12:53:45 -0000 1.4 +++ openacs-4/packages/invoices/www/offer-ae.xql 27 Oct 2005 17:24:39 -0000 1.5 @@ -68,16 +68,6 @@ - - - - select credit_percent as _credit_percent - from iv_price_lists - where list_id = :list_id - - - -