[freeside-commits] branch master updated. a172aa2d549f2c62978fa1f6b6851a68ae0f2a4e

Mark Wells mark at 420.am
Mon Apr 7 14:42:18 PDT 2014


The branch, master has been updated
       via  a172aa2d549f2c62978fa1f6b6851a68ae0f2a4e (commit)
      from  cb304f6953644812382d0aa55486fa4858a8fd6a (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 a172aa2d549f2c62978fa1f6b6851a68ae0f2a4e
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Apr 7 14:42:10 2014 -0700

    cust_pkg import format with location, #28082

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index bdae736..ae25da1 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2573,7 +2573,7 @@ sub tables_hashref {
         'manual_flag',        'char', 'NULL',  1, '', '', 
         'no_auto',            'char', 'NULL',  1, '', '', 
         'quantity',            'int', 'NULL', '', '', '',
-        'agent_pkgid',         'int', 'NULL', '', '', '',
+        'agent_pkgid',     'varchar', 'NULL', $char_d, '', '',
         'waive_setup',        'char', 'NULL',  1, '', '', 
         'recur_show_zero',    'char', 'NULL',  1, '', '',
         'setup_show_zero',    'char', 'NULL',  1, '', '',
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index daec07e..a893e5c 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -649,7 +649,7 @@ sub check {
     || $self->ut_numbern('dundate')
     || $self->ut_enum('no_auto', [ '', 'Y' ])
     || $self->ut_enum('waive_setup', [ '', 'Y' ])
-    || $self->ut_numbern('agent_pkgid')
+    || $self->ut_textn('agent_pkgid')
     || $self->ut_enum('recur_show_zero', [ '', 'Y', 'N', ])
     || $self->ut_enum('setup_show_zero', [ '', 'Y', 'N', ])
     || $self->ut_foreign_keyn('main_pkgnum', 'cust_pkg', 'pkgnum')
diff --git a/FS/FS/cust_pkg/Import.pm b/FS/FS/cust_pkg/Import.pm
index fe69f82..694d814 100644
--- a/FS/FS/cust_pkg/Import.pm
+++ b/FS/FS/cust_pkg/Import.pm
@@ -106,6 +106,7 @@ my %formatfields = (
   'svc_acct'     => [qw( username _password domsvc )],
   'svc_phone'    => [qw( countrycode phonenum sip_password pin )],
   'svc_external' => [qw( id title )],
+  'location'     => [qw( address1 address2 city state zip country )],
 );
 
 sub _formatfields {
@@ -115,11 +116,31 @@ sub _formatfields {
 my %import_options = (
   'table'         => 'cust_pkg',
 
+  'preinsert_callback'  => sub {
+    my($record, $param) = @_;
+    my @location_params = grep /^location\./, keys %$param;
+    if (@location_params) {
+      my $cust_location = FS::cust_location->new({
+          'custnum' => $record->custnum,
+      });
+      foreach my $p (@location_params) {
+        $p =~ /^location.(\w+)$/;
+        $cust_location->set($1, $param->{$p});
+      }
+
+warn Dumper $cust_location; # XXX
+      my $error = $cust_location->find_or_insert; # this avoids duplicates
+      return "error creating location: $error" if $error;
+      $record->set('locationnum', $cust_location->locationnum);
+    }
+    '';
+  },
+
   'postinsert_callback' => sub {
     my( $record, $param ) = @_;
 
     my $formatfields = _formatfields;
-    foreach my $svc_x ( grep { $_ ne 'default' } keys %$formatfields ) {
+    foreach my $svc_x ( grep /^svc/, keys %$formatfields ) {
 
       my $ff = $formatfields->{$svc_x};
 
diff --git a/httemplate/misc/cust_pkg-import.html b/httemplate/misc/cust_pkg-import.html
index f86d317..94e7dd9 100644
--- a/httemplate/misc/cust_pkg-import.html
+++ b/httemplate/misc/cust_pkg-import.html
@@ -36,6 +36,9 @@ Import a file containing package records.
         <OPTION VALUE="svc_phone-agent_custid">Phone service with agent_custid
         <OPTION VALUE="svc_external">External service
         <OPTION VALUE="svc_external-agent_custid">External service with agent_custid
+        <OPTION VALUE="location">Location
+        <OPTION VALUE="location-agent_custid">Location with agent_custid
+        <OPTION VALUE="location-agent_custid-agent_pkgid">Location with agent_custid and agent_pkgid
       </SELECT>
     </TD>
   </TR>
@@ -88,6 +91,27 @@ Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.
 <b>External service with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, id, title</i>
 <BR><BR>
 
+<b>Location</b> format has the following field order: <i>custnum<%$req%>,
+pkgpart<%$req%>, discountnum,
+start_date, setup, bill, last_bill, susp, adjourn, cancel, expire,
+address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%>
+</i>
+<BR><BR>
+
+<b>Location with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>,
+pkgpart<%$req%>, discountnum,
+start_date, setup, bill, last_bill, susp, adjourn, cancel, expire,
+address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%>
+</i>
+<BR><BR>
+
+<b>Location with agent_custid and agent_pkgid</b> format has the following field order: <i>agent_custid<%$req%>, agent_pkgid,
+pkgpart<%$req%>, discountnum,
+start_date, setup, bill, last_bill, susp, adjourn, cancel, expire,
+address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country<%$req%>
+</i>
+<BR><BR>
+
 <%$req%> Required fields
 <BR><BR>
 
@@ -99,6 +123,8 @@ Field information:
 
   <li><i>agent_custid</i>: This specifies an existing customer record by agent_custid.
 
+  <li><i>agent_pkgid</i>: This specifies an existing customer record by agent_custid.
+
   <li><i>pkgpart</i>: Package definition.  Configuration -> Packages -> Package definitions
 
   <li><i>discountnum</i>: Optional discount.  Configuration -> Packages -> Discounts
@@ -129,6 +155,18 @@ Field information:
 
   <li><i>title</i>: External service identifier, text
 
+  <li><i>address1</i>: Service address, number and street, text
+
+  <li><i>address2</i>: Service address, suite/unit/building identifier, text
+
+  <li><i>city</i>: Service address, name of city, text
+
+  <li><i>state</i>: Service address, state/province, abbreviated
+
+  <li><i>zip</i>: Service address, postal code
+
+  <li><i>country</i>: Service address, country, 2-letter code
+
 </ul>
 
 <BR>

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

Summary of changes:
 FS/FS/Schema.pm                      |    2 +-
 FS/FS/cust_pkg.pm                    |    2 +-
 FS/FS/cust_pkg/Import.pm             |   23 +++++++++++++++++++-
 httemplate/misc/cust_pkg-import.html |   38 ++++++++++++++++++++++++++++++++++
 4 files changed, 62 insertions(+), 3 deletions(-)




More information about the freeside-commits mailing list