[open-ils-commits] r15664 - branches/rel_1_6_0/Open-ILS/src/sql/Pg (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Mar 2 17:31:06 EST 2010


Author: miker
Date: 2010-03-02 17:31:00 -0500 (Tue, 02 Mar 2010)
New Revision: 15664

Modified:
   branches/rel_1_6_0/Open-ILS/src/sql/Pg/080.schema.money.sql
Log:
protect mmbxs mat view from NULLs

Modified: branches/rel_1_6_0/Open-ILS/src/sql/Pg/080.schema.money.sql
===================================================================
--- branches/rel_1_6_0/Open-ILS/src/sql/Pg/080.schema.money.sql	2010-03-02 21:32:20 UTC (rev 15663)
+++ branches/rel_1_6_0/Open-ILS/src/sql/Pg/080.schema.money.sql	2010-03-02 22:31:00 UTC (rev 15664)
@@ -213,15 +213,15 @@
 		xact.usr,
 		xact.xact_start,
 		xact.xact_finish,
-		credit.amount AS total_paid,
+		COALESCE(credit.amount, 0.0::numeric) AS total_paid,
 		credit.payment_ts AS last_payment_ts,
 		credit.note AS last_payment_note,
 		credit.payment_type AS last_payment_type,
-		debit.amount AS total_owed,
+		COALESCE(debit.amount, 0.0::numeric) AS total_owed,
 		debit.billing_ts AS last_billing_ts,
 		debit.note AS last_billing_note,
 		debit.billing_type AS last_billing_type,
-		COALESCE(debit.amount, 0::numeric) - COALESCE(credit.amount, 0::numeric) AS balance_owed,
+		COALESCE(debit.amount, 0.0::numeric) - COALESCE(credit.amount, 0.0::numeric) AS balance_owed,
 		p.relname AS xact_type
 	  FROM	money.billable_xact xact
 		JOIN pg_class p ON xact.tableoid = p.oid
@@ -294,7 +294,7 @@
 BEGIN
 	IF NOT NEW.voided THEN
 		UPDATE	money.materialized_billable_xact_summary
-		  SET	total_owed = total_owed + NEW.amount,
+		  SET	total_owed = COALESCE(total_owed, 0.0::numeric) + NEW.amount,
 			last_billing_ts = NEW.billing_ts,
 			last_billing_note = NEW.note,
 			last_billing_type = NEW.billing_type,
@@ -394,7 +394,7 @@
 BEGIN
 	IF NOT NEW.voided THEN
 		UPDATE	money.materialized_billable_xact_summary
-		  SET	total_paid = total_paid + NEW.amount,
+		  SET	total_paid = COALESCE(total_paid, 0.0::numeric) + NEW.amount,
 			last_payment_ts = NEW.payment_ts,
 			last_payment_note = NEW.note,
 			last_payment_type = TG_ARGV[0],



More information about the open-ils-commits mailing list