From 18812d0ae7de3cc62caf0e00fd284e706a940f03 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 15 Nov 2013 16:40:36 -0500 Subject: [PATCH] Enforce one-payment-per-xact-per-call There is no legitimate reason for a transaction to receive more than one payment per call to open-ils.circ open-ils.circ.money.payment, but we have seen the staff client generate such a data structure. This leads to seemingly duplicate payments, and is bad all around. So, we will enforce the restriction by taking only the first payment per xact in the list of payments. Signed-off-by: Mike Rylander Signed-off-by: Bill Erickson --- .../src/perlmods/lib/OpenILS/Application/Circ/Money.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm index b46e57818c..c127d7514c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm @@ -162,8 +162,16 @@ sub make_payments { # first collect the transactions and make sure the transaction # user matches the requested user my %xacts; + + # We rewrite the payments array for sanity's sake, to avoid more + # than one payment per transaction per call, which is not legitimate + # but has been seen in the wild coming from the staff client. This + # is presumably a staff client (xulrunner) bug. + my @unique_xact_payments; for my $pay (@{$payments->{payments}}) { my $xact_id = $pay->[0]; + next if (exists($xacts{$xact_id})); + my $xact = $e->retrieve_money_billable_transaction_summary($xact_id) or return $e->die_event; @@ -173,7 +181,9 @@ sub make_payments { } $xacts{$xact_id} = $xact; + push @unique_xact_payments, $pay; } + $payments->{payments} = \@unique_xact_payments; my @payment_objs; -- 2.43.2