X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_event.pm;h=094c4fa8b3512316878ba1873ce799b1d8ac2a02;hb=e2a9dcac3b97254fc0a64ce3e2bf1ce582ce8162;hp=3edfaefde99bd6acab20684da942625a90e3e82e;hpb=46fe3dbcb3ca97d1f3c70d49351846cf0ab6461d;p=freeside.git diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm index 3edfaefde..094c4fa8b 100644 --- a/FS/FS/cust_event.pm +++ b/FS/FS/cust_event.pm @@ -12,7 +12,7 @@ use FS::cust_bill; use FS::cust_pay; use FS::svc_acct; -$DEBUG = 0; +$DEBUG = 1; $me = '[FS::cust_event]'; =head1 NAME @@ -245,7 +245,13 @@ sub do_event { $statustext = "Error running ". $part_event->action. " action: $@"; } elsif ( $error ) { $status = 'done'; - $statustext = $error; + if ( $error eq 'N/A' ) { + # archaic way to indicate no-op completion of spool_csv (and maybe + # other events)? + $self->no_action('Y'); + } else { + $statustext = $error; + } } else { $status = 'done'; } @@ -387,20 +393,28 @@ sub search_sql_where { #} # huh? - if ( $param->{'event_status'} ) { - + my @event_status = ref($param->{'event_status'}) + ? @{ $param->{'event_status'} } + : split(',', $param->{'event_status'}); + if ( @event_status ) { my @status; - my ($done_Y, $done_N); - foreach (@{ $param->{'event_status'} }) { + + my ($done_Y, $done_N, $done_S); + # done_Y: action was taken + # done_N: action was not taken + # done_S: status message returned + foreach (@event_status) { if ($_ eq 'done_Y') { $done_Y = 1; } elsif ( $_ eq 'done_N' ) { $done_N = 1; + } elsif ( $_ eq 'done_S' ) { + $done_S = 1; } else { push @status, $_; } } - if ( $done_Y or $done_N ) { + if ( $done_Y or $done_N or $done_S ) { push @status, 'done'; } if ( @status ) { @@ -409,12 +423,23 @@ sub search_sql_where { ')'; } - if ( $done_Y and not $done_N ) { - push @search, "cust_event.no_action IS NULL"; - } elsif ( $done_N and not $done_Y ) { - push @search, "cust_event.no_action = 'Y'"; - } # else they're both true, so don't add a constraint, or both false, - # and it doesn't matter. + # done_S status should include only those where statustext is not null, + # and done_Y should include only those where it is. + if ( $done_Y and $done_N and $done_S ) { + # then not necessary + } else { + my @done_status; + if ( $done_Y ) { + push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NULL)"; + } + if ( $done_N ) { + push @done_status, "(cust_event.no_action = 'Y')"; + } + if ( $done_S ) { + push @done_status, "(cust_event.no_action IS NULL AND cust_event.statustext IS NOT NULL)"; + } + push @search, join(' OR ', @done_status) if @done_status; + } } # event_status