From 8f83fe5dedcd703c469a001a6916eff709733c6a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Mar 2010 06:52:59 +0000 Subject: [PATCH] oops, move start_1st and expire_months handling from check to insert, so it doesn't get triggered on edit, RT#7347 --- FS/FS/cust_pkg.pm | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index e553aa36c..e11e82f81 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -251,6 +251,26 @@ an optional queue name for ticket additions sub insert { my( $self, %options ) = @_; + if ( $self->part_pkg->option('start_1st') && !$self->start_date ) { + my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time) )[0,1,2,3,4,5]; + $mon += 1 unless $mday == 1; + until ( $mon < 12 ) { $mon -= 12; $year++; } + $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); + } + + my $expire_months = $self->part_pkg->option('expire_months'); + if ( $expire_months && !$self->expire ) { + my $start = $self->start_date || $self->setup || time; + + #false laziness w/part_pkg::add_freq + my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($start) )[0,1,2,3,4,5]; + $mon += $expire_months; + until ( $mon < 12 ) { $mon -= 12; $year++; } + + #$self->expire( timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year) ); + $self->expire( timelocal_nocheck(0,0,0,$mday,$mon,$year) ); + } + local $SIG{HUP} = 'IGNORE'; local $SIG{INT} = 'IGNORE'; local $SIG{QUIT} = 'IGNORE'; @@ -530,26 +550,6 @@ sub check { } - if ( $self->part_pkg->option('start_1st') && !$self->start_date ) { - my ($sec,$min,$hour,$mday,$mon,$year) = (localtime(time) )[0,1,2,3,4,5]; - $mon += 1 unless $mday == 1; - until ( $mon < 12 ) { $mon -= 12; $year++; } - $self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) ); - } - - my $expire_months = $self->part_pkg->option('expire_months'); - if ( $expire_months && !$self->expire ) { - my $start = $self->start_date || $self->setup || time; - - #false laziness w/part_pkg::add_freq - my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($start) )[0,1,2,3,4,5]; - $mon += $expire_months; - until ( $mon < 12 ) { $mon -= 12; $year++; } - - #$self->expire( timelocal_nocheck($sec,$min,$hour,$mday,$mon,$year) ); - $self->expire( timelocal_nocheck(0,0,0,$mday,$mon,$year) ); - } - $self->otaker(getotaker) unless $self->otaker; $self->otaker =~ /^(\w{1,32})$/ or return "Illegal otaker"; $self->otaker($1); -- 2.11.0