From a69ac979dbf9b2dcdde579aea0b6ab72ccdc5f5d Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Fri, 30 Aug 2019 11:37:24 -0400 Subject: [PATCH] Lp 1835035: Refactor auto_renewal back end code Refactor the auto_renewal feature so that it works like other renewal types: opac_renewal, sip_renewal, etc. This refactor prevents desk_renewal from being set when auto_renewal is set. Deprecate the newly added open-ils.circ.renew.auto API and ensure that it still works as intended. Add release note indicating the deprecation of this API and intent to remove it in Evergreen 3.5. Modify the AutoRenew action trigger reactor to use the plain open-ils.circ.renew API with the auto_renewal option set to 1. Add database update script to cleanup (i.e. set to FALSE) the desk_renewal field on action.circulation and action.aged_circulation tables where auto_renewal is TRUE. Signed-off-by: Jason Stephenson Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Circ/Circulate.pm | 24 ++++++++++--------- .../Trigger/Reactor/Circ/AutoRenew.pm | 4 ++-- ...XXX.data.auto_renewal-not-desk_renewal.sql | 9 +++++++ .../auto-renew-api-deprecation.adoc | 6 +++++ 4 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.auto_renewal-not-desk_renewal.sql create mode 100644 docs/RELEASE_NOTES_NEXT/Circulation/auto-renew-api-deprecation.adoc diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 5c810d6826..d99d5259c4 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -128,6 +128,10 @@ __PACKAGE__->register_method( method => "run_method", api_name => "open-ils.circ.renew.auto", signature => q/@see open-ils.circ.renew/, + notes => q/ + The open-ils.circ.renew.auto API is deprecated. Please use the + auto_renew => 1 option to open-ils.circ.renew, instead. + / ); __PACKAGE__->register_method( @@ -244,7 +248,7 @@ sub run_method { } $circulator->is_renewal(1) if $api =~ /renew/; - $circulator->is_autorenewal(1) if $api =~ /renew.auto/; + $circulator->auto_renewal(1) if $api =~ /renew.auto/; $circulator->is_checkin(1) if $api =~ /checkin/; $circulator->is_checkout(1) if $api =~ /checkout/; $circulator->override(1) if $api =~ /override/o; @@ -435,7 +439,6 @@ my @AUTOLOAD_FIELDS = qw/ volume title is_renewal - is_autorenewal is_checkout is_res_checkout is_precat @@ -487,6 +490,7 @@ my @AUTOLOAD_FIELDS = qw/ phone_renewal desk_renewal sip_renewal + auto_renewal retarget matrix_test_result circ_matrix_matchpoint @@ -565,8 +569,9 @@ sub new { ($self->circ_lib) ? $self->circ_lib : $self->editor->requestor->ws_ou); # if this is a renewal, default to desk_renewal - $self->desk_renewal(1) unless - $self->opac_renewal or $self->phone_renewal or $self->sip_renewal; + $self->desk_renewal(1) unless + $self->opac_renewal or $self->phone_renewal or $self->sip_renewal + or $self->auto_renewal; $self->capture('') unless $self->capture; @@ -2155,13 +2160,10 @@ sub build_checkout_circ_object { $circ->opac_renewal('t') if $self->opac_renewal; $circ->phone_renewal('t') if $self->phone_renewal; $circ->desk_renewal('t') if $self->desk_renewal; + $circ->auto_renewal('t') if $self->auto_renewal; $circ->renewal_remaining($self->renewal_remaining); - $circ->circ_staff($self->editor->requestor->id); - } - - if ( $self->is_autorenewal ){ $circ->auto_renewal_remaining($self->auto_renewal_remaining); - $circ->auto_renewal('t'); + $circ->circ_staff($self->editor->requestor->id); } # if the user provided an overiding checkout time, @@ -4057,7 +4059,7 @@ sub do_renew { if $circ->renewal_remaining < 1; $self->push_events(OpenILS::Event->new('MAX_AUTO_RENEWALS_REACHED')) - if $api =~ /renew.auto/ and $circ->auto_renewal_remaining < 1; + if $self->auto_renewal and $circ->auto_renewal_remaining < 1; # ----------------------------------------------------------------- $self->parent_circ($circ->id); @@ -4066,7 +4068,7 @@ sub do_renew { $self->circ($circ); # Opac renewal - re-use circ library from original circ (unless told not to) - if($self->opac_renewal or $api =~ /renew.auto/) { + if($self->opac_renewal or $self->auto_renewal) { unless(defined($opac_renewal_use_circ_lib)) { my $use_circ_lib = $self->editor->retrieve_config_global_flag('circ.opac_renewal.use_original_circ_lib'); if($use_circ_lib and $U->is_true($use_circ_lib->enabled)) { 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 f06adc85e1..09dc0b18ae 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 @@ -53,12 +53,12 @@ sub handler { $logger->info( "AUTORENEW: circ.target_copy: " . Dumper($_->target_copy()) ); my $evt = $AppUtils->simplereq( 'open-ils.circ', - 'open-ils.circ.renew.auto', + 'open-ils.circ.renew', $token, { patron_id => $_->usr(), copy_id => $_->target_copy(), - opac_renewal => 0 + auto_renewal => 1 } ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auto_renewal-not-desk_renewal.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auto_renewal-not-desk_renewal.sql new file mode 100644 index 0000000000..0afb614fa1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.auto_renewal-not-desk_renewal.sql @@ -0,0 +1,9 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +UPDATE action.circulation SET desk_renewal = FALSE WHERE auto_renewal IS TRUE; + +UPDATE action.aged_circulation SET desk_renewal = FALSE WHERE auto_renewal IS TRUE; + +COMMIT; diff --git a/docs/RELEASE_NOTES_NEXT/Circulation/auto-renew-api-deprecation.adoc b/docs/RELEASE_NOTES_NEXT/Circulation/auto-renew-api-deprecation.adoc new file mode 100644 index 0000000000..8f3ae666ee --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Circulation/auto-renew-api-deprecation.adoc @@ -0,0 +1,6 @@ +open-ils.circ.renew.auto API Deprecated +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The open-ils.circ.renew.auto API added in release 3.2 is deprecated +and will be removed in Evergreen release 3.5. Please switch to using +the open-ils.circ.renew API with the auto_renew option set to 1 in any +custom code. -- 2.43.2