From 6a32fbd3014266bf2dc47a80d26bd7749873205f Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 31 Jul 2020 15:14:59 -0400 Subject: [PATCH] Lp 1843079: Refine the new field for AutorenewNotify Template Rename the renewal_remaining udata field to auto_renewal_remaining. Guard against negative values in the fields as renewal_remaining can go negative if staff use overrides when renewing. There's no point reporting negative values to a patron. Fix a couple of typos in the release note heading. Signed-off-by: Jason Stephenson --- .../lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm | 5 ++++- .../Circulation/autorenewnotify-renewal-field.adoc | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm index 4add52dc8b..7274c408e0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm @@ -68,6 +68,9 @@ sub handler { my $new_circ_due = $is_renewed ? $evt->{payload}->{circ}->due_date : ''; my $total_remaining = $is_renewed ? $evt->{payload}->{circ}->renewal_remaining : $_->renewal_remaining; my $auto_remaining = $is_renewed ? $evt->{payload}->{circ}->auto_renewal_remaining : $_->auto_renewal_remaining; + # Check for negative renewal remaining. It can happen with an override renewal: + $total_remaining = ($total_remaining < 0) ? 0 : $total_remaining; + $auto_remaining = ($auto_remaining < 0) ? 0 : $auto_remaining; # Just making sure.... my %user_data = ( copy => $_->target_copy(), @@ -77,7 +80,7 @@ sub handler { old_due_date => !$is_renewed ? $_->due_date() : '', textcode => $evt->{textcode}, total_renewal_remaining => $total_remaining, - renewal_remaining => ($auto_remaining < $total_remaining) ? $auto_remaining : $total_remaining, + auto_renewal_remaining => ($auto_remaining < $total_remaining) ? $auto_remaining : $total_remaining, ); # Create the event from the source circ instead of the diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc index e992b2ad18..df3431ee9b 100644 --- a/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc +++ b/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc @@ -1,7 +1,7 @@ -New Field for AutorenewNotify Eevent Template +New Fields for AutorenewNotify Event Template ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Two new fields, `renewal_remaining`, and `total_renewal_remaining` have +Two new fields, `auto_renewal_remaining`, and `total_renewal_remaining` have been added to the AutorenewNotify action/trigger event code. They will report the number of autorenewals and regular renewals, respectively, remaining on the new circulation if renewed, or on the old circulation @@ -10,7 +10,7 @@ inaccurate math in the template. You may access them in the template via the `udata`: ................................................. -Automatic Renewals Remaining: [% udata.renewal_remaining %] +Automatic Renewals Remaining: [% udata.auto_renewal_remaining %] Total Renewals Remaining: [% udata.total_renewal_remaining %] ................................................. -- 2.11.0