X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fvoip_cdr.pm;h=34b5571e60c0f7a45e3b62235875365b09c21e35;hb=6d63ac7337203c5ea73aebce87d93d663606f386;hp=7c5272edcb4ff45ab2b17b03df0d01fe2480b046;hpb=2b8f2f7d7c2fa79072f7404865691239f23fa5ba;p=freeside.git diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 7c5272edc..34b5571e6 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -12,7 +12,7 @@ use FS::rate; use FS::rate_prefix; use FS::rate_detail; -@ISA = qw(FS::part_pkg::flat); +@ISA = qw(FS::part_pkg::prorate); $DEBUG = 0; @@ -55,6 +55,14 @@ tie my %temporalities, 'Tie::IxHash', 'type' => 'checkbox', }, + 'enable_prorate' => { 'name' => 'Enable prorating of the first month', + 'type' => 'checkbox', + }, + + 'cutoff_day' => { 'name' => 'Billing Day (1 - 28) for prorating ', + 'default' => '1', + }, + 'rating_method' => { 'name' => 'Region rating method', 'type' => 'radio', 'options' => \%rating_method, @@ -175,6 +183,7 @@ tie my %temporalities, 'Tie::IxHash', }, 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit + enable_prorate cutoff_day rating_method ratenum ignore_unrateable default_prefix disable_src @@ -183,6 +192,7 @@ tie my %temporalities, 'Tie::IxHash', use_amaflags use_disposition use_disposition_taqua use_carrierid use_cdrtypenum skip_dcontext skip_dstchannel_prefix + skip_dst_length_less skip_lastapp use_duration 411_rewrite output_format summarize_usage usage_section @@ -199,7 +209,8 @@ sub calc_setup { #false laziness w/voip_sqlradacct calc_recur resolve it if that one ever gets used again sub calc_recur { - my($self, $cust_pkg, $sdate, $details, $param ) = @_; + my $self = shift; + my($cust_pkg, $sdate, $details, $param ) = @_; #my $last_bill = $cust_pkg->last_bill; my $last_bill = $cust_pkg->get('last_bill'); #->last_bill falls back to setup @@ -456,9 +467,11 @@ sub calc_recur { $included_min{$regionnum} -= $minutes; if ( $included_min{$regionnum} < 0 ) { - my $charge_min = 0 - $included_min{$regionnum}; + my $charge_min = 0 - $included_min{$regionnum}; #XXX should preserve + #(display?) this $included_min{$regionnum} = 0; - $charge = sprintf('%.2f', $rate_detail->min_charge * $charge_min ); + $charge = sprintf('%.2f', ( $rate_detail->min_charge * $charge_min ) + + 0.00000001 ); #so 1.005 rounds to 1.01 $charges += $charge; } @@ -541,8 +554,13 @@ sub calc_recur { } #if ( $spool_cdr && length($downstream_cdr) ) - $charges += $self->option('recur_fee') - if $param->{'increment_next_bill'}; + if ($param->{'increment_next_bill'}) { + if ( $self->option('enable_prorate', 1) ) { + $charges += $self->SUPER::calc_recur(@_); + } else { + $charges += $self->option('recur_fee') + } + } $charges; }