better detection of new locations that are the same as existing locations, #940,...
[freeside.git] / httemplate / edit / process / quick-cust_pkg.cgi
index c5eee0c..4ea4ace 100644 (file)
@@ -64,9 +64,9 @@ die 'no custnum or prospectnum' unless $cust_main || $prospect_main;
 $cgi->param('pkgpart') =~ /^(\d+)$/
   or die 'illegal pkgpart '. $cgi->param('pkgpart');
 my $pkgpart = $1;
-$cgi->param('quantity') =~ /^(\d+)$/
+$cgi->param('quantity') =~ /^(\d*)$/
   or die 'illegal quantity '. $cgi->param('quantity');
-my $quantity = $1;
+my $quantity = $1 || 1;
 $cgi->param('refnum') =~ /^(\d*)$/
   or die 'illegal refnum '. $cgi->param('refnum');
 my $refnum = $1;
@@ -143,10 +143,10 @@ if ( $quotationnum ) {
   my %opt = ( 'cust_pkg' => $cust_pkg );
 
   if ( $locationnum == -1 ) {
-    my $cust_location = new FS::cust_location {
+    my $cust_location = FS::cust_location->new_or_existing({
       map { $_ => scalar($cgi->param($_)) }
-          qw( custnum address1 address2 city county state zip country geocode )
-    };
+          ('custnum', FS::cust_main->location_fields)
+    });
     $opt{'cust_location'} = $cust_location;
   }