X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=44fb8d6966e4805a268a5c6ee8f13b1e0a0a281d;hb=f7afca1829f8496509d10806439c37fcc1349135;hp=34ca9d4afafe43de0f11445562f367487b53f035;hpb=3beb53d9d87b5667c306dc4abd6cd6c0165ad852;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 34ca9d4af..44fb8d696 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1009,6 +1009,27 @@ sub unsuspended_pkgs { grep { ! $_->susp } $self->ncancelled_pkgs; } +=item num_cancelled_pkgs + +Returns the number of cancelled packages (see L) for this +customer. + +=cut + +sub num_cancelled_pkgs { + my $self = shift; + $self->num_pkgs("cancel IS NOT NULL AND cust_pkg.cancel != 0"); +} + +sub num_pkgs { + my( $self, $sql ) = @_; + my $sth = dbh->prepare( + "SELECT COUNT(*) FROM cust_pkg WHERE custnum = ? AND $sql" + ) or die dbh->errstr; + $sth->execute($self->custnum) or die $sth->errstr; + $sth->fetchrow_arrayref->[0]; +} + =item unsuspend Unsuspends all unflagged suspended packages (see L @@ -1582,6 +1603,7 @@ sub collect { my $error; { local $realtime_bop_decline_quiet = 1 if $options{'quiet'}; + local $SIG{__DIE__}; # don't want Mason __DIE__ handler active $error = eval $part_bill_event->eventcode; }