[freeside-commits] branch FREESIDE_4_BRANCH updated. be9a6369ff99184be0772c506e3fa9dce8d1b932
Mitch Jackson
mitch at freeside.biz
Sat Nov 18 16:37:22 PST 2017
The branch, FREESIDE_4_BRANCH has been updated
via be9a6369ff99184be0772c506e3fa9dce8d1b932 (commit)
from e1b3d8c0c08dd559ea7c18c1b53f2a79168c8627 (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 be9a6369ff99184be0772c506e3fa9dce8d1b932
Author: Mitch Jackson <mitch at freeside.biz>
Date: Sun Nov 19 00:25:51 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 c4e9820b7..c929b41db 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 c4e9820b7..41cf917a7 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