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