[freeside-commits] freeside/FS/FS cust_pkg.pm,1.154,1.155

Ivan,,, ivan at wavetail.420.am
Mon Mar 8 18:43:38 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv2093/FS/FS

Modified Files:
	cust_pkg.pm 
Log Message:
a package that starts on the 1st and expires after N months, RT#7738

Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -w -d -r1.154 -r1.155
--- cust_pkg.pm	9 Mar 2010 02:12:28 -0000	1.154
+++ cust_pkg.pm	9 Mar 2010 02:43:36 -0000	1.155
@@ -6,6 +6,7 @@
 use Scalar::Util qw( blessed );
 use List::Util qw(max);
 use Tie::IxHash;
+use Time::Local qw( timelocal_nocheck );
 use MIME::Entity;
 use FS::UID qw( getotaker dbh );
 use FS::Misc qw( send_email );
@@ -543,6 +544,26 @@
 
   }
 
+  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);



More information about the freeside-commits mailing list