X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=884e3ad803fcf16d06d05e928db99da9f898698f;hb=24a8ce8e5163b2916503c277854aba96ca52a047;hp=aba3ead4096da9191786ad8b2213c9b72c6aa488;hpb=aea97dbd5c5ac96c4610b112e55f64da66028ef6;p=freeside.git diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index aba3ead40..884e3ad80 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -586,6 +586,26 @@ sub num_cust_svc { $sth->fetchrow_arrayref->[0]; } +=item num_cust_svc_cancelled + +Returns the number of associated customer services that are +attached to cancelled packages. + +=cut + +sub num_cust_svc_cancelled { + my $self = shift; + my $sth = dbh->prepare( + "SELECT COUNT(*) FROM cust_svc + LEFT JOIN cust_pkg USING ( pkgnum ) + WHERE svcpart = ? + AND cust_pkg.cancel IS NOT NULL" + ) or die dbh->errstr; + $sth->execute($self->svcpart) + or die $sth->errstr; + $sth->fetchrow_arrayref->[0]; +} + =item svc_x Returns a list of associated FS::svc_* records.