From: miker Date: Mon, 18 Jun 2007 20:35:35 +0000 (+0000) Subject: Adding billing location to the open billable transaction summary view X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=9e4a2500c567c40b34efbb8587e91b1fc5baa575;p=Evergreen.git Adding billing location to the open billable transaction summary view git-svn-id: svn://svn.open-ils.org/ILS/trunk@7444 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index beef509578..0674721aa3 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -609,6 +609,7 @@ + diff --git a/Open-ILS/src/sql/Pg/080.schema.money.sql b/Open-ILS/src/sql/Pg/080.schema.money.sql index 0ffc89187a..68dc8184dc 100644 --- a/Open-ILS/src/sql/Pg/080.schema.money.sql +++ b/Open-ILS/src/sql/Pg/080.schema.money.sql @@ -236,6 +236,7 @@ CREATE OR REPLACE VIEW money.billable_xact_summary AS CREATE OR REPLACE VIEW money.open_billable_xact_summary AS SELECT xact.id AS id, xact.usr AS usr, + COALESCE(circ.circ_lib,groc.billing_location) AS billing_location, xact.xact_start AS xact_start, xact.xact_finish AS xact_finish, SUM(credit.amount) AS total_paid, @@ -250,10 +251,32 @@ CREATE OR REPLACE VIEW money.open_billable_xact_summary AS p.relname AS xact_type FROM money.billable_xact xact JOIN pg_class p ON (xact.tableoid = p.oid) - LEFT JOIN money.billing debit ON (xact.id = debit.xact AND debit.voided IS FALSE) - LEFT JOIN money.payment_view credit ON (xact.id = credit.xact AND credit.voided IS FALSE) + LEFT JOIN "action".circulation circ ON (circ.id = xact.id) + LEFT JOIN money.grocery groc ON (circ.id = xact.id) + LEFT JOIN ( + SELECT billing.xact, + billing.voided, + sum(billing.amount) AS amount, + max(billing.billing_ts) AS billing_ts, + last(billing.note) AS note, + last(billing.billing_type) AS billing_type + FROM money.billing + WHERE billing.voided IS FALSE + GROUP BY billing.xact, billing.voided + ) debit ON (xact.id = debit.xact AND debit.voided IS FALSE) + LEFT JOIN ( + SELECT payment_view.xact, + payment_view.voided, + sum(payment_view.amount) AS amount, + max(payment_view.payment_ts) AS payment_ts, + last(payment_view.note) AS note, + last(payment_view.payment_type) AS payment_type + FROM money.payment_view + WHERE payment_view.voided IS FALSE + GROUP BY payment_view.xact, payment_view.voided + ) credit ON (xact.id = credit.xact AND credit.voided IS FALSE) WHERE xact.xact_finish IS NULL - GROUP BY 1,2,3,4,14 + GROUP BY 1,2,3,4,5,15 ORDER BY MAX(debit.billing_ts), MAX(credit.payment_ts);