[freeside-commits] freeside/FS/FS part_pkg.pm, 1.105, 1.106 cust_pkg.pm, 1.169, 1.170
Mark Wells
mark at wavetail.420.am
Wed Sep 8 17:35:31 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv22368
Modified Files:
part_pkg.pm cust_pkg.pm
Log Message:
auto-adjourn option in flat packages, RT#9516
Index: part_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg.pm,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -w -d -r1.105 -r1.106
--- part_pkg.pm 29 Jul 2010 23:11:31 -0000 1.105
+++ part_pkg.pm 9 Sep 2010 00:35:29 -0000 1.106
@@ -809,32 +809,34 @@
}
}
-=item add_freq TIMESTAMP
+=item add_freq TIMESTAMP [ FREQ ]
-Adds the frequency of this package to the provided timestamp and returns
-the resulting timestamp, or -1 if the frequency of this package could not be
-parsed (shouldn't happen).
+Adds a billing period of some frequency to the provided timestamp and
+returns the resulting timestamp, or -1 if the frequency could not be
+parsed (shouldn't happen). By default, the frequency of this package
+will be used; to override this, pass a different frequency as a second
+argument.
=cut
sub add_freq {
- my( $self, $date ) = @_;
- my $freq = $self->freq;
+ my( $self, $date, $freq ) = @_;
+ $freq = $self->freq if !defined($freq);
#change this bit to use Date::Manip? CAREFUL with timezones (see
# mailing list archive)
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($date) )[0,1,2,3,4,5];
- if ( $self->freq =~ /^\d+$/ ) {
- $mon += $self->freq;
+ if ( $freq =~ /^\d+$/ ) {
+ $mon += $freq;
until ( $mon < 12 ) { $mon -= 12; $year++; }
- } elsif ( $self->freq =~ /^(\d+)w$/ ) {
+ } elsif ( $freq =~ /^(\d+)w$/ ) {
my $weeks = $1;
$mday += $weeks * 7;
- } elsif ( $self->freq =~ /^(\d+)d$/ ) {
+ } elsif ( $freq =~ /^(\d+)d$/ ) {
my $days = $1;
$mday += $days;
- } elsif ( $self->freq =~ /^(\d+)h$/ ) {
+ } elsif ( $freq =~ /^(\d+)h$/ ) {
my $hours = $1;
$hour += $hours;
} else {
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -w -d -r1.169 -r1.170
--- cust_pkg.pm 27 Aug 2010 02:10:14 -0000 1.169
+++ cust_pkg.pm 9 Sep 2010 00:35:29 -0000 1.170
@@ -259,17 +259,12 @@
$self->start_date( timelocal_nocheck(0,0,0,1,$mon,$year) );
}
- my $expire_months = $self->part_pkg->option('expire_months', 1);
- if ( $expire_months && !$self->expire ) {
+ foreach my $action ( qw(expire adjourn) ) {
+ my $months = $self->part_pkg->option("${action}_months",1);
+ if($months and !$self->$action) {
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->$action( $self->part_pkg->add_freq($start, $months) );
+ }
}
local $SIG{HUP} = 'IGNORE';
More information about the freeside-commits
mailing list