- while (my $cdr = $cdr_search->fetch) {
- my $classnum = $cdr->rated_classnum;
- $classname{$classnum} ||= FS::usage_class->by_key($classnum)->classname
- if $classnum;
- $taxproduct{$classnum} ||= $part_pkg->taxproduct($classnum);
- if (!$taxproduct{$classnum}) {
- warn "part_pkg $pkgpart, class $classnum: ".
- ($taxproduct{$classnum} ?
- "using taxproduct ".$taxproduct{$classnum}->description."\n" :
- "taxproduct not found\n")
- if $DEBUG;
- next;
- }
-
- my $line = sprintf($format,
- substr($cdr->src, 0, 6), 'N',
- substr($cdr->dst, 0, 6), 'N',
- $location->geocode, 'P',
- $cust_type,
- $invoice_date,
- 100000 * $cdr->rated_price, # price (5 decimal places)
- 0, # lines
- 0, # locations
- $taxproduct{$classnum}->taxproduct,
- $resale_mode,
- ($location->incorporated ? 'I' : 'O'),
- 'C', # for Call
- $cdr->acctid,
- # Call duration (tenths of minutes)
- $cdr->duration / 6,
- # Service class indicator ('L'ocal, Long 'D'istance)
- # stupid hack
- (lc($classname{$classnum}) eq 'local' ? 'L' : 'D'),
- );
-
- print $fh $line;
-
- $usage_total += $cdr->rated_price;
-
- } # while $cdr = $cdr_search->fetch
- } # if @$detailnums; otherwise there are no usage details for this line