Lp 1843079: Add renewals remaining to AutoRenew reactor's user data user/dyrcona/lp1843079-autorenew-renewal_remaining
authorJason Stephenson <jason@sigio.com>
Fri, 6 Sep 2019 14:38:25 +0000 (10:38 -0400)
committerJason Stephenson <jason@sigio.com>
Fri, 31 Jul 2020 16:22:02 +0000 (12:22 -0400)
Add a renewal_remaining field to the autorenew event's user data so
that we can report the number of renewals remaining to the patron
without doing (possibly erroneous) math in the template.  When the
circulation is renewed, we use the renewal remaining count from the
new circulation.  When the renewal fails, we use the number from the
original circulation.

The current template is not modified to add this field.  That is left
as an exercise for sites that want to add this information for the
convenience of their patrons.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor/Circ/AutoRenew.pm
docs/RELEASE_NOTES_NEXT/Circulation/autorenewnotify-renewal-field.adoc [new file with mode: 0644]

index a64d19c..f091995 100644 (file)
@@ -66,6 +66,7 @@ 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 %user_data = (
             copy => $_->target_copy(),
@@ -74,6 +75,7 @@ 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,
         );
 
         # 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
new file mode 100644 (file)
index 0000000..fdc2857
--- /dev/null
@@ -0,0 +1,14 @@
+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`:
+
+.................................................
+Renewals Remaining: [% udata.renewal_remaining %]
+.................................................
+