add skip_dcontext_suffix to skip CDRs with dcontext ending in a definable string...
[freeside.git] / FS / FS / cust_class.pm
1 package FS::cust_class;
2 use base qw( FS::class_Common );
3
4 use strict;
5 use FS::cust_category;
6
7 =head1 NAME
8
9 FS::cust_class - Object methods for cust_class records
10
11 =head1 SYNOPSIS
12
13   use FS::cust_class;
14
15   $record = new FS::cust_class \%hash;
16   $record = new FS::cust_class { 'column' => 'value' };
17
18   $error = $record->insert;
19
20   $error = $new_record->replace($old_record);
21
22   $error = $record->delete;
23
24   $error = $record->check;
25
26 =head1 DESCRIPTION
27
28 An FS::pkg_class object represents an customer class.  Every customer (see
29 L<FS::cust_main>) has, optionally, a customer class. FS::cust_class inherits
30 from FS::Record.  The following fields are currently supported:
31
32 =over 4
33
34 =item classnum
35
36 primary key
37
38 =item classname
39
40 Text name of this customer class
41
42 =item categorynum
43
44 Number of associated cust_category (see L<FS::cust_category>)
45
46 =item tax
47
48 Tax exempt flag, empty or 'Y'.  Used when the cust_class-tax_exempt
49 configuration setting is turned on.
50
51 =item disabled
52
53 Disabled flag, empty or 'Y'
54
55 =back
56
57 =head1 METHODS
58
59 =over 4
60
61 =item new HASHREF
62
63 Creates a new customer class.  To add the customer class to the database, see
64 L<"insert">.
65
66 =cut
67
68 sub table { 'cust_class'; }
69 sub _target_table { 'cust_main'; }
70
71 =item insert
72
73 Adds this customer class to the database.  If there is an error, returns the
74 error, otherwise returns false.
75
76 =item delete
77
78 Delete this customer class from the database.  Only customer classes with no
79 associated customers can be deleted.  If there is an error, returns
80 the error, otherwise returns false.
81
82 =item replace [ OLD_RECORD ]
83
84 Replaces OLD_RECORD with this one in the database.  If there is an error,
85 returns the error, otherwise returns false.
86
87 =item check
88
89 Checks all fields to make sure this is a valid customer class.  If there is
90 an error, returns the error, otherwise returns false.  Called by the insert
91 and replace methods.
92
93 =cut
94
95 sub check {
96   my $self = shift;
97
98      $self->ut_enum('tax', [ '', 'Y' ])
99   || $self->SUPER::check;
100
101 }
102
103 =item cust_category
104
105 Returns the cust_category record associated with this class, or false if there
106 is none.
107
108 =cut
109
110 sub cust_category {
111   my $self = shift;
112   $self->category;
113 }
114
115 =item categoryname
116
117 Returns the category name associated with this class, or false if there
118 is none.
119
120 =cut
121
122 =back
123
124 =head1 BUGS
125
126 =head1 SEE ALSO
127
128 L<FS::cust_main>, L<FS::Record>
129
130 =cut
131
132 1;