X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=884e3ad803fcf16d06d05e928db99da9f898698f;hb=79129a414248ce263a8810ba7966bfdc82680674;hp=8a5fc35c9940d3fdc04a1f91f73d4efd4323dd91;hpb=9e6a4720dba6074864ad6464f663e161fd179052;p=freeside.git diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 8a5fc35c9..884e3ad80 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -561,6 +561,9 @@ is specified as B<0>, returns the number of unlinked customer services. sub num_cust_svc { my $self = shift; + return $self->{Hash}{num_cust_svc} + if !@_ && exists($self->{Hash}{num_cust_svc}); + my @param = ( $self->svcpart ); my( $join, $and ) = ( '', '' ); @@ -583,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.