default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / FS / FS / cdr / broadsoft.pm
index d9530bb..ab48150 100644 (file)
@@ -23,6 +23,20 @@ use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
   sep_char => ',',
   disabled => 0,
 
+  #deal with broadsoft's awful non-standard CSV escaping :/
+  row_callback => sub {
+    my $line = shift;
+    $line = qq("$line");       # put " at the beginning and end
+    $line =~ s/(?<!\\),/","/g; # all commas not after a \ become ","
+    $line =~ s/\\,/,/g;        # and now we can turn \, into ,
+    #XXX embedded \r and \n ?  none in my test data, and might be better to 
+    # leave escaped and deal with it from there?
+    $line =~ s/\\\\/\\/g;     # undo double backslashes?  none in my test data
+
+    #and now we have a properly formed CSV line
+    $line;
+  },
+
   import_fields => [
 
     # 1: recordId
@@ -119,7 +133,13 @@ use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
     #122: otherPartyName
     'clid',
 
-    skip(23), #123-145 inclusive
+    #123: otherPartyNamePresentationIndicator
+    sub {
+      my( $cdr, $data ) = @_;
+      $cdr->clid( $data ) unless $data =~ /^Public$/i;
+    },
+
+    skip(22), #124-145 inclusive
 
     # 146: chargedNumber
     'charged_party',