freeside/FS/FS Conf.pm,1.102,1.103 svc_Common.pm,1.21,1.22 cust_svc.pm,1.42,1.43

ivan ivan at pouncequick.420.am
Thu Jul 29 21:54:45 PDT 2004


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv8444/FS/FS

Modified Files:
	Conf.pm svc_Common.pm cust_svc.pm 
Log Message:
svcpart changes now trigger all necessary export actions, manual svcpart changing on svc_acct view, linking changes svcpart if you ask it to, closes: Bug#671, Bug#644

Index: cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_svc.pm,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- cust_svc.pm	10 Jul 2004 14:30:59 -0000	1.42
+++ cust_svc.pm	30 Jul 2004 04:54:40 -0000	1.43
@@ -172,20 +172,20 @@
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  my $error = $new->SUPER::replace($old);
-  if ( $error ) {
-    $dbh->rollback if $oldAutoCommit;
-    return $error if $error;
-  }
-
   if ( $new->svcpart != $old->svcpart ) {
     my $svc_x = $new->svc_x;
-    my $new_svc_x = ref($svc_x)->new({$svc_x->hash});
+    my $new_svc_x = ref($svc_x)->new({$svc_x->hash, svcpart=>$new->svcpart });
     my $error = $new_svc_x->replace($svc_x);
     if ( $error ) {
       $dbh->rollback if $oldAutoCommit;
       return $error if $error;
     }
+  }
+
+  my $error = $new->SUPER::replace($old);
+  if ( $error ) {
+    $dbh->rollback if $oldAutoCommit;
+    return $error if $error;
   }
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- Conf.pm	6 Jul 2004 17:26:02 -0000	1.102
+++ Conf.pm	30 Jul 2004 04:54:40 -0000	1.103
@@ -1237,7 +1237,7 @@
   {
     'key'         => 'cust_pkg-change_svcpart',
     'section'     => '',
-    'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.  Use with caution!  No provision is made for export differences between the old and new service definitions.  Probably only should be used when your exports for all service definitions of a given svcdb are identical.",
+    'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
     'type'        => 'checkbox',
   },
 

Index: svc_Common.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_Common.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- svc_Common.pm	3 Mar 2004 13:42:08 -0000	1.21
+++ svc_Common.pm	30 Jul 2004 04:54:40 -0000	1.22
@@ -302,14 +302,52 @@
 
   #new-style exports!
   unless ( $noexport_hack ) {
-    foreach my $part_export ( $new->cust_svc->part_svc->part_export ) {
-      my $error = $part_export->export_replace($new,$old);
+
+    #not quite false laziness, but same pattern as FS::svc_acct::replace and
+    #FS::part_export::sqlradius::_export_replace.  List::Compare or something
+    #would be useful but too much of a pain in the ass to deploy
+
+    my @old_part_export = $old->cust_svc->part_svc->part_export;
+    my %old_exportnum = map { $_->exportnum => 1 } @old_part_export;
+    my @new_part_export = 
+      $new->svcpart
+        ? qsearchs('part_svc', { svcpart=>$new->svcpart } )->part_export
+        : $new->cust_svc->part_svc->part_export;
+    my %new_exportnum = map { $_->exportnum => 1 } @new_part_export;
+
+    foreach my $delete_part_export (
+      grep { ! $new_exportnum{$_->exportnum} } @old_part_export
+    ) {
+      my $error = $delete_part_export->export_delete($old);
       if ( $error ) {
         $dbh->rollback if $oldAutoCommit;
-        return "error exporting to ". $part_export->exporttype.
+        return "error deleting, export to ". $delete_part_export->exporttype.
+               " (transaction rolled back): $error";
+      }
+    }
+
+    foreach my $replace_part_export (
+      grep { $old_exportnum{$_->exportnum} } @new_part_export
+    ) {
+      my $error = $replace_part_export->export_replace($new,$old);
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return "error exporting to ". $replace_part_export->exporttype.
+               " (transaction rolled back): $error";
+      }
+    }
+
+    foreach my $insert_part_export (
+      grep { ! $old_exportnum{$_->exportnum} } @new_part_export
+    ) {
+      my $error = $insert_part_export->export_insert($new);
+      if ( $error ) {
+        $dbh->rollback if $oldAutoCommit;
+        return "error inserting export to ". $insert_part_export->exporttype.
                " (transaction rolled back): $error";
       }
     }
+
   }
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;




More information about the freeside-commits mailing list