From: Galen Charlton Date: Wed, 31 Aug 2016 21:02:17 +0000 (-0400) Subject: teach copy alerts how to automatically generate certain overrides X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1de20f8f9604795455796f49fd45014b8d95a2a5;p=working%2FEvergreen.git teach copy alerts how to automatically generate certain overrides When a new-style copy alert type is active but supressed, any system-generated events of that type should be recorded but not present a pop-up. In some cases, an older-style circ event make get generated; this patch supplies a way for the new copy alerts to override the old-style events without having to sprinkle a bunch of special checks. Signed-off-by: Galen Charlton Signed-off-by: Galen Charlton --- 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 2f6f9c2656..a8b7b83c9d 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -40,6 +40,12 @@ my $MK_ENV_FLESH = { flesh_fields => {acp => ['call_number','parts','floating'], acn => ['record']} }; +# table of cases where suppressing a system-generated copy alerts +# should generate an override of an old-style event +my %COPY_ALERT_OVERRIDES = ( + "CLAIMSRETURNED\tCHECKOUT" => 'CIRC_CLAIMS_RETURNED', +); + sub initialize {} __PACKAGE__->register_method( @@ -406,6 +412,7 @@ my @AUTOLOAD_FIELDS = qw/ new_copy_alerts user_copy_alerts system_copy_alerts + overrides_per_copy_alerts next_copy_status copy_state patron @@ -792,6 +799,11 @@ sub generate_system_copy_alerts { } my @alerts; + + # keep track of conditions corresponding to suppressed + # system alerts, as these may be used to overridee + # certain old-style-events + my %auto_override_conditions = (); foreach my $t (@final_types) { $t->next_status([$U->unique_unnested_numbers($t->next_status)]) if ($t->next_status); @@ -812,10 +824,25 @@ sub generate_system_copy_alerts { $alert->alert_type($t->clone); push(@{$self->next_copy_status}, @{$t->next_status}) if ($t->next_status); + if (grep {$_->alert_type == $t->id} @$suppressions) { + $auto_override_conditions{join("\t", $t->state, $t->event)} = 1; + } push(@alerts, $alert) unless (grep {$_->alert_type == $t->id} @$suppressions); } $self->system_copy_alerts(\@alerts); + $self->overrides_per_copy_alerts(\%auto_override_conditions); +} + +sub add_overrides_from_system_copy_alerts { + my $self = shift; + + foreach my $condition (keys %{$self->overrides_per_copy_alerts()}) { + if (exists $COPY_ALERT_OVERRIDES{$condition}) { + $self->override(1); + push @{$self->override_args->{events}}, $COPY_ALERT_OVERRIDES{$condition}; + } + } } sub mk_env { @@ -882,6 +909,7 @@ sub mk_env { ); $self->generate_system_copy_alerts; + $self->add_overrides_from_system_copy_alerts; $self->collect_user_copy_alerts; $self->filter_user_copy_alerts;