From: levinse Date: Tue, 26 Jul 2011 23:48:01 +0000 (+0000) Subject: accountcode billing, RT12181 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=fd81134f9f262894f7133ac3084d64c52a686093 accountcode billing, RT12181 --- diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 6fde8b1e5..49eddf6df 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 7669479eb..4ea67b69a 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 d332e363f..29663c5cc 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 9ac164ced..eb0ae9677 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 836387325..5f191f280 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 a96e9787c..15faf5b33 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 ];