X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fflat.pm;h=9bb45e624881515970e95a1443ebd6257f965790;hb=0fcdc36642e1430f02ebf5326740e231883bd41f;hp=17188577050dd8df2e29d35fa9f8e97d88c0c9a0;hpb=467b269c5cacef3e8486e2288f1b0eeec8fea088;p=freeside.git diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm index 171885770..9bb45e624 100644 --- a/FS/FS/part_pkg/flat.pm +++ b/FS/FS/part_pkg/flat.pm @@ -144,7 +144,8 @@ sub unit_setup { } sub calc_recur { - my($self, $cust_pkg) = @_; + my $self = shift; + my($cust_pkg) = @_; #my $last_bill = $cust_pkg->last_bill; my $last_bill = $cust_pkg->get('last_bill'); #->last_bill falls back to setup @@ -152,7 +153,7 @@ sub calc_recur { return 0 if $self->option('recur_temporality', 1) eq 'preceding' && $last_bill == 0; - $self->base_recur($cust_pkg); + $self->base_recur(@_); } sub base_recur { @@ -161,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 { @@ -183,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 @@ -201,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 ); } @@ -209,20 +210,20 @@ sub is_free_options { qw( setup_fee recur_fee ); } -sub is_prepaid { - 0; #no, we're postpaid -} +sub is_prepaid { 0; } #no, we're postpaid + +sub can_discount { 1; } #and anything that inherits from us sub usage_valuehash { my $self = shift; - map { $_, $self->option($_) } + map { $_, $self->option($_) } grep { $self->option($_, 'hush') } qw(seconds upbytes downbytes totalbytes); } sub reset_usage { my($self, $cust_pkg, %opt) = @_; - warn " resetting usage counters" if $opt{debug} > 1; + warn " resetting usage counters" if defined($opt{debug}) && $opt{debug} > 1; my %values = $self->usage_valuehash; if ($self->option('usage_rollover', 1)) { $cust_pkg->recharge(\%values);