[freeside-commits] branch FREESIDE_4_BRANCH updated. 8b610864ee3d14b7874fc21685651004bf94cb1d
Mitch Jackson
mitch at freeside.biz
Mon Nov 5 15:36:06 PST 2018
The branch, FREESIDE_4_BRANCH has been updated
via 8b610864ee3d14b7874fc21685651004bf94cb1d (commit)
from 7b2b8052d52ede6900a1da79de670eacb966095a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8b610864ee3d14b7874fc21685651004bf94cb1d
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue May 15 14:53:25 2018 -0700
more efficient invoice voiding, RT#80366
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index 983f62bed..1262c3874 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -365,8 +365,10 @@ sub void {
return $error;
}
+ #more efficiently than below, because there could be lots
+ $self->void_cust_bill_pkg_detail($reprocess_cdrs);
+
foreach my $table (qw(
- cust_bill_pkg_detail
cust_bill_pkg_display
cust_bill_pkg_discount
cust_bill_pkg_tax_location
@@ -374,17 +376,13 @@ sub void {
cust_tax_exempt_pkg
cust_bill_pkg_fee
)) {
- my %delete_args = ();
- $delete_args{'reprocess_cdrs'} = $reprocess_cdrs
- if $table eq 'cust_bill_pkg_detail';
-
foreach my $linked ( qsearch($table, { billpkgnum=>$self->billpkgnum }) ) {
my $vclass = 'FS::'.$table.'_void';
my $void = $vclass->new( {
map { $_ => $linked->get($_) } $linked->fields
});
- my $error = $void->insert || $linked->delete(%delete_args);
+ my $error = $void->insert || $linked->delete;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@ -406,6 +404,40 @@ sub void {
}
+sub void_cust_bill_pkg_detail {
+ my( $self, $reprocess_cdrs ) = @_;
+
+ my $from_cust_bill_pkg_detail =
+ 'FROM cust_bill_pkg_detail WHERE billpkgnum = ?';
+ my $where_detailnum =
+ "WHERE detailnum IN ( SELECT detailnum $from_cust_bill_pkg_detail )";
+
+ if ( $reprocess_cdrs ) {
+ #well, technically this could have been on other invoices / termination
+ # partners... separate flag?
+ $self->scalar_sql(
+ "DELETE FROM cdr_termination
+ WHERE acctid IN ( SELECT acctid FROM cdr $where_detailnum )
+ ",
+ $self->billpkgnum
+ );
+ }
+
+ my $setstatus = $reprocess_cdrs ? ', freesidestatus = NULL' : '';
+ $self->scalar_sql(
+ "UPDATE cdr SET detailnum = NULL $setstatus $where_detailnum",
+ $self->billpkgnum
+ );
+
+ $self->scalar_sql("INSERT INTO cust_bill_pkg_detail_void
+ SELECT * $from_cust_bill_pkg_detail",
+ $self->billpkgnum
+ );
+
+ $self->scalar_sql("DELETE $from_cust_bill_pkg_detail", $self->billpkgnum);
+
+}
+
=item delete
Not recommended.
@@ -716,6 +748,7 @@ Returns the customer (L<FS::cust_main> object) for this line item.
=cut
sub cust_main {
+ carp "->cust_main called" if $DEBUG;
# required for cust_main_Mixin equivalence
# and use cust_bill instead of cust_pkg because this might not have a
# cust_pkg
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cust_bill_pkg.pm | 45 +++++++++++++++++++++++++++++++++++++++------
1 file changed, 39 insertions(+), 6 deletions(-)
More information about the freeside-commits
mailing list