X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill.pm;h=79dbbba67995a05f87e289931864b9a3956735a5;hp=6546bfa95b471f59c6d81bc8ed92e836973316e1;hb=674cb2d9d7105f4cc2871539b2e9f7088cdaa750;hpb=cace897d9c5fbe1f80277b0cb14e85c9d2272cf1 diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 6546bfa95..79dbbba67 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -37,6 +37,8 @@ use FS::cust_bill_pay_pkg; use FS::cust_credit_bill_pkg; use FS::discount_plan; use FS::cust_bill_void; +use FS::reason; +use FS::reason_type; use FS::L10N; $DEBUG = 0; @@ -212,7 +214,7 @@ sub insert { } -=item void +=item void [ REASON ] Voids this invoice: deletes the invoice and adds a record of the voided invoice to the FS::cust_bill_void table (and related tables starting from @@ -224,6 +226,14 @@ sub void { my $self = shift; my $reason = scalar(@_) ? shift : ''; + unless (ref($reason) || !$reason) { + $reason = FS::reason->new_or_existing( + 'class' => 'I', + 'type' => 'Invoice void', + 'reason' => $reason + ); + } + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -238,7 +248,7 @@ sub void { my $cust_bill_void = new FS::cust_bill_void ( { map { $_ => $self->get($_) } $self->fields } ); - $cust_bill_void->reason($reason); + $cust_bill_void->reasonnum($reason->reasonnum) if $reason; my $error = $cust_bill_void->insert; if ( $error ) { $dbh->rollback if $oldAutoCommit; @@ -1105,9 +1115,8 @@ sub queueable_email { my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } ) or die "invalid invoice number: " . $opt{invnum}; - if ( $opt{mode} ) { - $self->set('mode', $opt{mode}); - } + $self->set('mode', $opt{mode}) + if $opt{mode}; my %args = map {$_ => $opt{$_}} grep { $opt{$_} } @@ -1248,6 +1257,10 @@ sub batch_invoice { batchnum => $bill_batch->batchnum, invnum => $self->invnum, }); + if ( $self->mode ) { + $opt->{mode} ||= $self->mode; + $opt->{mode} = $opt->{mode}->modenum if ref $opt->{mode}; + } return $cust_bill_batch->insert($opt); }