fix for new svc_pbx.title CDR matching, thanks jeff, RT#8084
[freeside.git] / FS / FS / part_pkg / voip_cdr.pm
index 326f3cc..9e21ba2 100644 (file)
@@ -15,7 +15,7 @@ use FS::part_pkg::recur_Common;
 
 @ISA = qw(FS::part_pkg::recur_Common);
 
-$DEBUG = 0;
+$DEBUG = 1;
 
 tie my %cdr_svc_method, 'Tie::IxHash',
   'svc_phone.phonenum' => 'Phone numbers (svc_phone.phonenum)',
@@ -325,7 +325,7 @@ sub calc_usage {
   die $@ if $@;
   my $csv = new Text::CSV_XS;
 
-  my($svc_table, $svc_field) = split('.', $cdr_svc_method);
+  my($svc_table, $svc_field) = split('\.', $cdr_svc_method);
 
   foreach my $cust_svc (
     grep { $_->part_svc->svcdb eq $svc_table } $cust_pkg->cust_svc
@@ -581,16 +581,16 @@ sub calc_usage {
 
           $charge = sprintf('%.2f', $rate_detail->conn_charge);
 
-          if ( $included_min{$regionnum} <= 0 ) {
+          if ( $included_min{$regionnum} < 0 ) {
             my $charge_min = 0 - $included_min{$regionnum}; #XXX should preserve
                                                             #(display?) this
             $included_min{$regionnum} = 0;
             $charge += sprintf('%.2f', ($rate_detail->min_charge * $charge_min)
                                        + 0.00000001 ); #so 1.005 rounds to 1.01
             $charge = sprintf('%.2f', $charge);
-            warn "Incrementing \$charges by $charge.  Now $charges\n" if $DEBUG;
-            $charges += $charge;
           }
+          warn "Incrementing \$charges by $charge.  Now $charges\n" if $DEBUG;
+          $charges += $charge;
 
           # this is why we need regionnum/rate_region....
           warn "  (rate region $rate_region)\n" if $DEBUG;