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.6 -r1.7 --- openacs-4/packages/invoices/lib/projects-billable.xql 14 Dec 2005 22:06:38 -0000 1.6 +++ openacs-4/packages/invoices/lib/projects-billable.xql 19 Dec 2005 20:08:28 -0000 1.7 @@ -12,7 +12,7 @@ total.count_total, billed.count_billed, name, - billed.recipient_id, + sub.recipient_id, sub.customer_id as org_id from ( select @@ -21,6 +21,7 @@ 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 from cr_items pi, @@ -44,12 +45,13 @@ 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 + from iv_invoice_items ii, iv_invoices i, cr_items ci where ii.offer_item_id = ofi.offer_item_id and i.invoice_id = ii.invoice_id + and ci.latest_revision = i.invoice_id and i.cancelled_p = 'f') group by - oi.item_id, pr.revision_id, o.creation_date, p.customer_id, oz.name + oi.item_id, pr.revision_id, o.creation_date, p.customer_id, oz.name, p.recipient_id ) sub, ( select @@ -63,17 +65,19 @@ ) total, ( select - count(i.invoice_id) as count_billed, oi.item_id, i.recipient_id + count(ci.item_id) as count_billed, oi.item_id from cr_items oi, iv_offer_items ofi left outer join iv_invoice_items ii on (ii.offer_item_id = ofi.offer_item_id) left outer join iv_invoices i on (ii.invoice_id = i.invoice_id and i.cancelled_p = 'f') + left outer join cr_items ci + on (ci.latest_revision = i.invoice_id) where ofi.offer_id = oi.latest_revision group by - oi.item_id, i.recipient_id + oi.item_id ) billed, cr_revisions r where 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.9 -r1.10 --- openacs-4/packages/invoices/www/invoice-ae.xql 14 Dec 2005 22:06:38 -0000 1.9 +++ openacs-4/packages/invoices/www/invoice-ae.xql 19 Dec 2005 20:08:28 -0000 1.10 @@ -65,7 +65,7 @@ from persons p, pm_projects pj, cr_items i where i.item_id in ([join $project_id ,]) and i.latest_revision = pj.project_id - and p.person_id in ( select party_id from pm_project_assignment where project_id in ([join $project_id ,])) + and pj.recipient_id = p.person_id order by lower(p.last_name), lower(p.first_names) @@ -90,9 +90,10 @@ and cr.revision_id = ofi.offer_item_id and of.offer_id = ofi.offer_id and not exists (select 1 - from iv_invoice_items ii, iv_invoices i + from iv_invoice_items ii, iv_invoices i, cr_items ci where ii.offer_item_id = ofi.offer_item_id and i.invoice_id = ii.invoice_id + and ci.latest_revision = i.invoice_id and i.cancelled_p = 'f') order by pi.item_id, ofi.item_nr @@ -241,8 +242,7 @@ select - distinct - customer_id + distinct customer_id from pm_projectsx where