taqua config to rewrite DA calls, RT#4502
authorivan <ivan>
Mon, 12 Jan 2009 23:51:34 +0000 (23:51 +0000)
committerivan <ivan>
Mon, 12 Jan 2009 23:51:34 +0000 (23:51 +0000)
FS/FS/Conf.pm
FS/FS/Record.pm
FS/FS/cdr/taqua.pm

index 1e594e5..72fb98c 100644 (file)
@@ -2014,14 +2014,14 @@ worry that config_items is freeside-specific and icky.
   {
     'key'         => 'tax-ship_address',
     'section'     => 'billing',
-    'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.  Note: Tax reports can take a long time when enabled.',
+    'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.',
     'type'        => 'checkbox',
   }
 ,
   {
     'key'         => 'tax-pkg_address',
     'section'     => 'billing',
-    'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the package address instead (when present).  Note: Tax reports can take a long time when enabled.',
+    'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the package address instead (when present).',
     'type'        => 'checkbox',
   },
 
@@ -2624,6 +2624,12 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cdr-taqua-da_rewrite',
+    'section'     => '',
+    'description' => 'For the Taqua CDR format, a comma-separated list of directory assistance 800 numbers.  Any CDRs with these numbers as "BilledNumber" will be rewritten to the "CallingPartyNumber" (and CallType "12") on import.',
+    'type'        => 'text',
+  },
 
 );
 
index 16949fa..b53c333 100644 (file)
@@ -1365,14 +1365,16 @@ Formats hashref.  Keys are field names, values are listrefs that define the
 format.
 
 Each listref value can be a column name or a code reference.  Coderefs are run
-with the row object and data as the two parameters.  For example, this coderef
-does the same thing as using the "columnname" string:
+with the row object, data and a FS::Conf object as the three parameters.
+For example, this coderef does the same thing as using the "columnname" string:
 
   sub {
-    my( $record, $data ) = @_;
+    my( $record, $data, $conf ) = @_;
     $record->columnname( $data );
   },
 
+Coderefs are run after all "column name" fields are assigned.
+
 =item format_types
 
 Optional format hashref of types.  Keys are field names, values are "csv",
@@ -1662,7 +1664,7 @@ sub batch_import {
     while ( scalar(@later) ) {
       my $sub = shift @later;
       my $data = shift @later;
-      &{$sub}($record, $data);  # $record->&{$sub}($data); 
+      &{$sub}($record, $data, $conf);  # $record->&{$sub}($data, $conf); 
     }
 
     my $error = $record->insert;
index fdbba8e..3052f83 100644 (file)
@@ -1,7 +1,7 @@
 package FS::cdr::taqua;
 
 use strict;
-use vars qw(@ISA %info);
+use vars qw(@ISA %info $da_rewrite);
 use FS::cdr qw(_cdr_date_parser_maker);
 
 @ISA = qw(FS::cdr);
@@ -60,7 +60,28 @@ use FS::cdr qw(_cdr_date_parser_maker);
     sub { my($cdr, $field) = @_; },       #TermCircuit
     sub { my($cdr, $field) = @_; },       #TermCircuitType
     'carrierid',                          #OutboundCarrierId
-    'charged_party',                      #BillingNumber
+
+    #BillingNumber
+    #'charged_party',                      
+    sub {
+      my( $cdr, $field, $conf ) = @_;
+
+      #could be more efficient for the no config case, if anyone ever needs that
+      $da_rewrite ||= $conf->config('cdr-taqua-da_rewrite');
+
+      if ( $da_rewrite && $field =~ /\d/ ) {
+        my $rewrite = $da_rewrite;
+        $rewrite =~ s/\s//g;
+        my @rewrite = split(',', $conf->config('cdr-taqua-da_rewrite') );
+        if ( grep { $field eq $_ } @rewrite ) {
+          $cdr->charged_party( $cdr->src() );
+          $cdr->calltypenum(12);
+          return;
+        }
+      }
+      $cdr->charged_party($field);
+    },
+
     sub { my($cdr, $field) = @_; },       #SubscriberNumber
     'lastapp',                            #ServiceName
     sub { my($cdr, $field) = @_; },       #some weirdness #ChargeTime