X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=621a554102038d2bba696ff950e19c5249b197b4;hb=3cbdd85a96348a287623e3b97c937c7749e99392;hp=612c59013c3d7b04d51e44e8fae6d230fb3145c1;hpb=c4c8512adc83e2c6e6640112735e887b71222e1d;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.