[freeside-commits] branch master updated. 63da5ded686cf29353617d4c51385da4906b749b

Mitch Jackson mitch at 420.am
Thu Nov 2 15:08:38 PDT 2017


The branch, master has been updated
       via  63da5ded686cf29353617d4c51385da4906b749b (commit)
      from  3e691871dc24b785968e5a3b5c4d12463e154efc (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 63da5ded686cf29353617d4c51385da4906b749b
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Thu Nov 2 22:04:54 2017 +0000

    RT# 73211 - Add billing event: remove customer tag
    
     - Created billing event removetag, named to match addtag
     - Weighted addtag and removetag both at 21, to group them in menus

diff --git a/FS/FS/part_event/Action/addtag.pm b/FS/FS/part_event/Action/addtag.pm
index c4e9820..c929b41 100644
--- a/FS/FS/part_event/Action/addtag.pm
+++ b/FS/FS/part_event/Action/addtag.pm
@@ -25,12 +25,12 @@ sub option_fields {
   );
 }
 
-sub default_weight { 20; }
+sub default_weight { 21; }
 
 sub do_action {
   my( $self, $object, $tagnum ) = @_;
 
-  my %exists = map { $_->tagnum => $_->tagnum } 
+  my %exists = map { $_->tagnum => $_->tagnum }
         qsearch({
           table     => 'cust_tag',
           hashref   => { custnum  => $object->custnum, },
diff --git a/FS/FS/part_event/Action/addtag.pm b/FS/FS/part_event/Action/removetag.pm
similarity index 55%
copy from FS/FS/part_event/Action/addtag.pm
copy to FS/FS/part_event/Action/removetag.pm
index c4e9820..41cf917 100644
--- a/FS/FS/part_event/Action/addtag.pm
+++ b/FS/FS/part_event/Action/removetag.pm
@@ -1,10 +1,10 @@
-package FS::part_event::Action::addtag;
+package FS::part_event::Action::removetag;
 
 use strict;
 use base qw( FS::part_event::Action );
 use FS::Record qw( qsearch );
 
-sub description { 'Add customer tag'; }
+sub description { 'Remove customer tag'; }
 
 sub eventtable_hashref {
     { 'cust_main'      => 1,
@@ -25,23 +25,21 @@ sub option_fields {
   );
 }
 
-sub default_weight { 20; }
+sub default_weight { 21; }
 
 sub do_action {
   my( $self, $object, $tagnum ) = @_;
 
-  my %exists = map { $_->tagnum => $_->tagnum } 
-        qsearch({
-          table     => 'cust_tag',
-          hashref   => { custnum  => $object->custnum, },
-        });
+  # Get hashref of tags applied to selected customer record
+  my %cust_tag = map { $_->tagnum => $_ } qsearch({
+    table     => 'cust_tag',
+    hashref   => { custnum  => $object->custnum, },
+  });
 
-  my @tags = split(/\,/, $self->option('tagnum'));
+  # Remove tags chosen for this billing event from the customer record
   foreach my $tagnum ( split(/\,/, $self->option('tagnum') ) ) {
-    if ( !$exists{$tagnum} ) {
-      my $cust_tag = new FS::cust_tag { 'tagnum'  => $tagnum,
-                                        'custnum' => $object->custnum, };
-      my $error = $cust_tag->insert;
+    if ( exists $cust_tag{$tagnum} ) {
+      my $error = $cust_tag{$tagnum}->delete;
       die $error if $error;
     }
   }

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

Summary of changes:
 FS/FS/part_event/Action/addtag.pm                  |    4 ++--
 .../part_event/Action/{addtag.pm => removetag.pm}  |   24 +++++++++-----------
 2 files changed, 13 insertions(+), 15 deletions(-)
 copy FS/FS/part_event/Action/{addtag.pm => removetag.pm} (55%)




More information about the freeside-commits mailing list