diff options
author | Mark Wells <mark@freeside.biz> | 2013-07-06 17:30:47 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-07-06 17:30:47 -0700 |
commit | 8240403713de07e6b9c1d8a645838791e80823b7 (patch) | |
tree | cc9e0f177e9a764b9dc231f1a1458cdb7104ce9e /FS/FS/part_pkg.pm | |
parent | 5e4d3c3f6b9b1aa27ff66f4c772f8f8a8c7ade54 (diff) |
delayed package start option, #20686
Diffstat (limited to 'FS/FS/part_pkg.pm')
-rw-r--r-- | FS/FS/part_pkg.pm | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 22e8828d6..0722647b4 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -5,7 +5,7 @@ use strict; use vars qw( %plans $DEBUG $setup_hack $skip_pkg_svc_hack ); use Carp qw(carp cluck confess); use Scalar::Util qw( blessed ); -use Time::Local qw( timelocal_nocheck ); +use Time::Local qw( timelocal timelocal_nocheck ); use Tie::IxHash; use FS::Conf; use FS::Record qw( qsearch qsearchs dbh dbdef ); @@ -116,6 +116,8 @@ If this record is not obsolete, will be null. ancestor of this record. If this record is not a successor to another part_pkg, will be equal to pkgpart. +=item delay_start - Number of days to delay package start, by default + =back =head1 METHODS @@ -682,6 +684,7 @@ sub check { ) || $self->ut_numbern('fcc_ds0s') || $self->ut_numbern('fcc_voip_class') + || $self->ut_numbern('delay_start') || $self->ut_foreign_keyn('successor', 'part_pkg', 'pkgpart') || $self->ut_foreign_keyn('family_pkgpart', 'part_pkg', 'pkgpart') || $self->SUPER::check @@ -1072,9 +1075,39 @@ sub is_free { } } +# whether the plan allows discounts to be applied to this package sub can_discount { 0; } - + +# whether the plan allows changing the start date sub can_start_date { 1; } + +# the default start date; takes an FS::cust_main as an argument +sub default_start_date { + my $self = shift; + my $cust_main = shift; + my $conf = FS::Conf->new; + + if ( $self->delay_start ) { + my $delay = $self->delay_start; + + my ($mday,$mon,$year) = (localtime(time))[3,4,5]; + my $start_date = timelocal(0,0,0,$mday,$mon,$year) + 86400 * $delay; + return $start_date; + + } elsif ( $conf->exists('order_pkg-no_start_date') ) { + + return ''; + + } elsif ( $cust_main ) { + + return $cust_main->next_bill_date; + + } else { + + return ''; + + } +} sub can_currency_exchange { 0; } |