Index: openacs-4/packages/invoices/lib/projects-billable.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/projects-billable.tcl,v diff -u -r1.18 -r1.19 --- openacs-4/packages/invoices/lib/projects-billable.tcl 11 Aug 2006 19:37:51 -0000 1.18 +++ openacs-4/packages/invoices/lib/projects-billable.tcl 19 Oct 2006 17:06:49 -0000 1.19 @@ -71,6 +71,18 @@ append row_list "$element {}\n" } +# Make sure we don't kill ourself +set new_elements [list] +foreach element $elements { + if {$element eq "count_total" || $element eq "count_billed"} { + # get rid of it + } else { + lappend new_elements $element + } +} + +set elements $new_elements + if {[lsearch $elements "count_total"] > -1 || [lsearch $elements "count_billed"] > -1} { set query "projects_to_bill2" } else { @@ -119,12 +131,6 @@ label {[_ invoices.iv_invoice_amount_open]} display_template {@projects.amount_open@ @projects.currency@} } - count_total { - label {[_ invoices.iv_invoice_count_total]} - } - count_billed { - label {[_ invoices.iv_invoice_count_billed]} - } creation_date { label {[_ invoices.iv_invoice_closed_date]} } @@ -167,12 +173,6 @@ orderby_asc {lower(r.description) asc, r.item_id} default_direction asc } - amount_open { - label {[_ invoices.iv_invoice_amount_open]} - orderby_desc {sub.amount_open desc, r.item_id} - orderby_asc {sub.amount_open asc, r.item_id} - default_direction desc - } creation_date { label {[_ invoices.iv_invoice_closed_date]} orderby {sub.creation_date} Index: openacs-4/packages/invoices/lib/projects-billable.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/projects-billable.xql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/lib/projects-billable.xql 18 May 2006 19:33:59 -0000 1.10 +++ openacs-4/packages/invoices/lib/projects-billable.xql 19 Oct 2006 17:06:49 -0000 1.11 @@ -1,6 +1,17 @@ +-- +-- +++ READ THIS +++ +-- +-- Sept. 2006 cognovis/nfl +-- projects_to_bill changed (and only that one!) +-- now it's getting the information about the sum from iv_offers.amount_open +-- instead of summing iv_offer_items +-- so there is no support if more items will be added and amount_open won't be updated +-- and there is no support for credit advices (Gutschriften) +-- + select @@ -19,7 +30,8 @@ pr.title, pr.description, o.creation_date, - sum(ofi.item_units * ofi.price_per_unit * (1-(ofi.rebate/100))) as amount_open, + -- sum(ofi.item_units * ofi.price_per_unit * (1-(ofi.rebate/100))) as amount_open_old, + io.amount_total as amount_open, p.customer_id, p.recipient_id, oz.name @@ -29,9 +41,10 @@ pm_projects p, acs_objects o, acs_data_links r, - iv_offer_items ofi, + -- iv_offer_items ofi, cr_items oi, - organizations oz + organizations oz, + iv_offers io where pi.latest_revision = pr.revision_id and p.project_id = pr.revision_id @@ -40,10 +53,11 @@ and r.object_id_two = oi.item_id and p.status_id = :p_closed_id and p.invoice_p = true - and ofi.offer_id = oi.latest_revision + -- and ofi.offer_id = oi.latest_revision and p.customer_id = oz.organization_id + and io.offer_id = oi.latest_revision group by - oi.item_id, pi.item_id, pr.title, pr.description, o.creation_date, p.customer_id, oz.name, p.recipient_id) sub + oi.item_id, pi.item_id, pr.title, pr.description, o.creation_date, p.customer_id, oz.name, p.recipient_id, io.amount_total) sub where 1=1 [template::list::filter_where_clauses -and -name projects] [template::list::page_where_clause -and -name projects -key sub.project_id] [template::list::orderby_clause -name projects -orderby] @@ -142,7 +156,6 @@ pr.title, pr.description, o.creation_date, - sum(ofi.item_units * ofi.price_per_unit * (1-(ofi.rebate/100))) as amount_open, p.customer_id, p.recipient_id, oz.name @@ -152,9 +165,8 @@ pm_projects p, acs_objects o, acs_data_links r, + cr_items oi, iv_offer_items ofi, - acs_objects oo, - cr_items oi, organizations oz where pi.latest_revision = pr.revision_id @@ -165,8 +177,6 @@ and p.status_id = :p_closed_id and p.invoice_p = true and ofi.offer_id = oi.latest_revision - and oo.object_id = oi.item_id - and oo.package_id = :package_id and p.customer_id = oz.organization_id and not exists (select 1 from iv_invoice_items ii, iv_invoices i, cr_items ci Index: openacs-4/packages/invoices/tcl/invoice-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/invoice-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/invoices/tcl/invoice-procs.tcl 24 Aug 2006 09:18:14 -0000 1.26 +++ openacs-4/packages/invoices/tcl/invoice-procs.tcl 19 Oct 2006 17:06:49 -0000 1.27 @@ -348,19 +348,23 @@ set data(am_name) $am_name set data(am_directphoneno) [ad_html_to_text -no_format $account_manager(directphoneno)] set am_directphoneno $data(am_directphoneno) + set data(jobtitle) $account_manager(jobtitle) } else { # Someone else is sending the offer. We need to mark this in the name contact::employee::get -employee_id [lindex $account_manager_ids 0] -array account_manager + contact::employee::get -employee_id $user_id -array user_arr set account_manager_name "$account_manager(first_names) $account_manager(last_name)" set data(am_name) $account_manager_name set data(am_directphoneno) [ad_html_to_text -no_format $account_manager(directphoneno)] set am_directphoneno $data(am_directphoneno) - set am_name "[_ contacts.pp] [contact::name -party_id $user_id]

$account_manager_name" + set am_name "[_ contacts.pp] $user_arr(first_names) $user_arr(last_name)

$account_manager_name" + set data(jobtitle) $user_arr(jobtitle) } } else { set default_orga_id [parameter::get_from_package_key -package_key contacts -parameter DefaultOrganizationID] set am_name "[contact::name -party_id $default_orga_id]" set am_directphoneno [ams::value -object_id [content::item::get_best_revision -item_id $default_orga_id] -attribute_name directphoneno] + set data(jobtitle) [ams::value -object_id [content::item::get_best_revision -item_id $user_id] -attribute_name jobtitle] set data(am_name) "[contact::name -party_id $user_id]" set data(am_directphoneno) [ad_html_to_text -no_format $am_directphoneno] } Index: openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 5 Jun 2006 11:34:17 -0000 1.17 +++ openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 19 Oct 2006 17:06:49 -0000 1.18 @@ -370,18 +370,14 @@ set root_folder_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type content_folder] 0] foreach folder {invoices offers accepted} { - if {[empty_string_p [fs::get_folder -name $folder -parent_id $root_folder_id]]} { + if {[empty_string_p [fs::get_folder -name "${folder}_${root_folder_id}" -parent_id $root_folder_id]]} { set folder_id [fs::new_folder \ -name "${folder}_${root_folder_id}" \ -pretty_name "#invoices.${folder}#" \ -parent_id $root_folder_id \ -no_callback] } } - - foreach package_id [apm_package_id_from_key invoices] { - iv::offer::new_credit -organization_id $organization_id -package_id $package_id - } } } } 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.38 -r1.39 --- openacs-4/packages/invoices/www/invoice-ae.tcl 11 Aug 2006 19:37:52 -0000 1.38 +++ openacs-4/packages/invoices/www/invoice-ae.tcl 19 Oct 2006 17:06:49 -0000 1.39 @@ -483,7 +483,7 @@ set rec_organization_id $organization_id } else { if {[person::person_p -party_id $recipient_id]} { - set rec_organization_id [contact::util::get_employee_organization -employee_id $recipient_id] + set rec_organization_id [lindex [contact::util::get_employee_organization -employee_id $recipient_id] 0] } else { set rec_organization_id $recipient_id } @@ -577,6 +577,10 @@ foreach offer_item_id [array names offer_item_ids] { incr counter array set offer $offers($offer_item_id) + if {![string is double -strict $offer(vat)]} { + set offer(vat) 0 + } + set offer(vat) [expr $vat_percent * $offer(vat) / 100.] set new_item_rev_id [iv::invoice_item::new \ @@ -640,6 +644,9 @@ foreach iv_item_id [array names offer_item_ids] { incr counter array set offer $offers($iv_item_id) + if {![string is double -strict $offer(vat_old)]} { + set offer(vat_old) 0 + } set offer(vat) [expr $vat_percent * $offer(old_vat) / 100.] set new_item_rev_id [iv::invoice_item::edit \ 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.3 -r1.4 --- openacs-4/packages/invoices/www/journal-add.tcl 24 May 2006 09:40:38 -0000 1.3 +++ openacs-4/packages/invoices/www/journal-add.tcl 19 Oct 2006 17:06:49 -0000 1.4 @@ -160,6 +160,7 @@ } else { set tax_account 4690 set tax_type 10 + set final_amount $total_amount } append financial_text "F;0;940;;;$invoice_type;$invoice_date;$invoice_period;$invoice_nr;;$client_id;$tax_account;$tax_type;;$final_amount;$invoice_name;;;$currency;$country_code;$ust_id_nr;;;0;0\n" 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.38 -r1.39 --- openacs-4/packages/invoices/www/offer-ae.tcl 8 Sep 2006 13:37:24 -0000 1.38 +++ openacs-4/packages/invoices/www/offer-ae.tcl 19 Oct 2006 17:06:49 -0000 1.39 @@ -232,7 +232,7 @@ } ad_form -extend -name iv_offer_form -form { - {payment_days:integer,optional {mode display} {label "[_ invoices.iv_offer_payment_days]"} {html {size 5 maxlength 5}} {help_text "[_ invoices.iv_offer_payment_days_help]"}} + {payment_days:integer,optional {label "[_ invoices.iv_offer_payment_days]"} {html {size 5 maxlength 5}} {help_text "[_ invoices.iv_offer_payment_days_help]"}} {show_sum_p:text(select),optional {label "[_ invoices.iv_offer_show_sum_p]"} {options $boolean_options} {help_text "[_ invoices.iv_offer_show_sum_p_help]"}} } @@ -616,18 +616,9 @@ set vat_percent [format "%.1f" $org_data(vat_percent)] } } -edit_request { - #--- added 2006/08/29 by cognovis/nfl - set customer_payment [ams::value -object_id [content::item::get_best_revision -item_id $organization_id] -attribute_name "payment_days"] - #--- db_1row get_data {} - #--- added 2006/08/29 by cognovis/nfl - if {![string eq "" $customer_payment]} { - set payment_days $customer_payment - } - #--- - regsub -all {\[} $comment {\(} comment set title [lang::util::localize $title] set description [lang::util::localize $description] Index: openacs-4/packages/invoices/www/offer-send.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-send.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/invoices/www/offer-send.adp 4 Aug 2006 15:29:44 -0000 1.7 +++ openacs-4/packages/invoices/www/offer-send.adp 19 Oct 2006 17:06:49 -0000 1.8 @@ -2,7 +2,7 @@ @page_title;noquote@ @context;noquote@ -