diff options
author | jeff <jeff> | 2007-03-15 00:02:04 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-03-15 00:02:04 +0000 |
commit | 68964b014db53863408ec5c5796a6205a4b9e679 (patch) | |
tree | a3b2748424ef7adf691b12301a5d0acc1cc45661 | |
parent | e8e3d8d1e1d0b77fcbf3327805862c2406f9f30d (diff) |
correcting ->replace on bill (backport)
-rw-r--r-- | FS/FS/svc_acct.pm | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm index 0a7d6be6d..f7b76e7b4 100644 --- a/FS/FS/svc_acct.pm +++ b/FS/FS/svc_acct.pm @@ -1616,6 +1616,7 @@ sub set_usage { my $dbh = dbh; my $reset = 0; + my %handyhash = (); foreach my $field (keys %$valueref){ $reset = 1 if $valueref->{$field}; $self->setfield($field, $valueref->{$field}); @@ -1627,9 +1628,28 @@ sub set_usage { ) ) ); + $handyhash{$field} = $self->getfield($field); + $handyhash{$field.'_threshold'} = $self->getfield($field.'_threshold'); + } + #my $error = $self->replace; #NO! we avoid the call to ->check for + #die $error if $error; #services not explicity changed via the UI + + my $sql = "UPDATE svc_acct SET " . + join (',', map { "$_ = ?" } (keys %handyhash) ). + " WHERE svcnum = ?"; + + warn "$me $sql\n" + if $DEBUG; + + if (scalar(keys %handyhash)) { + my $sth = $dbh->prepare( $sql ) + or die "Error preparing $sql: ". $dbh->errstr; + my $rv = $sth->execute((grep{$_} values %handyhash), $self->svcnum); + die "Error executing $sql: ". $sth->errstr + unless defined($rv); + die "Can't update usage for svcnum ". $self->svcnum + if $rv == 0; } - my $error = $self->replace; - die $error if $error; if ( $conf->exists("svc_acct-usage_unsuspend") && $reset ) { my $error = $self->cust_svc->cust_pkg->unsuspend; |