[open-ils-commits] [GIT] Evergreen ILS branch rel_2_1 updated. c4d92bcf1ca43d9630636637edd6cb9617fc0187

Evergreen Git git at git.evergreen-ils.org
Thu Sep 22 11:24:12 EDT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_1 has been updated
       via  c4d92bcf1ca43d9630636637edd6cb9617fc0187 (commit)
       via  16923a798c7febf5c1c9424d7e8cec4e9d304ae2 (commit)
      from  7a5899df767122c3275c63f9abb8716ca76407a9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c4d92bcf1ca43d9630636637edd6cb9617fc0187
Author: Bill Erickson <berick at esilibrary.com>
Date:   Thu Sep 22 11:10:09 2011 -0400

    Stamped upgrade script for ACQ fund view repairs
    
    At the heart of this change is the need to force acq.fund_debit_total to
    return exactly 1 row per fund, instead of 1 per fund + encumbrance
    value.  However, such a change required rearranging a number of
    dependent views.
    
    Also added acq.fund_spent_balance to the set of views that needs
    dropping and re-building.
    
    Minor SQL format change to match surrounding code in schema file
    
    See also https://bugs.launchpad.net/evergreen/+bug/800477
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 71a6fa6..bc501a3 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -57,7 +57,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0624'); -- miker/tsbere
+INSERT INTO config.upgrade_log (version) VALUES ('0628'); -- jamesrf/berick
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql
index 9f8dbd3..92cb0bf 100644
--- a/Open-ILS/src/sql/Pg/200.schema.acq.sql
+++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql
@@ -2459,33 +2459,33 @@ CREATE OR REPLACE VIEW acq.fund_allocation_total AS
     GROUP BY 1;
 
 CREATE OR REPLACE VIEW acq.fund_debit_total AS
-    SELECT fund.id AS fund,
-           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    SELECT  fund.id AS fund, 
+            sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount
     FROM acq.fund fund
-          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
     GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
-    SELECT fund.id AS fund,
-           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    SELECT 
+        fund.id AS fund, 
+        sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount 
     FROM acq.fund fund
-          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
-    WHERE fund_debit.encumbrance
-    GROUP BY fund.id;
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund 
+    WHERE fund_debit.encumbrance GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_spent_total AS
-    SELECT fund.id AS fund,
-           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    SELECT  fund.id AS fund, 
+            sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount 
     FROM acq.fund fund
-          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
-    WHERE NOT fund_debit.encumbrance
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund 
+    WHERE NOT fund_debit.encumbrance 
     GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_combined_balance AS
-    SELECT  c.fund,
-            c.amount - COALESCE(d.amount,0.0) AS amount
-      FROM  acq.fund_allocation_total c
-            LEFT JOIN acq.fund_debit_total d USING (fund);
+    SELECT  c.fund, 
+            c.amount - COALESCE(d.amount, 0.0) AS amount
+    FROM acq.fund_allocation_total c
+    LEFT JOIN acq.fund_debit_total d USING (fund);
 
 CREATE OR REPLACE VIEW acq.fund_spent_balance AS
     SELECT  c.fund,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0628.schema.acq_fund_view_repairs.sql b/Open-ILS/src/sql/Pg/upgrade/0628.schema.acq_fund_view_repairs.sql
new file mode 100644
index 0000000..9138d7c
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0628.schema.acq_fund_view_repairs.sql
@@ -0,0 +1,52 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0628');
+
+-- acq.fund_combined_balance and acq.fund_spent_balance are unchanged,
+-- however we need to drop them to recreate the other views.
+-- we need to drop all our views because we change the number of columns
+-- for example, debit_total does not need an encumberance column when we 
+-- have a sepearate total for that.
+
+DROP VIEW acq.fund_spent_balance;
+DROP VIEW acq.fund_combined_balance;
+DROP VIEW acq.fund_encumbrance_total;
+DROP VIEW acq.fund_spent_total;
+DROP VIEW acq.fund_debit_total;
+
+CREATE OR REPLACE VIEW acq.fund_debit_total AS
+    SELECT  fund.id AS fund, 
+            sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    FROM acq.fund fund
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+    GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
+    SELECT 
+        fund.id AS fund, 
+        sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount 
+    FROM acq.fund fund
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund 
+    WHERE fund_debit.encumbrance GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_spent_total AS
+    SELECT  fund.id AS fund, 
+            sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount 
+    FROM acq.fund fund
+        LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund 
+    WHERE NOT fund_debit.encumbrance 
+    GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_combined_balance AS
+    SELECT  c.fund, 
+            c.amount - COALESCE(d.amount, 0.0) AS amount
+    FROM acq.fund_allocation_total c
+    LEFT JOIN acq.fund_debit_total d USING (fund);
+
+CREATE OR REPLACE VIEW acq.fund_spent_balance AS
+    SELECT  c.fund,
+            c.amount - COALESCE(d.amount,0.0) AS amount
+      FROM  acq.fund_allocation_total c
+            LEFT JOIN acq.fund_spent_total d USING (fund);
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477 b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477
deleted file mode 100644
index dc21cd0..0000000
--- a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477
+++ /dev/null
@@ -1,34 +0,0 @@
-BEGIN;
-
-INSERT INTO config.upgrade_log (version, install_date) VALUES ('XXXXXXX',now());
-
--- acq.fund_combined_balance is unchanged however we need to drop it to recreate the other views
--- we need to drop all our views because we change the number of columns
--- for example, debit_total does not need an encumberance column when we have a sepearate total for that
-
-DROP VIEW acq.fund_combined_balance;
-DROP VIEW acq.fund_encumbrance_total;
-DROP VIEW acq.fund_spent_total;
-DROP VIEW acq.fund_debit_total;
-
-CREATE OR REPLACE VIEW acq.fund_debit_total AS
- SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount
-   FROM acq.fund fund
-   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
-  GROUP BY fund.id;
-
-CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
-SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount FROM acq.fund fund
-   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund WHERE fund_debit.encumbrance GROUP BY fund.id;
-
-CREATE OR REPLACE VIEW acq.fund_spent_total AS
-SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount FROM acq.fund fund
-   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund WHERE NOT fund_debit.encumbrance GROUP BY fund.id;
-
-CREATE OR REPLACE VIEW acq.fund_combined_balance AS
- SELECT c.fund, c.amount - COALESCE(d.amount, 0.0) AS amount
-   FROM acq.fund_allocation_total c
-   LEFT JOIN acq.fund_debit_total d USING (fund);
-
-
-COMMIT;

commit 16923a798c7febf5c1c9424d7e8cec4e9d304ae2
Author: James Fournie <jfournie at sitka.bclibraries.ca>
Date:   Mon Sep 19 16:01:01 2011 -0700

    Addresses LP#800477 where some acq views calculate the totals incorrectly or in unexpected ways.
    
    Signed-off-by: James Fournie <jfournie at sitka.bclibraries.ca>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql
index e8869a3..9f8dbd3 100644
--- a/Open-ILS/src/sql/Pg/200.schema.acq.sql
+++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql
@@ -2459,27 +2459,27 @@ CREATE OR REPLACE VIEW acq.fund_allocation_total AS
     GROUP BY 1;
 
 CREATE OR REPLACE VIEW acq.fund_debit_total AS
-    SELECT  fund.id AS fund,
-            fund_debit.encumbrance AS encumbrance,
-			SUM( COALESCE( fund_debit.amount, 0 ) ) AS amount
-      FROM acq.fund AS fund
-            LEFT JOIN acq.fund_debit AS fund_debit
-                ON ( fund.id = fund_debit.fund )
-      GROUP BY 1,2;
+    SELECT fund.id AS fund,
+           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    FROM acq.fund fund
+          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+    GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
-    SELECT  fund,
-            SUM(amount) AS amount
-      FROM  acq.fund_debit_total
-      WHERE encumbrance IS TRUE
-      GROUP BY 1;
+    SELECT fund.id AS fund,
+           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    FROM acq.fund fund
+          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+    WHERE fund_debit.encumbrance
+    GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_spent_total AS
-    SELECT  fund,
-            SUM(amount) AS amount
-      FROM  acq.fund_debit_total
-      WHERE encumbrance IS FALSE
-      GROUP BY 1;
+    SELECT fund.id AS fund,
+           SUM(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+    FROM acq.fund fund
+          LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+    WHERE NOT fund_debit.encumbrance
+    GROUP BY fund.id;
 
 CREATE OR REPLACE VIEW acq.fund_combined_balance AS
     SELECT  c.fund,
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477 b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477
new file mode 100644
index 0000000..dc21cd0
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.acq_lp800477
@@ -0,0 +1,34 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version, install_date) VALUES ('XXXXXXX',now());
+
+-- acq.fund_combined_balance is unchanged however we need to drop it to recreate the other views
+-- we need to drop all our views because we change the number of columns
+-- for example, debit_total does not need an encumberance column when we have a sepearate total for that
+
+DROP VIEW acq.fund_combined_balance;
+DROP VIEW acq.fund_encumbrance_total;
+DROP VIEW acq.fund_spent_total;
+DROP VIEW acq.fund_debit_total;
+
+CREATE OR REPLACE VIEW acq.fund_debit_total AS
+ SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount
+   FROM acq.fund fund
+   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund
+  GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_encumbrance_total AS
+SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount FROM acq.fund fund
+   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund WHERE fund_debit.encumbrance GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_spent_total AS
+SELECT fund.id AS fund, sum(COALESCE(fund_debit.amount, 0::numeric)) AS amount FROM acq.fund fund
+   LEFT JOIN acq.fund_debit fund_debit ON fund.id = fund_debit.fund WHERE NOT fund_debit.encumbrance GROUP BY fund.id;
+
+CREATE OR REPLACE VIEW acq.fund_combined_balance AS
+ SELECT c.fund, c.amount - COALESCE(d.amount, 0.0) AS amount
+   FROM acq.fund_allocation_total c
+   LEFT JOIN acq.fund_debit_total d USING (fund);
+
+
+COMMIT;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 Open-ILS/src/sql/Pg/200.schema.acq.sql             |   42 ++++++++--------
 .../upgrade/0628.schema.acq_fund_view_repairs.sql  |   52 ++++++++++++++++++++
 3 files changed, 74 insertions(+), 22 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/0628.schema.acq_fund_view_repairs.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list