[freeside-commits] branch master updated. 649606c0123e1c21b9b054abf63b2933d41df2cc

Ivan ivan at 420.am
Wed Jan 15 22:17:40 PST 2014


The branch, master has been updated
       via  649606c0123e1c21b9b054abf63b2933d41df2cc (commit)
       via  14ab966b8235505b035908eb00159901b0bbf1d5 (commit)
       via  d0eefd4ab72b8c7989dd7d32f8edfbcdc0a733f9 (commit)
       via  6319221f32300d4c641e2a22d5e0836d58fbd1b3 (commit)
       via  964f0dc15597f3abb58a0135ec6c44ed8d022365 (commit)
       via  11171a2f45def9e2edc48d8e5c545a5005ed6bd0 (commit)
       via  b7c25d5e38e6459efe5d1c2f09f437b79798038e (commit)
      from  84f6470e43578bfdc0f57f3083e5924572e88a57 (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 649606c0123e1c21b9b054abf63b2933d41df2cc
Merge: 14ab966 84f6470
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 22:17:36 2014 -0800

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 14ab966b8235505b035908eb00159901b0bbf1d5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 22:16:37 2014 -0800

    voip innovations v3 api, RT#25641

diff --git a/FS/FS/part_export/voip_innovations3.pm b/FS/FS/part_export/voip_innovations3.pm
new file mode 100644
index 0000000..630d0c4
--- /dev/null
+++ b/FS/FS/part_export/voip_innovations3.pm
@@ -0,0 +1,217 @@
+package FS::part_export::voip_innovations3;
+
+use vars qw(@ISA %info);
+use Tie::IxHash;
+use FS::Record qw(qsearch dbh);
+use FS::part_export;
+use FS::phone_avail;
+use Data::Dumper;
+
+ at ISA = qw(FS::part_export);
+
+tie my %options, 'Tie::IxHash',
+  'login'         => { label=>'VoIP Innovations API login' },
+  'password'      => { label=>'VoIP Innovations API password' },
+  'endpointgroup' => { label=>'VoIP Innovations endpoint group number' },
+  'e911'          => { label=>'Provision E911 data',
+                       type=>'checkbox',
+                     },
+  'no_did_provision' => { label=>'Disable DID provisioning',
+                       type=>'checkbox',
+                     },
+  'dry_run'       => { label=>"Test mode - don't actually provision",
+                       type=>'checkbox',
+                     },
+;
+
+%info = (
+  'svc'     => 'svc_phone',
+  'desc'    => 'Provision phone numbers / E911 to VoIP Innovations (API 3.0)',
+  'options' => \%options,
+  'no_machine' => 1,
+  'notes'   => <<'END'
+Requires installation of
+<a href="http://search.cpan.org/dist/Net-VoIP_Innovations">Net::VoIP_Innovations</a>
+from CPAN.
+END
+);
+
+sub rebless { shift; }
+
+sub can_get_dids { 0; } #with API 3.0?  not yet
+
+sub vi_command {
+  my( $self, $command, @args ) = @_;
+
+  eval "use Net::VoIP_Innovations 3.00;";
+  if ( $@ ) {
+    warn $@;
+    die $@;
+  }
+
+  my $gp = Net::VoIP_Innovations->new(
+    'login'    => $self->option('login'),
+    'password' => $self->option('password'),
+    #'debug'    => $debug,
+  );
+
+  $gp->$command(@args);
+}
+
+
+sub _export_insert {
+  my( $self, $svc_phone ) = (shift, shift);
+
+  return '' if $self->option('dry_run');
+
+  #we want to provision and catch errors now, not queue
+
+  unless ( $self->option('no_provision_did') ) {
+
+    ###
+    # reserveDID
+    ###
+
+    my $r = $self->vi_command('reserveDID',
+      'did'           => $svc_phone->phonenum,
+      'minutes'       => 1,
+      'endpointgroup' => $self->option('endpointgroup'),
+    );
+
+    my $rdid = $r->{did};
+
+    if ( $rdid->{'statuscode'} != 100 ) {
+      return "Error running VoIP Innovations reserveDID: ".
+             $rdid->{'statuscode'}. ': '. $rdid->{'status'};
+    }
+
+    ###
+    # assignDID
+    ###
+
+    my $a = $self->vi_command('assignDID',
+      'did'           => $svc_phone->phonenum,
+      'endpointgroup' => $self->option('endpointgroup'),
+      #'rewrite'
+      #'cnam'
+    );
+
+    my $adid = $a->{did};
+
+    if ( $adid->{'statuscode'} != 100 ) {
+      return "Error running VoIP Innovations assignDID: ".
+             $adid->{'statuscode'}. ': '. $adid->{'status'};
+    }
+
+  }
+
+  ###
+  # 911Insert
+  ###
+
+  if ( $self->option('e911') ) {
+
+    my %location_hash = $svc_phone->location_hash;
+    my( $zip, $plus4 ) = split('-', $location_hash->{zip});
+    my $e = $self->vi_command('911Insert',
+      'did'        => $svc_phone->phonenum,
+      'Address1'   => $location_hash{address1},
+      'Address2'   => $location_hash{address2},
+      'City'       => $location_hash{city},
+      'State'      => $location_hash{state},
+      'ZipCode'    => $zip,
+      'PlusFour'   => $plus4,
+      'CallerName' =>
+        $svc_phone->phone_name
+          || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast,
+    );
+
+    my $edid = $e->{did};
+
+    if ( $edid->{'statuscode'} != 100 ) {
+      return "Error running VoIP Innovations 911Insert: ".
+             $edid->{'statuscode'}. ': '. $edid->{'status'};
+    }
+
+  }
+
+  '';
+}
+
+sub _export_replace {
+  my( $self, $new, $old ) = (shift, shift, shift);
+
+  #hmm, anything to change besides E911 data?
+
+  ###
+  # 911Update
+  ###
+
+  if ( $self->option('e911') ) {
+
+    my %location_hash = $svc_phone->location_hash;
+    my( $zip, $plus4 ) = split('-', $location_hash->{zip});
+    my $e = $self->vi_command('911Update',
+      'did'        => $svc_phone->phonenum,
+      'Address1'   => $location_hash{address1},
+      'Address2'   => $location_hash{address2},
+      'City'       => $location_hash{city},
+      'State'      => $location_hash{state},
+      'ZipCode'    => $zip,
+      'PlusFour'   => $plus4,
+      'CallerName' =>
+        $svc_phone->phone_name
+          || $svc_phone->cust_svc->cust_pkg->cust_main->contact_firstlast,
+    );
+
+    my $edid = $e->{did};
+
+    if ( $edid->{'statuscode'} != 100 ) {
+      return "Error running VoIP Innovations 911Update: ".
+             $edid->{'statuscode'}. ': '. $edid->{'status'};
+    }
+
+  }
+
+  '';
+}
+
+sub _export_delete {
+  my( $self, $svc_phone ) = (shift, shift);
+
+  return '' if $self->option('dry_run')
+            || $self->option('no_provision_did');
+
+  #probably okay to queue the deletion...?
+  #but hell, let's do it inline anyway, who wants phone numbers hanging around
+
+  my $r = $self->vi_command('releaseDID',
+    'did'           => $svc_phone->phonenum,
+  );
+
+  my $rdid = $r->{did};
+
+  if ( $rdid->{'statuscode'} != 100 ) {
+    return "Error running VoIP Innovations releaseDID: ".
+           $rdid->{'statuscode'}. ': '. $rdid->{'status'};
+  }
+
+  #delete e911 information?  assuming release clears all that
+
+  '';
+}
+
+sub _export_suspend {
+  my( $self, $svc_phone ) = (shift, shift);
+  #nop for now
+  '';
+}
+
+sub _export_unsuspend {
+  my( $self, $svc_phone ) = (shift, shift);
+  #nop for now
+  '';
+}
+
+1;
+

commit d0eefd4ab72b8c7989dd7d32f8edfbcdc0a733f9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 16:07:30 2014 -0800

    bulk credit import, RT#26319

diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index a403bb3..5225cce 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -428,9 +428,10 @@ $report_menu{'SQL Query'}      = [ $fsurl.'search/report_sql.html', 'SQL Query']
 tie my %tools_importing, 'Tie::IxHash',
   'Customers' => [ $fsurl.'misc/cust_main-import.cgi', '' ],
   'Customer packages' => [ $fsurl.'misc/cust_pkg-import.html', '' ],
-  'Customer comments from CSV file' => [ $fsurl.'misc/cust_main_note-import.html', '' ],
-  'One-time charges from CSV file' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ],
-  'Payments from CSV file' => [ $fsurl.'misc/cust_pay-import.cgi', '' ],
+  'Customer comments' => [ $fsurl.'misc/cust_main_note-import.html', '' ],
+  'One-time charges' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ],
+  'Payments' => [ $fsurl.'misc/cust_pay-import.cgi', '' ],
+  'Credits' => [ $fsurl.'misc/cust_credit-import.html', '' ],
   'Phone numbers (DIDs)' => [ $fsurl.'misc/phone_avail-import.html', '' ],
   'Call Detail Records (CDRs)' => [ $fsurl.'misc/cdr-import.html', '' ],
 ;

commit 6319221f32300d4c641e2a22d5e0836d58fbd1b3
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 16:06:37 2014 -0800

    bulk credit import, RT#26319

diff --git a/httemplate/misc/cust_credit-import.html b/httemplate/misc/cust_credit-import.html
new file mode 100644
index 0000000..6de34e3
--- /dev/null
+++ b/httemplate/misc/cust_credit-import.html
@@ -0,0 +1,79 @@
+<& /elements/header.html, 'Batch Credit Import' &>
+
+Import a file containing credits.
+<BR><BR>
+
+<& /elements/form-file_upload.html,
+     'name'      => 'CreditImportForm',
+     'action'    => 'process/cust_credit-import.cgi',
+     'num_files' => 1,
+     'fields'    => [ 'format', 'credbatch' ],
+     'message'   => 'Credit import successful',
+     'url'       => $p."search/cust_credit.html?credbatch=$credbatch",
+     'onsubmit'  => "document.CreditImportForm.submitButton.disabled=true;",
+&>
+
+
+<% &ntable("#cccccc", 2) %>
+
+  <INPUT TYPE="hidden" NAME="credbatch" VALUE="<% $credbatch %>"%>
+
+  <!--
+  <TR>
+    <TH ALIGN="right">Format</TH>
+    <TD>
+      <SELECT NAME="format">
+        <OPTION VALUE="simple">Simple
+      </SELECT>
+    </TD>
+  </TR>
+  -->
+  <INPUT TYPE="hidden" NAME="format" VALUE="simple">
+
+  <% include( '/elements/file-upload.html',
+                'field' => 'file',
+                'label' => 'Filename',
+            )
+  %>
+
+  <TR>
+    <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
+      <INPUT TYPE    = "submit"
+             ID      = "submitButton"
+             NAME    = "submitButton"
+             VALUE   = "Import file"
+      >
+    </TD>
+  </TR>
+
+</TABLE>
+
+</FORM>
+
+<BR>
+
+Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.  The file should have a .CSV or .XLS extension.
+<BR><BR>
+
+    <b>Default</b> format has the following field order: <i>custnum, amount, reasonnum, invnum</i><br>
+<BR><BR>
+
+Field information:
+<ul>
+  <li><i>custnum</i>: Customer number
+  <li><i>amount</i>:
+  <li><i>reasonnum</i>: <A HREF="<%$p%>browse/reason.html?class=R">Credit reason</A>
+  <li><i>invnum</i>: Invoice number
+</ul>
+<BR><BR>
+
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+my $credbatch = time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
+
+</%init>
diff --git a/httemplate/misc/process/cust_credit-import.cgi b/httemplate/misc/process/cust_credit-import.cgi
new file mode 100644
index 0000000..5a5cfe2
--- /dev/null
+++ b/httemplate/misc/process/cust_credit-import.cgi
@@ -0,0 +1,10 @@
+<% $server->process %>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+my $server =
+  new FS::UI::Web::JSRPC 'FS::cust_credit::process_batch_import', $cgi;
+
+</%init>

commit 964f0dc15597f3abb58a0135ec6c44ed8d022365
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 16:06:00 2014 -0800

    add customer class event condition, RT#26997

diff --git a/FS/FS/part_event/Condition/cust_class.pm b/FS/FS/part_event/Condition/cust_class.pm
new file mode 100644
index 0000000..791bb63
--- /dev/null
+++ b/FS/FS/part_event/Condition/cust_class.pm
@@ -0,0 +1,29 @@
+package FS::part_event::Condition::cust_class;
+use base qw( FS::part_event::Condition );
+
+use strict;
+
+sub description {
+  'Customer class';
+}
+
+sub option_fields {
+  (
+    'cust_class'  => { 'label'    => 'Customer Class',
+                       'type'     => 'select-cust_class',
+                       'multiple' => 1,
+                     },
+  );
+}
+
+sub condition {
+  my( $self, $object ) = @_;
+
+  my $cust_main = $self->cust_main($object);
+
+  my $hashref = $self->option('cust_class') || {};
+  
+  $hashref->{ $cust_main->classnum };
+}
+
+1;

commit 11171a2f45def9e2edc48d8e5c545a5005ed6bd0
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 14:41:16 2014 -0800

    bulk credit import, RT#26319

diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index df59950..3f8d57c 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -1103,6 +1103,58 @@ sub credit_lineitems {
 
 =back
 
+=head1 SUBROUTINES
+
+=over 4
+
+=item process_batch_import
+
+=cut
+
+use List::Util qw( min );
+use FS::cust_bill;
+use FS::cust_credit_bill;
+sub process_batch_import {
+  my $job = shift;
+
+  my $opt = { 'table'   => 'cust_credit',
+              'params'  => [ 'credbatch' ],
+              'formats' => { 'simple' =>
+                               [ 'custnum', 'amount', 'reasonnum', 'invnum' ],
+                           },
+              'default_csv' => 1,
+              'postinsert_callback' => sub {
+                my $cust_credit = shift; #my ($cust_credit, $param ) = @_;
+
+                if ( $cust_credit->invnum ) {
+
+                  my $cust_bill = qsearchs('cust_bill', { invnum=>$cust_credit->invnum } );
+                  my $amount = min( $cust_credit->credited, $cust_bill->owed );
+    
+                  my $cust_credit_bill = new FS::cust_credit_bill ( {
+                    'crednum' => $cust_credit->crednum,
+                    'invnum'  => $cust_bill->invnum,
+                    'amount'  => $amount,
+                  } );
+                  my $error = $cust_credit_bill->insert;
+                  return '' unless $error;
+
+                }
+
+                #apply_payments_and_credits ?
+                $cust_credit->cust_main->apply_credits;
+
+                return '';
+
+              },
+            };
+
+  FS::Record::process_batch_import( $job, $opt, @_ );
+
+}
+
+=back
+
 =head1 BUGS
 
 The delete method.  The replace method.
diff --git a/httemplate/search/cust_credit.html b/httemplate/search/cust_credit.html
index fb6ef83..4526171 100755
--- a/httemplate/search/cust_credit.html
+++ b/httemplate/search/cust_credit.html
@@ -97,6 +97,10 @@ if ( $cgi->param('agentnum') && $cgi->param('agentnum') =~ /^(\d+)$/ ) {
   $title = $agent->agent. " $title";
 }
 
+if ( $cgi->param('credbatch') =~ /^([\w\-\/\.\:]+)$/ ) {
+  push @search, "cust_credit.credbatch = '$1'";
+}
+
 # commission_salesnum
 if ( $cgi->param('commission_salesnum') =~ /^(\d+)$/ ) {
   push @search, "commission_salesnum = $1";

commit b7c25d5e38e6459efe5d1c2f09f437b79798038e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Jan 15 14:36:53 2014 -0800

    bulk credit import, RT#26319

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 150a19d..30a35de 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1285,11 +1285,12 @@ sub tables_hashref {
         'commission_agentnum', 'int', 'NULL', '', '', '', #
         'commission_salesnum', 'int', 'NULL', '', '', '', #
         'commission_pkgnum',   'int', 'NULL', '', '', '', #
+        'credbatch',    'varchar', 'NULL', $char_d, '', '',
       ],
       'primary_key'  => 'crednum',
       'unique'       => [],
       'index'        => [ ['custnum'], ['_date'], ['usernum'], ['eventnum'],
-                          ['commission_salesnum'],
+                          ['commission_salesnum'], ['credbatch'],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],

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

Summary of changes:
 FS/FS/Schema.pm                                    |    3 +-
 FS/FS/cust_credit.pm                               |   52 +++++
 FS/FS/part_event/Condition/cust_class.pm           |   29 +++
 FS/FS/part_export/voip_innovations3.pm             |  217 ++++++++++++++++++++
 httemplate/elements/menu.html                      |    7 +-
 httemplate/misc/cust_credit-import.html            |   79 +++++++
 ...cust_pkg-import.html => cust_credit-import.cgi} |    2 +-
 httemplate/search/cust_credit.html                 |    4 +
 8 files changed, 388 insertions(+), 5 deletions(-)
 create mode 100644 FS/FS/part_event/Condition/cust_class.pm
 create mode 100644 FS/FS/part_export/voip_innovations3.pm
 create mode 100644 httemplate/misc/cust_credit-import.html
 copy httemplate/misc/process/{cust_pkg-import.html => cust_credit-import.cgi} (64%)




More information about the freeside-commits mailing list