[freeside-commits] freeside/FS/FS svc_acct.pm,1.219,1.220

Jeff Finucane,420,, jeff at wavetail.420.am
Wed Mar 14 16:27:50 PDT 2007


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv12316

Modified Files:
	svc_acct.pm 
Log Message:
correcting ->replace on bill

Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- svc_acct.pm	27 Feb 2007 01:48:06 -0000	1.219
+++ svc_acct.pm	14 Mar 2007 23:27:47 -0000	1.220
@@ -41,7 +41,7 @@
 
 @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 @@
   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 @@
                            )
                        )
                      );
+    $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;



More information about the freeside-commits mailing list