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