tax engine refactoring for Avalara and Billsoft tax vendors, #25718
[freeside.git] / FS / FS / detail_format / sum_duration_prefix.pm
index 0459041..3c33dc1 100644 (file)
@@ -24,8 +24,12 @@ my $prefix_length = 6;
 sub append {
   my $self = shift;
   my $prefixes = ($self->{prefixes} ||= {});
+  my $acctids = ($self->{acctids} ||= []);
   foreach my $cdr (@_) {
-    my $phonenum = $self->{inbound} ? $cdr->src : $cdr->dst;
+    my (undef, $phonenum) = $cdr->parse_number(
+      column => ( $self->{inbound} ? 'src' : 'dst' ),
+    );
+
     $phonenum =~ /^(\d{$prefix_length})/;
     my $prefix = $1 || 'other';
     warn "$me appending ".$cdr->dst." to $prefix\n" if $DEBUG;
@@ -49,6 +53,8 @@ sub append {
     $subtotal->{duration} += $object->rated_seconds;
     $subtotal->{amount} += $object->rated_price
       if $object->freesidestatus ne 'no-charge';
+
+    push @$acctids, $cdr->acctid;
   }
 }
 
@@ -88,6 +94,7 @@ sub finish {
         startdate   => '', #could use the earliest startdate in the bunch?
         regionname  => '', #no, we're using prefix instead
         detail      => $self->csv->string,
+        acctid      => $self->{acctids},
     });
   } #foreach $prefix
 }