[freeside-commits] freeside/FS/FS/part_pkg voip_inbound.pm, 1.8, 1.9
Erik Levinson
levinse at wavetail.420.am
Thu Jun 16 12:42:05 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv31406/FS/FS/part_pkg
Modified Files:
voip_inbound.pm
Log Message:
part_pkg/voip_inbound.pm: add included minutes feature, RT12306
Index: voip_inbound.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_inbound.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- voip_inbound.pm 27 Apr 2011 05:22:22 -0000 1.8
+++ voip_inbound.pm 16 Jun 2011 19:42:03 -0000 1.9
@@ -48,6 +48,9 @@
'min_charge' => { 'name' => 'Charge per minute',
},
+ 'min_included' => { 'name' => 'Minutes included',
+ },
+
'sec_granularity' => { 'name' => 'Granularity',
'type' => 'select',
'select_options' => \%granularity,
@@ -145,7 +148,7 @@
'fieldorder' => [qw(
recur_temporality
recur_method cutoff_day add_full_period
- min_charge sec_granularity
+ min_charge min_included sec_granularity
default_prefix
disable_tollfree
use_amaflags use_disposition
@@ -207,7 +210,9 @@
my $spool_cdr = $cust_pkg->cust_main->spool_cdr;
- my %included_min = ();
+ my $included_min = ($self->option('min_included')
+ && $self->option('min_included') > 0)
+ ? $self->option('min_included') : 0;
my $charges = 0;
@@ -254,9 +259,23 @@
my $minutes = sprintf("%.1f",$seconds / 60);
$minutes =~ s/\.0$// if $granularity == 60; # count whole minutes, convert to integer
$minutes = 1 unless $granularity; # per call
- my $charge = sprintf('%.2f', ( $self->option('min_charge') * $minutes )
+
+ my $charge_min = $minutes;
+ my $charge = 0;
+
+ $included_min -= $minutes;
+ if ( $included_min > 0 ) {
+ $charge_min = 0;
+ }
+ else {
+ $charge_min = 0 - $included_min;
+ $included_min = 0;
+ }
+
+ $charge = sprintf('%.2f', ( $self->option('min_charge') * $charge_min )
+ 0.00000001 ); #so 1.00005 rounds to 1.0001
- next if !$charge;
+
+ if ( $charge > 0 ) {
$charges += $charge;
my @call_details = ($cdr->downstream_csv( 'format' => $output_format,
'charge' => $charge,
@@ -274,6 +293,7 @@
$seconds,
'', #regionname, not set for inbound calls
];
+ }
my $error = $cdr->set_status_and_rated_price( 'done',
$charge,
More information about the freeside-commits
mailing list