[freeside-commits] branch master updated. 905f2144894749fc95baab979e176dddac9073c2

Ivan ivan at 420.am
Thu Jun 21 22:14:14 PDT 2012


The branch, master has been updated
       via  905f2144894749fc95baab979e176dddac9073c2 (commit)
       via  8fda1089d5d697c9c11fa7ad163c2647ad15ce91 (commit)
      from  f8befd3b7d617e918214ef786c642130d5634675 (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 905f2144894749fc95baab979e176dddac9073c2
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Jun 21 22:14:13 2012 -0700

    freeside-daily optimization

diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 8d1223b..a9df376 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -200,15 +200,15 @@ sub bill_where {
   # select * from cust_main where
   my $where_pkg = <<"END";
     EXISTS(
-      SELECT 1 FROM cust_pkg
+      SELECT 1 FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart )
         WHERE cust_main.custnum = cust_pkg.custnum
           AND ( cancel IS NULL OR cancel = 0 )
-          AND (    ( ( setup IS NULL OR setup =  0 )
+          AND (    ( ( cust_pkg.setup IS NULL OR cust_pkg.setup =  0 )
                      AND ( start_date IS NULL OR start_date = 0
                            OR ( start_date IS NOT NULL AND start_date <= $^T )
                          )
                    )
-                OR bill  IS NULL OR bill  <= $billtime 
+                OR ( freq != '0' AND ( bill IS NULL OR bill  <= $billtime ) )
                 OR ( expire  IS NOT NULL AND expire  <= $^T )
                 OR ( adjourn IS NOT NULL AND adjourn <= $^T )
                 OR ( resume  IS NOT NULL AND resume  <= $^T )

commit 8fda1089d5d697c9c11fa7ad163c2647ad15ce91
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Thu Jun 21 21:07:30 2012 -0700

    remove SG stuff

diff --git a/FS/FS/ClientAPI/SGNG.pm b/FS/FS/ClientAPI/SGNG.pm
deleted file mode 100644
index 7f784dc..0000000
--- a/FS/FS/ClientAPI/SGNG.pm
+++ /dev/null
@@ -1,277 +0,0 @@
-#this stuff is SG-specific (i.e. multi-customer company username hack)
-
-package FS::ClientAPI::SGNG;
-
-use strict;
-use vars qw( $cache $DEBUG );
-use Time::Local qw(timelocal timelocal_nocheck);
-use Business::CreditCard;
-use FS::Record qw( qsearch qsearchs );
-use FS::Conf;
-use FS::cust_main;
-use FS::cust_pkg;
-use FS::ClientAPI::MyAccount; #qw( payment_info process_payment )
-
-$DEBUG = 0;
-
-sub _cache {
-  $cache ||= new FS::ClientAPI_SessionCache( {
-               'namespace' => 'FS::ClientAPI::MyAccount', #yes, share session_ids
-             } );
-}
-
-sub ping {
-  #my $p = shift;
-
-  return { 'pong' => '1' };
-
-}
-
-#this might almost be general-purpose
-sub decompify_pkgs {
-  my $p = shift;
-
-  my $session = _cache->get($p->{'session_id'})
-    or return { 'error' => "Can't resume session" }; #better error message
-
-  my $custnum = $session->{'custnum'};
-
-  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
-    or return { 'error' => "unknown custnum $custnum" };
-
-  return { 'error' => 'Not a complimentary customer' }
-    unless $cust_main->payby eq 'COMP';
-
-  my $paydate =
-    $cust_main->paydate =~ /^\S+$/ ? $cust_main->paydate : '2037-12-31';
-
-  my ($payyear,$paymonth,$payday) = split (/-/,$paydate);
-
-  my $date = timelocal(0,0,0,$payday,--$paymonth,$payyear);
-
-  foreach my $cust_pkg (
-    qsearch({ 'table'     => 'cust_pkg',
-              'hashref'   => { 'custnum' => $custnum,
-                               'bill'    => '',
-                             },
-              'extra_sql' => ' AND '. FS::cust_pkg->active_sql,
-           })
-  ) {
-    $cust_pkg->set('bill', $date);
-    my $error = $cust_pkg->replace;
-    return { 'error' => $error } if $error;
-  }
-
-  return { 'error' => '' };
-
-}
-
-#find old payment info
-# (should work just like MyAccount::payment_info, except returns previous info
-#  too)
-# definitly sg-specific, no one else stores past customer records like this
-sub previous_payment_info {
-  my $p = shift;
-
-  my $session = _cache->get($p->{'session_id'})
-    or return { 'error' => "Can't resume session" }; #better error message
-
-  my $payment_info = FS::ClientAPI::MyAccount::payment_info($p);
-
-  my $custnum = $session->{'custnum'};
-
-  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
-    or return { 'error' => "unknown custnum $custnum" };
-
-  #?
-  return $payment_info if $cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/;
-
-  foreach my $prev_cust_main (
-    reverse _previous_cust_main( 'custnum'       => $custnum, 
-                                 'username'      => $cust_main->company,
-                                 'with_payments' => 1,
-                               )
-  ) {
-
-    next unless $prev_cust_main->payby =~ /^(CARD|DCRD|CHEK|DCHK)$/;
-
-    if ( $prev_cust_main->payby =~ /^(CARD|DCRD)$/ ) {
-
-      #card expired?
-      my ($payyear,$paymonth,$payday) = split (/-/, $cust_main->paydate);
-
-      my $expdate = timelocal_nocheck(0,0,0,1,$paymonth,$payyear);
-
-      next if $expdate < time;
-
-    } elsif ( $prev_cust_main->payby =~ /^(CHEK|DCHK)$/ ) {
-
-      #any check?  or just skip these in favor of cards?
-
-    }
-
-    return { %$payment_info,
-             #$prev_cust_main->payment_info
-             _cust_main_payment_info( $prev_cust_main ),
-             'previous_custnum' => $prev_cust_main->custnum,
-           };
-
-  }
-
-  #still nothing?  return an error?
-  return $payment_info;
-
-}
-
-#this is really FS::cust_main::payment_info, but here for now
-sub _cust_main_payment_info {
-  my $self = shift;
-
-  my %return = ();
-
-  $return{balance} = $self->balance;
-
-  $return{payname} = $self->payname
-                     || ( $self->first. ' '. $self->get('last') );
-
-  $return{$_} = $self->get($_) for qw(address1 address2 city state zip);
-
-  $return{payby} = $self->payby;
-  $return{stateid_state} = $self->stateid_state;
-
-  if ( $self->payby =~ /^(CARD|DCRD)$/ ) {
-    $return{card_type} = cardtype($self->payinfo);
-    $return{payinfo} = $self->paymask;
-
-    @return{'month', 'year'} = $self->paydate_monthyear;
-
-  }
-
-  if ( $self->payby =~ /^(CHEK|DCHK)$/ ) {
-    my ($payinfo1, $payinfo2) = split '@', $self->paymask;
-    $return{payinfo1} = $payinfo1;
-    $return{payinfo2} = $payinfo2;
-    $return{paytype}  = $self->paytype;
-    $return{paystate} = $self->paystate;
-
-  }
-
-  #doubleclick protection
-  my $_date = time;
-  $return{paybatch} = "webui-MyAccount-$_date-$$-". rand() * 2**32;
-
-  %return;
-
-}
-
-#find old cust_main records (with payments)
-sub _previous_cust_main {
-
-  #safety check!  return nothing unless we're enabled explicitly
-  return () unless FS::Conf->new->exists('sg-multicustomer_hack');
-
-  my %opt = @_;
-  my $custnum  = $opt{'custnum'};
-  my $username = $opt{'username'};
-  
-  my %search = ();
-  if ( $opt{'with_payments'} ) {
-    $search{'extra_sql'} =
-      ' AND 0 < ( SELECT COUNT(*) FROM cust_pay
-                    WHERE cust_pay.custnum = cust_main.custnum
-                )
-      ';
-  }
-
-  qsearch( {
-    'table'    => 'cust_main', 
-    'hashref'  => { 'company' => { op => 'ILIKE', value => $opt{'username'} },
-                    'custnum' => { op => '!=',    value => $opt{'custnum'}  },
-                  },
-    'order_by' => 'ORDER BY custnum',
-    %search,
-  } );
-
-}
-
-#since we could be passing masked old CC data, need to look that up and
-#replace it (like regular process_payment does) w/info from old customer record
-sub previous_process_payment {
-  my $p = shift;
-
-  return FS::ClientAPI::MyAccount::process_payment($p)
-    unless $p->{'previous_custnum'}
-        && (    ( $p->{'payby'} =~ /^(CARD|DCRD)$/ && $p->{'payinfo'}  =~ /x/i )
-             || ( $p->{'payby'} =~ /^(CHEK|DCHK)$/ && $p->{'payinfo1'} =~ /x/i )
-           );
-
-  my $session = _cache->get($p->{'session_id'})
-    or return { 'error' => "Can't resume session" }; #better error message
-
-  my $custnum = $session->{'custnum'};
-
-  my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
-    or return { 'error' => "unknown custnum $custnum" };
-
-  #make sure this is really a previous custnum of this customer
-  my @previous_cust_main =
-    grep { $_->custnum == $p->{'previous_custnum'} }
-         _previous_cust_main( 'custnum'       => $custnum, 
-                              'username'      => $cust_main->company,
-                              'with_payments' => 1,
-                            );
-
-  my $previous_cust_main = $previous_cust_main[0];
-
-  #causes problems with old data w/old masking method
-  #if $previous_cust_main->paymask eq $payinfo;
-  
-  if ( $p->{'payby'} =~ /^(CHEK|DCHK)$/ && $p->{'payinfo1'} =~ /x/i ) {
-    ( $p->{'payinfo1'}, $p->{'payinfo2'} ) =
-      split('@', $previous_cust_main->payinfo);
-  } elsif ( $p->{'payby'} =~ /^(CARD|DCRD)$/ && $p->{'payinfo'} =~ /x/i ) {
-    $p->{'payinfo'} = $previous_cust_main->payinfo;
-  }
-
-  FS::ClientAPI::MyAccount::process_payment($p);
-
-}
-
-sub previous_payment_info_renew_info {
-  my $p = shift;
-  my $renew_info   = renew_info($p);
-  my $payment_info = previous_payment_info($p);
-  return { %$renew_info,
-           %$payment_info,
-         };
-}
-
-sub previous_process_payment_order_pkg {
-  my $p = shift;
-
-  my $hr = previous_process_payment($p);
-  return $hr if $hr->{'error'};
-
-  order_pkg($p);
-}
-
-sub previous_process_payment_change_pkg {
-  my $p = shift;
-
-  my $hr = previous_process_payment($p);
-  return $hr if $hr->{'error'};
-
-  change_pkg($p);
-}
-
-sub previous_process_payment_order_renew {
-  my $p = shift;
-
-  my $hr = previous_process_payment($p);
-  return $hr if $hr->{'error'};
-
-  order_renew($p);
-}
-
-1;
-
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 7e81996..7dd20c6 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -177,22 +177,6 @@ sub ss2clientapi {
   'call_time'                 => 'PrepaidPhone/call_time',
   'call_time_nanpa'           => 'PrepaidPhone/call_time_nanpa',
   'phonenum_balance'          => 'PrepaidPhone/phonenum_balance',
-  #izoom
-  #'bulk_processrow'           => 'Bulk/processrow',
-  #conflicts w/Agentone# 'check_username'            => 'Bulk/check_username',
-  #sg
-  'ping'                      => 'SGNG/ping',
-  'decompify_pkgs'            => 'SGNG/decompify_pkgs',
-  'previous_payment_info'     => 'SGNG/previous_payment_info',
-  'previous_payment_info_renew_info'
-                              => 'SGNG/previous_payment_info_renew_info',
-  'previous_process_payment'  => 'SGNG/previous_process_payment',
-  'previous_process_payment_order_pkg'
-                              => 'SGNG/previous_process_payment_order_pkg',
-  'previous_process_payment_change_pkg'
-                              => 'SGNG/previous_process_payment_change_pkg',
-  'previous_process_payment_order_renew'
-                              => 'SGNG/previous_process_payment_order_renew',
   };
 }
 
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 9cfea20..13625da 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4514,34 +4514,6 @@ and customer address. Include units.',
   },
 
   {
-    'key'         => 'sg-multicustomer_hack',
-    'section'     => '',
-    'description' => "Don't use this.",
-    'type'        => 'checkbox',
-  },
-
-  {
-    'key'         => 'sg-ping_username',
-    'section'     => '',
-    'description' => "Don't use this.",
-    'type'        => 'text',
-  },
-
-  {
-    'key'         => 'sg-ping_password',
-    'section'     => '',
-    'description' => "Don't use this.",
-    'type'        => 'text',
-  },
-
-  {
-    'key'         => 'sg-login_username',
-    'section'     => '',
-    'description' => "Don't use this.",
-    'type'        => 'text',
-  },
-
-  {
     'key'         => 'mc-outbound_packages',
     'section'     => '',
     'description' => "Don't use this.",
diff --git a/FS/FS/Cron/check.pm b/FS/FS/Cron/check.pm
index 9d3ffbd..75247fb 100644
--- a/FS/FS/Cron/check.pm
+++ b/FS/FS/Cron/check.pm
@@ -16,7 +16,6 @@ use FS::cust_pay_pending;
 @ISA = qw( Exporter );
 @EXPORT_OK = qw(
   check_queued check_selfservice check_apache check_bop_failures
-  check_sg check_sg_login check_sgng
   alert error_msg
 );
 
@@ -48,79 +47,6 @@ sub check_selfservice {
   return 1;
 }
 
-sub check_sg {
-  my $conf = new FS::Conf;
-  #different trigger if they ever stop using multicustomer_hack ?
-  return 1 unless $conf->exists('sg-multicustomer_hack');
-
-  my $ua = new LWP::UserAgent;
-  $ua->agent("FreesideCronCheck/0.1 " . $ua->agent);
-
-  my $USER = $conf->config('sg-ping_username');
-  my $PASS = $conf->config('sg-ping_password');
-  my $req = new HTTP::Request GET=>"https://$USER:$PASS\@localhost/sg/ping.cgi";
-  my $res = $ua->request($req);
-
-  return 1 if $res->is_success
-           && $res->content =~ /OK/
-           && $res->content !~ /error/i; #doh, the error message includes "OK"
-
-  $error_msg = $res->is_success ? $res->content : $res->status_line;
-  return 0;
-}
-
-sub check_sg_login {
-  my $conf = new FS::Conf;
-  #different trigger if they ever stop using multicustomer_hack ?
-  return 1 unless $conf->exists('sg-multicustomer_hack');
-
-  my $ua = new LWP::UserAgent;
-  $ua->agent("FreesideCronCheck/0.1 " . $ua->agent);
-
-  my $USER = $conf->config('sg-ping_username');
-  my $PASS = $conf->config('sg-ping_password');
-  my $USERNAME = $conf->config('sg-login_username');
-  my $req = new HTTP::Request
-    GET=>"https://$USER:$PASS\@localhost/sg/start.cgi?".
-         'username='. uri_escape($USERNAME);
-  my $res = $ua->request($req);
-
-  return 1 if $res->is_success
-           && $res->content =~ /[\da-f]{32}/i #session_id
-           && $res->content !~ /error/i;
-
-  $error_msg = $res->is_success ? $res->content : $res->status_line;
-  return 0;
-}
-
-sub check_sgng {
-  my $conf = new FS::Conf;
-  #different trigger if they ever stop using multicustomer_hack ?
-  return 1 unless $conf->exists('sg-multicustomer_hack');
-
-  eval 'use RPC::XML; use RPC::XML::Client;';
-  if ($@) { $error_msg = $@; return 0; };
-
-  my $cli = RPC::XML::Client->new('https://localhost/selfservice/xmlrpc.cgi');
-  my $resp = $cli->send_request('FS.SelfService.XMLRPC.ping');
-
-  return 1 if ref($resp)
-           && ! $resp->is_fault
-           && ref($resp->value)
-           && $resp->value->{'pong'} == 1;
-
-  #hua
-  $error_msg = ref($resp)
-                 ? ( $resp->is_fault
-                       ? $resp->string
-                       : ( ref($resp->value) ? $resp->value->{'error'}
-                                             : $resp->value
-                         )
-                 )
-                 : $resp;
-  return 0;
-}
-
 sub _check_fsproc {
   my $arg = shift;
   _check_pidfile( "freeside-$arg.pid" );
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 030e69b..e7aba20 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -37,7 +37,6 @@ FS/ClientAPI/Bulk.pm
 FS/ClientAPI/MasonComponent.pm
 FS/ClientAPI/MyAccount.pm
 FS/ClientAPI/PrepaidPhone.pm
-FS/ClientAPI/SGNG.pm
 FS/ClientAPI/Signup.pm
 FS/Conf.pm
 FS/ConfItem.pm
diff --git a/FS/bin/freeside-check b/FS/bin/freeside-check
index 9930aae..fdfc66a 100644
--- a/FS/bin/freeside-check
+++ b/FS/bin/freeside-check
@@ -5,7 +5,6 @@ use strict;
 use FS::UID qw( adminsuidsetup );
 use FS::Cron::check qw(
   check_queued check_selfservice check_apache check_bop_failures
-  check_sg check_sg_login check_sgng
   alert error_msg
 );
 
@@ -21,11 +20,5 @@ check_queued       or alert('Queue daemon not running', @emails);
 check_selfservice  or alert(error_msg(), @emails);
 check_apache       or alert('Apache not running: '. error_msg(), @emails);
 
-#no-ops unless you are sg
-my $sg = 'FS::ClientAPI::SG';
-check_sg           or alert("$sg not responding: ".     error_msg(), @emails);
-check_sg_login     or alert("$sg login errort: ".       error_msg(), @emails);
-check_sgng         or alert("${sg}NG not responding: ". error_msg(), @emails);
-
 check_bop_failures or alert(error_msg(), @emails);
 
diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index bbc34bb..c22e426 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -105,22 +105,6 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'call_time'                 => 'PrepaidPhone/call_time',
   'call_time_nanpa'           => 'PrepaidPhone/call_time_nanpa',
   'phonenum_balance'          => 'PrepaidPhone/phonenum_balance',
-  #izoom
-  #'bulk_processrow'           => 'Bulk/processrow',
-  #conflicts w/Agent one# 'check_username'            => 'Bulk/check_username',
-  #sg
-  'ping'                      => 'SGNG/ping',
-  'decompify_pkgs'            => 'SGNG/decompify_pkgs',
-  'previous_payment_info'     => 'SGNG/previous_payment_info',
-  'previous_payment_info_renew_info'
-                              => 'SGNG/previous_payment_info_renew_info',
-  'previous_process_payment'  => 'SGNG/previous_process_payment',
-  'previous_process_payment_order_pkg'
-                              => 'SGNG/previous_process_payment_order_pkg',
-  'previous_process_payment_change_pkg'
-                              => 'SGNG/previous_process_payment_change_pkg',
-  'previous_process_payment_order_renew'
-                              => 'SGNG/previous_process_payment_order_renew',
 );
 @EXPORT_OK = (
   keys(%autoload),

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

Summary of changes:
 FS/FS/ClientAPI/SGNG.pm                      |  277 --------------------------
 FS/FS/ClientAPI_XMLRPC.pm                    |   16 --
 FS/FS/Conf.pm                                |   28 ---
 FS/FS/Cron/bill.pm                           |    6 +-
 FS/FS/Cron/check.pm                          |   74 -------
 FS/MANIFEST                                  |    1 -
 FS/bin/freeside-check                        |    7 -
 fs_selfservice/FS-SelfService/SelfService.pm |   16 --
 8 files changed, 3 insertions(+), 422 deletions(-)
 delete mode 100644 FS/FS/ClientAPI/SGNG.pm




More information about the freeside-commits mailing list