[freeside-commits] branch master updated. 5d36f5f81d84e116caae80667e37750e6798e2b1

Ivan Kohler ivan at freeside.biz
Mon May 23 12:27:38 PDT 2022


The branch, master has been updated
       via  5d36f5f81d84e116caae80667e37750e6798e2b1 (commit)
      from  f8a1e695f5339a1fc93960e15f146c96845a881a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5d36f5f81d84e116caae80667e37750e6798e2b1
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon May 23 12:27:38 2022 -0700

    add -i flag to set carrierid, RT#86028, RT#81941

diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 97d444076..e0c4bd4a4 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -1872,10 +1872,11 @@ sub batch_import {
   my $iopt = _import_options;
   $opt->{$_} = $iopt->{$_} foreach keys %$iopt;
 
-  if ( defined $opt->{'cdrtypenum'} ) {
-        $opt->{'preinsert_callback'} = sub {
-                my($record,$param) = (shift,shift);
-                $record->cdrtypenum($opt->{'cdrtypenum'});
+  if ( grep defined $opt->{$_}, qw(cdrtypenum carrierid) ) {
+        $opt->{preinsert_callback} = sub {
+                my($record, $param) = @_;
+                $record->$_($opt->{$_})
+                  foreach grep defined $opt->{$_}, qw(cdrtypenum carrierid);
                 '';
         };
   }
diff --git a/FS/bin/freeside-cdr-sftp_and_import b/FS/bin/freeside-cdr-sftp_and_import
index aa4bf6471..bae805151 100755
--- a/FS/bin/freeside-cdr-sftp_and_import
+++ b/FS/bin/freeside-cdr-sftp_and_import
@@ -12,8 +12,8 @@ use FS::cdr;
 # parse command line
 ###
 
-use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v $opt_P $opt_a $opt_c $opt_g $opt_s $opt_b );
-getopts('c:m:p:r:e:d:v:P:agsb');
+use vars qw( $opt_m $opt_p $opt_r $opt_e $opt_d $opt_v $opt_P $opt_a $opt_c $opt_i $opt_g $opt_s $opt_b );
+getopts('c:i:m:p:r:e:d:v:P:agsb');
 
 $opt_e ||= 'csv';
 #$opt_e = ".$opt_e" unless $opt_e =~ /^\./;
@@ -22,6 +22,7 @@ $opt_e =~ s/^\.//;
 $opt_p ||= '';
 
 die "invalid cdrtypenum" if $opt_c && $opt_c !~ /^\d+$/;
+die "invalid carrierid"  if $opt_i && $opt_i !~ /^\d+$/;
 
 my %options = ();
 
@@ -114,6 +115,7 @@ foreach my $filename ( @$ls ) {
     'empty_ok'        => 1,
   };
   $import_options->{'cdrtypenum'} = $opt_c if $opt_c;
+  $import_options->{'carrierid'}  = $opt_i if $opt_i;
   
   my $error = FS::cdr::batch_import($import_options);
 
@@ -205,7 +207,8 @@ freeside-cdr-sftp_and_import - Download CDR files from a remote server via SFTP
 
   freeside-cdr-sftp_and_import [ -m method ] [ -p prefix ] [ -e extension ] 
     [ -r remotefolder ] [ -d donefolder ] [ -v level ] [ -P port ]
-    [ -a ] [ -g ] [ -s ] [ -c cdrtypenum ] user format [sftpuser@]servername
+    [ -a ] [ -g ] [ -s ] [ -c cdrtypenum ] [ -i carrierid]
+    user format [sftpuser@]servername
 
 =head1 DESCRIPTION
 
@@ -233,6 +236,8 @@ or FTP and then import them into the database.
 
 -c: cdrtypenum to set, defaults to none
 
+-i: carrierid to set, defaults to none
+
 -g: File is gzipped
 
 -s: Warn and skip files which could not be imported rather than abort

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cdr.pm                        |  9 +++++----
 FS/bin/freeside-cdr-sftp_and_import | 11 ++++++++---
 2 files changed, 13 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list