summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-03-08 20:30:02 -0800
committerMark Wells <mark@freeside.biz>2012-03-08 20:30:02 -0800
commit984fff08c579ff72f6eb7f658d9373079eafb16a (patch)
tree7652101bc01162e6d4fea5482767d22309bfb225 /FS
parent440a4fe4f826a59a660d744889b24eb751da675b (diff)
"simple with accountcode" CDR format, #16348
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cdr.pm12
-rw-r--r--FS/FS/detail_format.pm7
-rw-r--r--FS/FS/detail_format/accountcode_simple.pm24
-rw-r--r--FS/FS/part_pkg/voip_inbound.pm59
4 files changed, 77 insertions, 25 deletions
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 9b70719..1769fe9 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -1017,6 +1017,10 @@ my %export_names = (
'invoice_header' => "Date,Time,Called From,Destination,Duration,Price",
#"Date,Time,Name,Called From,Destination,Duration,Price",
},
+ 'accountcode_simple' => {
+ 'name' => 'Simple with accountcode',
+ 'invoice_header' => "Date,Time,Called From,Account,Duration,Price",
+ },
'basic' => {
'name' => 'Basic',
'invoice_header' => "Date/Time,Called Number,Min/Sec,Price",
@@ -1114,6 +1118,14 @@ sub export_formats {
#sub { sprintf('%.3f', shift->upstream_price ) }, #PRICE
$price_sub,
],
+ 'accountcode_simple' => [
+ sub { time2str($date_format, shift->calldate_unix ) }, #DATE
+ sub { time2str('%r', shift->calldate_unix ) }, #TIME
+ 'src', #called from
+ 'accountcode', #NUMBER_DIALED
+ $duration_sub, #DURATION
+ $price_sub,
+ ],
'sum_duration' => [
# for summary formats, the CDR is a fictitious object containing the
# total billsec and the phone number of the service
diff --git a/FS/FS/detail_format.pm b/FS/FS/detail_format.pm
index af97f36..f70acc6 100644
--- a/FS/FS/detail_format.pm
+++ b/FS/FS/detail_format.pm
@@ -171,11 +171,12 @@ sub single_detail {
die "$me error combining ".$self->csv->error_input."\n"
if !$status;
- my $rated_price = $cdr->rated_price;
- $rated_price = 0 if $cdr->freesidestatus eq 'no-charge';
+ my $object = $self->{inbound} ? $cdr->cdr_termination(1) : $cdr;
+ my $price = $object->rated_price if $object;
+ $price = 0 if $cdr->freesidestatus eq 'no-charge';
FS::cust_bill_pkg_detail->new( {
- 'amount' => $rated_price,
+ 'amount' => $price,
'classnum' => $cdr->rated_classnum,
'duration' => $cdr->rated_seconds,
'regionname' => $cdr->rated_regionname,
diff --git a/FS/FS/detail_format/accountcode_simple.pm b/FS/FS/detail_format/accountcode_simple.pm
new file mode 100644
index 0000000..10a28db
--- /dev/null
+++ b/FS/FS/detail_format/accountcode_simple.pm
@@ -0,0 +1,24 @@
+package FS::detail_format::accountcode_simple;
+
+use strict;
+use base qw(FS::detail_format);
+use Date::Format qw(time2str);
+
+sub name { 'Simple with source' }
+
+sub header_detail { 'Date,Time,Called From,Account,Duration,Price' }
+
+sub columns {
+ my $self = shift;
+ my $cdr = shift;
+ (
+ time2str($self->date_format, $cdr->startdate),
+ time2str('%r', $cdr->startdate),
+ $cdr->src,
+ $cdr->accountcode,
+ $self->duration($cdr),
+ $self->price($cdr),
+ )
+}
+
+1;
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index a16ef1f..f4e5183 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -10,6 +10,7 @@ use FS::Conf;
use FS::Record qw(qsearchs qsearch);
use FS::cdr;
use FS::rate_detail;
+use FS::detail_format;
$DEBUG = 0;
@@ -208,6 +209,10 @@ sub calc_usage {
my $included_min = $self->option('min_included', 1) || 0;
my $use_duration = $self->option('use_duration');
my $output_format = $self->option('output_format', 1) || 'default';
+
+ my $formatter =
+ FS::detail_format->new($output_format, buffer => $details, inbound => 1);
+
my $granularity = length($self->option('sec_granularity'))
? $self->option('sec_granularity')
: 60;
@@ -279,31 +284,41 @@ sub calc_usage {
'granularity' => $granularity,
)
);
- push @$details,
- { format => 'C',
- detail => $call_details[0],
- amount => $charge,
- classnum => $cdr->calltypenum, #classnum
- #phonenum => $self->phonenum,
- accountcode => $cdr->accountcode,
- startdate => $cdr->startdate,
- duration => $seconds,
- # regionname?? => '', #regionname, not set for inbound calls
- };
- }
-
- my $error = $cdr->set_status_and_rated_price( 'done',
- $charge,
- $cust_svc->svcnum,
- 'inbound' => 1 );
- die $error if $error;
+# push @$details,
+# { format => 'C',
+# detail => $call_details[0],
+# amount => $charge,
+# classnum => $cdr->calltypenum, #classnum
+# #phonenum => $self->phonenum,
+# accountcode => $cdr->accountcode,
+# startdate => $cdr->startdate,
+# duration => $seconds,
+# # regionname?? => '', #regionname, not set for inbound calls
+# };
+ }
+
+ # eventually use FS::cdr::rate for this
+ my $error = $cdr->set_status_and_rated_price(
+ 'done',
+ $charge,
+ $cust_svc->svcnum,
+ 'rated_seconds' => $use_duration ? $cdr->duration : $cdr->billsec,
+ 'rated_granularity' => $granularity,
+ 'rated_classnum' => $cdr->calltypenum,
+ 'inbound' => 1,
+ );
+ die $error if $error;
+ $formatter->append($cdr);
} #$cdr
} # $cust_svc
- unshift @$details, { format => 'C',
- detail => FS::cdr::invoice_header($output_format),
- }
- if @$details;
+# unshift @$details, { format => 'C',
+# detail => FS::cdr::invoice_header($output_format),
+# }
+# if @$details;
+
+ $formatter->finish;
+ unshift @$details, $formatter->header if @$details;
$charges;
}