'duration', 'int', 'NULL', '', 0, '',
'phonenum', 'varchar', 'NULL', 15, '', '',
'accountcode', 'varchar', 'NULL', 20, '', '',
+ 'startdate', @date_type, '', '',
'regionname', 'varchar', 'NULL', $char_d, '', '',
'detail', 'varchar', '', 255, '', '',
],
# (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"
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;
}
'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 ) {
=item accountcode - accountcode
+=item startdate - CDR startdate, if any
+
=item detail - detail description
=back
$classnum,
$phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
$regionname,
];
$classnum,
$phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
$regionname,
];
$cdr->calltypenum, #classnum
$self->phonenum,
$cdr->accountcode,
+ $cdr->startdate,
$seconds,
'', #regionname, not set for inbound calls
];