Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Tue, 1 Nov 2016 23:20:44 +0000 (16:20 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 1 Nov 2016 23:20:44 +0000 (16:20 -0700)
FS/FS/cust_main/Billing_Realtime.pm
FS/FS/quotation_pkg.pm
httemplate/edit/process/quick-cust_pkg.cgi

index 09e2dfa..7718f7a 100644 (file)
@@ -2199,7 +2199,8 @@ sub realtime_tokenize {
                                   );
 
   my %supported_actions = $transaction->info('supported_actions');
-  return '' unless $supported_actions{'CC'} and grep(/^Tokenize$/,@{$supported_actions{'CC'}});
+  return '' unless $supported_actions{'CC'}
+                && grep /^Tokenize$/, @{$supported_actions{'CC'}};
 
   ###
   # check for banned credit card/ACH
index 9854c45..3f6742c 100644 (file)
@@ -121,6 +121,22 @@ sub insert {
   my $oldAutoCommit = $FS::UID::AutoCommit;
   local $FS::UID::AutoCommit = 0;
 
+  #false laziness w/cust_main::Packages::order_pkg
+  if ( $options{'locationnum'} and $options{'locationnum'} != -1 ) {
+
+    $self->locationnum($options{'locationnum'});
+
+  } elsif ( $options{'cust_location'} ) {
+
+    my $error = $options{'cust_location'}->find_or_insert;
+    if ( $error ) {
+      $dbh->rollback if $oldAutoCommit;
+      return "inserting cust_location (transaction rolled back): $error";
+    }
+    $self->locationnum($options{'cust_location'}->locationnum);
+
+  }
+
   my $error = $self->SUPER::insert;
 
   if ( !$error and ($self->setup_discountnum || $self->recur_discountnum) ) {
index da5afe4..6a346e0 100644 (file)
@@ -189,7 +189,18 @@ if ( $quotationnum ) {
   )
   : ();
 
-  #XXX handle new location
+  if ( $locationnum == -1 ) {
+    my $cust_location = FS::cust_location->new({
+      'custnum'     => $custnum,
+      'prospectnum' => $prospectnum,
+      map { $_ => scalar($cgi->param($_)) }
+        FS::cust_main->location_fields
+    });
+    $opt{'cust_location'} = $cust_location;
+  } else {
+    $opt{'locationnum'} = $locationnum;
+  }
+
   $error = $quotation_pkg->insert(%opt);
 
 } else {