JBAS-2101 Improve refundable xact summary payment count fix
authorBill Erickson <berickxx@gmail.com>
Wed, 14 Nov 2018 17:21:28 +0000 (12:21 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/refundable-xact-summary-view-speed.sql

index a1adab2..693aa4a 100644 (file)
@@ -21,7 +21,7 @@ CREATE OR REPLACE VIEW money.refundable_xact_summary AS
         SUM(positive_payments.amount)::NUMERIC(8,2) AS refundable_paid,
         SUM(total_paid.amount)::NUMERIC(8,2) AS total_paid,
         COALESCE(-SUM(refund_payments.amount), 0)::NUMERIC(8,2) AS total_refunded,
-        COUNT(mrp.id) AS num_refundable_payments
+        COUNT(DISTINCT(mrp.id)) AS num_refundable_payments
     FROM money.refundable_xact xact
         JOIN action.circulation circ ON (circ.id = xact.xact)
         JOIN asset.copy acp ON (acp.id = circ.target_copy)