LP#1206936 - Fix wrong billing info in money.transaction_billing_summary
authorChris Sharp <csharp@georgialibraries.org>
Mon, 30 Nov 2015 14:48:26 +0000 (09:48 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 24 Feb 2016 19:22:55 +0000 (14:22 -0500)
The money.transaction_billing_summary view was showing the wrong
last billing type and last billing note for certain transactions.
This fix, from Dan Scott, in turn from Mike Rylander, recreates
that view so that it depends on the speedier and more accurate
money.materialized_billable_xact_summary view.

Signed-off-by: Chris Sharp <csharp@georgialibraries.org>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/080.schema.money.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.correct_mtbs_view.sql [new file with mode: 0644]

index e67c0a7..19a88c7 100644 (file)
@@ -95,15 +95,13 @@ CREATE OR REPLACE VIEW money.transaction_billing_type_summary AS
          ORDER BY MAX(billing_ts);
 
 CREATE OR REPLACE VIEW money.transaction_billing_summary AS
-       SELECT  xact,
-               LAST(billing_type) AS last_billing_type,
-               LAST(note) AS last_billing_note,
-               MAX(billing_ts) AS last_billing_ts,
-               SUM(COALESCE(amount,0)) AS total_owed
-         FROM  money.billing
-         WHERE voided IS FALSE
-         GROUP BY xact
-         ORDER BY MAX(billing_ts);
+    SELECT id as xact,
+        last_billing_type,
+        last_billing_note,
+        last_billing_ts,
+        total_owed
+      FROM money.materialized_billable_xact_summary;            
+
 
 CREATE OR REPLACE VIEW money.transaction_payment_summary AS
        SELECT  xact,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.correct_mtbs_view.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.correct_mtbs_view.sql
new file mode 100644 (file)
index 0000000..c45b3c6
--- /dev/null
@@ -0,0 +1,13 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW money.transaction_billing_summary AS
+    SELECT id as xact,
+        last_billing_type,
+        last_billing_note,
+        last_billing_ts,
+        total_owed
+      FROM money.materialized_billable_xact_summary;
+
+COMMIT;