[freeside-commits] branch FREESIDE_3_BRANCH updated. 5dd8c04f5d4d760b1e186e67123c9b7d9c5d58c8

Mark Wells mark at 420.am
Wed Dec 7 17:02:45 PST 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  5dd8c04f5d4d760b1e186e67123c9b7d9c5d58c8 (commit)
       via  8b9017962e8f337554f9d15f513ede606f8725e2 (commit)
      from  9813252ec987e72242efa564c7a927b111f9222a (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 5dd8c04f5d4d760b1e186e67123c9b7d9c5d58c8
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Dec 7 17:02:33 2016 -0800

    script to create invoice-recipient contacts on version 3, #73708

diff --git a/bin/create-billing-contacts-v3 b/bin/create-billing-contacts-v3
new file mode 100755
index 0000000..35b81f8
--- /dev/null
+++ b/bin/create-billing-contacts-v3
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+
+use strict;
+use FS::Misc::Getopt;
+use FS::Record qw(qsearchs qsearch dbh);
+use FS::cust_main;
+use FS::cust_main_invoice;
+use FS::contact;
+
+our %opt;
+getopts('c:'); # contact classname
+
+$FS::UID::AutoCommit = 0;
+
+my $error;
+
+my $classnum = '';
+if ( $opt{c} ) {
+  my $class = qsearchs('contact_class', { classname => $opt{c} });
+  if (!$class) {
+    $class = FS::contact_class->new({ classname => $opt{c} });
+    $error = $class->insert;
+    die $error if $error;
+  }
+  $classnum = $class->classnum;
+}
+
+# Find all invoice destinations that are email addresses,
+# except those where the customer already has a contact with that
+# email address.
+my @invoice_dests = qsearch({
+  select    => 'cust_main_invoice.*',
+  table     => 'cust_main_invoice',
+  hashref   => { 'dest' => { op=>'!=', value=>'POST' } },
+  addl_from => ' LEFT JOIN (contact JOIN contact_email USING (contactnum)) ON
+    (cust_main_invoice.custnum = contact.custnum AND
+     cust_main_invoice.dest    = contact_email.emailaddress)',
+  extra_sql => ' AND contact.contactnum IS NULL',
+});
+print "Found email destinations: ".scalar(@invoice_dests)."\n";
+  
+foreach my $invoice_dest (@invoice_dests) {
+  my $cust_main = $invoice_dest->cust_main;
+  my $last = $cust_main->get('last');
+  my $first = $cust_main->get('first');
+  my $email = $invoice_dest->dest;
+  print "$first $last <$email>\n";
+
+  my $contact = qsearchs('contact', {
+    'custnum' => $invoice_dest->custnum,
+    'last'    => $last,
+    'first'   => $first,
+  });
+  if ($contact) {
+    my $contact_email = FS::contact_email->new({
+      'contactnum'    => $contact->contactnum,
+      'emailaddress'  => $email
+    });
+    $error = $contact_email->insert;
+    die "inserting contact email: $error\n" if $error;
+  } else {
+    # use the 'emailaddress' param here so that send_reset_email will
+    # work right
+    $contact = FS::contact->new({
+      'custnum'     => $invoice_dest->custnum,
+      'locationnum' => $cust_main->bill_locationnum,
+      'last'        => $last,
+      'first'       => $first,
+      'classnum'    => $classnum,
+      'selfservice_access' => 'Y',
+      'emailaddress'  => $email,
+      '_password'   => '',
+      '_password_encoding' => '',
+    });
+    $error = $contact->insert;
+    die "inserting contact: $error\n" if $error;
+  }
+}
+dbh->commit;
+print "Finished!\n";
+

commit 8b9017962e8f337554f9d15f513ede606f8725e2
Author: Mark Wells <mark at freeside.biz>
Date:   Wed Dec 7 16:56:47 2016 -0800

    silence a warning when creating contacts

diff --git a/FS/FS/Password_Mixin.pm b/FS/FS/Password_Mixin.pm
index 2e400ec..963fa54 100644
--- a/FS/FS/Password_Mixin.pm
+++ b/FS/FS/Password_Mixin.pm
@@ -212,8 +212,9 @@ sub insert_password_history {
     }
   
   } else {
-    warn "unrecognized password encoding '$encoding'; treating as plain text"
-      unless $encoding eq 'plain';
+    if ($encoding and $encoding ne 'plain') {
+      warn "unrecognized password encoding '$encoding'; treating as plain text";
+    }
 
     $auth = $self->_blowfishcrypt( $password );
 

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

Summary of changes:
 FS/FS/Password_Mixin.pm        |    5 ++-
 bin/create-billing-contacts-v3 |   81 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100755 bin/create-billing-contacts-v3




More information about the freeside-commits mailing list