1 package FS::cust_bill_pkg_void;
2 use base qw( FS::TemplateItem_Mixin FS::Record );
5 use FS::Record qw( qsearch qsearchs dbh fields );
6 use FS::cust_bill_void;
7 use FS::cust_bill_pkg_detail;
8 use FS::cust_bill_pkg_display;
9 use FS::cust_bill_pkg_discount;
10 use FS::cust_bill_pkg;
11 use FS::cust_bill_pkg_tax_location;
12 use FS::cust_bill_pkg_tax_rate_location;
13 use FS::cust_tax_exempt_pkg;
17 FS::cust_bill_pkg_void - Object methods for cust_bill_pkg_void records
21 use FS::cust_bill_pkg_void;
23 $record = new FS::cust_bill_pkg_void \%hash;
24 $record = new FS::cust_bill_pkg_void { 'column' => 'value' };
26 $error = $record->insert;
28 $error = $new_record->replace($old_record);
30 $error = $record->delete;
32 $error = $record->check;
36 An FS::cust_bill_pkg_void object represents a voided invoice line item.
37 FS::cust_bill_pkg_void inherits from FS::Record. The following fields are
54 =item pkgpart_override
115 Creates a new record. To add the record to the database, see L<"insert">.
117 Note that this stores the hash reference, not a distinct copy of the hash it
118 points to. You can ask the object for a copy with the I<hash> method.
122 sub table { 'cust_bill_pkg_void'; }
124 sub detail_table { 'cust_bill_pkg_detail_void'; }
125 sub display_table { 'cust_bill_pkg_display_void'; }
126 sub discount_table { 'cust_bill_pkg_discount_void'; }
127 #sub tax_location_table { 'cust_bill_pkg_tax_location'; }
128 #sub tax_rate_location_table { 'cust_bill_pkg_tax_rate_location'; }
129 #sub tax_exempt_pkg_table { 'cust_tax_exempt_pkg'; }
133 Adds this record to the database. If there is an error, returns the error,
134 otherwise returns false.
138 "Un-void"s this line item: Deletes the voided line item from the database and
139 adds back a normal line item (and related tables).
146 local $SIG{HUP} = 'IGNORE';
147 local $SIG{INT} = 'IGNORE';
148 local $SIG{QUIT} = 'IGNORE';
149 local $SIG{TERM} = 'IGNORE';
150 local $SIG{TSTP} = 'IGNORE';
151 local $SIG{PIPE} = 'IGNORE';
153 my $oldAutoCommit = $FS::UID::AutoCommit;
154 local $FS::UID::AutoCommit = 0;
157 my $cust_bill_pkg = new FS::cust_bill_pkg ( {
158 map { $_ => $self->get($_) } fields('cust_bill_pkg')
160 my $error = $cust_bill_pkg->insert;
162 $dbh->rollback if $oldAutoCommit;
166 foreach my $table (qw(
168 cust_bill_pkg_display
169 cust_bill_pkg_discount
170 cust_bill_pkg_tax_location
171 cust_bill_pkg_tax_rate_location
176 qsearch($table.'_void', { billpkgnum=>$self->billpkgnum })
179 my $class = 'FS::'.$table;
180 my $unvoid = $class->new( {
181 map { $_ => $voided->get($_) } fields($table)
183 my $error = $unvoid->insert || $voided->delete;
185 $dbh->rollback if $oldAutoCommit;
193 $error = $self->delete;
195 $dbh->rollback if $oldAutoCommit;
199 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
207 Delete this record from the database.
209 =item replace OLD_RECORD
211 Replaces the OLD_RECORD with this one in the database. If there is an error,
212 returns the error, otherwise returns false.
216 Checks all fields to make sure this is a valid record. If there is
217 an error, returns the error, otherwise returns false. Called by the insert
226 $self->ut_number('billpkgnum')
227 || $self->ut_snumber('pkgnum')
228 || $self->ut_number('invnum') #cust_bill or cust_bill_void, if we ever support line item voiding
229 || $self->ut_numbern('pkgpart_override')
230 || $self->ut_money('setup')
231 || $self->ut_money('recur')
232 || $self->ut_numbern('sdate')
233 || $self->ut_numbern('edate')
234 || $self->ut_textn('itemdesc')
235 || $self->ut_textn('itemcomment')
236 || $self->ut_textn('section')
237 || $self->ut_textn('freq')
238 || $self->ut_numbern('quantity')
239 || $self->ut_moneyn('unitsetup')
240 || $self->ut_moneyn('unitrecur')
241 || $self->ut_enum('hidden', [ '', 'Y' ])
243 return $error if $error;
250 Returns the voided invoice (see L<FS::cust_bill_void>) for this voided line
257 #cust_bill or cust_bill_void, if we ever support line item voiding
258 qsearchs( 'cust_bill_void', { 'invnum' => $self->invnum } );
267 L<FS::Record>, schema.html from the base documentation.