1 package FS::part_pkg::flat_introrate;
4 use vars qw(@ISA %info $DEBUG $me);
5 use FS::part_pkg::flat;
7 @ISA = qw(FS::part_pkg::flat);
8 $me = '[' . __PACKAGE__ . ']';
12 'name' => 'Introductory price for X months, then flat rate,'.
13 'relative to setup date (anniversary billing)',
14 'shortname' => 'Anniversary, with intro price',
15 'inherit_fields' => [ 'flat', 'usage_Mixin', 'global_Mixin' ],
17 'intro_fee' => { 'name' => 'Introductory recurring fee for this package',
21 { 'name' => 'Duration of the introductory period, in number of months',
25 'fieldorder' => [ qw(intro_duration intro_fee) ],
30 my($self, $cust_pkg, $time ) = @_;
32 warn "flat_introrate base_recur requires date!" if !$time;
33 my $now = $time ? $$time : time;
35 my ($duration) = ($self->option('intro_duration') =~ /^\s*(\d+)\s*$/);
36 unless (length($duration)) {
37 die "Invalid intro_duration: " . $self->option('intro_duration');
39 my $intro_end = $self->add_freq($cust_pkg->setup, $duration);
41 if ($now < $intro_end) {
42 return $self->option('intro_fee');
44 return $self->option('recur_fee');