invoice voiding, RT#18677
[freeside.git] / FS / FS / cust_bill_pkg_void.pm
1 package FS::cust_bill_pkg_void;
2 use base qw( FS::TemplateItem_Mixin FS::Record );
3
4 use strict;
5 use FS::Record qw( qsearch qsearchs );
6 use FS::cust_bill_void;
7 use FS::cust_bill_pkg_detail_void;
8 use FS::cust_bill_pkg_display_void;
9 use FS::cust_bill_pkg_discount_void;
10
11 =head1 NAME
12
13 FS::cust_bill_pkg_void - Object methods for cust_bill_pkg_void records
14
15 =head1 SYNOPSIS
16
17   use FS::cust_bill_pkg_void;
18
19   $record = new FS::cust_bill_pkg_void \%hash;
20   $record = new FS::cust_bill_pkg_void { '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_bill_pkg_void object represents a voided invoice line item.
33 FS::cust_bill_pkg_void inherits from FS::Record.  The following fields are
34 currently supported:
35
36 =over 4
37
38 =item billpkgnum
39
40 primary key
41
42 =item invnum
43
44 invnum
45
46 =item pkgnum
47
48 pkgnum
49
50 =item pkgpart_override
51
52 pkgpart_override
53
54 =item setup
55
56 setup
57
58 =item recur
59
60 recur
61
62 =item sdate
63
64 sdate
65
66 =item edate
67
68 edate
69
70 =item itemdesc
71
72 itemdesc
73
74 =item itemcomment
75
76 itemcomment
77
78 =item section
79
80 section
81
82 =item freq
83
84 freq
85
86 =item quantity
87
88 quantity
89
90 =item unitsetup
91
92 unitsetup
93
94 =item unitrecur
95
96 unitrecur
97
98 =item hidden
99
100 hidden
101
102
103 =back
104
105 =head1 METHODS
106
107 =over 4
108
109 =item new HASHREF
110
111 Creates a new record.  To add the record to the database, see L<"insert">.
112
113 Note that this stores the hash reference, not a distinct copy of the hash it
114 points to.  You can ask the object for a copy with the I<hash> method.
115
116 =cut
117
118 sub table { 'cust_bill_pkg_void'; }
119
120 sub detail_table            { 'cust_bill_pkg_detail_void'; }
121 sub display_table           { 'cust_bill_pkg_display_void'; }
122 sub discount_table          { 'cust_bill_pkg_discount_void'; }
123 #sub tax_location_table      { 'cust_bill_pkg_tax_location'; }
124 #sub tax_rate_location_table { 'cust_bill_pkg_tax_rate_location'; }
125 #sub tax_exempt_pkg_table    { 'cust_tax_exempt_pkg'; }
126
127 =item insert
128
129 Adds this record to the database.  If there is an error, returns the error,
130 otherwise returns false.
131
132 =cut
133
134 =item delete
135
136 Delete this record from the database.
137
138 =cut
139
140 =item replace OLD_RECORD
141
142 Replaces the OLD_RECORD with this one in the database.  If there is an error,
143 returns the error, otherwise returns false.
144
145 =cut
146
147 =item check
148
149 Checks all fields to make sure this is a valid record.  If there is
150 an error, returns the error, otherwise returns false.  Called by the insert
151 and replace methods.
152
153 =cut
154
155 sub check {
156   my $self = shift;
157
158   my $error = 
159     $self->ut_number('billpkgnum')
160     || $self->ut_snumber('pkgnum')
161     || $self->ut_number('invnum') #cust_bill or cust_bill_void, if we ever support line item voiding
162     || $self->ut_numbern('pkgpart_override')
163     || $self->ut_money('setup')
164     || $self->ut_money('recur')
165     || $self->ut_numbern('sdate')
166     || $self->ut_numbern('edate')
167     || $self->ut_textn('itemdesc')
168     || $self->ut_textn('itemcomment')
169     || $self->ut_textn('section')
170     || $self->ut_textn('freq')
171     || $self->ut_numbern('quantity')
172     || $self->ut_moneyn('unitsetup')
173     || $self->ut_moneyn('unitrecur')
174     || $self->ut_enum('hidden', [ '', 'Y' ])
175   ;
176   return $error if $error;
177
178   $self->SUPER::check;
179 }
180
181 =item cust_bill
182
183 Returns the voided invoice (see L<FS::cust_bill_void>) for this voided line
184 item.
185
186 =cut
187
188 sub cust_bill {
189   my $self = shift;
190   #cust_bill or cust_bill_void, if we ever support line item voiding
191   qsearchs( 'cust_bill_void', { 'invnum' => $self->invnum } );
192 }
193
194 =back
195
196 =head1 BUGS
197
198 =head1 SEE ALSO
199
200 L<FS::Record>, schema.html from the base documentation.
201
202 =cut
203
204 1;
205