summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2011-07-26 23:48:01 +0000
committerlevinse <levinse>2011-07-26 23:48:01 +0000
commitfd81134f9f262894f7133ac3084d64c52a686093 (patch)
tree051abc3ea7cc1b6fa5fe673dc47e6222ddd661e0 /FS
parent31c11989cb384c8e5eac83bebac5d00519b217d9 (diff)
accountcode billing, RT12181
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_bill.pm13
-rw-r--r--FS/FS/cust_bill_pkg.pm5
-rw-r--r--FS/FS/cust_bill_pkg_detail.pm2
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm2
-rw-r--r--FS/FS/part_pkg/voip_inbound.pm1
6 files changed, 17 insertions, 7 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6fde8b1..49eddf6 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -701,6 +701,7 @@ sub tables_hashref {
'duration', 'int', 'NULL', '', 0, '',
'phonenum', 'varchar', 'NULL', 15, '', '',
'accountcode', 'varchar', 'NULL', 20, '', '',
+ 'startdate', @date_type, '', '',
'regionname', 'varchar', 'NULL', $char_d, '', '',
'detail', 'varchar', '', 255, '', '',
],
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 7669479..4ea67b6 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -2351,7 +2351,6 @@ notice_name - overrides "Invoice" as the name of the sent document (templates fr
# (alignment in text invoice?) problems to change them all to '%.2f' ?
# yes: fixed width (dot matrix) text printing will be borked
sub print_generic {
-
my( $self, %params ) = @_;
my $today = $params{today} ? $params{today} : time;
warn "$me print_generic called on $self with suffix $params{template}\n"
@@ -4222,21 +4221,25 @@ sub _items_accountcode_cdr {
quantity => '',
product_code => 'N/A',
section => $section,
- ext_description => [],
+ ext_description => [ $section->{'header'} ],
+ detail_temp => [],
};
$section->{'amount'} += $amount;
$accountcodes{$accountcode}{'amount'} += $amount;
$accountcodes{$accountcode}{calls}++;
$accountcodes{$accountcode}{duration} += $detail->duration;
- push @{$accountcodes{$accountcode}{ext_description}},
- $detail->formatted('format' => $format);
+ push @{$accountcodes{$accountcode}{detail_temp}}, $detail;
}
}
foreach my $l ( values %accountcodes ) {
$l->{amount} = sprintf( "%.2f", $l->{amount} );
- unshift @{$l->{ext_description}}, $section->{'header'};
+ my @sorted_detail = sort { $a->startdate <=> $b->startdate } @{$l->{detail_temp}};
+ foreach my $sorted_detail ( @sorted_detail ) {
+ push @{$l->{ext_description}}, $sorted_detail->formatted('format'=>$format);
+ }
+ delete $l->{detail_temp};
push @lines, $l;
}
diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm
index d332e36..29663c5 100644
--- a/FS/FS/cust_bill_pkg.pm
+++ b/FS/FS/cust_bill_pkg.pm
@@ -154,8 +154,9 @@ sub insert {
'classnum' => (ref($detail) ? $detail->[3] : '' ),
'phonenum' => (ref($detail) ? $detail->[4] : '' ),
'accountcode' => (ref($detail) ? $detail->[5] : '' ),
- 'duration' => (ref($detail) ? $detail->[6] : '' ),
- 'regionname' => (ref($detail) ? $detail->[7] : '' ),
+ 'startdate' => (ref($detail) ? $detail->[6] : '' ),
+ 'duration' => (ref($detail) ? $detail->[7] : '' ),
+ 'regionname' => (ref($detail) ? $detail->[8] : '' ),
};
$error = $cust_bill_pkg_detail->insert;
if ( $error ) {
diff --git a/FS/FS/cust_bill_pkg_detail.pm b/FS/FS/cust_bill_pkg_detail.pm
index 9ac164c..eb0ae96 100644
--- a/FS/FS/cust_bill_pkg_detail.pm
+++ b/FS/FS/cust_bill_pkg_detail.pm
@@ -57,6 +57,8 @@ inherits from FS::Record. The following fields are currently supported:
=item accountcode - accountcode
+=item startdate - CDR startdate, if any
+
=item detail - detail description
=back
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 8363873..5f191f2 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -774,6 +774,7 @@ sub calc_usage {
$classnum,
$phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
$regionname,
];
@@ -786,6 +787,7 @@ sub calc_usage {
$classnum,
$phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
$regionname,
];
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index a96e978..15faf5b 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -285,6 +285,7 @@ sub calc_usage {
$cdr->calltypenum, #classnum
$self->phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
'', #regionname, not set for inbound calls
];