1 package FS::part_pkg::flat_introrate;
2 use base qw( FS::part_pkg::flat );
10 'name' => 'Introductory price for X months, then flat rate,'.
11 'relative to setup date (anniversary billing)',
12 'shortname' => 'Anniversary, with intro price',
13 'inherit_fields' => [ 'flat', 'usage_Mixin', 'global_Mixin' ],
15 'intro_fee' => { 'name' => 'Introductory recurring fee for this package',
19 { 'name' => 'Duration of the introductory period, in number of months',
23 'fieldorder' => [ qw(intro_duration intro_fee) ],
28 my($self, $cust_pkg, $time ) = @_;
30 warn "flat_introrate base_recur requires date!" if !$time;
31 my $now = $time ? $$time : time;
33 my ($duration) = ($self->option('intro_duration') =~ /^\s*(\d+)\s*$/);
34 unless (length($duration)) {
35 my $log = FS::Log->new('FS::part_pkg');
36 $log->warning("Invalid intro_duration '".$self->option('intro_duration')."' on pkgpart ".$self->pkgpart
37 .", defaulting to 0, check package definition");
40 my $intro_end = $self->add_freq($cust_pkg->setup, $duration);
42 if ($now < $intro_end) {
43 return $self->option('intro_fee');
45 return $self->option('recur_fee');