[freeside-commits] freeside/FS/FS cust_pkg.pm, 1.81, 1.82 Schema.pm, 1.62, 1.63

Ivan,,, ivan at wavetail.420.am
Fri Aug 10 00:01:04 PDT 2007


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

Modified Files:
	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.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- Schema.pm	1 Aug 2007 22:33:55 -0000	1.62
+++ Schema.pm	10 Aug 2007 07:01:02 -0000	1.63
@@ -746,24 +746,28 @@
 
     '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'],
                    ['setup'], ['last_bill'], ['bill'], ['susp'], ['adjourn'],
-                   ['expire'], ['cancel']
+                   ['expire'], ['cancel'],
+                   ['change_date'],
                  ],
     },
 

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- cust_pkg.pm	8 Aug 2007 19:18:35 -0000	1.81
+++ cust_pkg.pm	10 Aug 2007 07:01:02 -0000	1.82
@@ -793,6 +793,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
@@ -1591,9 +1603,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