Index: openacs-4/packages/invoices/catalog/invoices.de_DE.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/catalog/invoices.de_DE.ISO-8859-1.xml,v diff -u -r1.34 -r1.35 --- openacs-4/packages/invoices/catalog/invoices.de_DE.ISO-8859-1.xml 18 May 2006 12:48:46 -0000 1.34 +++ openacs-4/packages/invoices/catalog/invoices.de_DE.ISO-8859-1.xml 24 May 2006 09:40:37 -0000 1.35 @@ -179,6 +179,7 @@ Titel Mehrwertsteuer Rechnungsposition ansehen + Vorbereitete Rechnungen Neue Rechnung Neue Rechnung erstellen Nicht abzurechnende Subprojekte @@ -234,7 +235,7 @@ Auftragsdatum Datum der Annahme <html><body>%data.contact_salutation%, <p>vielen Dank f�r Ihren Auftrag!<p> -Die Details entnehmen Sie bitte der angeh�ngten PDF-Datei.<p>Mit freundlichen Gr&uuml;&szlig;en<p>%am_name;noquote%<br>Kundenberatung</html></body> +Die Details entnehmen Sie bitte der angeh�ngten PDF-Datei.<p>Viele Gr&uuml;&szlig;e<p>%am_name;noquote%<br>Kundenberatung</html></body> Auftragsbest�tigung # %offer_nr% Vielen Dank f�r die Annahme unseres Angebots. Wir werden Sie so schnell wie m�glich diesbez�glich kontaktieren. Kostenaufstellung f�r "%organization_name%" @@ -264,7 +265,11 @@ Beschreibung der Kostenaufstellung Projektaufstellung �ndern Sie d�rfen keine akzeptierte oder berechnete Kostenaufstellung �ndern. +<<<<<<< invoices.de_DE.ISO-8859-1.xml + <html><body>%data.contact_salutation%,<p>anbei erhalten Sie das gew�nschte Angebot als PDF-Datei.<p>Um das Angebot freizugeben, klicken Sie bitte <a href="%accept_link%">hier</a>.<p>Viele Grüße<p>%am_name;noquote%<br>Kundenberatung<br/> +======= <html><body>%data.contact_salutation%,<p>anbei erhalten Sie das gew�nschte Angebot als PDF-Datei.<p>Um das Angebot freizugeben, klicken Sie bitte <a href="%accept_link;noquote%">hier</a>.<p>Mit freundlichen Gr��en<p>%am_name;noquote%<br>Kundenberatung<br/> +>>>>>>> 1.33 Durchwahl: %am_directphoneno%<br><b>WIENERS+WIENERS GmbH</b></body></html> Angebot # %offer_nr% Datei anh�ngen Index: openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml,v diff -u -r1.38 -r1.39 --- openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 18 May 2006 12:48:46 -0000 1.38 +++ openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 24 May 2006 09:40:37 -0000 1.39 @@ -179,6 +179,7 @@ Title VAT View Invoice Item + Prepared invoices New Invoice Create New Invoice Subprojects without invoice Index: openacs-4/packages/invoices/lib/invoice-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-list.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/invoices/lib/invoice-list.tcl 3 May 2006 05:52:35 -0000 1.15 +++ openacs-4/packages/invoices/lib/invoice-list.tcl 24 May 2006 09:40:38 -0000 1.16 @@ -67,7 +67,7 @@ lappend actions "[_ invoices.iv_invoice_url]" $base_url "[_ invoices.iv_invoice_url2]" if {$invoice_cancel_p} { - lappend actions "[_ invoices.iv_journal_check]" "${base_url}journal-check" "[_ invoices.iv_journal_check]" "[_ invoices.iv_join_invoice]" "${base_url}invoice-join" "[_ invoices.iv_join_invoice]" + lappend actions "[_ invoices.iv_journal_check]" "${base_url}journal-check" "[_ invoices.iv_journal_check]" "[_ invoices.iv_join_invoice]" [export_vars -base "${base_url}invoice-join" {return_url}] "[_ invoices.iv_join_invoice]" } # If the sum was paid, the total_amount should appear green. @@ -217,14 +217,30 @@ set contacts_package_id [apm_package_id_from_key contacts] set return_url "[ad_conn url]?[ad_conn query]" -db_multirow -extend {creator_link edit_link display_link cancel_link delete_link preview_link create_link copy_link recipient} iv_invoice iv_invoice {} { +db_multirow -extend {creator_link edit_link display_link cancel_link delete_link preview_link create_link copy_link recipient invoice_type} iv_invoice iv_invoice {} { # Ugly hack. We should find out which contact package is linked + + if {$total_amount >= 0} { + # send invoice + set invoice_type "invoice" + } elseif {[empty_string_p $parent_invoice_id]} { + # A credit has a negative total amount and no parent_id + set invoice_type "credit" + } else { + # A cancellation invoice has a negative amount and the parent_id set to the + # Invoice it is cancelling. + set invoice_type "cancellation" + } set creation_date [lc_time_fmt $creation_date $time_format] set due_date [lc_time_fmt $due_date $date_format] set display_link [export_vars -base "${base_url}invoice-ae" {invoice_id {mode display}}] - set edit_link [export_vars -base "${base_url}invoice-ae" {invoice_id return_url}] + if {$invoice_type eq "credit"} { + set edit_link [export_vars -base "${base_url}invoice-credit" {invoice_id organization_id return_url}] + } else { + set edit_link [export_vars -base "${base_url}invoice-ae" {invoice_id return_url}] + } set cancel_link [export_vars -base "${base_url}invoice-cancellation" {{organization_id $orga_id} {parent_id $invoice_rev_id} return_url}] set delete_link [export_vars -base "${base_url}invoice-delete" {invoice_id return_url}] set preview_link [export_vars -base "${base_url}invoice-preview" {invoice_id}] Index: openacs-4/packages/invoices/lib/offer-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/offer-list.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/invoices/lib/offer-list.tcl 2 May 2006 12:07:11 -0000 1.13 +++ openacs-4/packages/invoices/lib/offer-list.tcl 24 May 2006 09:40:38 -0000 1.14 @@ -38,10 +38,12 @@ set show_filter_p 0 } +set party_id_where_clause "" if {[exists_and_not_null party_id]} { - set party_id_where_clause "pi.item_id in ([join [pm::util::assigned_projects -party_id $party_id] ","])" -} else { - set party_id_where_clause "" + set assigned_projects [pm::util::assigned_projects -party_id $party_id] + lappend assigned_projects 0 + + set party_id_where_clause "pi.item_id in ([join $assigned_projects ","])" } if {[empty_string_p $package_id]} { @@ -124,7 +126,7 @@ } project_contact { label {[_ invoices.iv_offer_project_contact]} - display_template {@iv_offer.contact_first_names@ @iv_offer.contact_last_name@
@iv_offer.contact_phone;noquote@} + display_template {@iv_offer.contact_first_names@ @iv_offer.contact_last_name@ @iv_offer.contact_phone;noquote@} } amount_total { label {[_ invoices.iv_offer_amount_total]} @@ -270,5 +272,5 @@ multirow foreach iv_offer { contact::employee::get -employee_id $contact_id -array contact_data -use_cache - set contact_phone $contact_data(directphoneno) + set contact_phone [ad_html_to_text -no_format $contact_data(directphoneno)] } 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 Index: openacs-4/packages/invoices/www/invoice-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-join.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/www/invoice-join.tcl 3 May 2006 05:52:35 -0000 1.1 +++ openacs-4/packages/invoices/www/invoice-join.tcl 24 May 2006 09:40:38 -0000 1.2 @@ -4,6 +4,7 @@ @author Timo Hentschel (timo@timohentschel.de) @creation-date 2006-05-02 } { + return_url } -properties { context:onevalue page_title:onevalue @@ -32,17 +33,37 @@ lappend files "${tmpdir}/[file tail $content].pdf" } - set file_id [contact::oo::join_pdf -filenames $files -title $invoice_title -parent_id $root_folder_id] - db_1row get_file_location {} + if {[llength $files] > 0} { + set file_id [contact::oo::join_pdf -filenames $files -title $invoice_title -parent_id $root_folder_id] + db_1row get_file_location {} - db_dml mark_join_creation {} - db_dml mark_invoices_billed {} + db_dml mark_join_creation {} + db_dml mark_invoices_billed {} - # delete old files - foreach one_file $files { - ns_unlink $one_file + # delete old files + foreach one_file $files { + ns_unlink $one_file + } } ns_rmdir $tmpdir } -ns_returnfile 200 "application/pdf" "${root_dir}$file_location" +set actions [list "[_ invoices.ok]" $return_url "[_ invoices.ok]"] +multirow create documents file_id file_title file_url + +if {[llength $files] > 0} { + multirow append documents $file_id $invoice_title [export_vars -base "/tracking/download/$invoice_title" {file_id}] +} + +template::list::create \ + -name documents \ + -key file_id \ + -no_data "[_ invoices.None]" \ + -elements { + file_id { + label {[_ invoices.iv_invoice_file]} + display_template {@documents.file_title@} + } + } -actions $actions -sub_class narrow + +ad_return_template Index: openacs-4/packages/invoices/www/journal-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/journal-add.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/invoices/www/journal-add.tcl 3 May 2006 05:57:37 -0000 1.2 +++ openacs-4/packages/invoices/www/journal-add.tcl 24 May 2006 09:40:38 -0000 1.3 @@ -99,7 +99,7 @@ set email [string range $email 0 49] array unset address_array - set new_line "S;0;D;$client_id;;$company_name;$zip_and_municipality;$ust_id_nr;1200;;;;0;;;;;;0;;;;;;;;$company_name;$company_name_ext;;$address;$zip_code;$municipality;;;;$company_phone;$company_fax;;;;;;;;;;;;$email;;$country_code" + set new_line "S;0;D;$client_id;;$company_name;$zip_and_municipality;$ust_id_nr;1200;;;;0;;;$payment_days Tage netto;;;0;;;;;;;;$company_name;$company_name_ext;;$address;$zip_code;$municipality;;;;$company_phone;$company_fax;;;;;;;;;;;;$email;;$country_code" set new_line [string map {{&} {&} {\n} {} {\x0a} {}} $new_line] 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.28 -r1.29 --- openacs-4/packages/invoices/www/offer-ae.tcl 22 May 2006 11:06:02 -0000 1.28 +++ openacs-4/packages/invoices/www/offer-ae.tcl 24 May 2006 09:40:38 -0000 1.29 @@ -615,7 +615,9 @@ set creator_name "$first_names $last_name" set customer_percent [ams::value -object_id [content::item::get_best_revision -item_id $organization_id] -attribute_name "vat_percent"] # set vat_percent [format "%.1f" $vat_percent] - set vat_percent [format "%.1f" $customer_percent] + if {![string eq "" $customer_percent]} { + set vat_percent [format "%.1f" $customer_percent] + } set vat [format "%.2f" $vat] if {$amount_total == 0} { set amount_total $amount_sum Index: openacs-4/packages/invoices/www/offer-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-list.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/invoices/www/offer-list.adp 2 May 2006 12:07:11 -0000 1.4 +++ openacs-4/packages/invoices/www/offer-list.adp 24 May 2006 09:40:38 -0000 1.5 @@ -6,6 +6,6 @@

-