[open-ils-commits] [GIT] Evergreen ILS branch master updated. 9b4693f07a26eed41dfdd98cbc8a59a1a6070962

Evergreen Git git at git.evergreen-ils.org
Thu Sep 22 11:19:02 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, master has been updated
       via  9b4693f07a26eed41dfdd98cbc8a59a1a6070962 (commit)
       via  4bd5e0b84af5c14cd9e4edbe631e193df4de4274 (commit)
      from  0c2ec9663097fcb42a55931799619b99adbe1233 (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 9b4693f07a26eed41dfdd98cbc8a59a1a6070962
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 e9ef912..67fe0e8 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0626', :eg_version); -- senator
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0628', :eg_version); -- 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 9276248..8765c4a 100644
--- a/Open-ILS/src/sql/Pg/200.schema.acq.sql
+++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql
@@ -2460,33 +2460,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..6320424
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0628.schema.acq_fund_view_repairs.sql
@@ -0,0 +1,52 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0628', :eg_version);
+
+-- 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 4bd5e0b84af5c14cd9e4edbe631e193df4de4274
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 b566ff5..9276248 100644
--- a/Open-ILS/src/sql/Pg/200.schema.acq.sql
+++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql
@@ -2460,27 +2460,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