[freeside-commits] branch FREESIDE_3_BRANCH updated. 79129a414248ce263a8810ba7966bfdc82680674
Mark Wells
mark at 420.am
Thu Jun 2 09:51:07 PDT 2016
The branch, FREESIDE_3_BRANCH has been updated
via 79129a414248ce263a8810ba7966bfdc82680674 (commit)
from 02d95b3bb4f7beb0c4c52751c25bd6d37f8f9b59 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 79129a414248ce263a8810ba7966bfdc82680674
Author: Mark Wells <mark at freeside.biz>
Date: Thu Jun 2 09:17:48 2016 -0700
new CDR detail format to summarize by accountcode, #37808
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index df16c7f..a2b9a8c 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -1264,6 +1264,10 @@ my %export_names = (
'name' => 'Number of calls, one line per service',
'invoice_header' => 'Caller,Rate,Messages,Price',
},
+ 'sum_duration' => {
+ 'name' => 'Summary, one line per service',
+ 'invoice_header' => 'Caller,Rate,Calls,Minutes,Price',
+ },
'sum_duration_prefix' => {
'name' => 'Summary, one line per destination prefix',
'invoice_header' => 'Caller,Rate,Calls,Minutes,Price',
@@ -1272,6 +1276,10 @@ my %export_names = (
'name' => 'Summary, one line per usage class',
'invoice_header' => 'Caller,Class,Calls,Price',
},
+ 'sum_duration_accountcode' => {
+ 'name' => 'Summary, one line per accountcode',
+ 'invoice_header' => 'Caller,Rate,Calls,Minutes,Price',
+ },
);
my %export_formats = ();
diff --git a/FS/FS/detail_format/sum_duration_accountcode.pm b/FS/FS/detail_format/sum_duration_accountcode.pm
new file mode 100644
index 0000000..d181d47
--- /dev/null
+++ b/FS/FS/detail_format/sum_duration_accountcode.pm
@@ -0,0 +1,69 @@
+package FS::detail_format::sum_duration_accountcode;
+
+use strict;
+use vars qw( $DEBUG );
+use base qw(FS::detail_format);
+
+$DEBUG = 0;
+
+my $me = '[sum_duration_accountcode]';
+
+sub name { 'Summary, one line per accountcode' };
+
+sub header_detail {
+ 'Account code,Calls,Duration,Price';
+}
+
+sub append {
+ my $self = shift;
+ my $codes = ($self->{codes} ||= {});
+ my $acctids = ($self->{acctids} ||= []);
+ foreach my $cdr (@_) {
+ my $accountcode = $cdr->accountcode || 'other';
+
+ my $object = $self->{inbound} ? $cdr->cdr_termination(1) : $cdr;
+ my $subtotal = $codes->{$accountcode}
+ ||= { count => 0, duration => 0, amount => 0.0 };
+ $subtotal->{count}++;
+ $subtotal->{duration} += $object->rated_seconds;
+ $subtotal->{amount} += $object->rated_price
+ if $object->freesidestatus ne 'no-charge';
+
+ push @$acctids, $cdr->acctid;
+ }
+}
+
+sub finish {
+ my $self = shift;
+ my $codes = $self->{codes};
+ foreach my $accountcode (sort { $a cmp $b } keys %$codes) {
+
+ warn "processing $accountcode\n" if $DEBUG;
+
+ my $subtotal = $codes->{$accountcode};
+
+ $self->csv->combine(
+ $accountcode,
+ $subtotal->{count},
+ sprintf('%.01f min', $subtotal->{duration}/60),
+ $self->money_char . sprintf('%.02f', $subtotal->{amount})
+ );
+
+ warn "adding detail: ".$self->csv->string."\n" if $DEBUG;
+
+ push @{ $self->{buffer} }, FS::cust_bill_pkg_detail->new({
+ amount => $subtotal->{amount},
+ format => 'C',
+ classnum => '', #ignored in this format
+ duration => $subtotal->{duration},
+ phonenum => '', # not divided up per service
+ accountcode => $accountcode,
+ startdate => '',
+ regionname => '',
+ detail => $self->csv->string,
+ acctid => $self->{acctids},
+ });
+ } #foreach $accountcode
+}
+
+1;
-----------------------------------------------------------------------
Summary of changes:
FS/FS/cdr.pm | 8 +++
FS/FS/detail_format/sum_duration_accountcode.pm | 69 +++++++++++++++++++++++
2 files changed, 77 insertions(+)
create mode 100644 FS/FS/detail_format/sum_duration_accountcode.pm
More information about the freeside-commits
mailing list