summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-06-15 22:19:13 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-06-15 22:22:39 -0500
commit66d34b037f3c79a1fcb60418f34dff56a7d467b8 (patch)
treeca4d673da61be6a0ada6ba8182fbd6c657b27dc0 /FS
parent347ec57e34dd8d3447fdb05cbdec9bda627a000b (diff)
RT#71298: Suspend Option for billing to continue
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/AccessRight.pm1
-rw-r--r--FS/FS/access_right.pm27
2 files changed, 28 insertions, 0 deletions
diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm
index 417e4433a..c19b41ea8 100644
--- a/FS/FS/AccessRight.pm
+++ b/FS/FS/AccessRight.pm
@@ -143,6 +143,7 @@ tie my %rights, 'Tie::IxHash',
'Cancel customer package later',
'Un-cancel customer package',
'Delay suspension events',
+ 'Customize billing during suspension',
'Add on-the-fly cancel reason', #NEW
'Add on-the-fly suspend reason', #NEW
'Edit customer package invoice details', #NEW
diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 2ea4856bd..882658d9e 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -294,6 +294,33 @@ sub _upgrade_data { # class method
}
+ # some false laziness with @onetime above,
+ # but for use when multiple old acls trigger a single new acl
+ # (keys/values reversed from @onetime, expects arrayref value)
+ my @onetime_bynew = (
+ 'Customize billing during suspension' => [ 'Suspend customer package', 'Suspend customer package later' ],
+ );
+ while ( @onetime_bynew ) {
+ my( $new_acl, $old_acl ) = splice(@onetime_bynew, 0, 2);
+ ( my $journal = 'ACL_'.lc($new_acl) ) =~ s/\W/_/g;
+ next if FS::upgrade_journal->is_done($journal);
+ # grant $new_acl to all groups who have one of @old_acl
+ for my $group (@all_groups) {
+ next unless grep { $group->access_right($_) } @$old_acl;
+ next if $group->access_right($new_acl);
+ my $access_right = FS::access_right->new( {
+ 'righttype' => 'FS::access_group',
+ 'rightobjnum' => $group->groupnum,
+ 'rightname' => $new_acl,
+ } );
+ my $error = $access_right->insert;
+ die $error if $error;
+ }
+
+ FS::upgrade_journal->set_done($journal);
+
+ }
+
### ACL_download_report_data
if ( !FS::upgrade_journal->is_done('ACL_download_report_data') ) {