Index: openacs-4/packages/invoices/invoices.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/invoices.info,v
diff -u -r1.19 -r1.20
--- openacs-4/packages/invoices/invoices.info 31 Dec 2005 07:36:23 -0000 1.19
+++ openacs-4/packages/invoices/invoices.info 15 Mar 2006 17:05:05 -0000 1.20
@@ -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-15
Cognovis
Collect costs to invoice items and invoices, store payment information.
0
-
+
@@ -36,6 +36,7 @@
+
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.27 -r1.28
--- openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 29 Jan 2006 14:21:57 -0000 1.27
+++ openacs-4/packages/invoices/catalog/invoices.en_US.ISO-8859-1.xml 15 Mar 2006 17:05:05 -0000 1.28
@@ -29,6 +29,7 @@
Contact
Continue with Offer Acceptance
Continue with Delete
+ Continue with Export
Cost
Cost cause
Cost item
@@ -199,6 +200,7 @@
View Invoices
<html><body><h3>Invoices</h3>%contact.salutation%,<p>see attached invoices %invoice_nrs%.<p>Best wishes,<br>WIENERS + WIENERS GmbH<br></html></body>
Invoices # %invoice_nrs%
+ Export Journal
Invoices of %long_month% %year%:
Invoices of year %year%:
Cost Sheet
@@ -393,6 +395,7 @@
Invoice
Invoice cancellation
Credit
+ Invoice-Nr.
Offer
Order confirmation
Total
Index: openacs-4/packages/invoices/lib/invoice-list-portlet.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-list-portlet.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/invoices/lib/invoice-list-portlet.adp 13 Oct 2005 17:13:34 -0000 1.1
+++ openacs-4/packages/invoices/lib/invoice-list-portlet.adp 15 Mar 2006 17:05:05 -0000 1.2
@@ -11,6 +11,7 @@
organization_id="@organization_id@"
row_list="@row_list@"
orderby="@orderby@"
+ page="@page@"
format="@format@"
page_size="@page_size@" />
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.11 -r1.12
--- openacs-4/packages/invoices/lib/invoice-list.tcl 27 Jan 2006 16:22:47 -0000 1.11
+++ openacs-4/packages/invoices/lib/invoice-list.tcl 15 Mar 2006 17:05:05 -0000 1.12
@@ -14,6 +14,8 @@
if {![info exists base_url]} {
set base_url [apm_package_url_from_id $package_id]
+} else {
+ set package_id [site_node::get_object_id -node_id [site_node::get_node_id -url $base_url]]
}
@@ -32,8 +34,7 @@
}
set user_id [ad_conn user_id]
-set date_format [lc_get formbuilder_date_format]
-set timestamp_format "$date_format [lc_get formbuilder_time_format]"
+set timestamp_format "YYYY-MM-DD HH24:MI:SS"
set bulk_actions [list "[_ invoices.iv_invoice_send]" "${base_url}invoices-view" "[_ invoices.iv_invoice_send]" "[_ invoices.iv_invoice_pay]" "${base_url}invoice-pay" "[_ invoices.iv_invoice_pay]"]
set invoice_cancel_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege invoice_cancel]
set return_url [ad_return_url]
@@ -43,12 +44,16 @@
set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0]
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]]
if {$invoice_cancel_p} {
- set actions [list "[_ invoices.iv_invoice_New]" [export_vars -base invoice-add {organization_id}] "[_ invoices.iv_invoice_New2]" "[_ invoices.iv_invoice_credit_New]" [export_vars -base invoice-credit {organization_id}] "[_ invoices.iv_invoice_credit_New2]" "[_ invoices.iv_offer_2]" [export_vars -base offer-list {organization_id}] "[_ invoices.iv_offer_2]" "[_ invoices.projects]" $pm_base_url "[_ invoices.projects]" "[_ invoices.iv_reports]" [export_vars -base invoice-reports {organization_id}]]
+ set actions [list "[_ invoices.iv_invoice_New]" [export_vars -base invoice-add {organization_id}] "[_ invoices.iv_invoice_New2]" "[_ invoices.iv_invoice_credit_New]" [export_vars -base invoice-credit {organization_id}] "[_ invoices.iv_invoice_credit_New2]" "[_ invoices.iv_offer_2]" [export_vars -base offer-list {organization_id}] "[_ invoices.iv_offer_2]" "[_ invoices.projects]" $pm_base_url "[_ invoices.projects]" "[_ invoices.iv_reports]" [export_vars -base invoice-reports {organization_id}] "[_ invoices.iv_reports]"]
} else {
set actions [list "[_ invoices.iv_invoice_New]" [export_vars -base invoice-add {organization_id}] "[_ invoices.iv_invoice_New2]" "[_ invoices.iv_offer_2]" [export_vars -base offer-list {organization_id}] "[_ invoices.iv_offer_2]" "[_ invoices.projects]" $pm_base_url "[_ invoices.projects]" "[_ invoices.iv_reports]" [export_vars -base invoice-reports {organization_id}]]
}
}
+if {$invoice_cancel_p} {
+ lappend actions "[_ invoices.iv_journal_check]" "${base_url}journal-check" "[_ invoices.iv_journal_check]"
+}
+
# If the sum was paid, the total_amount should appear green.
# If it was billed, yet not paid, the total amount is red. Otherwise don't bother
@@ -63,7 +68,7 @@
}
title {
label {[_ invoices.iv_invoice_1]}
- link_url_eval {[export_vars -base "invoice-ae" {invoice_id {mode display}}]}
+ display_template {@iv_invoice.title@}
}
description {
label {[_ invoices.iv_invoice_Description]}
@@ -157,6 +162,7 @@
organization_id {
where_clause {t.organization_id = :organization_id}
}
+ page_num {}
} \
-formats {
normal {
@@ -172,13 +178,19 @@
}
}
+set time_format "[lc_get d_fmt] %X"
+set date_format [lc_get d_fmt]
set contacts_p [apm_package_installed_p contacts]
-db_multirow -extend {creator_link edit_link cancel_link delete_link preview_link recipient} iv_invoice iv_invoice {} {
+db_multirow -extend {creator_link edit_link display_link cancel_link delete_link preview_link recipient} iv_invoice iv_invoice {} {
# Ugly hack. We should find out which contact package is linked
+ 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}]
- set cancel_link [export_vars -base "${base_url}invoice-cancellation" {organization_id {parent_id $invoice_rev_id}}]
+ set cancel_link [export_vars -base "${base_url}invoice-cancellation" {{organization_id $orga_id} {parent_id $invoice_rev_id}}]
set delete_link [export_vars -base "${base_url}invoice-delete" {invoice_id}]
set preview_link [export_vars -base "${base_url}invoice-preview" {invoice_id}]
if {[empty_string_p $total_amount]} {
Index: openacs-4/packages/invoices/lib/invoice-list.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/invoice-list.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/invoices/lib/invoice-list.xql 9 Dec 2005 18:26:33 -0000 1.5
+++ openacs-4/packages/invoices/lib/invoice-list.xql 15 Mar 2006 17:05:05 -0000 1.6
@@ -8,8 +8,9 @@
t.invoice_nr, t.total_amount, t.currency, t.paid_amount,
t.paid_currency, p.first_names, p.last_name, o.creation_user,
to_char(o.creation_date, :timestamp_format) as creation_date,
- to_char(t.due_date, :date_format) as due_date, t.parent_invoice_id,
- t.invoice_id as invoice_rev_id, t.cancelled_p, t.status, t.recipient_id, t.organization_id
+ to_char(t.due_date, :timestamp_format) as due_date, t.parent_invoice_id,
+ t.invoice_id as invoice_rev_id, t.cancelled_p, t.status, t.recipient_id,
+ t.organization_id as orga_id
from cr_folders cf, cr_items ci, cr_revisions cr, iv_invoices t,
acs_objects o, persons p
where cr.revision_id = ci.latest_revision
@@ -28,7 +29,7 @@
- select cr.item_id as invoice_id
+ select cr.item_id
from cr_folders cf, cr_items ci, cr_revisions cr, iv_invoices t,
acs_objects o, persons p
where cr.revision_id = ci.latest_revision
Index: openacs-4/packages/invoices/lib/offer-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/lib/offer-list.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/invoices/lib/offer-list.adp 16 Aug 2005 20:04:31 -0000 1.1
+++ openacs-4/packages/invoices/lib/offer-list.adp 15 Mar 2006 17:05:05 -0000 1.2
@@ -1 +1,4 @@
+
+
+
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.11 -r1.12
--- openacs-4/packages/invoices/lib/offer-list.tcl 29 Jan 2006 17:35:47 -0000 1.11
+++ openacs-4/packages/invoices/lib/offer-list.tcl 15 Mar 2006 17:05:05 -0000 1.12
@@ -1,5 +1,5 @@
set required_param_list [list]
-set optional_param_list [list orderby elements base_url package_id]
+set optional_param_list [list orderby elements base_url package_id page_num party_id]
set optional_unset_list [list organization_id]
foreach required_param $required_param_list {
@@ -34,6 +34,9 @@
if {![info exists page_size]} {
set page_size "25"
}
+if {![info exists show_filter_p]} {
+ set show_filter_p 0
+}
if {[empty_string_p $package_id]} {
set package_id [apm_package_id_from_key "invoices"]
@@ -43,27 +46,44 @@
set base_url [apm_package_url_from_id $package_id]
}
+set project_where_clause "1 = 1"
+if {[exists_and_not_null project_id]} {
+ set project_ids $project_id
+}
+if {[exists_and_not_null project_ids]} {
+ set project_where_clause "pi.item_id in ([join $project_ids ,])"
+}
+
+if {[exists_and_not_null party_id]} {
+ set party_where_clause "o.creation_user = :party_id"
+} else {
+ set party_where_clause ""
+}
+
foreach element $elements {
append row_list "$element {}\n"
}
+set user_id [ad_conn user_id]
set pm_base_url ""
if {[exists_and_not_null organization_id]} {
- set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0]
-
- if {$dotlrn_club_id > 0} {
- 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]]
- }
}
#set package_id [ad_conn package_id]
-set date_format [lc_get formbuilder_date_format]
-set timestamp_format "$date_format [lc_get formbuilder_time_format]"
+set timestamp_format "YYYY-MM-DD HH24:MI:SS"
if {[exists_and_not_null organization_id]} {
set price_list_id [iv::price_list::get_list_id -organization_id $organization_id]
if {![info exists actions]} {
set actions [list "[_ invoices.iv_invoice_2]" [export_vars -base "${base_url}invoice-list" {organization_id}] "[_ invoices.iv_invoice_2]" "[_ invoices.iv_price_list]" [export_vars -base "${base_url}price-list" {{list_id $price_list_id} organization_id}] "[_ invoices.iv_display_price_list]"]
+
+ # We are looking at an organization, try to get the base_url for the Project manager
+ set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $organization_id -to_object_type "dotlrn_club"] 0]
+
+ if {$dotlrn_club_id > 0} {
+ 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]]
+ }
+
if {[exists_and_not_null pm_base_url]} {
lappend actions "[_ project-manager.Projects]" $pm_base_url "[_ project-manager.Projects]"
lappend actions "[_ invoices.Add_offer_project]" "[export_vars -base "${pm_base_url}/add-edit" -url {{customer_id $organization_id} status_id}]" "[_ invoices.Add_offer_project]"
@@ -96,6 +116,10 @@
label {[_ invoices.iv_offer_project]}
display_template {@iv_offer.project_title@}
}
+ project_customer {
+ label {[_ invoices.iv_offer_project_customer]}
+ display_template {@iv_offer.customer_name@}
+ }
project_contact {
label {[_ invoices.iv_offer_project_contact]}
display_template {@iv_offer.contact_first_names@ @iv_offer.contact_last_name@}
@@ -122,7 +146,7 @@
}
} -actions $actions -sub_class narrow \
-orderby {
- default_value offer_nr
+ default_value project_id
offer_nr {
label {[_ invoices.iv_offer_offer_nr]}
orderby {t.offer_nr}
@@ -146,7 +170,7 @@
project_id {
label {[_ invoices.iv_offer_project]}
orderby {lower(pr.title)}
- default_direction asc
+ default_direction desc
}
project_contact {
label {[_ invoices.iv_offer_project_contact]}
@@ -175,7 +199,7 @@
orderby {t.finish_date}
default_direction desc
}
- finish_date {
+ accepted_date {
label {[_ invoices.iv_offer_accepted_date]}
orderby {t.accepted_date}
default_direction desc
@@ -189,12 +213,16 @@
organization_id {
where_clause {t.organization_id = :organization_id}
}
- project_id {
- where_clause {pi.item_id = :project_id}
+ project_ids {
+ where_clause {$project_where_clause}
}
status_id {
where_clause {pp.status_id = :status_id}
}
+ party_id {
+ where_clause {$party_where_clause}
+ }
+ page_num {}
} \
-formats {
normal {
@@ -210,15 +238,30 @@
}
}
+set time_format "[lc_get d_fmt] %X"
-db_multirow -extend {creator_link contact_link edit_link delete_link title_link project_link} iv_offer iv_offer {} {
+db_multirow -extend {creator_link contact_link edit_link delete_link title_link project_link customer_name customer_link} iv_offer iv_offer {} {
# Ugly hack. We should find out which contact package is linked
# aso. asf.
set creator_link "/contacts/$creation_user"
set contact_link "/contacts/$contact_id"
+ set customer_link "/contacts/$customer_id"
+ set customer_name [contact::name -party_id $customer_id]
set edit_link [export_vars -base "${base_url}offer-ae" {offer_id}]
set title_link [export_vars -base "${base_url}offer-ae" {offer_id {mode display}}]
set delete_link [export_vars -base "${base_url}offer-delete" {offer_id}]
+
+ # Get the base url for the customer
+ set dotlrn_club_id [lindex [application_data_link::get_linked -from_object_id $customer_id -to_object_type "dotlrn_club"] 0]
+
+ if {$dotlrn_club_id > 0} {
+ 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]]
+ }
+
set project_link [export_vars -base "${pm_base_url}one" {{project_item_id $project_id}}]
+
+ set creation_date [lc_time_fmt $creation_date $time_format]
+ set accepted_date [lc_time_fmt $accepted_date $time_format]
+ set finish_date [lc_time_fmt $finish_date $time_format]
}
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.10 -r1.11
--- openacs-4/packages/invoices/lib/offer-list.xql 16 Dec 2005 09:25:21 -0000 1.10
+++ openacs-4/packages/invoices/lib/offer-list.xql 15 Mar 2006 17:05:05 -0000 1.11
@@ -21,16 +21,17 @@
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,
- p2.first_names as contact_first_names,
- p2.last_name as contact_last_name
+ p2.first_names as contact_first_names, p2.last_name as contact_last_name,
+ case when pp.subproject_p = true then 'f' else 'f' end as subproject_p,
+ pp.customer_id
from cr_folders cf, cr_revisions cr, iv_offers t,
acs_objects o, persons p, cr_items ci, acs_data_links r,
cr_items pi, cr_revisions pr, pm_projects pp, persons p2
where cr.revision_id = ci.latest_revision
and t.offer_id = cr.revision_id
and ci.parent_id = cf.folder_id
and cf.package_id = :package_id
- and o.object_id = t.offer_id
+ and o.object_id = cr.item_id
and p.person_id = o.creation_user
and r.object_id_one = ci.item_id
and r.object_id_two = pi.item_id
@@ -47,15 +48,15 @@
- select cr.item_id as offer_id
+ select cr.item_id
from cr_folders cf, cr_revisions cr, iv_offers t,
acs_objects o, persons p, cr_items ci, acs_data_links r,
cr_items pi, cr_revisions pr, pm_projects pp, persons p2
where cr.revision_id = ci.latest_revision
and t.offer_id = cr.revision_id
and ci.parent_id = cf.folder_id
and cf.package_id = :package_id
- and o.object_id = t.offer_id
+ and o.object_id = cr.item_id
and p.person_id = o.creation_user
and r.object_id_one = ci.item_id
and r.object_id_two = pi.item_id
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.11 -r1.12
--- openacs-4/packages/invoices/lib/projects-billable.tcl 29 Jan 2006 14:21:57 -0000 1.11
+++ openacs-4/packages/invoices/lib/projects-billable.tcl 15 Mar 2006 17:05:05 -0000 1.12
@@ -1,6 +1,6 @@
set required_param_list [list]
-set optional_param_list [list elements base_url package_id no_actions_p]
-set optional_unset_list [list organization_id orderby]
+set optional_param_list [list elements base_url package_id no_actions_p page_num orderby format groupby]
+set optional_unset_list [list organization_id orderby page_num format groupby]
foreach required_param $required_param_list {
if {![info exists $required_param]} {
@@ -53,6 +53,7 @@
}
+set return_url "[ad_conn url]?[ad_conn query]"
set p_closed_id [pm::project::default_status_closed]
set t_closed_id [pm::task::default_status_closed]
set contacts_p [apm_package_installed_p contacts]
@@ -69,7 +70,7 @@
set bulk_id_list ""
} else {
set actions [list "[_ invoices.iv_invoice_New]" "${base_url}invoice-ae" "[_ invoices.iv_invoice_New2]" ]
- set bulk_id_list [list organization_id]
+ set bulk_id_list [list organization_id return_url]
set row_list "checkbox {}\n $row_list"
}
@@ -135,6 +136,12 @@
orderby_asc {lower(r.title) asc, r.item_id}
default_direction asc
}
+ recipient {
+ label {[_ invoices.iv_invoice_recipient]}
+ orderby_desc {sub.recipient_id desc, r.item_id}
+ orderby_asc {sub.recipient_id, r.item_id}
+ default_direction asc
+ }
description {
label {[_ invoices.iv_invoice_project_descr]}
orderby_desc {lower(r.description) desc, r.item_id}
@@ -166,6 +173,7 @@
}
} -orderby_name orderby -html {width 100%} \
-filters {
+ page_num {}
organization_id {
where_clause {sub.customer_id = :organization_id}
}
@@ -185,20 +193,21 @@
}
+set time_format "[lc_get d_fmt] %X"
set tot_amount_open 0
db_multirow -extend {project_link recipient currency} projects projects_to_bill {} {
set amount_open [format "%.2f" $amount_open]
set tot_amount_open [expr $tot_amount_open + $amount_open]
set currency [iv::price_list::get_currency -organization_id $org_id]
- set creation_date [lc_time_fmt $creation_date "%q %X"]
+ set creation_date [lc_time_fmt $creation_date $time_format]
if { $contacts_p } {
set recipient "[contact::name -party_id $recipient_id]"
set name "[contact::name -party_id $org_id]"
} else {
set recipient [person::name -person_id $recipient_id]
- set name $name
+ set name $recipient
}
set dotlrn_club_id [lindex \
[application_data_link::get_linked \
Index: openacs-4/packages/invoices/sql/postgresql/invoices-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/sql/postgresql/invoices-create.sql,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/invoices/sql/postgresql/invoices-create.sql 4 Jan 2006 08:06:45 -0000 1.9
+++ openacs-4/packages/invoices/sql/postgresql/invoices-create.sql 15 Mar 2006 17:05:06 -0000 1.10
@@ -317,7 +317,27 @@
references acs_objects
);
+create table iv_journals (
+ file_id integer
+ constraint iv_journals_pk
+ primary key,
+ creation_date timestamptz
+ constraint iv_journals_date_nn
+ not null
+);
+create table iv_journal_country_codes (
+ iso_code char(2)
+ constraint iv_journal_country_codes_pk
+ primary key
+ constraint iv_journal_country_codes_iso_code_fk
+ references countries,
+ journal_code varchar(4)
+ constraint iv_journal_country_codes_journal_code_nn
+ not null
+);
+
+
begin;
select acs_privilege__create_privilege('invoice_cancel',null,null);
select acs_privilege__create_privilege('invoice_export',null,null);
Index: openacs-4/packages/invoices/sql/postgresql/invoices-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/sql/postgresql/invoices-drop.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/invoices/sql/postgresql/invoices-drop.sql 16 Aug 2005 20:04:31 -0000 1.1
+++ openacs-4/packages/invoices/sql/postgresql/invoices-drop.sql 15 Mar 2006 17:05:06 -0000 1.2
@@ -6,10 +6,14 @@
--
+drop table iv_journal_country_codes;
+drop table iv_journals;
drop table iv_default_objects;
drop table iv_payments cascade;
drop table iv_invoice_items cascade;
drop table iv_invoices cascade;
+drop table iv_offer_items cascade;
+drop table iv_offers cascade;
drop table iv_costs cascade;
drop table iv_prices cascade;
drop table iv_price_lists cascade;
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.19 -r1.20
--- openacs-4/packages/invoices/tcl/invoice-procs.tcl 31 Jan 2006 11:35:21 -0000 1.19
+++ openacs-4/packages/invoices/tcl/invoice-procs.tcl 15 Mar 2006 17:05:06 -0000 1.20
@@ -191,12 +191,13 @@
# Get the invoice data
db_1row get_data {} -column_array data
+
set locale [lang::user::site_wide_locale -user_id $data(recipient_id)]
set contact_locale [lang::user::site_wide_locale -user_id $data(contact_id)]
set rec_locale $locale
set data(creator_name) "$data(first_names) $data(last_name)"
set data(amount_diff) [format "%.2f" [expr abs($data(total_amount) - $data(amount_sum))]]
- set amount_diff $data(amount_diff)
+ set total_amount_diff $data(amount_diff)
set data(amount_diff) [lc_numeric $data(amount_diff) "" $locale]
set data(final_amount) [lc_numeric [format "%.2f" [expr $data(total_amount)+$data(vat)]] "" $locale]
set data(vat) [lc_numeric [format "%.2f" $data(vat)] "" $locale]
@@ -251,17 +252,27 @@
# get the invoice item data
set sum 0.
- db_multirow -local -extend {amount_sum amount_total amount_diff contact_name category} items invoice_items {} {
+ set project_sum 0.
+ set project_count 0
+ set prev_project_id 0
+ db_multirow -local -extend {amount_sum amount_total amount_diff contact_name category amount_sum_project} items invoice_items {} {
if {[empty_string_p $credit_percent]} {
set credit_percent 0
}
+ if {$prev_project_id != $project_id} {
+ set prev_project_id $project_id
+ incr project_count
+ set project_sum 0.
+ }
set item_units [format "%.2f" [expr $item_units * (1. + ($credit_percent / 100.))]]
set amount_sum [format "%.2f" [expr $item_units * $price_per_unit]]
set amount_total [format "%.2f" [expr (1. - ($rebate / 100.)) * $amount_sum]]
set sum [expr $sum + $amount_total]
+ set project_sum [expr $project_sum + $amount_total]
set amount_diff [format "%.2f" [expr $amount_total - $amount_sum]]
set amount_total [lc_numeric $amount_total "" $locale]
set amount_sum [lc_numeric $amount_sum "" $locale]
+ set amount_sum_project [lc_numeric [format "%.2f" $project_sum] "" $locale]
set price_per_unit [lc_numeric [format "%.2f" $price_per_unit] "" $locale]
set item_units [lc_numeric [format "%.2f" $item_units] "" $locale]
set rebate [lc_numeric [format "%.1f" $rebate] "" $locale]
@@ -273,7 +284,7 @@
# It is possible that you have an invoice without items, e.g. a credit invoice
if {$sum ne "0."} {
set data(amount_sum) $sum
- set data(total_amount) [expr $sum + $amount_diff]
+ set data(total_amount) [expr $sum - $total_amount_diff]
set data(vat) [expr $data(vat_percent) * $data(total_amount) / 100.]
set data(final_amount) [lc_numeric [format "%.2f" [expr $data(total_amount)+$data(vat)]] "" $locale]
set data(vat) [lc_numeric [format "%.2f" $data(vat)] "" $locale]
@@ -282,6 +293,7 @@
}
set data(vat_percent) [lc_numeric [format "%.1f" $data(vat_percent)] "" $locale]
+ set data(project_count) $project_count
# Get the account manager information for the organization.
set account_manager_ids [contacts::util::get_account_manager -organization_id $data(organization_id)]
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.12 -r1.13
--- openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 27 Dec 2005 20:17:40 -0000 1.12
+++ openacs-4/packages/invoices/tcl/invoices-callback-procs.tcl 15 Mar 2006 17:05:06 -0000 1.13
@@ -106,6 +106,29 @@
if {![empty_string_p $offer_id]} {
# link to linked offer
# append project_links " [_ invoices.iv_offer_View]"
+
+ # check if invoice exists
+ db_foreach invoices {
+ select cri.item_id as invoice_id, r.title as invoice_title
+ from iv_invoice_items ii, iv_offer_items oi, iv_invoices i, cr_items cri,
+ cr_items cro, cr_revisions r
+ where ii.offer_item_id = oi.offer_item_id
+ and oi.offer_id = cro.latest_revision
+ and i.invoice_id = ii.invoice_id
+ and i.cancelled_p = 'f'
+ and r.revision_id = i.invoice_id
+ and cri.latest_revision = i.invoice_id
+ and cro.item_id = :offer_id
+ and not exists (select 1
+ from iv_invoices ci, cr_items cri
+ where ci.parent_invoice_id = i.invoice_id
+ and i.cancelled_p = 't'
+ and cri.latest_revision = ci.invoice_id)
+ group by cri.item_id, r.title
+ } {
+ append project_links " $invoice_title"
+ }
+
} else {
# link to offer-list
db_1row get_project_organization {
Index: openacs-4/packages/invoices/tcl/offer-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/tcl/offer-procs.tcl,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/invoices/tcl/offer-procs.tcl 25 Jan 2006 16:58:32 -0000 1.18
+++ openacs-4/packages/invoices/tcl/offer-procs.tcl 15 Mar 2006 17:05:06 -0000 1.19
@@ -60,6 +60,18 @@
[list vat $vat] \
[list status new] \
[list credit_percent $credit_percent] ] ]
+
+ set account_manager_id [lindex [contacts::util::get_account_manager -organization_id $organization_id] 0]
+
+ if {[empty_string_p $account_manager_id]} {
+ set account_manager_id [ad_conn user_id]
+ }
+
+ db_dml set_account_manager_creator {
+ update acs_objects
+ set creation_user = :account_manager_id
+ where object_id = :item_id
+ }
}
return $new_id
Index: openacs-4/packages/invoices/www/invoice-add.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-add.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/invoices/www/invoice-add.adp 13 Oct 2005 17:11:55 -0000 1.2
+++ openacs-4/packages/invoices/www/invoice-add.adp 15 Mar 2006 17:05:06 -0000 1.3
@@ -4,7 +4,7 @@
$cancel_title"
+
+ ad_form -extend -name iv_invoice_form -form {
+ {cancelled_invoice:text(inform) {label "[_ invoices.iv_invoice_cancelled_invoice]"} {help_text "[_ invoices.iv_invoice_cancelled_help]"}}
+ }
+}
+
+# display link to cancellation
+if {[exists_and_not_null invoice_id] && [db_0or1row check_cancellation {}]} {
+
+ set cancel_link [export_vars -base invoice-ae {{invoice_id $cancel_id} {mode display}}]
+ set cancellation "$cancel_title"
+
+ ad_form -extend -name iv_invoice_form -form {
+ {cancellation:text(inform) {label "[_ invoices.iv_invoice_cancellation]"} {help_text "[_ invoices.iv_invoice_cancellation_help]"}}
+ }
+}
+
if {$has_submit} {
# we are just displaying an invoice
if {$cur_invoice_rebate > 0} {
@@ -265,7 +296,7 @@
[list label "$offer(item_nr), $offer(title)"] \
[list options [list [list "$offer_name" t]]] \
[list values [list t]] \
- [list section "$offer(project_id) $offer(project_title)"] ] ]
+ [list section "[_ invoices.iv_invoice_project_title] $offer(project_title)"] ] ]
}
}
} else {
@@ -306,14 +337,14 @@
[list label "$offer(item_nr), $offer(title)"] \
[list options [list [list "$offer_name" t]]] \
[list values [list t]] \
- [list section "$offer(project_id) $offer(project_title)"] ] ]
+ [list section "[_ invoices.iv_invoice_project_title] $offer(project_title)"] ] ]
} else {
# display: no checkboxes
ad_form -extend -name iv_invoice_form -form \
[list [list "offer_item_ids.${offer(iv_item_id)}:text(inform)" \
[list label "$offer(title), $offer(item_nr)"] \
[list value "$offer_name"] \
- [list section "$offer(project_id) $offer(project_title)"] ] ]
+ [list section "[_ invoices.iv_invoice_project_title] $offer(project_title)"] ] ]
}
}
}
@@ -360,6 +391,13 @@
}
set total_amount [format "%.2f" $total_amount]
set vat [format "%.2f" [expr $total_amount * $vat_percent / 100.]]
+
+ if {[person::person_p -party_id $recipient_id]} {
+ set rec_organization_id [contact::util::get_employee_organization -employee_id $recipient_id]
+ } else {
+ set rec_organization_id $recipient_id
+ }
+
} -new_data {
db_transaction {
set new_invoice_rev_id [iv::invoice::new \
@@ -511,7 +549,11 @@
}
}
- ad_returnredirect "/contacts/$organization_id/"
+ if {[empty_string_p $return_url]} {
+ ad_returnredirect "/contacts/$organization_id/"
+ } else {
+ ad_returnredirect $return_url
+ }
ad_script_abort
}
Index: openacs-4/packages/invoices/www/invoice-ae.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-ae.xql,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/invoices/www/invoice-ae.xql 10 Jan 2006 11:22:18 -0000 1.12
+++ openacs-4/packages/invoices/www/invoice-ae.xql 15 Mar 2006 17:05:06 -0000 1.13
@@ -48,11 +48,9 @@
- select p.first_names || ' ' || p.last_name, p.person_id
- from persons p, iv_invoices i
+ select i.recipient_id as rec_id
+ from iv_invoices i
where i.invoice_id = :parent_invoice_id
- and p.person_id = i.recipient_id
- order by lower(p.last_name), lower(p.first_names)
@@ -86,16 +84,40 @@
- select p.first_names || ' ' || p.last_name, p.person_id
- from persons p, pm_projects pj, cr_items i
+ select pj.recipient_id as rec_id
+ from pm_projects pj, cr_items i
where i.item_id in ([join $project_id ,])
and i.latest_revision = pj.project_id
- and pj.recipient_id = p.person_id
- order by lower(p.last_name), lower(p.first_names)
+
+
+
+ select cri.item_id as cancel_id, r.title as cancel_title
+ from iv_invoices ci, cr_items cri, cr_revisions r
+ where cri.latest_revision = ci.invoice_id
+ and ci.invoice_id = :parent_invoice_id
+ and r.revision_id = ci.invoice_id
+
+
+
+
+
+
+
+ select ii.item_id as cancel_id, r.title as cancel_title
+ from iv_invoices ci, cr_items cri, iv_invoices i, cr_items ii, cr_revisions r
+ where cri.latest_revision = ci.invoice_id
+ and ci.invoice_id = i.parent_invoice_id
+ and i.invoice_id = ii.latest_revision
+ and cri.item_id = :invoice_id
+ and r.revision_id = i.invoice_id
+
+
+
+
Index: openacs-4/packages/invoices/www/invoice-cancellation.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-cancellation.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/invoices/www/invoice-cancellation.tcl 4 Jan 2006 08:06:48 -0000 1.4
+++ openacs-4/packages/invoices/www/invoice-cancellation.tcl 15 Mar 2006 17:05:06 -0000 1.5
@@ -30,9 +30,14 @@
set language [lang::conn::language]
set currency_options [db_list_of_lists currencies {}]
set contact_options [db_list_of_lists cancellation_contacts {}]
-set recipient_options [db_list_of_lists cancellation_recipients {}]
+set recipient_options {}
+db_foreach cancellation_recipients {} {
+ lappend recipient_options [list [contact::name -party_id $rec_id -reverse_order] $rec_id]
+}
+set recipient_options [lsort -dictionary $recipient_options]
+
ad_form -name iv_invoice_cancel_form -action invoice-cancellation -export {organization_id parent_id} -form {
{invoice_id:key}
{organization_name:text(inform) {label "[_ invoices.iv_invoice_organization]"} {value $organization_name} {help_text "[_ invoices.iv_invoice_organization_help]"}}
Index: openacs-4/packages/invoices/www/invoice-cancellation.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-cancellation.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/invoices/www/invoice-cancellation.xql 4 Jan 2006 08:06:48 -0000 1.5
+++ openacs-4/packages/invoices/www/invoice-cancellation.xql 15 Mar 2006 17:05:06 -0000 1.6
@@ -16,11 +16,9 @@
- select p.first_names || ' ' || p.last_name, p.person_id
- from persons p, iv_invoices i
+ select i.recipient_id as rec_id
+ from iv_invoices i
where i.invoice_id = :parent_id
- and p.person_id = i.recipient_id
- order by lower(p.last_name), lower(p.first_names)
Index: openacs-4/packages/invoices/www/invoice-list.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-list.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/invoices/www/invoice-list.adp 26 Oct 2005 14:31:05 -0000 1.3
+++ openacs-4/packages/invoices/www/invoice-list.adp 15 Mar 2006 17:05:06 -0000 1.4
@@ -3,5 +3,5 @@
@context;noquote@
Index: openacs-4/packages/invoices/www/invoice-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-list.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/invoices/www/invoice-list.tcl 29 Jan 2006 16:24:04 -0000 1.5
+++ openacs-4/packages/invoices/www/invoice-list.tcl 15 Mar 2006 17:05:06 -0000 1.6
@@ -6,6 +6,7 @@
} {
{format:optional "normal"}
{orderby:optional ""}
+ {page:optional 1}
{page_size:optional 25}
{organization_id ""}
} -properties {
@@ -24,6 +25,6 @@
set page_title "[_ invoices.iv_invoice_2]"
set context [list $page_title]
-set row_list {checkbox {} invoice_nr {} title {} description {} recipient {} total_amount {} creation_user {} creation_date {} due_date {} action {}}
+set row_list {checkbox {} invoice_nr {} title {} description {} recipient {} total_amount {} creation_date {} due_date {} action {}}
ad_return_template
Index: openacs-4/packages/invoices/www/invoice-send.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send.tcl,v
diff -u -r1.14 -r1.15
--- openacs-4/packages/invoices/www/invoice-send.tcl 29 Jan 2006 15:43:16 -0000 1.14
+++ openacs-4/packages/invoices/www/invoice-send.tcl 15 Mar 2006 17:05:06 -0000 1.15
@@ -22,6 +22,7 @@
# We are only getting the invoice_nr here.
if {[string eq $invoice_nr ""]} {
set invoice_nr [db_nextval iv_invoice_seq]
+ db_dml set_invoice_nr {}
}
set locale [lang::user::site_wide_locale -user_id $contact_id]
@@ -133,7 +134,6 @@
db_dml set_publish_status {}
db_dml set_context_id {}
}
- db_dml set_invoice_nr {}
if {$status != "paid"} {
iv::invoice::set_status -invoice_id $invoice_id -status "billed"
}
Index: openacs-4/packages/invoices/www/invoice-send.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/invoice-send.xql,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/invoices/www/invoice-send.xql 29 Jan 2006 15:43:16 -0000 1.6
+++ openacs-4/packages/invoices/www/invoice-send.xql 15 Mar 2006 17:05:06 -0000 1.7
@@ -4,7 +4,7 @@
- select i.invoice_nr, i.organization_id, i.parent_invoice_id, i.invoice_nr,
+ select i.invoice_nr, i.organization_id, i.parent_invoice_id,
i.total_amount, i.recipient_id, i.contact_id, i.organization_id, i.status
from iv_invoices i, cr_items ii
where ii.latest_revision = i.invoice_id
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.20 -r1.21
--- openacs-4/packages/invoices/www/offer-ae.tcl 25 Jan 2006 17:04:34 -0000 1.20
+++ openacs-4/packages/invoices/www/offer-ae.tcl 15 Mar 2006 17:05:06 -0000 1.21
@@ -68,7 +68,7 @@
db_1row get_organization_and_currencies {}
set files {}
db_foreach get_files {} {
- lappend files [list "$file_name ($file_length bytes)" $file_id]
+ lappend files [list "$file_name ($file_length bytes)" $file_id]
}
set cur_vat_percent [format "%.1f" $cur_vat_percent]
@@ -175,16 +175,50 @@
ad_form -extend -name iv_offer_form -form {
{creator_name:text,optional {label "[_ invoices.iv_offer_creation_user]"} {html {size 80 maxlength 200}} {help_text "[_ invoices.iv_offer_creation_user_help]"}}
{creation_date:text,optional {label "[_ invoices.iv_offer_creation_date]"} {html {size 12 maxlength 10}} {help_text "[_ invoices.iv_offer_creation_date_help]"}}
- {finish_date:text,optional {label "[_ invoices.iv_offer_finish_date]"} {html {size 12 maxlength 10}} {help_text "[_ invoices.iv_offer_finish_date_help]"}}
- {date_comment:text,optional {label "[_ invoices.iv_offer_date_comment]"} {html {size 80 maxlength 1000}} {help_text "[_ invoices.iv_offer_date_comment_help]"}}
}
if {![empty_string_p $accepted_date]} {
ad_form -extend -name iv_offer_form -form {
{accepted_date:text,optional {label "[_ invoices.iv_offer_accepted_date]"} {html {size 12 maxlength 10}} {help_text "[_ invoices.iv_offer_accepted_date_help]"}}
}
}
+}
+if {[exists_and_not_null _project_id]} {
+ # display timings of all subprojects
+
+ set subprojects [db_list_of_lists all_subprojects {
+ select p.title, to_char(p.planned_end_date,'YYYY-MM-DD HH24:MI:SS')
+ from pm_projectsx p, cr_items i
+ where p.parent_id = :item_id
+ and p.project_id = i.latest_revision
+ }]
+
+ # set subprojects ""
+
+ set i 0
+ foreach one_subproject $subprojects {
+ incr i
+ util_unlist $one_subproject subproject_title subproject_finish_date
+ set subproject_finish_date [lc_time_fmt $subproject_finish_date "%x %X"]
+
+ ad_form -extend -name iv_offer_form -form \
+ [list [list "sub_finish_date.${i}:text(inform),optional" \
+ [list label "[_ invoices.iv_offer_project_date] $subproject_title"] \
+ [list html [list size 12 maxlength 10]] \
+ [list value $subproject_finish_date] \
+ [list help_text "[_ invoices.iv_offer_subproject_finish_date_help]"] ] ]
+ }
+}
+
+if {$has_submit} {
+ # we are just displaying an offer
+
+ ad_form -extend -name iv_offer_form -form {
+ {finish_date:text,optional {label "[_ invoices.iv_offer_finish_date]"} {html {size 12 maxlength 10}} {help_text "[_ invoices.iv_offer_finish_date_help]"}}
+ {date_comment:text,optional {label "[_ invoices.iv_offer_date_comment]"} {html {size 80 maxlength 1000}} {help_text "[_ invoices.iv_offer_date_comment_help]"}}
+ }
+
} else {
# we are adding/editing data
@@ -196,13 +230,13 @@
}
ad_form -extend -name iv_offer_form -form {
- {payment_days:integer,optional {label "[_ invoices.iv_offer_payment_days]"} {html {size 5 maxlength 5}} {help_text "[_ invoices.iv_offer_payment_days_help]"}}
+ {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]"}}
}
if {!$has_submit} {
# we are adding/editing data
ad_form -extend -name iv_offer_form -form {
- {vat_percent:float {label "[_ invoices.iv_offer_vat_percent]"} {html {size 5 maxlength 10}} {help_text "[_ invoices.iv_offer_vat_percent_help]"} {after_html {%}}}
+ {vat_percent:float {mode display} {label "[_ invoices.iv_offer_vat_percent]"} {html {size 5 maxlength 10}} {help_text "[_ invoices.iv_offer_vat_percent_help]"} {after_html {%}}}
{currency:text(select) {mode display} {label "[_ invoices.iv_offer_currency]"} {options $currency_options} {help_text "[_ invoices.iv_offer_currency_help]"}}
}
@@ -255,6 +289,12 @@
db_foreach offer_items {} -column_array item {
incr i
+ if {[empty_string_p $item(price_per_unit)]} {
+ set item(price_per_unit) 0
+ }
+ if {[empty_string_p $item(item_units)]} {
+ set item(item_units) 0
+ }
set item(price_per_unit) [format "%.2f" $item(price_per_unit)]
set item(amount_sum) [format "%.2f" [expr $item(item_units) * $item(price_per_unit)]]
set item(amount_total) [format "%.2f" [expr (1. - ($item(rebate) / 100.)) * $item(amount_sum)]]
@@ -342,6 +382,7 @@
[list [list "item_category.${i}:text(category)" \
[list label "[_ invoices.iv_offer_item_category]"] \
[list value [list $item(offer_item_id) $container_objects(offer_item_id)]] \
+ [list html [list onChange setItemPrice(${i})]] \
[list help_text "[_ invoices.iv_offer_item_category_help]"] \
[list section "[_ invoices.iv_offer_item_1] $i"] ] ]
ad_form -extend -name iv_offer_form -form \
@@ -361,9 +402,9 @@
[list after_html $currency] \
[list section "[_ invoices.iv_offer_item_1] $i"] ] ]
ad_form -extend -name iv_offer_form -form \
- [list [list "amount_sum.${i}:float(inform)" \
+ [list [list "amount_sum.${i}:float,optional" \
[list label "[_ invoices.iv_offer_item_amount]"] \
- [list html [list size 10 maxlength 10]] \
+ [list html [list size 10 maxlength 10 disabled t]] \
[list value $item(amount_sum)] \
[list help_text "[_ invoices.iv_offer_item_amount_help]"] \
[list after_html $currency] \
@@ -525,12 +566,12 @@
set finish_time ""
if {[exists_and_not_null project_title]} {
set title "[_ invoices.iv_offer_1] $project_title"
+ set offer_nr $project_title
} else {
set title "[_ invoices.iv_offer_1] $organization_name $today"
}
# We do not want a seperate offer_number but use the project title
# set offer_nr [db_nextval iv_offer_seq]
- set offer_nr $project_title
set amount_sum "0.00"
set amount_total "0.00"
set credit_sum "0.00"
@@ -610,11 +651,19 @@
set item(title) "#invoices.iv_offer_item_title_cat_2# ($from_cat -> $to_cat)"
}
}
+ if {[empty_string_p $item(title)]} {
+ set item(title) [category::get_name $item(category)]
+ }
+
if {[empty_string_p $item(price)]} {
+ set item(price) 0
set item(sum) "0"
} else {
set item(sum) [expr $item(units) * $item(price)]
}
+ if {[empty_string_p $item(units)]} {
+ set item(units) 0
+ }
set item(total) [expr (1. - ($item(rebate)/100.)) * $item(sum)]
set item(vat) [expr $vat_percent * $item(total) / 100.]
set items($i) [array get item]
@@ -795,6 +844,7 @@
}
}
+ set return_url ""
if {[empty_string_p $return_url]} {
ad_returnredirect [export_vars -base offer-ae {offer_id {mode display}}]
ad_script_abort
Index: openacs-4/packages/invoices/www/offer-ae.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-ae.xql,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/invoices/www/offer-ae.xql 25 Jan 2006 17:02:44 -0000 1.9
+++ openacs-4/packages/invoices/www/offer-ae.xql 15 Mar 2006 17:05:06 -0000 1.10
@@ -43,9 +43,17 @@
select count(*) as invoice_count
- from iv_invoice_items ii, iv_offer_items oi
+ from iv_invoice_items ii, iv_offer_items oi, iv_invoices i, cr_items cri
where ii.offer_item_id = oi.offer_item_id
and oi.offer_id = :offer_rev_id
+ and i.invoice_id = ii.invoice_id
+ and i.cancelled_p = 'f'
+ and cri.latest_revision = i.invoice_id
+ and not exists (select 1
+ from iv_invoices ci, cr_items cri
+ where ci.parent_invoice_id = i.invoice_id
+ and i.cancelled_p = 't'
+ and cri.latest_revision = ci.invoice_id)
@@ -137,7 +145,7 @@
where r.revision_id = t.offer_id
and i.latest_revision = r.revision_id
and i.item_id = :offer_id
- and o.object_id = t.offer_id
+ and o.object_id = i.item_id
and p.person_id = o.creation_user
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.2 -r1.3
--- openacs-4/packages/invoices/www/offer-list.adp 13 Oct 2005 17:11:55 -0000 1.2
+++ openacs-4/packages/invoices/www/offer-list.adp 15 Mar 2006 17:05:06 -0000 1.3
@@ -3,5 +3,5 @@
@context;noquote@
Index: openacs-4/packages/invoices/www/offer-list.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/offer-list.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/invoices/www/offer-list.tcl 6 Sep 2005 23:01:24 -0000 1.2
+++ openacs-4/packages/invoices/www/offer-list.tcl 15 Mar 2006 17:05:06 -0000 1.3
@@ -6,6 +6,7 @@
} {
{format:optional "normal"}
{orderby:optional ""}
+ {page:optional 1}
{page_size:optional 25}
{organization_id:optional ""}
} -properties {
Index: openacs-4/packages/invoices/www/price-list-ae.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/invoices/www/price-list-ae.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/invoices/www/price-list-ae.tcl 9 Dec 2005 18:25:01 -0000 1.3
+++ openacs-4/packages/invoices/www/price-list-ae.tcl 15 Mar 2006 17:05:06 -0000 1.4
@@ -7,7 +7,7 @@
list_id:integer,optional
{__new_p 0}
{mode edit}
- {organization_id ""}
+ {organization_id:multiple ""}
} -properties {
context:onevalue
page_title:onevalue
@@ -57,7 +57,7 @@
{organization_id:text(multiselect),optional,multiple {label "[_ invoices.iv_price_list_organization]"} {options $organization_options} {help_text "[_ invoices.iv_price_list_organization_help]"} {values {$organization_values}}}
}
} else {
- set organization_name [contact::name -party_id $organization_id]
+ set organization_name [contact::name -party_id [lindex $organization_id 0]]
ad_form -extend -name iv_price_list_form -form {
{organization_name:text(inform) {label "[_ invoices.iv_price_list_organization]"} {value $organization_name } {help_text "[_ invoices.iv_price_list_organization_help]"} }
{organization_id:text(hidden)}
@@ -108,7 +108,20 @@
application_data_link::delete_links -object_id $new_list_id
foreach o_id $organization_id {
- set package_id [ad_conn package_id]
+ # delete old link from organization to price list
+ foreach old_list_id [application_data_link::get_linked_content -from_object_id $o_id -to_content_type iv_price_list] {
+ db_dml delete_forward_link {
+ delete from acs_data_links
+ where object_id_one = :o_id
+ and object_id_two = :old_list_id
+ }
+ db_dml delete_backward_link {
+ delete from acs_data_links
+ where object_id_one = :old_list_id
+ and object_id_two = :o_id
+ }
+ }
+
application_data_link::new -this_object_id $new_list_id -target_object_id $o_id
}
}