X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=621a554102038d2bba696ff950e19c5249b197b4;hb=19c77bd46e3d0155b9f2a1afb7a3c488bc050f65;hp=612c59013c3d7b04d51e44e8fae6d230fb3145c1;hpb=4551d052fce2c17e7c03e01ee66d2f91096f8649;p=freeside.git diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 612c59013..621a55410 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -590,6 +590,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.