use Carp;
use List::Util qw( sum min );
use Text::CSV_XS;
-use FS::Record qw( qsearch qsearchs dbh );
+use FS::Record qw( qsearch qsearchs dbh fields );
use FS::cust_pkg;
use FS::cust_bill_pkg_detail;
use FS::cust_bill_pkg_display;
$self->billpkgnum
);
- $self->scalar_sql("INSERT INTO cust_bill_pkg_detail_void
- SELECT * $from_cust_bill_pkg_detail",
+ my $fields = join(', ', fields('cust_bill_pkg_detail_void') );
+
+ $self->scalar_sql("INSERT INTO cust_bill_pkg_detail_void ($fields)
+ SELECT $fields $from_cust_bill_pkg_detail",
$self->billpkgnum
);
}
}
- my $error = $self->SUPER::delete(@_);
+ #fix the invoice amount
+
+ my $cust_bill = $self->cust_bill;
+ $cust_bill->charged( $cust_bill->charged - $self->setup - $self->recur );
+
+ #not adding a cc surcharge, but this override lets us modify charged
+ $cust_bill->{'Hash'}{'cc_surcharge_replace_hack'} = 1;
+
+ my $error = $cust_bill->replace
+ || $self->SUPER::delete(@_);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;