1 package FS::part_pkg::delayed_Mixin;
5 use Time::Local qw(timelocal);
11 'free_days' => { 'name' => 'Initial free days',
14 'delay_setup' => { 'name' => 'Delay setup fee in addition to recurring fee',
17 'recur_notify' => { 'name' => 'Number of days before recurring billing'.
18 ' commences to notify customer. (0 means'.
23 'fieldorder' => [ 'free_days', 'delay_setup', 'recur_notify', ],
28 my( $cust_pkg, $time ) = @_;
30 unless ( $self->option('delay_setup', 1) ) {
31 my $d = $cust_pkg->bill || $time;
32 $d += 86400 * $self->option('free_days');
36 $self->NEXT::calc_setup(@_);
40 my ($self, $cust_pkg, %options) = @_;
42 unless ( $self->option('delay_setup', 1) ) {
43 my $last_bill = $cust_pkg->last_bill || 0;
44 my $next_bill = $cust_pkg->getfield('bill') || 0;
45 my $free_days = $self->option('free_days');
47 return 0 if $last_bill + (86400 * $free_days) == $next_bill
48 && $last_bill == $cust_pkg->setup;
51 return $self->NEXT::calc_remain($cust_pkg, %options);
56 ! $self->option('delay_setup', 1) && $self->NEXT::can_start_date(@_);
59 sub default_start_date {
61 if ( $self->option('delay_setup') and $self->option('free_days') ) {
62 my $delay = $self->option('free_days');
64 my ($mday, $mon, $year) = (localtime(time))[3,4,5];
65 return timelocal(0,0,0,$mday,$mon,$year) + 86400 * $self->option('free_days');
67 return $self->NEXT::default_start_date(@_);