fix various thinkos and syntax errors to get the biz logic working
authorGalen Charlton <gmc@esilibrary.com>
Wed, 2 Dec 2015 22:49:01 +0000 (17:49 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 31 Aug 2017 16:20:59 +0000 (12:20 -0400)
As of now, open-ils.circ.checkin is now starting to emit
custom copy alerts.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index cb124fe..ea66588 100644 (file)
@@ -403,6 +403,7 @@ my @AUTOLOAD_FIELDS = qw/
     copy
     copy_id
     copy_barcode
+    new_copy_alerts
     user_copy_alerts
     system_copy_alerts
     next_copy_status
@@ -649,11 +650,11 @@ sub collect_user_copy_alerts {
 
     if($self->copy) {
         my $alerts = $e->search_asset_copy_alert([
-            {copy => $self->copy->id, ack_time => undef}
-            {flesh => 1, flesh_fields => { ccat => [ qw/ alert_type / ] }}
+            {copy => $self->copy->id, ack_time => undef},
+            {flesh => 1, flesh_fields => { aca => [ qw/ alert_type / ] }}
         ]);
         if (ref $alerts eq "ARRAY") {
-            $logger->info("circulator: found " . scalar(@$alerts) . " alerts for copy" .
+            $logger->info("circulator: found " . scalar(@$alerts) . " alerts for copy " .
                 $self->copy->id);
             $self->user_copy_alerts($alerts);
         }
@@ -663,6 +664,8 @@ sub collect_user_copy_alerts {
 sub filter_user_copy_alerts {
     my $self = shift;
 
+    my $e = $self->editor;
+
     if(my $alerts = $self->user_copy_alerts) {
 
         my $suppress_orgs = $U->get_org_descendants($self->circ_lib);
@@ -684,7 +687,7 @@ sub filter_user_copy_alerts {
 
             # filter on "only at circ lib"
             if (defined $a->alert_type->at_circ) {
-                my $copy_circ_lib = (ref $self->copy->circ_lib) ? 
+                my $copy_circ_lib = (ref $self->copy->circ_lib) ?
                     $self->copy->circ_lib->id : $self->copy->circ_lib;
                 my $orgs = $U->get_org_descendants($copy_circ_lib);
 
@@ -697,11 +700,11 @@ sub filter_user_copy_alerts {
 
             # filter on "only at owning lib"
             if (defined $a->alert_type->at_owning) {
-                my $copy_owning_lib = (ref $self->volume->owning_lib) ? 
+                my $copy_owning_lib = (ref $self->volume->owning_lib) ?
                     $self->volume->owning_lib->id : $self->volume->owning_lib;
                 my $orgs = $U->get_org_descendants($copy_owning_lib);
 
-                if ($U->is_true($a-->alert_type>invert_location)) {
+                if ($U->is_true($a->alert_type->invert_location)) {
                     next if (grep {$_ == $copy_owning_lib} @$orgs);
                 } else {
                     next unless (grep {$_ == $copy_owning_lib} @$orgs);
@@ -736,7 +739,7 @@ sub generate_system_copy_alerts {
 
     my $alert_orgs = $U->get_org_ancestors($self->circ_lib);
     my $alert_types = $e->search_config_copy_alert_type({
-        active    => 't'
+        active    => 't',
         scope_org => $alert_orgs,
         event     => $event,
         state => $self->copy_state,
@@ -747,7 +750,7 @@ sub generate_system_copy_alerts {
     foreach my $a (@$alert_types) {
         # filter on "only at circ lib"
         if (defined $a->at_circ) {
-            my $copy_circ_lib = (ref $self->copy->circ_lib) ? 
+            my $copy_circ_lib = (ref $self->copy->circ_lib) ?
                 $self->copy->circ_lib->id : $self->copy->circ_lib;
             my $orgs = $U->get_org_descendants($copy_circ_lib);
 
@@ -760,7 +763,7 @@ sub generate_system_copy_alerts {
 
         # filter on "only at owning lib"
         if (defined $a->at_owning) {
-            my $copy_owning_lib = (ref $self->volume->owning_lib) ? 
+            my $copy_owning_lib = (ref $self->volume->owning_lib) ?
                 $self->volume->owning_lib->id : $self->volume->owning_lib;
             my $orgs = $U->get_org_descendants($copy_owning_lib);
 
@@ -783,7 +786,7 @@ sub generate_system_copy_alerts {
     foreach my $t (@final_types) {
         $t->next_status($U->unique_unnested_numbers($t->next_status));
 
-        my $alert = new Fieldmapper::asset::copy_alert;
+        my $alert = new Fieldmapper::asset::copy_alert ();
         $alert->alert_type($t->id);
         $alert->copy($self->copy->id);
         $alert->temp(1);
@@ -1390,10 +1393,10 @@ sub check_copy_alert {
 
     if ($self->new_copy_alerts) {
         my @alerts;
-        push @alerts, @{$self->user_copy_alerts}) # we have preexisting alerts 
+        push @alerts, @{$self->user_copy_alerts} # we have preexisting alerts 
             if ($self->user_copy_alerts && @{$self->user_copy_alerts});
 
-        push @alerts, @{$self->system_copy_alerts}) # we have new dynamic alerts 
+        push @alerts, @{$self->system_copy_alerts} # we have new dynamic alerts 
             if ($self->system_copy_alerts && @{$self->system_copy_alerts});
 
         if (@alerts) {