+# tells whether cust_bill_pkg_detail should return a single line for
+# each phonenum
+sub sum_usage {
+ my $self = shift;
+ $self->option('output_format') =~ /^sum_/;
+}
+
+sub sum_detail {
+ my $self = shift;
+ my $svc_x = shift;
+ my $invoice_details = shift || [];
+ my $count = scalar(@$invoice_details);
+ return () if !$count;
+ my $sum_detail = {
+ amount => 0,
+ format => 'C',
+ classnum => '', #XXX
+ duration => 0,
+ phonenum => $svc_x->phonenum,
+ accountcode => '', #XXX
+ startdate => '', #XXX
+ regionnam => '',
+ };
+ # combine the entire set of CDRs
+ foreach ( @$invoice_details ) {
+ $sum_detail->{amount} += $_->[0]{amount};
+ $sum_detail->{duration} += $_->[0]{duration};
+ }
+ my $total_cdr = FS::cdr->new({
+ 'billsec' => $sum_detail->{duration},
+ 'src' => $sum_detail->{phonenum},
+ });
+ $sum_detail->{detail} = $total_cdr->downstream_csv(
+ format => $self->option('output_format'),
+ seconds => $sum_detail->{duration},
+ charge => sprintf('%.2f',$sum_detail->{amount}),
+ phonenum => $sum_detail->{phonenum},
+ count => $count,
+ );
+ return $sum_detail;
+}
+
+# and whether cust_bill should show a detail line for the service label
+# (separate from usage details)
+sub hide_svc_detail {
+ my $self = shift;
+ $self->option('output_format') =~ /^sum_/;
+}
+
+