X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fsqlradacct_daily.pm;h=ab1afd75c1b35bf87a440f299b4ff6fd272496b8;hb=dc83512c36dc6bea2585abada4f88d714c600e55;hp=7bfdd525fe6d65a99b137521ec1ffd092da5e9af;hpb=5569583bbd74d5f497e2b2923815ff1f66a28be7;p=freeside.git diff --git a/FS/FS/part_pkg/sqlradacct_daily.pm b/FS/FS/part_pkg/sqlradacct_daily.pm index 7bfdd525f..ab1afd75c 100644 --- a/FS/FS/part_pkg/sqlradacct_daily.pm +++ b/FS/FS/part_pkg/sqlradacct_daily.pm @@ -1,9 +1,10 @@ -package FS::part_pkg::sqlradacct_hour; +package FS::part_pkg::sqlradacct_daily; use base qw( FS::part_pkg::flat ); use strict; use vars qw(%info); use Time::Local qw( timelocal timelocal_nocheck ); +use Date::Format; #use FS::Record qw(qsearch qsearchs); %info = ( @@ -65,20 +66,25 @@ use Time::Local qw( timelocal timelocal_nocheck ); 'default' => 0, }, + 'monthly_cap' => { 'name' => 'Monthly (billing frequency) cap on all overage charges'. + ' (0 means no cap)', + 'default' => 0, + }, + }, - 'fieldorder' => [qw( recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap )], - 'weight' => 41, + 'fieldorder' => [qw( recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap monthly_cap )], + 'weight' => 40.1, ); sub price_info { my $self = shift; - my $str = $self->SUPER::price_info; + my $str = $self->SUPER::price_info(@_); $str .= " plus usage" if $str; $str; } #hacked-up false laziness w/sqlradacct_hour, -# but keeping it separate to start with is safer for existing folks +# but keeping it separate to start with is safer for existing folks sub calc_recur { my($self, $cust_pkg, $sdate, $details ) = @_; @@ -90,15 +96,15 @@ sub calc_recur { # bill that day, we didn't have a full picture of the day's usage) # and ending with sdate exclusive (same reason) - my($l_day, $l_mon, $l_year) = (localtime($last_bill))[3,5]; + my($l_day, $l_mon, $l_year) = (localtime($last_bill))[3..5]; my $day_start = timelocal(0,0,0, $l_day, $l_mon, $l_year); - my($s_day, $s_mon, $s_year) = (localtime($$sdate))[3,5]; + my($s_day, $s_mon, $s_year) = (localtime($$sdate))[3..5]; my $billday_start = timelocal(0,0,0, $s_day, $s_mon, $s_year); while ( $day_start < $billday_start ) { - my($day, $mon, $year) = (localtime($day_start))[3,5]; + my($day, $mon, $year) = (localtime($day_start))[3..5]; my $tomorrow = timelocal_nocheck(0,0,0, $day+1, $mon, $year); #afact the usage methods already use the lower bound inclusive and the upper @@ -178,6 +184,10 @@ sub calc_recur { $day_start = $tomorrow; } + $charges = $self->option('monthly_cap') + if $self->option('monthly_cap') + && $charges > $self->option('monthly_cap'); + $self->option('recur_fee') + $charges; }