summaryrefslogtreecommitdiff
path: root/FS/FS/cust_pkg.pm
diff options
context:
space:
mode:
authorjeff <jeff>2009-07-17 01:44:24 +0000
committerjeff <jeff>2009-07-17 01:44:24 +0000
commit725f4954f7d4efaf7cd3fd5e402a5dacd5d185b9 (patch)
treeefc694a364d3b5cb7715c67dd3b676a720c5c500 /FS/FS/cust_pkg.pm
parent72758ac1d94a4ce47e3160ee6227a5e191911c57 (diff)
bill usage when cancelling package
Diffstat (limited to 'FS/FS/cust_pkg.pm')
-rw-r--r--FS/FS/cust_pkg.pm17
1 files changed, 17 insertions, 0 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index d2f0690..f564023 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -560,6 +560,8 @@ Available options are:
=item date - can be set to a unix style timestamp to specify when to cancel (expire)
+=item nobill - can be set true to skip billing if it might otherwise be done.
+
=back
If there is an error, returns the error, otherwise returns false.
@@ -570,6 +572,8 @@ sub cancel {
my( $self, %options ) = @_;
my $error;
+ my $conf = new FS::Conf;
+
warn "cust_pkg::cancel called with options".
join(', ', map { "$_: $options{$_}" } keys %options ). "\n"
if $DEBUG;
@@ -595,6 +599,19 @@ sub cancel {
my $date = $options{date} if $options{date}; # expire/cancel later
$date = '' if ($date && $date <= time); # complain instead?
+ #race condition: usage could be ongoing until unprovisioned
+ #resolved by performing a change package instead (which unprovisions) and
+ #later cancelling
+ if ( !$options{nobill} && !$date && $conf->exists('bill_usage_on_cancel') ) {
+ my $error =
+ $self->cust_main->bill( pkg_list => [ $self ], cancel => 1 );
+ warn "Error billing during cancel, custnum ".
+ #$self->cust_main->custnum. ": $error"
+ ": $error"
+ if $error;
+ }
+
+
my $cancel_time = $options{'time'} || time;
if ( $options{'reason'} ) {