use List::Util qw( min );
use Date::Format;
use FS::UID qw( dbh );
-use FS::Misc qw(send_email);
use FS::Record qw( qsearch qsearchs dbdef );
use FS::CurrentUser;
use FS::cust_pkg;
our %reasontype_map = ( 'referral_credit_type' => 'Referral Credit',
'cancel_credit_type' => 'Cancellation Credit',
- 'signup_credit_type' => 'Self-Service Credit',
);
=head1 NAME
return $error;
}
- if ( !$opt{void} and $conf->config('deletecredits') ne '' ) {
-
- my $cust_main = $self->cust_main;
-
- my $error = send_email(
- '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',
- 'body' => [
- "This is an automatic message from your Freeside installation\n",
- "informing you that the following credit has been deleted:\n",
- "\n",
- 'crednum: '. $self->crednum. "\n",
- 'custnum: '. $self->custnum.
- " (". $cust_main->last. ", ". $cust_main->first. ")\n",
- 'amount: $'. sprintf("%.2f", $self->amount). "\n",
- 'date: '. time2str("%a %b %e %T %Y", $self->_date). "\n",
- 'reason: '. $self->reason. "\n",
- ],
- );
-
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "can't send credit deletion notification: $error";
- }
-
- }
-
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
my $cust_credit_void = new FS::cust_credit_void ( {
map { $_ => $self->get($_) } $self->fields
} );
- $cust_credit_void->set('void_reasonnum', $reason->reasonnum);
+ $cust_credit_void->set('void_reasonnum', $reason->reasonnum) if $reason;
my $error = $cust_credit_void->insert;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
}
- $error = $self->delete(void => 1); # suppress deletecredits warning
+ $error = $self->delete();
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
=cut
-use Data::Dumper; #XXX
-
#maybe i should just be an insert with extra args instead of a class method
sub credit_lineitems {
my( $class, %arg ) = @_;
# determine the tax adjustments
my %tax_adjust = $class->calculate_tax_adjustment(%arg);
- warn Dumper \%arg;
foreach my $billpkgnum ( @{$arg{billpkgnums}} ) {
my $setuprecur = shift @{$arg{setuprecurs}};
my $amount = shift @{$arg{amounts}};