X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg.pm;h=9ce2e9687a751e0ee38e78a241d2b87efaca6485;hb=65f3ee811a83be47ef02e0919ec122ad4083ccbd;hp=15c29c4bcfaf5d9f2ae6dbe101aac9274e997411;hpb=116ae6107240a49c854de2662678abb4fbb8acab;p=freeside.git diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 15c29c4bc..9ce2e9687 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -5,7 +5,8 @@ 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 timelocal_nocheck ); +use DateTime; +use Time::Local qw( timelocal timelocal_nocheck ); # eventually replace with DateTime use Tie::IxHash; use FS::Conf; use FS::Record qw( qsearch qsearchs dbh dbdef ); @@ -1089,32 +1090,16 @@ 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 { +# the delay start date if present +sub delay_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') ) { + my $delay = $self->delay_start or return ''; - return ''; - - } elsif ( $cust_main ) { - - return $cust_main->next_bill_date; - - } else { - - return ''; - - } + # avoid timelocal silliness + my $dt = DateTime->today(time_zone => 'local'); + $dt->add(days => $delay); + $dt->epoch; } sub can_currency_exchange { 0; } @@ -1665,6 +1650,17 @@ sub cust_bill_pkg_recur { $cust_bill_pkg->recur; } +=item unit_setup CUST_PKG + +Returns the setup fee for one unit of the package. + +=cut + +sub unit_setup { + my ($self, $cust_pkg) = @_; + $self->option('setup_fee') || 0; +} + =item format OPTION DATA Returns data formatted according to the function 'format' described