have the UI use full country names, and state names outside the US...
[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_main_Mixin;
7 use FS::cust_bill_pkg;
8 use FS::cust_main_county;
9
10 @ISA = qw( FS::cust_main_Mixin FS::Record );
11
12 =head1 NAME
13
14 FS::cust_tax_exempt_pkg - Object methods for cust_tax_exempt_pkg records
15
16 =head1 SYNOPSIS
17
18   use FS::cust_tax_exempt_pkg;
19
20   $record = new FS::cust_tax_exempt_pkg \%hash;
21   $record = new FS::cust_tax_exempt_pkg { 'column' => 'value' };
22
23   $error = $record->insert;
24
25   $error = $new_record->replace($old_record);
26
27   $error = $record->delete;
28
29   $error = $record->check;
30
31 =head1 DESCRIPTION
32
33 An FS::cust_tax_exempt_pkg object represents a record of a customer tax
34 exemption.  Currently this is only used for "texas tax".  FS::cust_tax_exempt
35 inherits from FS::Record.  The following fields are currently supported:
36
37 =over 4
38
39 =item exemptpkgnum - primary key
40
41 =item billpkgnum - invoice line item (see L<FS::cust_bill_pkg>)
42
43 =item taxnum - tax rate (see L<FS::cust_main_county>)
44
45 =item year
46
47 =item month
48
49 =item amount
50
51 =back
52
53 =head1 METHODS
54
55 =over 4
56
57 =item new HASHREF
58
59 Creates a new exemption record.  To add the examption record to the database,
60 see 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_pkg'; }
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 exemption record.  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('billpkgnum', 'cust_bill_pkg', 'billpkgnum')
114     || $self->ut_foreign_key('taxnum', 'cust_main_county', 'taxnum')
115     || $self->ut_number('year') #check better
116     || $self->ut_number('month') #check better
117     || $self->ut_money('amount')
118     || $self->SUPER::check
119   ;
120 }
121
122 =back
123
124 =head1 BUGS
125
126 Texas tax is still a royal pain in the ass.
127
128 =head1 SEE ALSO
129
130 L<FS::cust_main_county>, L<FS::cust_bill_pkg>, L<FS::Record>, schema.html from
131 the base documentation.
132
133 =cut
134
135 1;
136