[freeside-commits] branch master updated. 8d34fe53ba6c0aaf78cd20e9b5e276cf7d77ca12

Ivan ivan at 420.am
Thu Apr 27 16:46:07 PDT 2017


The branch, master has been updated
       via  8d34fe53ba6c0aaf78cd20e9b5e276cf7d77ca12 (commit)
      from  fe32569659388d3edbd08fe2b1327ec0005da4f8 (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 8d34fe53ba6c0aaf78cd20e9b5e276cf7d77ca12
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Apr 27 16:46:03 2017 -0700

    email referring customers on cancellation, RT#75756

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 50cd14e..714190a 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2428,6 +2428,21 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'cancel_msgnum-referring_cust-pkg_class',
+    'section'     => 'cancellation',
+    'description' => 'Enable cancellation messages to the referring customer for these package classes.',
+    'type'        => 'select-pkg_class',
+    'multiple'    => 1,
+  },
+
+  {
+    'key'         => 'cancel_msgnum-referring_cust',
+    'section'     => 'cancellation',
+    'description' => 'Template to use for cancellation emails sent to the referring customer.',
+    %msg_template_options,
+  },
+
+  {
     'key'         => 'require_cardname',
     'section'     => 'credit_cards',
     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index e2f7aca..b256dae 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1101,17 +1101,38 @@ sub cancel {
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
   return '' if $date; #no errors
 
-  my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } $self->cust_main->invoicing_list;
-  if ( !$options{'quiet'} && 
-        $conf->exists('emailcancel', $self->cust_main->agentnum) && 
-        @invoicing_list ) {
-    my $msgnum = $conf->config('cancel_msgnum', $self->cust_main->agentnum);
-    my $error = '';
-    if ( $msgnum ) {
-      my $msg_template = qsearchs('msg_template', { msgnum => $msgnum });
-      $error = $msg_template->send( 'cust_main' => $self->cust_main,
-                                    'object'    => $self );
-    }
+  my $cust_main = $self->cust_main;
+
+  my @invoicing_list = $cust_main->invoicing_list_emailonly;
+  my $msgnum = $conf->config('cancel_msgnum', $cust_main->agentnum);
+  if (    !$options{'quiet'}
+       && $conf->config_bool('emailcancel', $cust_main->agentnum)
+       && @invoicing_list
+       && $msgnum
+     )
+  {
+    my $msg_template = qsearchs('msg_template', { msgnum => $msgnum });
+    my $error = $msg_template->send(
+      'cust_main' => $cust_main,
+      'object'    => $self,
+    );
+    #should this do something on errors?
+  }
+
+  my %pkg_class = map { $_=>1 }
+                    $conf->config('cancel_msgnum-referring_cust-pkg_class');
+  my $ref_msgnum = $conf->config('cancel_msgnum-referring_cust');
+  if (    !$options{'quiet'}
+       && $cust_main->referral_custnum
+       && $pkg_class{ $self->classnum } 
+       && $ref_msgnum
+     )
+  {
+    my $msg_template = qsearchs('msg_template', { msgnum => $ref_msgnum });
+    my $error = $msg_template->send( 
+      'cust_main' => $cust_main->referring_cust_main,
+      'object'    => $self,
+    );
     #should this do something on errors?
   }
 

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

Summary of changes:
 FS/FS/Conf.pm     |   15 +++++++++++++++
 FS/FS/cust_pkg.pm |   43 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 47 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list