ACL for hardware class config, RT#85057
[freeside.git] / FS / FS / cust_tax_exempt.pm
1 package FS::cust_tax_exempt;
2 use base qw( FS::cust_main_Mixin FS::Record );
3
4 use strict;
5
6 =head1 NAME
7
8 FS::cust_tax_exempt - Object methods for cust_tax_exempt records
9
10 =head1 SYNOPSIS
11
12   use FS::cust_tax_exempt;
13
14   $record = new FS::cust_tax_exempt \%hash;
15   $record = new FS::cust_tax_exempt { 'column' => 'value' };
16
17   $error = $record->insert;
18
19   $error = $new_record->replace($old_record);
20
21   $error = $record->delete;
22
23   $error = $record->check;
24
25 =head1 DESCRIPTION
26
27 An FS::cust_tax_exempt object represents a record of an old-style customer tax
28 exemption.  Currently this is only used for "texas tax".  FS::cust_tax_exempt
29 inherits from FS::Record.  The following fields are currently supported:
30
31 =over 4
32
33 =item exemptnum - primary key
34
35 =item custnum - customer (see L<FS::cust_main>)
36
37 =item taxnum - tax rate (see L<FS::cust_main_county>)
38
39 =item year
40
41 =item month
42
43 =item amount
44
45 =back
46
47 =head1 NOTE
48
49 Old-style customer tax exemptions are only useful for legacy migrations - if
50 you are looking for current customer tax exemption data see
51 L<FS::cust_tax_exempt_pkg>.
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new exemption record.  To add the example to the database, see
60 L<"insert">.
61
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to.  You can ask the object for a copy with the I<hash> method.
64
65 =cut
66
67 # the new method can be inherited from FS::Record, if a table method is defined
68
69 sub table { 'cust_tax_exempt'; }
70
71 =item insert
72
73 Adds this record to the database.  If there is an error, returns the error,
74 otherwise returns false.
75
76 =cut
77
78 # the insert method can be inherited from FS::Record
79
80 =item delete
81
82 Delete this record from the database.
83
84 =cut
85
86 # the delete method can be inherited from FS::Record
87
88 =item replace OLD_RECORD
89
90 Replaces the OLD_RECORD with this one in the database.  If there is an error,
91 returns the error, otherwise returns false.
92
93 =cut
94
95 # the replace method can be inherited from FS::Record
96
97 =item check
98
99 Checks all fields to make sure this is a valid example.  If there is
100 an error, returns the error, otherwise returns false.  Called by the insert
101 and replace methods.
102
103 =cut
104
105 # the check method should currently be supplied - FS::Record contains some
106 # data checking routines
107
108 sub check {
109   my $self = shift;
110
111   $self->ut_numbern('exemptnum')
112     || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
113     || $self->ut_foreign_key('taxnum', 'cust_main_county', 'taxnum')
114     || $self->ut_number('year') #check better
115     || $self->ut_number('month') #check better
116     || $self->ut_money('amount')
117     || $self->SUPER::check
118   ;
119 }
120
121 =item cust_main_county
122
123 Returns the FS::cust_main_county object associated with this tax exemption.
124
125 =back
126
127 =head1 BUGS
128
129 Texas tax is a royal pain in the ass.
130
131 =head1 SEE ALSO
132
133 L<FS::cust_main_county>, L<FS::cust_main>, L<FS::Record>, schema.html from the
134 base documentation.
135
136 =cut
137
138 1;
139