Index: openacs-4/packages/invoices/www/invoice-credit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-credit.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/invoices/www/invoice-credit.tcl 4 Jan 2006 08:06:48 -0000 1.5 +++ openacs-4/packages/invoices/www/invoice-credit.tcl 24 May 2006 09:40:38 -0000 1.6 @@ -35,7 +35,7 @@ ad_form -name iv_invoice_credit_form -action invoice-credit -export {organization_id} -form { {invoice_id:key} {organization_name:text(inform) {label "[_ invoices.iv_invoice_organization]"} {value $organization_name} {help_text "[_ invoices.iv_invoice_organization_help]"}} - {recipient_id:integer(select),optional {label "[_ invoices.iv_invoice_recipient]"} {options $recipient_options} {help_text "[_ invoices.iv_invoice_recipient_help]"}} + {recipient_id:integer(select),optional {label "[_ invoices.iv_credit_recipient]"} {options $recipient_options} {help_text "[_ invoices.iv_credit_recipient_help]"}} {title:text {label "[_ invoices.iv_invoice_Title]"} {html {size 80 maxlength 1000}} {help_text "[_ invoices.iv_invoice_Title_help]"}} {description:text(textarea),optional {label "[_ invoices.iv_invoice_Description]"} {html {rows 5 cols 80}} {help_text "[_ invoices.iv_invoice_Description_help]"}} } @@ -45,11 +45,11 @@ } ad_form -extend -name iv_invoice_credit_form -form { - {invoice_nr:text {label "[_ invoices.iv_invoice_invoice_nr]"} {html {size 80 maxlength 200}} {help_text "[_ invoices.iv_invoice_invoice_nr_help]"}} + {invoice_nr:text {label "[_ invoices.iv_credit_invoice_nr]"} {html {size 80 maxlength 200}} {help_text "[_ invoices.iv_credit_invoice_nr_help]"}} {currency:text(select) {mode display} {label "[_ invoices.iv_invoice_currency]"} {options $currency_options} {help_text "[_ invoices.iv_invoice_currency_help]"}} - {due_date:text,optional {label "[_ invoices.iv_invoice_due_date]"} {html {size 12 maxlength 10 id sel1}} {help_text "[_ invoices.iv_invoice_due_date_help]"} {after_html { \[y-m-d \]}}} + {due_date:text,optional {label "[_ invoices.iv_credit_due_date]"} {html {size 12 maxlength 10 id sel1}} {help_text "[_ invoices.iv_credit_due_date_help]"} {after_html { \[y-m-d \]}}} {vat_percent:float {label "[_ invoices.iv_invoice_vat_percent]"} {html {size 5 maxlength 10}} {help_text "[_ invoices.iv_invoice_vat_percent_help]"} {after_html {%}}} - {total_amount:float,optional {label "[_ invoices.iv_invoice_total_amount]"} {html {size 10 maxlength 10}} {help_text "[_ invoices.iv_invoice_total_amount_help]"} {after_html $currency}} + {total_amount:float,optional {label "[_ invoices.iv_credit_amount]"} {html {size 10 maxlength 10}} {help_text "[_ invoices.iv_credit_amount_help]"} {after_html $currency}} } ad_form -extend -name iv_invoice_credit_form -new_request { @@ -68,6 +68,16 @@ if {[info exists org_data(vat_percent)]} { set vat_percent [format "%.1f" $org_data(vat_percent)] } +} -edit_request { + db_1row get_data {} + set creator_name "$first_names $last_name" + set vat_percent [format "%.1f" $vat_percent] + set vat [format "%.2f" $vat] + set total_amount [string trim [format "%.2f" $total_amount] "-"] + set invoice_rebate [format "%.2f" [expr $amount_sum - $total_amount]] + if {![empty_string_p $paid_amount]} { + set paid_amount [format "%.2f" $paid_amount] + } } -on_submit { set category_ids [category::ad_form::get_categories -container_object_id $container_objects(invoice_id)] } -new_data { @@ -94,6 +104,31 @@ category::map_object -object_id $new_invoice_rev_id $category_ids } } +} -edit_data { + db_transaction { + set total_amount [format "%.2f" [expr -1. * $total_amount]] + set vat [expr $total_amount * $vat_percent / 100.] + set vat [format "%.2f" $vat] + + set new_invoice_rev_id [iv::invoice::edit \ + -invoice_item_id $invoice_id \ + -title $title \ + -description $description \ + -invoice_nr $invoice_nr \ + -contact_id $recipient_id \ + -organization_id $organization_id \ + -recipient_id $recipient_id \ + -total_amount $total_amount \ + -amount_sum $total_amount \ + -currency $currency \ + -due_date $due_date \ + -vat_percent $vat_percent \ + -vat $vat] + + if {[exists_and_not_null category_ids]} { + category::map_object -object_id $new_invoice_rev_id $category_ids + } + } } -after_submit { ad_returnredirect [export_vars -base invoice-list {organization_id}] ad_script_abort