summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-05-07 02:13:54 +0000
committerjeff <jeff>2007-05-07 02:13:54 +0000
commit29a9975eb7068a20fd8538a1cad7e6a90bb77cc5 (patch)
tree41f23bbae53c5a1f1ad0b785cf14d2dd980576f6
parent596fe22104792b042efff8b2f690a052c177b17a (diff)
1606 correct bug in overlimit groups handling
-rw-r--r--FS/FS/cust_pkg.pm15
-rw-r--r--FS/FS/svc_acct.pm28
-rwxr-xr-xhttemplate/misc/process/link.cgi8
3 files changed, 25 insertions, 26 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 616a480..9b5066f 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 d94673b..1e0389d 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 fd3d8bb..7c71371 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);
%}