diff options
author | ivan <ivan> | 2007-08-10 07:01:02 +0000 |
---|---|---|
committer | ivan <ivan> | 2007-08-10 07:01:02 +0000 |
commit | 550c31c6cc2616461ec0f6cfd36f1b0a244a4bd1 (patch) | |
tree | e25eac6c3ce04c960288965c71a1e660dd1622a8 /FS | |
parent | 51055278448998492df09d0ecd8fbd5b000ee688 (diff) |
on changing packages, don't set setup date unless old package has one
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 30 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 24 |
2 files changed, 39 insertions, 15 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index adc32a29a..b7e754573 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -746,24 +746,28 @@ sub tables_hashref { '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'], ], }, diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index eca3af488..c411fb32f 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -793,6 +793,18 @@ sub part_pkg { : 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 @@ sub order { 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. |