summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorjeff <jeff>2007-03-14 23:27:47 +0000
committerjeff <jeff>2007-03-14 23:27:47 +0000
commit3f0a5f441a8b3c9b503e0f0e1f2a6d565baa8965 (patch)
treee1f12ae223ad2c1944ad782b6e8a08452a40f9c3 /FS
parent80d9bab5b9e16abfd7af996c79511bbf0c4a833b (diff)
correcting ->replace on bill
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/svc_acct.pm26
1 files changed, 23 insertions, 3 deletions
diff --git a/FS/FS/svc_acct.pm b/FS/FS/svc_acct.pm
index a06f4d797..0d612612b 100644
--- a/FS/FS/svc_acct.pm
+++ b/FS/FS/svc_acct.pm
@@ -41,7 +41,7 @@ use FS::cdr;
@ISA = qw( FS::svc_Common );
-$DEBUG = 0;
+$DEBUG = 1;
$me = '[FS::svc_acct]';
#ask FS::UID to run this stuff for us later
@@ -1671,6 +1671,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});
@@ -1682,9 +1683,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;