1 package FS::cust_bill_pkg_void;
2 use base qw( FS::TemplateItem_Mixin FS::reason_Mixin FS::Record );
5 use vars qw( $me $DEBUG );
6 use FS::Record qw( qsearch qsearchs dbh fields );
7 use FS::cust_bill_void;
8 use FS::cust_bill_pkg_detail;
9 use FS::cust_bill_pkg_display;
10 use FS::cust_bill_pkg_discount;
11 use FS::cust_bill_pkg;
12 use FS::cust_bill_pkg_fee;
13 use FS::cust_bill_pkg_tax_location;
14 use FS::cust_bill_pkg_tax_rate_location;
15 use FS::cust_tax_exempt_pkg;
17 $me = '[ FS::cust_bill_pkg_void ]';
22 FS::cust_bill_pkg_void - Object methods for cust_bill_pkg_void records
26 use FS::cust_bill_pkg_void;
28 $record = new FS::cust_bill_pkg_void \%hash;
29 $record = new FS::cust_bill_pkg_void { 'column' => 'value' };
31 $error = $record->insert;
33 $error = $new_record->replace($old_record);
35 $error = $record->delete;
37 $error = $record->check;
41 An FS::cust_bill_pkg_void object represents a voided invoice line item.
42 FS::cust_bill_pkg_void inherits from FS::Record. The following fields are
59 =item pkgpart_override
113 freeform string (deprecated)
117 reason for voiding the payment (see L<FS::reson>)
127 Creates a new record. To add the record to the database, see L<"insert">.
129 Note that this stores the hash reference, not a distinct copy of the hash it
130 points to. You can ask the object for a copy with the I<hash> method.
134 sub table { 'cust_bill_pkg_void'; }
136 sub detail_table { 'cust_bill_pkg_detail_void'; }
137 sub display_table { 'cust_bill_pkg_display_void'; }
138 sub discount_table { 'cust_bill_pkg_discount_void'; }
139 #sub tax_location_table { 'cust_bill_pkg_tax_location'; }
140 #sub tax_rate_location_table { 'cust_bill_pkg_tax_rate_location'; }
141 #sub tax_exempt_pkg_table { 'cust_tax_exempt_pkg'; }
145 Adds this record to the database. If there is an error, returns the error,
146 otherwise returns false.
150 Returns the text of the associated void reason (see L<FS::reason>) for this.
154 "Un-void"s this line item: Deletes the voided line item from the database and
155 adds back a normal line item (and related tables).
162 local $SIG{HUP} = 'IGNORE';
163 local $SIG{INT} = 'IGNORE';
164 local $SIG{QUIT} = 'IGNORE';
165 local $SIG{TERM} = 'IGNORE';
166 local $SIG{TSTP} = 'IGNORE';
167 local $SIG{PIPE} = 'IGNORE';
169 my $oldAutoCommit = $FS::UID::AutoCommit;
170 local $FS::UID::AutoCommit = 0;
173 my $cust_bill_pkg = new FS::cust_bill_pkg ( {
174 map { $_ => $self->get($_) } fields('cust_bill_pkg')
176 my $error = $cust_bill_pkg->insert;
178 $dbh->rollback if $oldAutoCommit;
182 foreach my $table (qw(
184 cust_bill_pkg_display
185 cust_bill_pkg_discount
186 cust_bill_pkg_tax_location
187 cust_bill_pkg_tax_rate_location
193 qsearch($table.'_void', { billpkgnum=>$self->billpkgnum })
196 my $class = 'FS::'.$table;
197 my $unvoid = $class->new( {
198 map { $_ => $voided->get($_) } fields($table)
200 my $error = $unvoid->insert || $voided->delete;
202 $dbh->rollback if $oldAutoCommit;
210 $error = $self->delete;
212 $dbh->rollback if $oldAutoCommit;
216 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
224 Delete this record from the database.
226 =item replace OLD_RECORD
228 Replaces the OLD_RECORD with this one in the database. If there is an error,
229 returns the error, otherwise returns false.
233 Checks all fields to make sure this is a valid record. If there is
234 an error, returns the error, otherwise returns false. Called by the insert
243 $self->ut_number('billpkgnum')
244 || $self->ut_snumber('pkgnum')
245 || $self->ut_number('invnum') #cust_bill or cust_bill_void, if we ever support line item voiding
246 || $self->ut_numbern('pkgpart_override')
247 || $self->ut_money('setup')
248 || $self->ut_money('recur')
249 || $self->ut_numbern('sdate')
250 || $self->ut_numbern('edate')
251 || $self->ut_textn('itemdesc')
252 || $self->ut_textn('itemcomment')
253 || $self->ut_textn('section')
254 || $self->ut_textn('freq')
255 || $self->ut_numbern('quantity')
256 || $self->ut_moneyn('unitsetup')
257 || $self->ut_moneyn('unitrecur')
258 || $self->ut_enum('hidden', [ '', 'Y' ])
259 || $self->ut_numbern('feepart')
260 || $self->ut_textn('reason')
261 || $self->ut_foreign_keyn('reasonnum', 'reason', 'reasonnum')
263 return $error if $error;
270 Returns the voided invoice (see L<FS::cust_bill_void>) for this voided line
277 #cust_bill or cust_bill_void, if we ever support line item voiding
278 qsearchs( 'cust_bill_void', { 'invnum' => $self->invnum } );
281 sub cust_bill_pkg_fee {
283 qsearch( 'cust_bill_pkg_fee_void', { 'billpkgnum' => $self->billpkgnum } );
289 # Used by FS::Upgrade to migrate to a new database.
290 sub _upgrade_data { # class method
291 my ($class, %opts) = @_;
293 warn "$me upgrading $class\n" if $DEBUG;
295 $class->_upgrade_reasonnum(%opts);
304 L<FS::Record>, schema.html from the base documentation.