[freeside-commits] branch master updated. aec7743508bd9565dd076ec019dbb3d5b7cedd9c

Mark Wells mark at 420.am
Fri Feb 27 12:13:19 PST 2015


The branch, master has been updated
       via  aec7743508bd9565dd076ec019dbb3d5b7cedd9c (commit)
      from  4b65bb78779b336aab60c9cb112b1efc1e653917 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aec7743508bd9565dd076ec019dbb3d5b7cedd9c
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Feb 27 12:13:13 2015 -0800

    change part_pkg_link cleanup to be smarter about its cancel reason, #33245

diff --git a/FS/FS/part_pkg_link.pm b/FS/FS/part_pkg_link.pm
index aee0131..8e43d15 100644
--- a/FS/FS/part_pkg_link.pm
+++ b/FS/FS/part_pkg_link.pm
@@ -170,6 +170,14 @@ sub delete {
   return;
 }
 
+=item remove_linked
+
+Removes any supplemental packages that were created by this link, by canceling
+them and setting their pkglinknum to null. This should be done in preparation
+for removing the link itself.
+
+=cut
+
 sub remove_linked {
   my $self = shift;
   my $pkglinknum = $self->pkglinknum;
@@ -180,23 +188,11 @@ sub remove_linked {
   warn "expiring ".scalar(@pkgs).
        " linked packages from part_pkg_link #$pkglinknum\n";
 
-  my $reason = qsearchs('reason', { reason => $cancel_reason_text });
-  if (!$reason) {
-    # upgrade/FS::Setup created this one automatically
-    my $reason_type = qsearchs('reason_type',
-                               { type => $cancel_reason_type }
-      ) or die "default cancel reason type does not exist";
-
-    $reason = FS::reason->new({
-        reason_type => $reason_type->typenum,
-        reason      => $cancel_reason_text,
-        disabled    => 'Y',
-    });
-    $error = $reason->insert;
-    if ( $error ) {
-      return "$error (creating package cancel reason)";
-    }
-  }
+  my $reason = FS::reason->new_or_existing(
+    class => 'C',
+    type => $cancel_reason_type,
+    reason => $cancel_reason_text
+  );
 
   foreach my $pkg (@pkgs) {
     $pkg->set('pkglinknum' => '');

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_pkg_link.pm |   30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list