projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f37f0b
)
respect granularity settings for display of inbound call duration, #71715
author
Mark Wells
<mark@freeside.biz>
Wed, 17 Aug 2016 03:56:07 +0000
(20:56 -0700)
committer
Mark Wells
<mark@freeside.biz>
Wed, 17 Aug 2016 03:56:07 +0000
(20:56 -0700)
FS/FS/Schema.pm
patch
|
blob
|
history
FS/FS/cdr.pm
patch
|
blob
|
history
FS/FS/cdr_termination.pm
patch
|
blob
|
history
FS/FS/detail_format.pm
patch
|
blob
|
history
FS/FS/part_pkg/voip_inbound.pm
patch
|
blob
|
history
diff --git
a/FS/FS/Schema.pm
b/FS/FS/Schema.pm
index
6e5637c
..
29f1b31
100644
(file)
--- a/
FS/FS/Schema.pm
+++ b/
FS/FS/Schema.pm
@@
-5613,6
+5613,7
@@
sub tables_hashref {
'rated_price', 'decimal', 'NULL', '10,4', '', '',
'rated_seconds', 'int', 'NULL', '', '', '',
'rated_minutes', 'double precision', 'NULL', '', '', '',
'rated_price', 'decimal', 'NULL', '10,4', '', '',
'rated_seconds', 'int', 'NULL', '', '', '',
'rated_minutes', 'double precision', 'NULL', '', '', '',
+ 'rated_granularity','int', 'NULL', '', '', '',
'status', 'varchar', 'NULL', 32, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
'status', 'varchar', 'NULL', 32, '', '',
'svcnum', 'int', 'NULL', '', '', '',
],
diff --git
a/FS/FS/cdr.pm
b/FS/FS/cdr.pm
index
d3d62e0
..
155090d
100644
(file)
--- a/
FS/FS/cdr.pm
+++ b/
FS/FS/cdr.pm
@@
-507,8
+507,9
@@
sub set_status_and_rated_price {
rated_price => $rated_price,
status => $status,
});
rated_price => $rated_price,
status => $status,
});
- $term->rated_seconds($opt{rated_seconds}) if exists($opt{rated_seconds});
- $term->rated_minutes($opt{rated_minutes}) if exists($opt{rated_minutes});
+ foreach (qw(rated_seconds rated_minutes rated_granularity)) {
+ $term->set($_, $opt{$_}) if exists($opt{$_});
+ }
$term->svcnum($svcnum) if $svcnum;
return $term->insert;
$term->svcnum($svcnum) if $svcnum;
return $term->insert;
diff --git
a/FS/FS/cdr_termination.pm
b/FS/FS/cdr_termination.pm
index
0209f0d
..
3c1f453
100644
(file)
--- a/
FS/FS/cdr_termination.pm
+++ b/
FS/FS/cdr_termination.pm
@@
-47,6
+47,12
@@
termpart
rated_price
rated_price
+=item rated_seconds
+
+=item rated_minutes
+
+=item rated_granularity
+
=item status
status
=item status
status
@@
-120,6
+126,9
@@
sub check {
#|| $self->ut_foreign_key('termpart', 'part_termination', 'termpart')
|| $self->ut_number('termpart')
|| $self->ut_floatn('rated_price')
#|| $self->ut_foreign_key('termpart', 'part_termination', 'termpart')
|| $self->ut_number('termpart')
|| $self->ut_floatn('rated_price')
+ || $self->ut_numbern('rated_seconds')
+ || $self->ut_floatn('rated_minutes')
+ || $self->ut_numbern('rated_granularity')
|| $self->ut_enum('status', [ '', 'processing-tiered', 'done' ] ) # , 'skipped' ] )
;
return $error if $error;
|| $self->ut_enum('status', [ '', 'processing-tiered', 'done' ] ) # , 'skipped' ] )
;
return $error if $error;
diff --git
a/FS/FS/detail_format.pm
b/FS/FS/detail_format.pm
index
d032100
..
78517dd
100644
(file)
--- a/
FS/FS/detail_format.pm
+++ b/
FS/FS/detail_format.pm
@@
-186,6
+186,11
@@
rated_regionname => regionname
accountcode => accountcode
startdate => startdate
accountcode => accountcode
startdate => startdate
+If the formatter is in inbound mode, it will look up a C<cdr_termination>
+record and use rated_price and rated_seconds from that, and acctid will be
+set to null to avoid linking the CDR to the detail record for the inbound
+leg of the call.
+
'phonenum' is set to the internal C<phonenum> value set on the formatter
object.
'phonenum' is set to the internal C<phonenum> value set on the formatter
object.
@@
-209,10
+214,10
@@
sub single_detail {
$price = 0 if $cdr->freesidestatus eq 'no-charge';
FS::cust_bill_pkg_detail->new( {
$price = 0 if $cdr->freesidestatus eq 'no-charge';
FS::cust_bill_pkg_detail->new( {
- 'acctid' =>
$cdr->acctid
,
+ 'acctid' =>
($self->{inbound} ? '' : $cdr->acctid)
,
'amount' => $price,
'classnum' => $cdr->rated_classnum,
'amount' => $price,
'classnum' => $cdr->rated_classnum,
- 'duration' => $
cdr
->rated_seconds,
+ 'duration' => $
object
->rated_seconds,
'regionname' => $cdr->rated_regionname,
'accountcode' => $cdr->accountcode,
'startdate' => $cdr->startdate,
'regionname' => $cdr->rated_regionname,
'accountcode' => $cdr->accountcode,
'startdate' => $cdr->startdate,
@@
-280,13
+285,11
@@
sub duration {
my $object = $self->{inbound} ? $cdr->cdr_termination(1) : $cdr;
my $sec = $object->rated_seconds if $object;
$sec ||= 0;
my $object = $self->{inbound} ? $cdr->cdr_termination(1) : $cdr;
my $sec = $object->rated_seconds if $object;
$sec ||= 0;
- # XXX termination objects don't have rated_granularity so this may
- # result in inbound CDRs being displayed as min/sec when they shouldn't.
- # Should probably fix this.
- if ( $cdr->rated_granularity eq '0' ) {
+ # termination objects now have rated_granularity.
+ if ( $object->rated_granularity eq '0' ) {
'1 call';
}
'1 call';
}
- elsif ( $
cdr
->rated_granularity eq '60' ) {
+ elsif ( $
object
->rated_granularity eq '60' ) {
sprintf('%dm', ($sec + 59)/60);
}
else {
sprintf('%dm', ($sec + 59)/60);
}
else {
diff --git
a/FS/FS/part_pkg/voip_inbound.pm
b/FS/FS/part_pkg/voip_inbound.pm
index
81f2765
..
e911439
100644
(file)
--- a/
FS/FS/part_pkg/voip_inbound.pm
+++ b/
FS/FS/part_pkg/voip_inbound.pm
@@
-292,10
+292,7
@@
sub calc_usage {
my @call_details = (
$cdr->downstream_csv( 'format' => $output_format,
'charge' => $charge,
my @call_details = (
$cdr->downstream_csv( 'format' => $output_format,
'charge' => $charge,
- 'seconds' => ($use_duration
- ? $cdr->duration
- : $cdr->billsec
- ),
+ 'seconds' => $seconds,
'granularity' => $granularity,
)
);
'granularity' => $granularity,
)
);
@@
-317,10
+314,10
@@
sub calc_usage {
'done',
$charge,
$cust_svc->svcnum,
'done',
$charge,
$cust_svc->svcnum,
- 'rated_seconds' => $
use_duration ? $cdr->duration : $cdr->billsec
,
+ 'rated_seconds' => $
seconds
,
'rated_granularity' => $granularity,
'rated_classnum' => $cdr->calltypenum,
'rated_granularity' => $granularity,
'rated_classnum' => $cdr->calltypenum,
- 'inbound' => 1,
+ 'inbound' => 1,
# to update cdr_termination, not cdr
);
die $error if $error;
$formatter->append($cdr);
);
die $error if $error;
$formatter->append($cdr);