From 6231b4d0a5f2c78cca6ba10adb920b4ada986f14 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 20 Jan 2011 00:38:15 +0000 Subject: [PATCH] intro periods and DST, RT#11018 --- FS/FS/part_pkg/bulk.pm | 4 ++-- FS/FS/part_pkg/discount_Mixin.pm | 2 +- FS/FS/part_pkg/flat_introrate.pm | 20 +++++--------------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm index 0df929edf..beee06913 100644 --- a/FS/FS/part_pkg/bulk.pm +++ b/FS/FS/part_pkg/bulk.pm @@ -45,7 +45,7 @@ sub calc_recur { my $last_bill = $cust_pkg->last_bill; - return sprintf("%.2f", $self->base_recur($cust_pkg) ) + return sprintf("%.2f", $self->base_recur($cust_pkg, $sdate) ) unless $$sdate > $last_bill; my $total_svc_charge = 0; @@ -113,7 +113,7 @@ sub calc_recur { } } - sprintf('%.2f', $self->base_recur($cust_pkg) + $total_svc_charge ); + sprintf('%.2f', $self->base_recur($cust_pkg, $sdate) + $total_svc_charge ); } sub can_discount { 0; } diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm index a0bdcee0a..83f1a77c1 100644 --- a/FS/FS/part_pkg/discount_Mixin.pm +++ b/FS/FS/part_pkg/discount_Mixin.pm @@ -41,7 +41,7 @@ discount and generates an invoice detail describing it. sub calc_discount { my($self, $cust_pkg, $sdate, $details, $param ) = @_; - my $br = $self->base_recur($cust_pkg); + my $br = $self->base_recur($cust_pkg, $sdate); $br += $param->{'override_charges'} if $param->{'override_charges'}; my $tot_discount = 0; diff --git a/FS/FS/part_pkg/flat_introrate.pm b/FS/FS/part_pkg/flat_introrate.pm index 1447730e7..33cc3d48a 100644 --- a/FS/FS/part_pkg/flat_introrate.pm +++ b/FS/FS/part_pkg/flat_introrate.pm @@ -4,8 +4,6 @@ use strict; use vars qw(@ISA %info $DEBUG $me); use FS::part_pkg::flat; -use Date::Manip qw(DateCalc UnixDate ParseDate); - @ISA = qw(FS::part_pkg::flat); $me = '[' . __PACKAGE__ . ']'; $DEBUG = 0; @@ -31,29 +29,21 @@ $DEBUG = 0; sub base_recur { my($self, $cust_pkg, $time ) = @_; + warn "flat_introrate base_recur requires date!" if !$time; my $now = $time ? $$time : time; my ($duration) = ($self->option('intro_duration') =~ /^(\d+)$/); unless ($duration) { die "Invalid intro_duration: " . $self->option('intro_duration'); } + my $intro_end = $self->add_freq($cust_pkg->setup, $duration); - my $setup = &ParseDate('epoch ' . $cust_pkg->getfield('setup')); - my $intro_end = &DateCalc($setup, "+${duration} month"); - my $recur; - - warn "$me: \$duration = ${duration}" if $DEBUG; - warn "$me: \$intro_end = ${intro_end}" if $DEBUG; - warn "$me: $now < " . &UnixDate($intro_end, '%s') if $DEBUG; - - if ($now < &UnixDate($intro_end, '%s')) { - $recur = $self->option('intro_fee'); + if ($now < $intro_end) { + return $self->option('intro_fee'); } else { - $recur = $self->option('recur_fee'); + return $self->option('recur_fee'); } - $recur; - } -- 2.11.0