From 29a9975eb7068a20fd8538a1cad7e6a90bb77cc5 Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 7 May 2007 02:13:54 +0000 Subject: [PATCH] 1606 correct bug in overlimit groups handling --- FS/FS/cust_pkg.pm | 15 +++++---------- FS/FS/svc_acct.pm | 28 +++++++++++++++++----------- httemplate/misc/process/link.cgi | 8 +++----- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 616a48084..9b5066f75 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -1267,11 +1267,8 @@ sub transfer { foreach my $cust_svc ($self->cust_svc) { if($target{$cust_svc->svcpart} > 0) { $target{$cust_svc->svcpart}--; - my $new = new FS::cust_svc { - svcnum => $cust_svc->svcnum, - svcpart => $cust_svc->svcpart, - pkgnum => $dest_pkgnum, - }; + my $new = new FS::cust_svc { $cust_svc->hash }; + $new->pkgnum($dest_pkgnum); my $error = $new->replace($cust_svc); return $error if $error; } elsif ( exists $opt{'change_svcpart'} && $opt{'change_svcpart'} ) { @@ -1290,11 +1287,9 @@ sub transfer { warn "alternate(s) found\n" if $DEBUG; my $change_svcpart = $alternate[0]; $target{$change_svcpart}--; - my $new = new FS::cust_svc { - svcnum => $cust_svc->svcnum, - svcpart => $change_svcpart, - pkgnum => $dest_pkgnum, - }; + my $new = new FS::cust_svc { $cust_svc->hash }; + $new->svcpart($change_svcpart); + $new->pkgnum($dest_pkgnum); my $error = $new->replace($cust_svc); return $error if $error; } else { diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index d94673b88..1e0389d5c 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1636,7 +1636,10 @@ sub _op_usage { my $action = $op2action{$op}; - if ( &{$op2condition{$op}}($self, $column, $amount) ) { + if ( &{$op2condition{$op}}($self, $column, $amount) && + ( $action eq 'suspend' && !$self->overlimit + || $action eq 'unsuspend' && $self->overlimit ) + ) { foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { if ($part_export->option('overlimit_groups')) { my ($new,$old); @@ -1663,7 +1666,7 @@ sub _op_usage { && &{$op2condition{$op}}($self, $column, $amount) ) { #my $error = $self->$action(); my $error = $self->cust_svc->cust_pkg->$action(); - $error ||= $self->overlimit($action); + # $error ||= $self->overlimit($action); if ( $error ) { $dbh->rollback if $oldAutoCommit; return "Error ${action}ing: $error"; @@ -1758,15 +1761,18 @@ sub set_usage { } if ( $reset ) { - my $error = $self->overlimit('unsuspend'); - - foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { - if ($part_export->option('overlimit_groups')) { - my $old = new FS::svc_acct $self->hashref; - my $groups = &{ $self->_fieldhandlers->{'usergroup'} } - ($self, $part_export->option('overlimit_groups')); - $old->usergroup( $groups ); - $error ||= $part_export->export_replace($self, $old); + my $error; + + if ($self->overlimit) { + $error = $self->overlimit('unsuspend'); + foreach my $part_export ( $self->cust_svc->part_svc->part_export ) { + if ($part_export->option('overlimit_groups')) { + my $old = new FS::svc_acct $self->hashref; + my $groups = &{ $self->_fieldhandlers->{'usergroup'} } + ($self, $part_export->option('overlimit_groups')); + $old->usergroup( $groups ); + $error ||= $part_export->export_replace($self, $old); + } } } diff --git a/httemplate/misc/process/link.cgi b/httemplate/misc/process/link.cgi index fd3d8bb13..7c71371ee 100755 --- a/httemplate/misc/process/link.cgi +++ b/httemplate/misc/process/link.cgi @@ -52,11 +52,9 @@ %if ( $old->pkgnum && ! $conf->exists('legacy_link-steal') ) { % $error = "svcnum $svcnum already linked to package ". $old->pkgnum; %} else { -% $new = new FS::cust_svc ({ -% 'svcnum' => $svcnum, -% 'pkgnum' => $pkgnum, -% 'svcpart' => $svcpart, -% }); +% $new = new FS::cust_svc { $old->hash }; +% $new->pkgnum($pkgnum); +% $new->svcpart($svcpart); % % $error = $new->replace($old); %} -- 2.11.0