Index: openacs-4/packages/invoices/www/mass-invoice.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/mass-invoice.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/invoices/www/mass-invoice.tcl 18 Jun 2006 14:10:15 -0000 1.2 +++ openacs-4/packages/invoices/www/mass-invoice.tcl 29 Jun 2006 14:45:02 -0000 1.3 @@ -23,6 +23,7 @@ set offer_ids [list] set files [list] set failed_project_ids [list] +set failed_project_id2 [list] if {$__new_p} { set project_id [string trim $project_id "{}"] @@ -39,7 +40,9 @@ ad_progress_bar_begin -title [_ invoices.Create_mass_invoices] -message_1 "[_ invoices.Create_mass_invoices2]" -foreach project_item_id $project_id { +# We need to catch this so the joined PDF is generated and send. +catch { + foreach project_item_id $project_id { # We need to make sure the whole process runs through smoothly for invoice # generation. Therefore we put this in transaction. If the transaction fails @@ -278,14 +281,18 @@ # move files to invoice_folder application_data_link::new -this_object_id $invoice_id -target_object_id $file_item_id - db_dml set_publish_status_and_parent {} - db_dml set_context_id {} - # Finally mark invoice as "Billed" in the system. - + db_transaction { + db_dml set_publish_status_and_parent {} + db_dml set_context_id {} + } on_error { + lappend failed_project_id2 $project_item_id + continue + } iv::invoice::set_status -invoice_id $invoice_id -status "billed" } } +} # foreach offer_id: check if there's an item that's not billed -> status new, else status billed foreach offer_id $offer_ids { @@ -324,6 +331,14 @@ set failed_projects_html "" } +if {[exists_and_not_null failed_projectid2]} { + append failed_projects_html "[_ invoices.mass_invoice_error]" +} + # and send out the e-mail if {$file_p} { 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.32 -r1.33 --- openacs-4/packages/invoices/www/offer-ae.tcl 18 Jun 2006 14:17:26 -0000 1.32 +++ openacs-4/packages/invoices/www/offer-ae.tcl 29 Jun 2006 14:45:02 -0000 1.33 @@ -858,10 +858,11 @@ # link offer to project if {[exists_and_not_null project_id]} { - catch { + # Check if offer is already linked + if {![db_string check_link "select 1 from acs_data_links where object_id_one = :offer_id and object_id_two =:project_id" -default 0]} { application_data_link::new -this_object_id $offer_id -target_object_id $project_id - set _project_id $project_id } + set _project_id $project_id } # set acceptance date if necessary