1 package FS::cust_bill_pkg_void;
2 use base qw( FS::TemplateItem_Mixin FS::reason_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_fee;
12 use FS::cust_bill_pkg_tax_location;
13 use FS::cust_bill_pkg_tax_rate_location;
14 use FS::cust_tax_exempt_pkg;
18 FS::cust_bill_pkg_void - Object methods for cust_bill_pkg_void records
22 use FS::cust_bill_pkg_void;
24 $record = new FS::cust_bill_pkg_void \%hash;
25 $record = new FS::cust_bill_pkg_void { 'column' => 'value' };
27 $error = $record->insert;
29 $error = $new_record->replace($old_record);
31 $error = $record->delete;
33 $error = $record->check;
37 An FS::cust_bill_pkg_void object represents a voided invoice line item.
38 FS::cust_bill_pkg_void inherits from FS::Record. The following fields are
55 =item pkgpart_override
109 freeform string (deprecated)
113 reason for voiding the payment (see L<FS::reson>)
123 Creates a new record. To add the record to the database, see L<"insert">.
125 Note that this stores the hash reference, not a distinct copy of the hash it
126 points to. You can ask the object for a copy with the I<hash> method.
130 sub table { 'cust_bill_pkg_void'; }
132 sub detail_table { 'cust_bill_pkg_detail_void'; }
133 sub display_table { 'cust_bill_pkg_display_void'; }
134 sub discount_table { 'cust_bill_pkg_discount_void'; }
135 #sub tax_location_table { 'cust_bill_pkg_tax_location'; }
136 #sub tax_rate_location_table { 'cust_bill_pkg_tax_rate_location'; }
137 #sub tax_exempt_pkg_table { 'cust_tax_exempt_pkg'; }
141 Adds this record to the database. If there is an error, returns the error,
142 otherwise returns false.
146 Returns the text of the associated void reason (see L<FS::reason>) for this.
150 "Un-void"s this line item: Deletes the voided line item from the database and
151 adds back a normal line item (and related tables).
158 local $SIG{HUP} = 'IGNORE';
159 local $SIG{INT} = 'IGNORE';
160 local $SIG{QUIT} = 'IGNORE';
161 local $SIG{TERM} = 'IGNORE';
162 local $SIG{TSTP} = 'IGNORE';
163 local $SIG{PIPE} = 'IGNORE';
165 my $oldAutoCommit = $FS::UID::AutoCommit;
166 local $FS::UID::AutoCommit = 0;
169 my $cust_bill_pkg = new FS::cust_bill_pkg ( {
170 map { $_ => $self->get($_) } fields('cust_bill_pkg')
172 my $error = $cust_bill_pkg->insert;
174 $dbh->rollback if $oldAutoCommit;
178 foreach my $table (qw(
180 cust_bill_pkg_display
181 cust_bill_pkg_discount
182 cust_bill_pkg_tax_location
183 cust_bill_pkg_tax_rate_location
189 qsearch($table.'_void', { billpkgnum=>$self->billpkgnum })
192 my $class = 'FS::'.$table;
193 my $unvoid = $class->new( {
194 map { $_ => $voided->get($_) } fields($table)
196 my $error = $unvoid->insert || $voided->delete;
198 $dbh->rollback if $oldAutoCommit;
206 $error = $self->delete;
208 $dbh->rollback if $oldAutoCommit;
212 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
220 Delete this record from the database.
222 =item replace OLD_RECORD
224 Replaces the OLD_RECORD with this one in the database. If there is an error,
225 returns the error, otherwise returns false.
229 Checks all fields to make sure this is a valid record. If there is
230 an error, returns the error, otherwise returns false. Called by the insert
239 $self->ut_number('billpkgnum')
240 || $self->ut_snumber('pkgnum')
241 || $self->ut_number('invnum') #cust_bill or cust_bill_void, if we ever support line item voiding
242 || $self->ut_numbern('pkgpart_override')
243 || $self->ut_money('setup')
244 || $self->ut_money('recur')
245 || $self->ut_numbern('sdate')
246 || $self->ut_numbern('edate')
247 || $self->ut_textn('itemdesc')
248 || $self->ut_textn('itemcomment')
249 || $self->ut_textn('section')
250 || $self->ut_textn('freq')
251 || $self->ut_numbern('quantity')
252 || $self->ut_moneyn('unitsetup')
253 || $self->ut_moneyn('unitrecur')
254 || $self->ut_enum('hidden', [ '', 'Y' ])
255 || $self->ut_numbern('feepart')
256 || $self->ut_textn('reason')
257 || $self->ut_foreign_keyn('reasonnum', 'reason', 'reasonnum')
259 return $error if $error;
266 Returns the voided invoice (see L<FS::cust_bill_void>) for this voided line
273 #cust_bill or cust_bill_void, if we ever support line item voiding
274 qsearchs( 'cust_bill_void', { 'invnum' => $self->invnum } );
277 sub cust_bill_pkg_fee {
279 qsearch( 'cust_bill_pkg_fee_void', { 'billpkgnum' => $self->billpkgnum } );
288 L<FS::Record>, schema.html from the base documentation.