diff options
author | mark <mark> | 2012-01-24 22:25:13 +0000 |
---|---|---|
committer | mark <mark> | 2012-01-24 22:25:13 +0000 |
commit | 4a0ec17006cfc39c3b8272f048d7cef3533e39c0 (patch) | |
tree | 43b4322a0d598a09e21810b54a2cdffb6b3e83b8 /FS/FS/part_pkg.pm | |
parent | c906c82c176ddaf7897a13fc78b1264e2f5d25bd (diff) |
option to bill partial period on cancel/suspend, #16066
Diffstat (limited to 'FS/FS/part_pkg.pm')
-rw-r--r-- | FS/FS/part_pkg.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index ed5fa9699..1c30b67ac 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -1290,7 +1290,6 @@ sub calc_recur { die 'no calc_recur for '. shift->plan. "\n"; } #fallback that return 0 for old legacy packages with no plan sub calc_remain { 0; } -sub calc_cancel { 0; } sub calc_units { 0; } #fallback for everything except bulk.pm @@ -1299,6 +1298,23 @@ sub hide_svc_detail { 0; } #fallback for packages that can't/won't summarize usage sub sum_usage { 0; } +# somewhat more intelligent fallback-- +# covers the standard cases of billing outstanding usage or just running +# another recurring billing cycle +sub calc_cancel { + my $self = shift; + my $conf = new FS::Conf; + if ( $self->recur_temporality eq 'preceding' + and $self->option('bill_recur_on_cancel',1) ) { + return $self->calc_recur(@_); + } + elsif ( $conf->exists('bill_usage_on_cancel') # should be a package option? + and $self->can('calc_usage') ) { + return $self->calc_usage(@_); + } + 0; +} + =item recur_cost_permonth CUST_PKG recur_cost divided by freq (only supported for monthly and longer frequencies) |