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
Number of associated cust_category (see L<FS::cust_category>)
+=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'
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.
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