X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling.pm;h=4821ce5555533760e41a16ac29e803a910b9044c;hp=d95376798addce3c44ba1c942f07e854fa0147d0;hb=47d5558991d119d7b8fbd9e8256a78776af5d585;hpb=6d821bf9a2419a177014cf882178370a0cdc748f diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index d95376798..4821ce555 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);