summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg_link.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-02-27 12:13:13 -0800
committerMark Wells <mark@freeside.biz>2015-02-27 12:13:13 -0800
commitaec7743508bd9565dd076ec019dbb3d5b7cedd9c (patch)
treeb4e54f79b5cdc531c830263b8956968425a304e3 /FS/FS/part_pkg_link.pm
parent4b65bb78779b336aab60c9cb112b1efc1e653917 (diff)
change part_pkg_link cleanup to be smarter about its cancel reason, #33245
Diffstat (limited to 'FS/FS/part_pkg_link.pm')
-rw-r--r--FS/FS/part_pkg_link.pm30
1 files changed, 13 insertions, 17 deletions
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' => '');