RT# 31208 Docs $FS::Record::qsearch_qualify_columns
[freeside.git] / FS / FS / cust_tax_exempt_pkg_void.pm
1 package FS::cust_tax_exempt_pkg_void;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record; # qw( qsearch qsearchs );
6 use FS::cust_bill_pkg_void;
7 use FS::cust_main_county;
8
9 =head1 NAME
10
11 FS::cust_tax_exempt_pkg_void - Object methods for cust_tax_exempt_pkg_void records
12
13 =head1 SYNOPSIS
14
15   use FS::cust_tax_exempt_pkg_void;
16
17   $record = new FS::cust_tax_exempt_pkg_void \%hash;
18   $record = new FS::cust_tax_exempt_pkg_void { 'column' => 'value' };
19
20   $error = $record->insert;
21
22   $error = $new_record->replace($old_record);
23
24   $error = $record->delete;
25
26   $error = $record->check;
27
28 =head1 DESCRIPTION
29
30 An FS::cust_tax_exempt_pkg_void object represents a voided record of a customer
31 tax exemption.  FS::cust_tax_exempt_pkg_void inherits from FS::Record.  The
32 following fields are currently supported:
33
34 =over 4
35
36 =item exemptpkgnum
37
38 primary key
39
40 =item billpkgnum
41
42 billpkgnum
43
44 =item taxnum
45
46 taxnum
47
48 =item year
49
50 year
51
52 =item month
53
54 month
55
56 =item creditbillpkgnum
57
58 creditbillpkgnum
59
60 =item amount
61
62 amount
63
64
65 =back
66
67 =head1 METHODS
68
69 =over 4
70
71 =item new HASHREF
72
73 Creates a new record.  To add the record to the database, see L<"insert">.
74
75 Note that this stores the hash reference, not a distinct copy of the hash it
76 points to.  You can ask the object for a copy with the I<hash> method.
77
78 =cut
79
80 sub table { 'cust_tax_exempt_pkg_void'; }
81
82 =item insert
83
84 Adds this record to the database.  If there is an error, returns the error,
85 otherwise returns false.
86
87 =cut
88
89 =item delete
90
91 Delete this record from the database.
92
93 =cut
94
95 =item replace OLD_RECORD
96
97 Replaces the OLD_RECORD with this one in the database.  If there is an error,
98 returns the error, otherwise returns false.
99
100 =cut
101
102 =item check
103
104 Checks all fields to make sure this is a valid record.  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 sub check {
111   my $self = shift;
112
113   my $error =
114     $self->ut_number('exemptpkgnum')
115     || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg_void', 'billpkgnum' )
116     || $self->ut_enum('taxtype', [ 'FS::cust_main_county', 'FS::tax_rate' ])
117     || $self->ut_number('taxnum')
118     || $self->ut_numbern('year')
119     || $self->ut_numbern('month')
120     || $self->ut_numbern('creditbillpkgnum') #no FK check, will have been del'ed
121     || $self->ut_money('amount')
122     || $self->ut_flag('exempt_cust')
123     || $self->ut_flag('exempt_setup')
124     || $self->ut_flag('exempt_recur')
125     || $self->ut_flag('exempt_cust_taxname')
126     || $self->ut_flag('exempt_monthly')
127   ;
128
129   $self->get('taxtype') =~ /^FS::(\w+)$/; 
130   my $rate_table = $1;
131   $error ||= $self->ut_foreign_key('taxnum', $rate_table, 'taxnum');
132
133   return $error if $error;
134
135   $self->SUPER::check;
136 }
137
138 =back
139
140 =head1 BUGS
141
142 =head1 SEE ALSO
143
144 L<FS::Record>, schema.html from the base documentation.
145
146 =cut
147
148 1;
149