[freeside-commits] branch master updated. b96df4d4dcfebb3df16af89b884e63164bcf15e5

Ivan Kohler ivan at freeside.biz
Mon Nov 27 12:26:01 PST 2017


The branch, master has been updated
       via  b96df4d4dcfebb3df16af89b884e63164bcf15e5 (commit)
       via  2cdb0b3f9e3b778fd914d847fc7851948a9930e4 (commit)
       via  b278990fcae28c2f2c09a66ed8f388ac0fa478f8 (commit)
       via  d2e3299a0af2b5122d73b9f3ca0814a36919b1da (commit)
       via  f2dca165c20e75f7a6048d048f353b56d9f2d621 (commit)
       via  ced2d1a30d90ee14614b767076c72137d2d015d0 (commit)
       via  20f3ebad3b34b3eb6f25ca91e5e794374a4daff8 (commit)
      from  95144265eeb3ecd13b16708dbdd75dd3701f92ad (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 b96df4d4dcfebb3df16af89b884e63164bcf15e5
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:26:00 2017 -0800

    doc

diff --git a/FS/FS/Log.pm b/FS/FS/Log.pm
index aed1f3969..ac218a019 100644
--- a/FS/FS/Log.pm
+++ b/FS/FS/Log.pm
@@ -127,4 +127,19 @@ sub levelmap {
   map { $_ => $LEVELS{$_} } levelnums;
 }
 
+=back
+
+=head1 BUGS
+
+Not yet used universally; being phased in over time.
+
+Not well documented.  Should document the error levels we're using (debug,
+info, warning, error, critical) and the methods to log them.
+
+=head1 SEE ALSO
+
+L<Log::Dispatch>
+
+=cut
+
 1;

commit 2cdb0b3f9e3b778fd914d847fc7851948a9930e4
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:25:35 2017 -0800

    better error handling when a package change fails, RT#78504

diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 2c9468b14..30eb1ab28 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -123,7 +123,7 @@ sub bill {
             'priority' => 99, #don't get in the way of provisioning jobs
           };
           my $error = $queue->insert( 'custnum'=>$custnum, %args );
-
+          die $error if $error;
         }
 
       } else {
@@ -132,7 +132,12 @@ sub bill {
         if ( $disable_bill ) {
           $cust_main->collect( %args, 'debug' => $debug );
         } else {
-          $cust_main->bill_and_collect( %args, 'debug' => $debug );
+          my $error = $cust_main->bill_and_collect( %args, 'fatal' => 'return',
+                                                           'debug' => $debug, );
+          if ( $error ) {
+            $log->error($error);
+            warn $error; #die $error;
+          }
         }
 
       }
diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm
index 69326470a..08b10c1ff 100644
--- a/FS/FS/cust_main/Billing.pm
+++ b/FS/FS/cust_main/Billing.pm
@@ -57,7 +57,7 @@ Cancels and suspends any packages due, generates bills, applies payments and
 credits, and applies collection events to run cards, send bills and notices,
 etc.
 
-By default, warns on errors and continues with the next operation (but see the
+Any errors prevent subsequent operations from continuing and die (but see the
 "fatal" flag below).
 
 Options are passed as name-value pairs.  Currently available options are:
@@ -131,8 +131,7 @@ sub bill_and_collect {
   if ( $error ) {
     $error = "Error expiring custnum ". $self->custnum. ": $error";
     if    ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
-    elsif ( $options{fatal}                                ) { die    $error; }
-    else                                                     { warn   $error; }
+    else                                                     { die    $error; }
   }
 
   $log->debug('suspending adjourned packages', %logopt);
@@ -140,8 +139,7 @@ sub bill_and_collect {
   if ( $error ) {
     $error = "Error adjourning custnum ". $self->custnum. ": $error";
     if    ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
-    elsif ( $options{fatal}                                ) { die    $error; }
-    else                                                     { warn   $error; }
+    else                                                     { die    $error; }
   }
 
   $log->debug('unsuspending resumed packages', %logopt);
@@ -149,8 +147,7 @@ sub bill_and_collect {
   if ( $error ) {
     $error = "Error resuming custnum ".$self->custnum. ": $error";
     if    ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
-    elsif ( $options{fatal}                                ) { die    $error; }
-    else                                                     { warn   $error; }
+    else                                                     { die    $error; }
   }
 
   $job->update_statustext('20,billing packages') if $job;
@@ -159,8 +156,7 @@ sub bill_and_collect {
   if ( $error ) {
     $error = "Error billing custnum ". $self->custnum. ": $error";
     if    ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
-    elsif ( $options{fatal}                                ) { die    $error; }
-    else                                                     { warn   $error; }
+    else                                                     { die    $error; }
   }
 
   $job->update_statustext('50,applying payments and credits') if $job;
@@ -169,8 +165,7 @@ sub bill_and_collect {
   if ( $error ) {
     $error = "Error applying custnum ". $self->custnum. ": $error";
     if    ( $options{fatal} && $options{fatal} eq 'return' ) { return $error; }
-    elsif ( $options{fatal}                                ) { die    $error; }
-    else                                                     { warn   $error; }
+    else                                                     { die    $error; }
   }
 
   # In a batch tax environment, do not run collection if any pending 
@@ -195,8 +190,7 @@ sub bill_and_collect {
     if ( $error ) {
       $error = "Error collecting custnum ". $self->custnum. ": $error";
       if    ($options{fatal} && $options{fatal} eq 'return') { return $error; }
-      elsif ($options{fatal}                               ) { die    $error; }
-      else                                                   { warn   $error; }
+      else                                                   { die    $error; }
     }
   }
 
@@ -216,12 +210,11 @@ sub cancel_expired_pkgs {
 
   my @errors = ();
 
-  my @really_cancel_pkgs;
-  my @cancel_reasons;
+  my @really_cancel_pkgs = ();
+  my @cancel_reasons = ();
 
   CUST_PKG: foreach my $cust_pkg ( @cancel_pkgs ) {
     my $cpr = $cust_pkg->last_cust_pkg_reason('expire');
-    my $error;
 
     if ( $cust_pkg->change_to_pkgnum ) {
 
@@ -231,9 +224,10 @@ sub cancel_expired_pkgs {
                       $cust_pkg->change_to_pkgnum.'; not expiring';
         next CUST_PKG;
       }
-      $error = $cust_pkg->change( 'cust_pkg'        => $new_pkg,
-                                  'unprotect_svcs'  => 1 );
-      $error = '' if ref $error eq 'FS::cust_pkg';
+      my $error = $cust_pkg->change( 'cust_pkg'        => $new_pkg,
+                                     'unprotect_svcs'  => 1,
+                                   );
+      push @errors, $error if $error && ref($error) ne 'FS::cust_pkg';
 
     } else { # just cancel it
 

commit b278990fcae28c2f2c09a66ed8f388ac0fa478f8
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:18:37 2017 -0800

    git merge bs

diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 1e9ce5cde..5762afbe5 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -33,13 +33,8 @@ Example:
 
                      },
                      # "select * from tablename";
-<<<<<<< HEAD
    
     #required (now even if 'query' is an SQL query string)
-=======
-
-    #required unless 'query' is an SQL query string (shouldn't be...)
->>>>>>> 95144265eeb3ecd13b16708dbdd75dd3701f92ad
     'count_query' => 'SELECT COUNT(*) FROM tablename',
 
     ###

commit d2e3299a0af2b5122d73b9f3ca0814a36919b1da
Merge: f2dca165c 95144265e
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:17:49 2017 -0800

    git merge bs

diff --cc httemplate/search/elements/search.html
index 5058a1ac7,476b5095e..1e9ce5cde
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@@ -30,11 -30,11 +30,16 @@@ Example
                         'addl_from' => '', #'LEFT JOIN othertable USING ( key )',
                         'extra_sql' => '', #'AND otherstuff', #'WHERE onlystuff',
                         'order_by'  => 'ORDER BY something',
-    
+ 
                       },
                       # "select * from tablename";
++<<<<<<< HEAD
 +   
 +    #required (now even if 'query' is an SQL query string)
++=======
+ 
+     #required unless 'query' is an SQL query string (shouldn't be...)
++>>>>>>> 95144265eeb3ecd13b16708dbdd75dd3701f92ad
      'count_query' => 'SELECT COUNT(*) FROM tablename',
  
      ###

commit f2dca165c20e75f7a6048d048f353b56d9f2d621
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:15:46 2017 -0800

    doc

diff --git a/httemplate/search/elements/search.html b/httemplate/search/elements/search.html
index 8658774e0..5058a1ac7 100644
--- a/httemplate/search/elements/search.html
+++ b/httemplate/search/elements/search.html
@@ -16,7 +16,7 @@ Example:
                                 # (deprecated, will be singularlized
                                 #  simplisticly)
 
-    #literal SQL query string (deprecated?) or qsearch hashref or arrayref
+    #literal SQL query string (corner cases only) or qsearch hashref or arrayref
     #of qsearch hashrefs for a union of qsearches
     'query'       => {
                        'table'     => 'tablename',
@@ -34,7 +34,7 @@ Example:
                      },
                      # "select * from tablename";
    
-    #required unless 'query' is an SQL query string (shouldn't be...)
+    #required (now even if 'query' is an SQL query string)
     'count_query' => 'SELECT COUNT(*) FROM tablename',
 
     ###
@@ -131,7 +131,7 @@ Example:
     'agent_pos'             => 3, # optional position (starting from 0) to
                                   # insert an Agent column (query needs to be a
                                   # qsearch hashref and header & fields need to
-                                  # be defined)cust_pkg_susp.html
+                                  # be defined)
 
     # sort, link & display properties for fields
 

commit ced2d1a30d90ee14614b767076c72137d2d015d0
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Nov 27 12:15:33 2017 -0800

    clean up encryption module use

diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 479f9b1f1..3dfe75629 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -18,6 +18,7 @@ use DBIx::DBSchema 0.43; #0.43 for foreign keys
 use Locale::Country;
 use Locale::Currency;
 use NetAddr::IP; # for validation
+use Crypt::OpenSSL::RSA;
 use FS::UID qw(dbh datasrc driver_name);
 use FS::CurrentUser;
 use FS::Schema qw(dbdef);
@@ -53,8 +54,6 @@ our $qsearch_qualify_columns = 1;
 
 our $no_check_foreign = 1; #well, not inefficiently in perl by default anymore
 
-my $rsa_module;
-my $rsa_loaded;
 my $rsa_encrypt;
 my $rsa_decrypt;
 
@@ -3363,27 +3362,19 @@ sub decrypt {
 }
 
 sub loadRSA {
-    my $self = shift;
-    #Initialize the Module
-    $rsa_module = 'Crypt::OpenSSL::RSA'; # The Default
+  my $self = shift;
 
-    if ($conf_encryptionmodule && $conf_encryptionmodule ne '') {
-      $rsa_module = $conf_encryptionmodule;
-    }
+  my $rsa_module = $conf_encryptionmodule || 'Crypt::OpenSSL::RSA';
 
-    if (!$rsa_loaded) {
-	eval ("require $rsa_module"); # No need to import the namespace
-	$rsa_loaded++;
-    }
-    # Initialize Encryption
-    if ($conf_encryptionpublickey && $conf_encryptionpublickey ne '') {
-      $rsa_encrypt = $rsa_module->new_public_key($conf_encryptionpublickey);
-    }
+  # Initialize Encryption
+  if ($conf_encryptionpublickey && $conf_encryptionpublickey ne '') {
+    $rsa_encrypt = $rsa_module->new_public_key($conf_encryptionpublickey);
+  }
     
-    # Intitalize Decryption
-    if ($conf_encryptionprivatekey && $conf_encryptionprivatekey ne '') {
-      $rsa_decrypt = $rsa_module->new_private_key($conf_encryptionprivatekey);
-    }
+  # Intitalize Decryption
+  if ($conf_encryptionprivatekey && $conf_encryptionprivatekey ne '') {
+    $rsa_decrypt = $rsa_module->new_private_key($conf_encryptionprivatekey);
+  }
 }
 
 =item h_search ACTION

commit 20f3ebad3b34b3eb6f25ca91e5e794374a4daff8
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Sun Nov 26 13:36:54 2017 -0800

    old config alert_expiration should have been migrated already by v5

diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index e0c555f7b..f1b7e58ec 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -55,14 +55,6 @@ tax_rate_update(%opt);
 use FS::Cron::set_lata_have_usage qw(set_lata_have_usage);
 set_lata_have_usage(%opt);
 
-# we used to send alerts about upcoming credit card expiration here
-my $conf = new FS::Conf;
-if($conf->exists('alert_expiration')) {
-  warn "WARNING: the alert_expiration option is obsolete.  If you ran 
-  freeside-upgrade, it should have configured credit card expiration alerts 
-  as billing events.\n";
-}
-
 #what to do about the below when using -m?  that is the question.
 
 #you don't want to skip this, besides, it should be cheap

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

Summary of changes:
 FS/FS/Cron/bill.pm                     |  9 +++++++--
 FS/FS/Log.pm                           | 15 +++++++++++++++
 FS/FS/Record.pm                        | 33 ++++++++++++---------------------
 FS/FS/cust_main/Billing.pm             | 32 +++++++++++++-------------------
 FS/bin/freeside-daily                  |  8 --------
 httemplate/search/elements/search.html |  8 ++++----
 6 files changed, 51 insertions(+), 54 deletions(-)




More information about the freeside-commits mailing list