Index: openacs-4/packages/invoices/invoices.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/invoices.info,v diff -u -r1.10 -r1.11 --- openacs-4/packages/invoices/invoices.info 2 Nov 2005 23:06:09 -0000 1.10 +++ openacs-4/packages/invoices/invoices.info 3 Nov 2005 22:49:12 -0000 1.11 @@ -7,15 +7,15 @@ f t - + Timo Hentschel Invoices package that will collect costs to invoice items in invoices and store data about received payment. - 2005-11-02 + 2005-11-03 Cognovis Collect costs to invoice items and invoices, store payment information. 0 - + 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.12 -r1.13 --- openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 2 Nov 2005 23:06:09 -0000 1.12 +++ openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 3 Nov 2005 22:49:12 -0000 1.13 @@ -1,5 +1,5 @@ - + Accepted on Add offer project @@ -19,6 +19,8 @@ Cancel Cancel and Return Cancelled? + Category + clear Client Account Manager Continue with Offer Acceptance Continue with Delete @@ -28,6 +30,7 @@ Cost number Costs Count + Creation Date Credit awarded by projects Credit Empty project to collect credit from other projects @@ -36,26 +39,32 @@ Currency Currency paid Customer + Date Range: Day Delete Due date Edit Template Number of files + Final Amount Finish date Fixed cost? Accepted Offers Invoices Offers + Group By Invoice Invoice Item Invoice item number + Invoice Item Title Invoice Items Invoice number Invoice reference + Invoice Title Invoices Invoices Invoices Items + Item ID Cost Costs Add Cost @@ -285,6 +294,8 @@ Invoice Reports Last Years Link package instances + Mapped + Month Month New New Clients @@ -293,9 +304,12 @@ Number of units Cost Sheet Offer Item + Offer Item ID Offer item number + Offer Item Title Offer Items Offer number + Offer Title Cost Sheets Cost Sheets Offers Items Index: openacs-4/packages/invoices/lib/invoice-items-list-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-items-list-portlet.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/invoice-items-list-portlet.adp 2 Nov 2005 23:11:04 -0000 1.1 +++ openacs-4/packages/invoices/lib/invoice-items-list-portlet.adp 3 Nov 2005 22:49:12 -0000 1.2 @@ -1,5 +1,5 @@ -#invoices.iv_invoice_2# +@portlet_title;noquote@ @@ -8,6 +8,16 @@ Index: openacs-4/packages/invoices/lib/invoice-items-list-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-items-list-portlet.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/invoice-items-list-portlet.tcl 2 Nov 2005 23:11:04 -0000 1.1 +++ openacs-4/packages/invoices/lib/invoice-items-list-portlet.tcl 3 Nov 2005 22:49:12 -0000 1.2 @@ -1 +1,9 @@ +set required_param_list [list portlet_title] + +foreach required_param $required_param_list { + if {![info exists $required_param]} { + return -code error "$required_param is a required parameter." + } +} + set portlet_layout [parameter::get -parameter "DefaultPortletLayout"] \ No newline at end of file Index: openacs-4/packages/invoices/lib/invoice-items-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-items-list.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/invoice-items-list.adp 2 Nov 2005 23:11:04 -0000 1.1 +++ openacs-4/packages/invoices/lib/invoice-items-list.adp 3 Nov 2005 22:49:12 -0000 1.2 @@ -1 +1,32 @@ - + +
+ + + + + + +
+
+ + + + + +
+ #invoices.Date_Range# + + + + +   +
+ [ yyyy-mm-dd ] +
+
+
+ +
+ + + Index: openacs-4/packages/invoices/lib/invoice-items-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-items-list.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/invoice-items-list.tcl 2 Nov 2005 23:11:04 -0000 1.1 +++ openacs-4/packages/invoices/lib/invoice-items-list.tcl 3 Nov 2005 22:49:12 -0000 1.2 @@ -1,70 +1,211 @@ +set optional_param_list [list elements category_filter_clause] +set optional_unset_list [list iv_items_orderby category_id \ + customer_id filter_package_id date_range \ + project_status_id groupby] + +foreach optional_unset $optional_unset_list { + if {[info exists $optional_unset]} { + if {[empty_string_p [set $optional_unset]]} { + unset $optional_unset + } + } +} + +foreach optional_param $optional_param_list { + if {![info exists $optional_param]} { + set $optional_param {} + } +} + +if { [exists_and_not_null date_range] } { + catch { set date_range [lc_time_fmt $date_range %y-%m-%d] } errMsg +} + +if {![info exist filters_p] } { + set filters_p 1 +} + if {![info exists format]} { set format "normal" } -if {![info exists orderby]} { - set orderby "" -} + if {![info exists page_size]} { set page_size "25" } -if {![info exists package_id]} { - set package_id [ad_conn package_id] +if {![info exists invoice_package_id]} { + set invoice_package_id [ad_conn package_id] } if {![info exists base_url]} { - set base_url [apm_package_url_from_id $package_id] + set base_url [apm_package_url_from_id $invoice_package_id] } -foreach optional_param {organization_id elements} { - if {![info exists $optional_param]} { - set $optional_param {} +if { ![exists_and_not_null return_url] } { + set return_url [ad_return_url] +} + +if { [exists_and_not_null category_id] } { + set category_filter_clause "and com.category_id = $category_id" +} + +set categories_p 0 + +# Elements to construnct row_lists +if { [exists_and_not_null elements] } { + set row_list [list] + foreach element $elements { + if { ![string equal $element "categories"] } { + lappend row_list $element + lappend row_list [list] + } else { + set categories_p 1 + } } +} else { + set row_list [list item_title {} final_amount {} invoice_title {} \ + rebate {} item_id {} invoice_item_id {} creation_date {}] } -set user_id [ad_conn user_id] +# Create the elements for the list template +set elements [list] -set dotlrn_club_id [lindex [application_data_link::get_linked \ - -from_object_id $organization_id \ - -to_object_type "dotlrn_club"] 0] +# We are going to create the elements for each mapped categories +if { $categories_p } { + set categories [db_list_of_lists get_categories { }] + + set mapped_objects [list] + set multirow_extend [list] + + foreach category $categories { + set cat_name [lindex $category 0] + set cat_id [lindex $category 1] + + lappend multirow_extend category_$cat_id + if { [exists_and_not_null category_id] } { + set label "$cat_name" + append label "  ([_ invoices.clear])" + } else { + set label "$cat_name" + } + lappend elements category_$cat_id [list label $label] + lappend row_list category_$cat_id + lappend row_list [list] + } +} -set pm_base_url [apm_package_url_from_id [dotlrn_community::get_package_id_from_package_key \ - -package_key "project-manager" \ - -community_id $dotlrn_club_id]] +lappend elements item_title [list label "[_ invoices.Invoice_Item_title]"] \ + final_amount [list label "[_ invoices.Final_Amount]"] \ + invoice_title [list label "[_ invoices.Invoice_Title]" \ + display_template { + @iv_items.invoice_title@ + } ] \ + rebate [list label "[_ invoices.Rebate]" \ + display_template { + @iv_items.rebate@ % + } + ] \ + item_id [list label "[_ invoices.Item_Id]"] \ + iv_item_id [list label "[_ invoices.Invoice_Item_Id]"] \ + creation_date [list label "[_ invoices.Creation_Date]"] \ + month [list label ""] -set row_list [list] -foreach element $elements { - lappend row_list [list $element {}] + +set filters [list category_id { } \ + filter_package_id { + where_clause { ii.object_package_id = :filter_package_id } + } \ + customer_id { + where_clause { iv.organization_id = :customer_id} + } \ + date_range { + where_clause { to_char(ii.creation_date,'yy-mm-dd') > :date_range } + }] + +if { [apm_package_installed_p "project-manager"] } { + lappend filters project_status_id { + label "Project Status Id:" + values { [pm::status::project_status_select] } + } } +set project_status_p 0 +if { [exists_and_not_null project_status_id] } { + set project_status_p 1 +} + + +set groupby_values { + { "#invoices.Customer#" { { groupby organization_id } { orderby organization_id,desc } } } + { "#invoices.Category#" { { groupby category_id } { orderby category_id,desc } } } + { "#invoices.Month#" { { groupby month } { orderby time_stamp,desc } } } +} + + template::list::create \ - -name invoice_items \ + -name iv_items \ + -key iv_item_id \ -no_data "[_ invoices.None]" \ + -has_checkboxes \ -selected_format $format \ - -elements { } \ - -actions { } \ - -bulk_actions { } \ - -orderby { } \ - -orderby_name orderby \ + -elements $elements \ + -orderby_name iv_items_orderby \ + -orderby { + item_title { + label { [_ invoices.Invoice_Item_title] } + orderby_desc { lower(ii.title) desc } + orderby_asc { lower(ii.title) asc } + } + invoice_title { + label "[_ invoices.Invoice_Title]" + orderby_desc { lower(iv.title) desc } + orderby_asc { lower(iv.title) asc } + } + } \ -html {width 100%} \ -page_size $page_size \ -page_flush_p 0 \ - -page_query_name "invoice_items_paginated" \ - -filters { } \ + -page_query_name "iv_items_paginated" \ + -pass_properties return_url \ + -groupby { + label "[_ invoices.Group_by]:" + type multivar + values $groupby_values + } \ + -filters $filters \ -formats { normal { label "[_ invoices.Table]" layout table row $row_list } - csv { - label "[_ invoices.CSV]" - output csv - page_size 0 - row $row_list - } } -db_multirow -extend { } invoice_items invoice_items { } { +# Elements to extend the multirow +lappend multirow_extend final_amount +db_multirow -extend $multirow_extend iv_items iv_items { } { + set final_amount [expr [expr $price_per_unit * $item_units] - [expr $rebate * $price_per_unit * $item_units]] + if { $categories_p && [exists_and_not_null category_id]} { + set category_$category_id "[_ invoices.Mapped]" + } + set project_item_id [lindex [application_data_link::get_linked -from_object_id $item_id -to_object_type content_item] 0] + if { $project_status_p } { + if { [exists_and_not_null project_item_id] } { + switch $project_status_id { + "1" { + if { ![pm::project::open_p -project_item_id $project_item_id] } { + continue + } + } + "2" { + if { [pm::project::open_p -project_item_id $project_item_id] } { + continue + } + } + } + } else { + continue + } + } } Index: openacs-4/packages/invoices/lib/invoice-items-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-items-list.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/lib/invoice-items-list.xql 2 Nov 2005 23:11:04 -0000 1.1 +++ openacs-4/packages/invoices/lib/invoice-items-list.xql 3 Nov 2005 22:49:12 -0000 1.2 @@ -1,25 +1,67 @@ - + select - + ii.iv_item_id, + ii.title as item_title, + iv.title as invoice_title, + ii.price_per_unit, + ii.rebate, + ii.item_units, + com.category_id, + iv.organization_id, + to_char(ii.creation_date,'yy-mm-dd') as creation_date, + to_char(ii.creation_date,'mm') as month, + ii.offer_item_id, + i.item_id from - + iv_invoice_itemsx ii, + iv_invoicesx iv, + category_object_map com, + cr_items i where - + iv.item_id = i.item_id + and ii.invoice_id = i.latest_revision + and iv.invoice_id = ii.invoice_id + and com.object_id = ii.offer_item_id + $category_filter_clause + and [template::list::page_where_clause -name "iv_items"] + [template::list::filter_where_clauses -and -name "iv_items"] + [template::list::orderby_clause -orderby -name "iv_items"] - + select - + iv_item_id, + title as item_title, + price_per_unit, + rebate, + item_units from + iv_invoice_itemsx + + - where - + + + select + distinct + o.title, + com.category_id + from + category_object_map com, + iv_invoice_items ii, + acs_objects o + where + com.object_id = ii.offer_item_id + and com.category_id = o.object_id + $category_filter_clause + order by + o.title asc Index: openacs-4/packages/invoices/lib/offer-items-list.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/offer-items-list.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/invoices/lib/offer-items-list.adp 3 Nov 2005 21:09:24 -0000 1.2 +++ openacs-4/packages/invoices/lib/offer-items-list.adp 3 Nov 2005 22:49:12 -0000 1.3 @@ -6,7 +6,7 @@
- Date Range: + #invoices.Date_Range# Index: openacs-4/packages/invoices/lib/offer-items-list.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/offer-items-list.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/invoices/lib/offer-items-list.tcl 3 Nov 2005 21:09:24 -0000 1.2 +++ openacs-4/packages/invoices/lib/offer-items-list.tcl 3 Nov 2005 22:49:12 -0000 1.3 @@ -18,7 +18,7 @@ } if { [exists_and_not_null date_range] } { - set date_range [lc_time_fmt $date_range %y-%m-%d] + catch { set date_range [lc_time_fmt $date_range %y-%m-%d] } errMsg } if {![info exist filters_p] } { @@ -83,7 +83,7 @@ lappend multirow_extend category_$cat_id if { [exists_and_not_null category_id] } { set label "$cat_name" - append label "  (clear)" + append label "  ([_ invoices.clear])" } else { set label "$cat_name" } @@ -93,20 +93,20 @@ } } -lappend elements item_title [list label "Offer Item Title"] \ - final_amount [list label "Final Ammount"] \ - offer_title [list label "Offer Title" \ +lappend elements item_title [list label "[_ invoices.Offer_Item_Title]"] \ + final_amount [list label "[_ invoices.Final_Amount]"] \ + offer_title [list label "[_ invoices.Offer_Title]" \ display_template { @offer_items.offer_title@ } ] \ - rebate [list label "Rebate" \ + rebate [list label "[_ invoices.Rebate]" \ display_template { @offer_items.rebate@ % } ] \ - item_id [list label "Item Id"] \ - offer_item_id [list label "Offer Item Id"] \ - creation_date [list label "Creation Date"] \ + item_id [list label "[_ invoices.Item_Id]"] \ + offer_item_id [list label "[_ invoices.Offer_Item_Id]"] \ + creation_date [list label "[_ invoices.Creation_Date]"] \ month [list label ""] @@ -135,9 +135,9 @@ set groupby_values { - { "Customer" { { groupby organization_id } { orderby organization_id,desc } } } - { "Category" { { groupby category_id } { orderby cateogory_id,desc } } } - { "Month" { { groupby month } { orderby time_stamp,desc } } } + { "#invoices.Customer#" { { groupby organization_id } { orderby organization_id,desc } } } + { "#invoices.Category#" { { groupby category_id } { orderby cateogory_id,desc } } } + { "#invoices.Month#" { { groupby month } { orderby time_stamp,desc } } } } @@ -151,12 +151,12 @@ -orderby_name offer_items_orderby \ -orderby { item_title { - label {Offer Item Title} + label { [_ invoices.Offer_Item_Title] } orderby_desc { lower(oi.title) desc } orderby_asc { lower(oi.title) asc } } offer_title { - label "Offer Title" + label "[_ invoices.Offer_Title]" orderby_desc { lower(o.title) desc } orderby_asc { lower(o.title) asc } } @@ -167,7 +167,7 @@ -page_query_name "offer_items_paginated" \ -pass_properties return_url \ -groupby { - label "Group By" + label "[_ invoices.Group_by]:" type multivar values $groupby_values } \ @@ -186,7 +186,7 @@ db_multirow -extend $multirow_extend offer_items offer_items { } { set final_amount [expr [expr $price_per_unit * $item_units] - [expr $rebate * $price_per_unit * $item_units]] if { $categories_p } { - set category_$category_id "Mapped" + set category_$category_id "[_ invoices.Mapped]" } set project_item_id [lindex [application_data_link::get_linked -from_object_id $item_id -to_object_type content_item] 0] if { $project_status_p } { 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.7 -r1.8 --- openacs-4/packages/invoices/lib/offer-list.tcl 21 Oct 2005 16:13:29 -0000 1.7 +++ openacs-4/packages/invoices/lib/offer-list.tcl 3 Nov 2005 22:49:12 -0000 1.8 @@ -21,7 +21,8 @@ } } } -# set status_id 2 + +#set status_id 2 # db_1row get_offer_status_id {} if {![info exists status_id]} { db_1row get_offer_status_id {} Index: openacs-4/packages/invoices/lib/offer-list.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/offer-list.xql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/invoices/lib/offer-list.xql 14 Oct 2005 06:25:03 -0000 1.6 +++ openacs-4/packages/invoices/lib/offer-list.xql 3 Nov 2005 22:49:12 -0000 1.7 @@ -21,7 +21,8 @@ to_char(t.accepted_date, :timestamp_format) as accepted_date, to_char(t.finish_date, :timestamp_format) as finish_date, pi.item_id as project_id, pr.title as project_title, t.status, - pp.contact_id, p2.first_names as contact_first_names, + pp.contact_id, + p2.first_names as contact_first_names, p2.last_name as contact_last_name from cr_folders cf, cr_revisions cr, iv_offers t, acs_objects o, persons p, cr_items ci, acs_rels r, 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.11 -r1.12 --- openacs-4/packages/invoices/www/invoice-ae.tcl 27 Oct 2005 18:11:24 -0000 1.11 +++ openacs-4/packages/invoices/www/invoice-ae.tcl 3 Nov 2005 22:49:12 -0000 1.12 @@ -87,8 +87,8 @@ set recipient_options [db_list_of_lists credit_recipients {}] } else { # normal invoice: get recipients from projects - # set recipient_options [db_list_of_lists recipients {}] - set recipient_options [wieners::get_recipients -customer_id $organization_id] + set recipient_options [db_list_of_lists recipients {}] + #set recipient_options [wieners::get_recipients -customer_id $organization_id] } Index: openacs-4/packages/invoices/www/invoice-items.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-items.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/www/invoice-items.adp 2 Nov 2005 23:11:05 -0000 1.1 +++ openacs-4/packages/invoices/www/invoice-items.adp 3 Nov 2005 22:49:12 -0000 1.2 @@ -3,4 +3,15 @@ @context;noquote@ Index: openacs-4/packages/invoices/www/invoice-items.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-items.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/invoices/www/invoice-items.tcl 2 Nov 2005 23:11:05 -0000 1.1 +++ openacs-4/packages/invoices/www/invoice-items.tcl 3 Nov 2005 22:49:12 -0000 1.2 @@ -1,2 +1,23 @@ -set page_title "" -set context [list $page_title] \ No newline at end of file +# /packages/invoices/www/invoice-items.tcl + +ad_page_contract { + Show all invoices items + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net +} { + {page "1"} + {iv_items_orderby ""} + {category_id ""} + {filter_package_id ""} + {customer_id ""} + {date_range ""} + {project_status_id ""} + {groupby ""} +} + +set page_title "[_ invoices.Invoices_items]" +set context [list $page_title] + +set elements [list item_title final_amount invoice_title rebate categories] +set filters_p 1 \ No newline at end of file