From 5b193ee2c5fae0743699adb1a28591f2a1735eb7 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Fri, 10 Jul 2015 18:14:40 -0700 Subject: [PATCH] avoid generating spurious zero-amount bills on cancellation, #37229, from #16066 --- FS/FS/cust_main/Billing.pm | 8 ++++++++ FS/FS/part_pkg/flat.pm | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index f4c804568..87be4e68d 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -1107,6 +1107,14 @@ sub _make_lines { return "$@ running $method for $cust_pkg\n" if ( $@ ); + if ($recur eq 'NOTHING') { + # then calc_cancel (or calc_recur but that's not used) has declined to + # generate a recurring lineitem at all. treat this as zero, but also + # try not to generate a lineitem. + $recur = 0; + $lineitems--; + } + #base_cancel??? $unitrecur = $cust_pkg->base_recur( \$sdate ) || $recur; #XXX uuh, better diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 930966a94..eb70253bb 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -220,13 +220,13 @@ sub calc_cancel { and $self->option('bill_recur_on_cancel', 1) ) { # run another recurring cycle return $self->calc_recur(@_); - } - elsif ( $conf->exists('bill_usage_on_cancel') # should be a package option? + } elsif ( $conf->exists('bill_usage_on_cancel') # should be a package option? and $self->can('calc_usage') ) { # bill for outstanding usage return $self->calc_usage(@_); + } else { + return 'NOTHING'; # numerically zero, but has special meaning } - 0; } sub calc_remain { -- 2.11.0