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 );
}
+ 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);
'type' => 'select',
'select_options' => \%temporalities,
},
-
- %usage_fields,
- %usage_recharge_fields,
-
'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
' of service at cancellation',
'type' => 'checkbox',
},
+
+ #used in cust_pkg.pm so could add to any price plan
+ 'expire_months' => { 'name' => 'Auto-add an expiration date this number of months out',
+ },
+ #used in cust_pkg.pm so could add to any price plan where it made sense
+ 'start_1st' => { 'name' => 'Auto-add a start date to the 1st, ignoring the current month.',
+ 'type' => 'checkbox',
+ },
+
+ %usage_fields,
+ %usage_recharge_fields,
+
'externalid' => { 'name' => 'Optional External ID',
'default' => '',
},
},
- 'fieldorder' => [ qw( setup_fee recur_fee recur_temporality unused_credit ),
+ 'fieldorder' => [ qw( setup_fee recur_fee
+ recur_temporality unused_credit
+ expire_months start_1st
+ ),
@usage_fieldorder, @usage_recharge_fieldorder,
qw( externalid ),
],