X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_credit.pm;h=badb673514ae49cfaf411a56adbbb35ba635d138;hb=46ca67d352957406bedb44680a9266e20f3cfd2c;hp=adaf17aa366206608ecb8fecee0a66ce37bb509c;hpb=e8fb3448ac1b9dae5410f88cf70eb36cd822c247;p=freeside.git diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index adaf17aa3..badb67351 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -22,6 +22,7 @@ use FS::cust_event; use FS::agent; use FS::sales; use FS::cust_credit_void; +use FS::cust_bill_pkg; use FS::upgrade_journal; $me = '[ FS::cust_credit ]'; @@ -247,7 +248,7 @@ sub delete { my $cust_main = $self->cust_main; my $error = send_email( - 'from' => $conf->config('invoice_from', $self->cust_main->agentnum), + 'from' => $conf->invoice_from_full($self->cust_main->agentnum), #invoice_from??? well as good as any 'to' => $conf->config('deletecredits'), 'subject' => 'FREESIDE NOTIFICATION: Credit deleted', @@ -782,18 +783,15 @@ Example: 'apply' => 1, #0 leaves the credit unapplied #the credit - 'newreasonnum' => scalar($cgi->param('newreasonnum')), - 'newreasonnum_type' => scalar($cgi->param('newreasonnumT')), map { $_ => scalar($cgi->param($_)) } #fields('cust_credit') - qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum + qw( custnum _date amount reasonnum addlinfo ), #pkgnum eventnum ); =cut #maybe i should just be an insert with extra args instead of a class method -use FS::cust_bill_pkg; sub credit_lineitems { my( $class, %arg ) = @_; my $curuser = $FS::CurrentUser::CurrentUser; @@ -829,26 +827,11 @@ sub credit_lineitems { #}); my $error = ''; - if ($arg{reasonnum} == -1) { - - $error = 'Enter a new reason (or select an existing one)' - unless $arg{newreasonnum} !~ /^\s*$/; - my $reason = new FS::reason { - 'reason' => $arg{newreasonnum}, - 'reason_type' => $arg{newreasonnum_type}, - }; - $error ||= $reason->insert; - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "Error inserting reason: $error"; - } - $arg{reasonnum} = $reason->reasonnum; - } my $cust_credit = new FS::cust_credit ( { map { $_ => $arg{$_} } #fields('cust_credit') - qw( custnum _date amount reason reasonnum addlinfo ), #pkgnum eventnum + qw( custnum _date amount reasonnum addlinfo ), #pkgnum eventnum } ); $error = $cust_credit->insert; if ( $error ) { @@ -919,9 +902,10 @@ sub credit_lineitems { # recalculate taxes with new amounts $taxlisthash{$invnum} ||= {}; - my $part_pkg = $cust_bill_pkg->part_pkg - if $cust_bill_pkg->pkgpart_override; - $cust_main->_handle_taxes( $taxlisthash{$invnum}, $cust_bill_pkg ); + if ( $cust_bill_pkg->pkgnum or $cust_bill_pkg->feepart ) { + $cust_main->_handle_taxes( $taxlisthash{$invnum}, $cust_bill_pkg ); + } # otherwise the item itself is a tax, and assume the caller knows + # what they're doing } ###