Online Renewal - Remove perm group ID references
authorTerran McCanna <tmccanna@georgialibraries.org>
Tue, 22 Nov 2022 22:04:47 +0000 (17:04 -0500)
committerJason Stephenson <jstephenson@cwmars.org>
Tue, 29 Nov 2022 20:10:21 +0000 (15:10 -0500)
Look up permission groups by name or by e-renewal eligibility flag
instead of by specific permission group ID.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Ecard.pm

index a38f893..c4a9d46 100644 (file)
@@ -3563,6 +3563,8 @@ sub has_penalties {
     my $ctx = $self->ctx;
     my $user = $self->ctx->{user};
     my $e = new_editor(xact => 1);
+    
+    #I'm sure there is a way to combine the following standing penalty checks, but this is working for now
 
     #check for INVALID_PATRON_ADDRESS
     my $findpenalty_address = $e->search_config_standing_penalty({name => 'INVALID_PATRON_ADDRESS'})->[0];
@@ -3641,8 +3643,9 @@ sub check_account_exp {
     $self->update_dashboard_stats();
 
     #make sure patron is in an eligible perm group for renewal
-    #On gapines.org production: 2 = Patron, 14 = Friend, 56 = GLS, 53 = Homebound, 22 = Trustee, 64 = Quipu, 60 = Digital Only
-    if ($ctx->{user}->profile eq '2' || $ctx->{user}->profile eq '14' || $ctx->{user}->profile eq '56' || $ctx->{user}->profile eq '53' || $ctx->{user}->profile eq '22' || $ctx->{user}->profile eq '64' || $ctx->{user}->profile eq '60') {
+    my $grp = new_editor()->retrieve_permission_grp_tree($ctx->{user}->profile);
+
+    if ($grp->erenew eq 't') {
         $ctx->{eligible_permgroup} = 1;
     } else {
         $ctx->{eligible_permgroup} = 0;
index 5002d44..6852d42 100644 (file)
@@ -542,19 +542,18 @@ sub update_user {
     }
 
     # Temp renewal is only 30 days, otherwise use perm_interval
-    # If perm group is Homebound (53) or GLS (56), allow full renewal
+    # If perm group is Homebound or GLS, allow full renewal
     my $temp_renewal = $cgi->param('temp_renewal');
-    my $perm_grp = $au->profile;
+    my $grp = new_editor()->retrieve_permission_grp_tree($au->profile);
 
-    if ($temp_renewal eq '1' && $perm_grp ne '53' && $perm_grp ne '56') {
+    if ($temp_renewal eq '1' && $grp->name ne 'GLS' && $grp->name ne 'Homebound') {
         $au->expire_date(
             DateTime->now(time_zone => 'local')->add(
                 seconds => interval_to_seconds('30 days'))->iso8601()
         );
-        # Add standing penalty to account
+        # Add temp renewal standing penalty to account
         $self->apply_temp_renewal_penalty;
     } else {
-        my $grp = new_editor()->retrieve_permission_grp_tree($perm_grp);
         $au->expire_date(
             DateTime->now(time_zone => 'local')->add(
                 seconds => interval_to_seconds($grp->perm_interval))->iso8601()