X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_class.pm;h=a71bc16bf8d6449e9b3e5f5b4780d101ac3e4e3a;hb=b0888dc8399fc4e8d75c874c00d01366eacf5596;hp=a811be7a70797989a2080d606504d80adb4dbd01;hpb=b5c4237a34aef94976bc343c8d9e138664fc3984;p=freeside.git diff --git a/FS/FS/cust_class.pm b/FS/FS/cust_class.pm index a811be7a7..a71bc16bf 100644 --- a/FS/FS/cust_class.pm +++ b/FS/FS/cust_class.pm @@ -1,9 +1,9 @@ package FS::cust_class; +use base qw( FS::class_Common ); use strict; -use base qw( FS::class_Common ); -use FS::cust_main; use FS::cust_category; +use FS::Record qw( dbh ); =head1 NAME @@ -44,6 +44,11 @@ Text name of this customer class Number of associated cust_category (see L) +=item tax + +Tax exempt flag, empty or 'Y'. Used when the cust_class-tax_exempt +configuration setting is turned on. + =item disabled Disabled flag, empty or 'Y' @@ -86,9 +91,17 @@ Checks all fields to make sure this is a valid customer class. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. -=item cust_category +=cut -=item category +sub check { + my $self = shift; + + $self->ut_enum('tax', [ '', 'Y' ]) + || $self->SUPER::check; + +} + +=item cust_category Returns the cust_category record associated with this class, or false if there is none. @@ -105,8 +118,35 @@ sub cust_category { Returns the category name associated with this class, or false if there is none. +=item num_prospect + +=item num_ordered + +=item num_active + +=item num_inactive + +=item num_suspended + +=item num_cancelled + =cut +sub num_sql { + my( $self, $sql ) = @_; + my $statement = "SELECT COUNT(*) FROM cust_main WHERE classnum = ? AND $sql"; + my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; + $sth->execute($self->classnum) or die $sth->errstr. " executing $statement"; + $sth->fetchrow_arrayref->[0]; +} + +sub num_prospect { shift->num_sql(FS::cust_main->prospect_sql) } +sub num_ordered { shift->num_sql(FS::cust_main->ordered_sql) } +sub num_active { shift->num_sql(FS::cust_main->active_sql) } +sub num_inactive { shift->num_sql(FS::cust_main->inactive_sql) } +sub num_suspended { shift->num_sql(FS::cust_main->susp_sql) } +sub num_cancelled { shift->num_sql(FS::cust_main->cancel_sql) } + =back =head1 BUGS