[freeside-commits] branch FREESIDE_3_BRANCH updated. ca9f1e88e00736efff1deff396d25165e67094cd

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


The branch, FREESIDE_3_BRANCH has been updated
       via  ca9f1e88e00736efff1deff396d25165e67094cd (commit)
      from  5393c4b8db83bb2196336b9e919e8ec1dc609aa8 (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 ca9f1e88e00736efff1deff396d25165e67094cd
Author: Mark Wells <mark at freeside.biz>
Date:   Fri Feb 27 12:12:59 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