change texas-style tax exemptions to be against a specific line item rather than...
[freeside.git] / FS / FS / cust_tax_exempt_pkg.pm
1 package FS::cust_tax_exempt_pkg;
2
3 use strict;
4 use vars qw( @ISA );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::cust_bill_pkg;
7 use FS::cust_main_county;
8
9 @ISA = qw(FS::Record);
10
11 =head1 NAME
12
13 FS::cust_tax_exempt_pkg - Object methods for cust_tax_exempt_pkg records
14
15 =head1 SYNOPSIS
16
17   use FS::cust_tax_exempt_pkg;
18
19   $record = new FS::cust_tax_exempt_pkg \%hash;
20   $record = new FS::cust_tax_exempt_pkg { '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_pkg object represents a record of a 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 exemptpkgnum - primary key
39
40 =item billpkgnum - invoice line item (see L<FS::cust_bill_pkg>)
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 METHODS
53
54 =over 4
55
56 =item new HASHREF
57
58 Creates a new exemption record.  To add the example to the database, see
59 L<"insert">.
60
61 Note that this stores the hash reference, not a distinct copy of the hash it
62 points to.  You can ask the object for a copy with the I<hash> method.
63
64 =cut
65
66 # the new method can be inherited from FS::Record, if a table method is defined
67
68 sub table { 'cust_tax_exempt_pkg'; }
69
70 =item insert
71
72 Adds this record to the database.  If there is an error, returns the error,
73 otherwise returns false.
74
75 =cut
76
77 # the insert method can be inherited from FS::Record
78
79 =item delete
80
81 Delete this record from the database.
82
83 =cut
84
85 # the delete method can be inherited from FS::Record
86
87 =item replace OLD_RECORD
88
89 Replaces the OLD_RECORD with this one in the database.  If there is an error,
90 returns the error, otherwise returns false.
91
92 =cut
93
94 # the replace method can be inherited from FS::Record
95
96 =item check
97
98 Checks all fields to make sure this is a valid example.  If there is
99 an error, returns the error, otherwise returns false.  Called by the insert
100 and replace methods.
101
102 =cut
103
104 # the check method should currently be supplied - FS::Record contains some
105 # data checking routines
106
107 sub check {
108   my $self = shift;
109
110   $self->ut_numbern('exemptnum')
111 #    || $self->ut_foreign_key('custnum', 'cust_main', 'custnum')
112     || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
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 =back
122
123 =head1 BUGS
124
125 Texas tax is still a royal pain in the ass.
126
127 =head1 SEE ALSO
128
129 L<FS::cust_main_county>, L<FS::cust_bill_pkg>, L<FS::Record>, schema.html from
130 the base documentation.
131
132 =cut
133
134 1;
135