[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.73.2.7, 1.73.2.8 Schema.pm, 1.44.2.11, 1.44.2.12

Ivan,,, ivan at wavetail.420.am
Fri Aug 10 00:02:27 PDT 2007


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

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	cust_pkg.pm Schema.pm 
Log Message:
on changing packages, don't set setup date unless old package has one

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.44.2.11
retrieving revision 1.44.2.12
diff -u -d -r1.44.2.11 -r1.44.2.12
--- Schema.pm	1 Aug 2007 22:37:46 -0000	1.44.2.11
+++ Schema.pm	10 Aug 2007 07:02:25 -0000	1.44.2.12
@@ -642,22 +642,29 @@
 
     'cust_pkg' => {
       'columns' => [
-        'pkgnum',    'serial',    '',   '', '', '', 
-        'custnum',   'int',    '',   '', '', '', 
-        'pkgpart',   'int',    '',   '', '', '', 
-        'otaker',    'varchar', '', 32, '', '', 
-        'setup',     @date_type, '', '', 
-        'bill',      @date_type, '', '', 
-        'last_bill', @date_type, '', '', 
-        'susp',      @date_type, '', '', 
-        'adjourn',   @date_type, '', '', 
-        'cancel',    @date_type, '', '', 
-        'expire',    @date_type, '', '', 
-        'manual_flag', 'char', 'NULL', 1, '', '', 
+        'pkgnum',         'serial',    '',   '', '', '', 
+        'custnum',        'int',    '',   '', '', '', 
+        'pkgpart',        'int',    '',   '', '', '', 
+        'otaker',         'varchar', '', 32, '', '', 
+        'setup',          @date_type, '', '', 
+        'bill',           @date_type, '', '', 
+        'last_bill',      @date_type, '', '', 
+        'susp',           @date_type, '', '', 
+        'adjourn',        @date_type, '', '', 
+        'cancel',         @date_type, '', '', 
+        'expire',         @date_type, '', '', 
+        'change_date',    @date_type, '', '',
+        'change_pkgnum',  'int', 'NULL', '', '', '',
+        'change_pkgpart', 'int', 'NULL', '', '', '',
+        'manual_flag',    'char', 'NULL', 1, '', '', 
       ],
       'primary_key' => 'pkgnum',
       'unique' => [],
-      'index' => [ ['custnum'], ['pkgpart'] ],
+      'index' => [ ['custnum'], ['pkgpart'],
+                   ['setup'], ['last_bill'], ['bill'], ['susp'], ['adjourn'],
+                   ['expire'], ['cancel'],
+                   ['change_date'],
+                 ],
     },
 
     'cust_pkg_option' => {

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.73.2.7
retrieving revision 1.73.2.8
diff -u -d -r1.73.2.7 -r1.73.2.8
--- cust_pkg.pm	8 Aug 2007 19:18:37 -0000	1.73.2.7
+++ cust_pkg.pm	10 Aug 2007 07:02:25 -0000	1.73.2.8
@@ -737,6 +737,18 @@
     : qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
 }
 
+=item old_cust_pkg
+
+Returns the cancelled package this package was changed from, if any.
+
+=cut
+
+sub old_cust_pkg {
+  my $self = shift;
+  return '' unless $self->change_pkgnum;
+  qsearchs('cust_pkg', { 'pkgnum' => $self->change_pkgnum } );
+}
+
 =item calc_setup
 
 Calls the I<calc_setup> of the FS::part_pkg object associated with this billing
@@ -1495,9 +1507,17 @@
   my $change = scalar(@old_cust_pkg) != 0;
 
   my %hash = (); 
-  if ( scalar(@old_cust_pkg) == 1 ) {
+  if ( scalar(@old_cust_pkg) == 1 && scalar(@$pkgparts) == 1 ) {
+
+    my $time = time;
+
     #$hash{$_} = $old_cust_pkg[0]->$_() foreach qw( last_bill bill );
-    $hash{'setup'} = time;
+    
+    #$hash{$_} = $old_cust_pkg[0]->$_() foreach qw( setup );
+    $hash{'setup'} = $time if $old_cust_pkg[0]->setup;
+
+    $hash{'change_date'} = $time;
+    $hash{"change_$_"}  = $old_cust_pkg[0]->$_() foreach qw( pkgnum pkgpart );
   }
 
   # Create the new packages.



More information about the freeside-commits mailing list