summaryrefslogtreecommitdiff
path: root/FS/FS/cust_main/Billing.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-06-07 13:47:45 -0700
committerMark Wells <mark@freeside.biz>2016-06-07 13:47:51 -0700
commit47d5558991d119d7b8fbd9e8256a78776af5d585 (patch)
tree841d7947a6ef067f498a21fbf1f0e18d71e6d327 /FS/FS/cust_main/Billing.pm
parent6d821bf9a2419a177014cf882178370a0cdc748f (diff)
when expiring multiple packages, remove services in cancel weight order, #37177
Diffstat (limited to 'FS/FS/cust_main/Billing.pm')
-rw-r--r--FS/FS/cust_main/Billing.pm25
1 files changed, 18 insertions, 7 deletions
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index d953767..4821ce5 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -216,6 +216,9 @@ sub cancel_expired_pkgs {
my @errors = ();
+ my @really_cancel_pkgs;
+ my @cancel_reasons;
+
CUST_PKG: foreach my $cust_pkg ( @cancel_pkgs ) {
my $cpr = $cust_pkg->last_cust_pkg_reason('expire');
my $error;
@@ -233,14 +236,22 @@ sub cancel_expired_pkgs {
$error = '' if ref $error eq 'FS::cust_pkg';
} else { # just cancel it
- $error = $cust_pkg->cancel($cpr ? ( 'reason' => $cpr->reasonnum,
- 'reason_otaker' => $cpr->otaker,
- 'time' => $time,
- )
- : ()
- );
+
+ push @really_cancel_pkgs, $cust_pkg;
+ push @cancel_reasons, $cpr;
+
}
- push @errors, 'pkgnum '.$cust_pkg->pkgnum.": $error" if $error;
+ }
+
+ if (@really_cancel_pkgs) {
+
+ my %cancel_opt = ( 'cust_pkg' => \@really_cancel_pkgs,
+ 'cust_pkg_reason' => \@cancel_reasons,
+ 'time' => $time,
+ );
+
+ push @errors, $self->cancel_pkgs(%cancel_opt);
+
}
join(' / ', @errors);