Index: openacs-4/packages/invoices/www/invoice-cancellation.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-cancellation.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/invoices/www/invoice-cancellation.tcl 2 Apr 2006 22:08:02 -0000 1.6 +++ openacs-4/packages/invoices/www/invoice-cancellation.tcl 2 May 2006 12:07:11 -0000 1.7 @@ -96,24 +96,27 @@ set parent_item_id [content::revision::item_id -revision_id $parent_id] db_1row get_credit_offer {} - if {[db_0or1row get_old_credit {}] && $old_credit > 0.} { + if {[db_0or1row get_old_credit {}] && $old_credit < 0.} { # cancelled invoice has credit set invoice_id [content::revision::item_id -revision_id $new_invoice_rev_id] - set total_credit "-$old_credit" + set total_credit [expr -1. * $old_credit] set vat_credit [format "%.2f" [expr $total_credit * $vat_percent / 100.]] # add new offer item + set credit_category_id [parameter::get -parameter "CreditCategory"] set offer_item_rev_id [iv::offer_item::new \ -offer_id $credit_offer_rev_id \ -title $title \ -description $description \ -comment "" \ -item_nr $invoice_id \ - -item_units 1 \ - -price_per_unit $total_credit \ + -item_units $total_credit \ + -price_per_unit 1 \ -rebate 0 \ -sort_order $invoice_id \ -vat $vat_credit] + + category::map_object -object_id $offer_item_rev_id $credit_category_id } if {[exists_and_not_null category_ids]} {