import tax exempt and force postal invoice optiosn
authorjeff <jeff>
Fri, 24 Sep 2010 22:08:05 +0000 (22:08 +0000)
committerjeff <jeff>
Fri, 24 Sep 2010 22:08:05 +0000 (22:08 +0000)
FS/FS/cust_main/Import.pm
httemplate/misc/cust_main-import.cgi

index e58a044..7f5a3f0 100644 (file)
@@ -34,7 +34,8 @@ FS::cust_main::Import - Batch customer importing
     file      => $file,      #filename
     type      => $type,      #csv or xls
     format    => $format,    #extended, extended-plus_company, svc_external,
-                             # or svc_external_svc_phone
+                             #extended-plus_company_and_options
+                             #extended-plus_options, or svc_external_svc_phone
     agentnum  => $agentnum,
     refnum    => $refnum,
     pkgpart   => $pkgpart,
@@ -144,6 +145,19 @@ sub batch_import {
                   svc_acct.username svc_acct._password 
                 );
     $payby = 'BILL';
+ } elsif ( $format eq 'extended-plus_options' ) {
+    @fields = qw( agent_custid refnum
+                  last first address1 address2 city state zip country
+                  daytime night
+                  ship_last ship_first ship_company ship_address1 ship_address2
+                  ship_city ship_state ship_zip ship_country
+                  payinfo paycvv paydate
+                  invoicing_list
+                  cust_pkg.pkgpart
+                  svc_acct.username svc_acct._password 
+                  customer_options
+                );
+    $payby = 'BILL';
  } elsif ( $format eq 'extended-plus_company' ) {
     @fields = qw( agent_custid refnum
                   last first company address1 address2 city state zip country
@@ -156,6 +170,19 @@ sub batch_import {
                   svc_acct.username svc_acct._password 
                 );
     $payby = 'BILL';
+ } elsif ( $format eq 'extended-plus_company_and_options' ) {
+    @fields = qw( agent_custid refnum
+                  last first company address1 address2 city state zip country
+                  daytime night
+                  ship_last ship_first ship_company ship_address1 ship_address2
+                  ship_city ship_state ship_zip ship_country
+                  payinfo paycvv paydate
+                  invoicing_list
+                  cust_pkg.pkgpart
+                  svc_acct.username svc_acct._password 
+                  customer_options
+                );
+    $payby = 'BILL';
  } elsif ( $format =~ /^svc_external/ ) {
     @fields = qw( agent_custid refnum
                   last first company address1 address2 city state zip country
@@ -318,14 +345,22 @@ sub batch_import {
       }
     }
 
-    $cust_main{'payby'} = 'CARD'
-      if defined $cust_main{'payinfo'}
-      && length  $cust_main{'payinfo'};
+    if ( defined $cust_main{'payinfo'} && length $cust_main{'payinfo'} ) {
+      $cust_main{'payby'} = 'CARD';
+      if ($cust_main{'payinfo'} =~ /\s*([AD]?)(.*)\s*$/) {
+        $cust_main{'payby'} = 'DCRD' if $1 eq 'D';
+        $cust_main{'payinfo'} = $2;
+      }
+    }
 
     my $invoicing_list = $cust_main{'invoicing_list'}
                            ? [ delete $cust_main{'invoicing_list'} ]
                            : [];
 
+    my $customer_options = delete $cust_main{customer_options};
+    $cust_main{tax} = 'Y' if $customer_options =~ /taxexempt/i;
+    push @$invoicing_list, 'POST' if $customer_options =~ /postalinvoice/i;
+
     my $cust_main = new FS::cust_main ( \%cust_main );
 
     use Tie::RefHash;
index 2ccf997..edf4665 100644 (file)
@@ -30,7 +30,9 @@ Import a file containing customer records.
       <SELECT NAME="format">
         <!-- <OPTION VALUE="simple">Simple -->
         <OPTION VALUE="extended" SELECTED>Extended
+        <OPTION VALUE="extended-plus_options">Extended + options
         <OPTION VALUE="extended-plus_company">Extended plus company
+        <OPTION VALUE="extended-plus_company_and_options">Extended plus company and options
         <OPTION VALUE="svc_external">External service
         <OPTION VALUE="svc_external_svc_phone">External service and phone service
       </SELECT>
@@ -89,7 +91,11 @@ Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.
 <b>Extended</b> format has the following field order: <i>agent_custid, refnum<%$req%>, last<%$req%>, first<%$req%>, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo, paycvv, paydate, invoicing_list, pkgpart, username, _password</i>
 <BR><BR>
 
+<b>Extended plus options</b> format has the following field order: <i>agent_custid, refnum<%$req%>, last<%$req%>, first<%$req%>, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo, paycvv, paydate, invoicing_list, pkgpart, username, _password, options</i>
+
 <b>Extended plus company</b> format has the following field order: <i>agent_custid, refnum<%$req%>, last<%$req%>, first<%$req%>, company, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_company, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo, paycvv, paydate, invoicing_list, pkgpart, username, _password</i>
+
+<b>Extended plus company and options </b> format has the following field order: <i>agent_custid, refnum<%$req%>, last<%$req%>, first<%$req%>, company, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_company, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo, paycvv, paydate, invoicing_list, pkgpart, username, _password, options</i>
 <BR><BR>
 
 <b>External service</b> format has the following field order: <i>agent_custid, refnum<%$req%>, last<%$req%>, first<%$req%>, company, address1<%$req%>, address2, city<%$req%>, state<%$req%>, zip<%$req%>, country, daytime, night, ship_last, ship_first, ship_company, ship_address1, ship_address2, ship_city, ship_state, ship_zip, ship_country, payinfo, paycvv, paydate, invoicing_list, pkgpart, next_bill_date, id, title</i>
@@ -111,7 +117,7 @@ Field information:
 of an integer, the string is searched for and if necessary auto-created in the
 advertising source table.
 
-  <li><i>payinfo</i>: Credit card number, or leave this, <i>paycvv</i> and <i>paydate</i> blank for email/paper invoicing.
+  <li><i>payinfo</i>: Credit card number, or leave this, <i>paycvv</i> and <i>paydate</i> blank for email/paper invoicing.  You may optionally prepend an 'A' or 'D' to the credit card number for automatic or on demand of customer billing respectively
 
   <li><i>paycvv</i>: CVV2 number (three digits on the back of the credit card)
 
@@ -127,6 +133,13 @@ advertising source table.
 
   <li><i>title</i>: External service identifier, text
 
+  <li><i>options</i>: text containing one or more of
+
+  <ul>
+    <li>taxexempt: this customer does not pay taxes
+    <li>postalinvoice: ensure this customer receives a postal invoice
+  </ul>
+
 </ul>
 
 <BR>