X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_event.pm;h=2884f127862f1b39fd29e645be7fdde6072d9f65;hb=5f3b423601b5ddd7605e1eaf4bd838c0fd6f5fcf;hp=93743c44782d8bc8da53fb15ca391e999babc81c;hpb=8ff31f04ed1e2da3e09c56e72ab0f879d0b7ab75;p=freeside.git diff --git a/FS/FS/cust_event.pm b/FS/FS/cust_event.pm index 93743c447..2884f1278 100644 --- a/FS/FS/cust_event.pm +++ b/FS/FS/cust_event.pm @@ -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'; } @@ -309,11 +315,16 @@ sub join_sql { " JOIN part_event USING ( eventpart ) + LEFT JOIN cust_bill ON ( eventtable = 'cust_bill' AND tablenum = invnum ) LEFT JOIN cust_pkg ON ( eventtable = 'cust_pkg' AND tablenum = pkgnum ) LEFT JOIN cust_pay ON ( eventtable = 'cust_pay' AND tablenum = paynum ) + LEFT JOIN cust_pay_batch ON ( eventtable = 'cust_pay_batch' AND tablenum = paybatchnum ) + LEFT JOIN cust_statement ON ( eventtable = 'cust_statement' AND tablenum = cust_statement.statementnum ) + LEFT JOIN cust_svc ON ( eventtable = 'svc_acct' AND tablenum = svcnum ) LEFT JOIN cust_pkg AS cust_pkg_for_svc ON ( cust_svc.pkgnum = cust_pkg_for_svc.pkgnum ) + LEFT JOIN cust_main ON ( ( eventtable = 'cust_main' AND tablenum = cust_main.custnum ) OR ( eventtable = 'cust_bill' AND cust_bill.custnum = cust_main.custnum ) @@ -393,17 +404,22 @@ sub search_sql_where { if ( @event_status ) { my @status; - my ($done_Y, $done_N); + 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 ) { @@ -412,12 +428,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