From 94a66b78bcda5605d7ee5eb7c3e692fb2fe5cf2c Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 5 Aug 2009 23:34:28 +0000 Subject: [PATCH] fix cancellation errors with updated flat_introrate, RT#5865 --- FS/FS/part_pkg/agent.pm | 2 +- FS/FS/part_pkg/base_rate.pm | 4 ++-- FS/FS/part_pkg/flat.pm | 10 +++++----- FS/FS/part_pkg/flat_delayed.pm | 2 +- FS/FS/part_pkg/prorate_delayed.pm | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/FS/FS/part_pkg/agent.pm b/FS/FS/part_pkg/agent.pm index 2ebaf5807..d41978cf5 100644 --- a/FS/FS/part_pkg/agent.pm +++ b/FS/FS/part_pkg/agent.pm @@ -119,7 +119,7 @@ sub calc_recur { my $pkg_setup_fee = $part_pkg->setup_cost || $part_pkg->option('setup_fee'); my $pkg_base_recur = - $part_pkg->recur_cost || $part_pkg->base_recur_permonth; + $part_pkg->recur_cost || $part_pkg->base_recur_permonth($cust_pkg); my $pkg_start = $cust_pkg->get('setup'); if ( $pkg_start < $last_bill ) { diff --git a/FS/FS/part_pkg/base_rate.pm b/FS/FS/part_pkg/base_rate.pm index 64636d9ae..440e98518 100644 --- a/FS/FS/part_pkg/base_rate.pm +++ b/FS/FS/part_pkg/base_rate.pm @@ -63,7 +63,7 @@ sub calc_remain { my $time = time; #should be able to pass this in for credit calculation my $next_bill = $cust_pkg->getfield('bill') || 0; my $last_bill = $cust_pkg->last_bill || 0; - return 0 if ! $self->base_recur + return 0 if ! $self->base_recur($cust_pkg) || ! $self->option('unused_credit', 1) || ! $last_bill || ! $next_bill @@ -81,7 +81,7 @@ sub calc_remain { my $freq_sec = $1 * $sec{$2||'m'}; return 0 unless $freq_sec; - sprintf("%.2f", $self->base_recur * ( $next_bill - $time ) / $freq_sec ); + sprintf("%.2f", $self->base_recur($cust_pkg) * ( $next_bill - $time ) / $freq_sec ); } diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index d1863f432..02ac6aeed 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -162,11 +162,11 @@ sub base_recur { } sub base_recur_permonth { - my($self, $cust_pkg) = @_; #$cust_pkg? + my($self, $cust_pkg) = @_; return 0 unless $self->freq =~ /^\d+$/ && $self->freq > 0; - sprintf('%.2f', $self->base_recur / $self->freq ); + sprintf('%.2f', $self->base_recur($cust_pkg) / $self->freq ); } sub calc_remain { @@ -184,7 +184,7 @@ sub calc_remain { #my $last_bill = $cust_pkg->last_bill || 0; my $last_bill = $cust_pkg->get('last_bill') || 0; #->last_bill falls back to setup - return 0 if ! $self->base_recur + return 0 if ! $self->base_recur($cust_pkg) || ! $self->option('unused_credit', 1) || ! $last_bill || ! $next_bill @@ -202,7 +202,7 @@ sub calc_remain { my $freq_sec = $1 * $sec{$2||'m'}; return 0 unless $freq_sec; - sprintf("%.2f", $self->base_recur * ( $next_bill - $time ) / $freq_sec ); + sprintf("%.2f", $self->base_recur($cust_pkg) * ( $next_bill - $time ) / $freq_sec ); } @@ -216,7 +216,7 @@ sub is_prepaid { sub usage_valuehash { my $self = shift; - map { $_, $self->option($_) } + map { $_, $self->option($_) } grep { $self->option($_, 'hush') } qw(seconds upbytes downbytes totalbytes); } diff --git a/FS/FS/part_pkg/flat_delayed.pm b/FS/FS/part_pkg/flat_delayed.pm index 4a2f1baf1..33f9dd80e 100644 --- a/FS/FS/part_pkg/flat_delayed.pm +++ b/FS/FS/part_pkg/flat_delayed.pm @@ -58,7 +58,7 @@ sub calc_remain { return 0 if $last_bill + (86400 * $free_days) == $next_bill && $last_bill == $cust_pkg->setup; - return 0 if ! $self->base_recur + return 0 if ! $self->base_recur($cust_pkg) || ! $self->option('unused_credit', 1) || ! $last_bill || ! $next_bill; diff --git a/FS/FS/part_pkg/prorate_delayed.pm b/FS/FS/part_pkg/prorate_delayed.pm index 1d227984c..0073493ed 100644 --- a/FS/FS/part_pkg/prorate_delayed.pm +++ b/FS/FS/part_pkg/prorate_delayed.pm @@ -56,7 +56,7 @@ sub calc_remain { return 0 if $last_bill + (86400 * $free_days) == $next_bill && $last_bill == $cust_pkg->setup; - return 0 if ! $self->base_recur + return 0 if ! $self->base_recur($cust_pkg) || ! $self->option('unused_credit', 1) || ! $last_bill || ! $next_bill; -- 2.11.0