projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add option to rate CDRs with toll-free accountcodes on src, RT#24031
[freeside.git]
/
FS
/
FS
/
cdr.pm
diff --git
a/FS/FS/cdr.pm
b/FS/FS/cdr.pm
index
3ebe6c4
..
5658be9
100644
(file)
--- a/
FS/FS/cdr.pm
+++ b/
FS/FS/cdr.pm
@@
-92,6
+92,8
@@
following fields are currently supported:
=item dst_ip_addr - Destination IP address (same)
=item dst_ip_addr - Destination IP address (same)
+=item dst_term - Terminating destination number (if different from dst)
+
=item startdate - Start of call (UNIX-style integer timestamp)
=item answerdate - Answer time of call (UNIX-style integer timestamp)
=item startdate - Start of call (UNIX-style integer timestamp)
=item answerdate - Answer time of call (UNIX-style integer timestamp)
@@
-194,6
+196,7
@@
sub table_info {
#'lastdata' => '',
'src_ip_addr' => 'Source IP',
'dst_ip_addr' => 'Dest. IP',
#'lastdata' => '',
'src_ip_addr' => 'Source IP',
'dst_ip_addr' => 'Dest. IP',
+ 'dst_term' => 'Termination dest.',
'startdate' => 'Start date',
'answerdate' => 'Answer date',
'enddate' => 'End date',
'startdate' => 'Start date',
'answerdate' => 'Answer date',
'enddate' => 'End date',
@@
-677,8
+680,19
@@
sub rate_prefix {
# (or calling station id for toll free calls)
###
# (or calling station id for toll free calls)
###
+ my $eff_ratenum = $self->is_tollfree('accountcode')
+ ? $part_pkg->option_cacheable('accountcode_tollfree_ratenum')
+ : '';
+
my( $to_or_from, $column );
my( $to_or_from, $column );
- if ( $self->is_tollfree && ! $part_pkg->option_cacheable('disable_tollfree') )
+ if(
+ ( $self->is_tollfree
+ && ! $part_pkg->option_cacheable('disable_tollfree')
+ )
+ or ( $eff_ratenum
+ && $part_pkg->option_cacheable('accountcode_tollfree_field') eq 'src'
+ )
+ )
{ #tollfree call
$to_or_from = 'from';
$column = 'src';
{ #tollfree call
$to_or_from = 'from';
$column = 'src';
@@
-699,10
+713,6
@@
sub rate_prefix {
#asterisks here causes inserting the detail to barf, so:
$pretty_dst =~ s/\*//g;
#asterisks here causes inserting the detail to barf, so:
$pretty_dst =~ s/\*//g;
- my $eff_ratenum = $self->is_tollfree('accountcode')
- ? $part_pkg->option_cacheable('accountcode_tollfree_ratenum')
- : '';
-
my $ratename = '';
my $intrastate_ratenum = $part_pkg->option_cacheable('intrastate_ratenum');
if ( $intrastate_ratenum && !$self->is_tollfree ) {
my $ratename = '';
my $intrastate_ratenum = $part_pkg->option_cacheable('intrastate_ratenum');
if ( $intrastate_ratenum && !$self->is_tollfree ) {
@@
-901,7
+911,7
@@
sub rate_prefix {
#${$opt{region_group_included_min}} -= $minutes
# if $region_group && $rate_detail->region_group;
#${$opt{region_group_included_min}} -= $minutes
# if $region_group && $rate_detail->region_group;
- if ( $included_min->{$regionnum}{$ratetimenum} > $minutes ) {
+ if ( $included_min->{$regionnum}{$ratetimenum} >
=
$minutes ) {
$charge_sec = 0;
$included_min->{$regionnum}{$ratetimenum} -= $minutes;
} else {
$charge_sec = 0;
$included_min->{$regionnum}{$ratetimenum} -= $minutes;
} else {
@@
-932,8
+942,12
@@
sub rate_prefix {
}
#should preserve (display?) this
}
#should preserve (display?) this
- my $charge_min = ( $charge_sec - $conn_seconds ) / 60;
- $charge += ($rate_detail->min_charge * $charge_min) if $charge_min > 0; #still not rounded
+ if ( $granularity == 0 ) { # per call rate
+ $charge += $rate_detail->min_charge;
+ } else {
+ my $charge_min = ( $charge_sec - $conn_seconds ) / 60;
+ $charge += ($rate_detail->min_charge * $charge_min) if $charge_min > 0; #still not rounded
+ }
}
}
@@
-951,9
+965,15
@@
sub rate_prefix {
# this is why we need regionnum/rate_region....
warn " (rate region $rate_region)\n" if $DEBUG;
# this is why we need regionnum/rate_region....
warn " (rate region $rate_region)\n" if $DEBUG;
+ # NOW round it.
+ my $rounding = $part_pkg->option_cacheable('rounding') || 2;
+ my $sprintformat = '%.'. $rounding. 'f';
+ my $roundup = 10**(-3-$rounding);
+ my $price = sprintf($sprintformat, $charge + $roundup);
+
$self->set_status_and_rated_price(
'rated',
$self->set_status_and_rated_price(
'rated',
- sprintf('%.2f', $charge + 0.000001), # NOW round it.
+ $price,
$opt{'svcnum'},
'rated_pretty_dst' => $pretty_dst,
'rated_regionname' => $rate_region->regionname,
$opt{'svcnum'},
'rated_pretty_dst' => $pretty_dst,
'rated_regionname' => $rate_region->regionname,