summaryrefslogtreecommitdiff
path: root/FS/FS/cust_pkg.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-01-26 18:31:31 -0800
committerMark Wells <mark@freeside.biz>2015-01-26 18:31:31 -0800
commit349bfb3f80c3af6be2b6c2af9e9d2e7a71b1ffe6 (patch)
treec7f09d81848d451dfa897616c7f95545e954e6fc /FS/FS/cust_pkg.pm
parentcf985eedaeb4b23a2050ebc0bb0cb304554e2a6d (diff)
avoid adjusting bill date for suspended time if the package was credited on suspension, #31651
Diffstat (limited to 'FS/FS/cust_pkg.pm')
-rw-r--r--FS/FS/cust_pkg.pm38
1 files changed, 30 insertions, 8 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index b51c955..5c82ad2 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1617,19 +1617,41 @@ sub unsuspend {
my $conf = new FS::Conf;
#adjust the next bill date forward
- $hash{'bill'} = ( $hash{'bill'} || $hash{'setup'} ) + $inactive
- if $inactive > 0
+ # increment next bill date if certain conditions are met:
+ # - it was due to be billed at some point
+ # - either the global or local config says to do this
+ my $adjust_bill = 0;
+ if (
+ $inactive > 0
&& ( $hash{'bill'} || $hash{'setup'} )
&& ( $opt{'adjust_next_bill'}
|| $conf->exists('unsuspend-always_adjust_next_bill_date')
|| $self->part_pkg->option('unsuspend_adjust_bill', 1)
)
- && ! $self->option('suspend_bill',1)
- && ( ! $self->part_pkg->option('suspend_bill',1)
- || $self->option('no_suspend_bill',1)
- )
- && $hash{'order_date'} != $hash{'susp'}
- ;
+ ) {
+ $adjust_bill = 1;
+ }
+
+ # but not if:
+ # - the package billed during suspension
+ # - or it was ordered on hold
+ # - or the customer was credited for the unused time
+
+ if ( $self->option('suspend_bill',1)
+ or ( $self->part_pkg->option('suspend_bill',1)
+ and ! $self->option('no_suspend_bill',1)
+ )
+ or $hash{'order_date'} == $hash{'susp'}
+ or $self->part_pkg->option('unused_credit_suspend')
+ or ( defined($reason) and $reason->unused_credit )
+ ) {
+ $adjust_bill = 0;
+ }
+
+ # then add the length of time suspended to the bill date
+ if ( $adjust_bill ) {
+ $hash{'bill'} = ( $hash{'bill'} || $hash{'setup'} ) + $inactive
+ }
$hash{'susp'} = '';
$hash{'adjourn'} = '' if $hash{'adjourn'} and $hash{'adjourn'} < time;