X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pkg.pm;h=e0e710e6fecabe77dd1e1c855a4aba95dc5ed748;hb=c8ea63ee0f94ff3d3ac3917e41b0e38fb53b3fd4;hp=9bcf455a5ff33519f865048c9e3ec610a04cef32;hpb=7fdbfcef21985e7c8455929eb0ad70c0863ac47b;p=freeside.git diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 9bcf455a5..e0e710e6f 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -815,9 +815,13 @@ the date. You are PROBABLY looking to expire the account instead of using this. =item reason - can be set to a cancellation reason (see L), -either a reasonnum of an existing reason, or passing a hashref will create -a new reason. The hashref should have the following keys: typenum - Reason -type (see L, reason - Text of the new reason. +either a reasonnum of an existing reason, or a hashref to create +a new reason. The hashref should have the following keys: +typenum - Reason type (see L +reason - Text of the new reason. + +If this argument isn't given or is a false value, then the package will be +canceled with no reason. =item date - can be set to a unix style timestamp to specify when to cancel (expire) @@ -1078,6 +1082,10 @@ Cancels this package if its expire date has been reached. =cut +# XXX should look for an expire reason +# but seems to be unused; this is now handled more holistically in +# cust_main::Billing + sub cancel_if_expired { my $self = shift; my $time = shift || time; @@ -1226,7 +1234,13 @@ sub uncancel_svc_summary { 'uncancel_svcnum' => $svc_x->get('_h_svc_x')->svcnum, }; $svc_x->pkgnum($self->pkgnum); # provisioning services on a canceled package, will be rolled back - if ($opt{'no_test_reprovision'} or $svc_x->insert) { + my $insert_error; + unless ($opt{'no_test_reprovision'}) { + # avoid possibly fatal errors from missing linked records + eval { $insert_error = $svc_x->insert }; + $insert_error ||= $@; + } + if ($opt{'no_test_reprovision'} or $insert_error) { # avoid possibly fatal errors from missing linked records eval { $out->{'label'} = $svc_x->label }; eval { $out->{'label'} = $svc_x->get('_h_svc_x')->label } unless defined($out->{'label'}); @@ -2484,6 +2498,21 @@ sub change { return "transferring package notes: $error"; } } + + # transfer scheduled expire/adjourn reasons + foreach my $action ('expire', 'adjourn') { + if ( $cust_pkg->get($action) ) { + my $reason = $self->last_cust_pkg_reason($action); + if ( $reason ) { + $reason->set('pkgnum', $cust_pkg->pkgnum); + $error = $reason->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "transferring $action reason: $error"; + } + } + } + } my @new_supp_pkgs;