From a76a44f0aec8bcad5a74bbcd4746111805f48751 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Fri, 31 Jul 2020 13:57:25 -0400 Subject: [PATCH] Lp 1843079: Distinguish between auto and regular renewals Make the number of potential remaining autorenewals available in addtion to the total number of renewals remaining. This prevents situations where fewer autorenewals are available than intentional renewals. Signed-off-by: Jason Boyer Signed-off-by: Jason Stephenson --- .../Application/Trigger/Reactor/Circ/AutoRenew.pm | 6 ++++-- .../Circulation/autorenewnotify-renewal-field.adoc | 16 +++++++++------- 2 files changed, 13 insertions(+), 9 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 f0919959f2..4add52dc8b 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 @@ -66,7 +66,8 @@ sub handler { my $is_renewed = $evt->{textcode} eq 'SUCCESS' ? 1 : 0; my $new_circ_due = $is_renewed ? $evt->{payload}->{circ}->due_date : ''; - my $renewal_remaining = $is_renewed ? $evt->{payload}->{circ}->renewal_remaining : $_->renewal_remaining; + 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; my %user_data = ( copy => $_->target_copy(), @@ -75,7 +76,8 @@ sub handler { new_due_date => $is_renewed ? $evt->{payload}->{circ}->due_date : '', old_due_date => !$is_renewed ? $_->due_date() : '', textcode => $evt->{textcode}, - renewal_remaining => $renewal_remaining, + total_renewal_remaining => $total_remaining, + 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 fdc2857c6b..e992b2ad18 100644 --- a/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc +++ b/docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc @@ -1,14 +1,16 @@ New Field for AutorenewNotify Eevent Template ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A new field, `renewal_remaining`, has been added to the -AutorenewNotify action/trigger event code. It will report the number -of renewals remaining on the new circulation, if renewed, or on the -old circulation, if not renewed. This is provided as a convenience to -avoid possibly inaccurate math in the template. You may access it in -the template via the `udata`: +Two new fields, `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 +if not renewed. This is provided as a convenience to avoid possibly +inaccurate math in the template. You may access them in the template via +the `udata`: ................................................. -Renewals Remaining: [% udata.renewal_remaining %] +Automatic Renewals Remaining: [% udata.renewal_remaining %] +Total Renewals Remaining: [% udata.total_renewal_remaining %] ................................................. -- 2.11.0