[interchange: 1/2] * Fix long-wrong code which had the effect of always stripping - signs.

Mike Heins <[email protected]> Mon, 14 Mar 2016 15:34:03 +0000
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit 9cffe132ee81963ce52966ba7bf70406a0b03aeb
Author: Mike Heins <[email protected]>
Date:   Mon Mar 14 11:30:26 2016 -0400

    * Fix long-wrong code which had the effect of always stripping - signs.
    
    * Fix code which was intended to remove amounts after the decimal point
      unless FractionalItems.

 lib/Vend/Order.pm |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/lib/Vend/Order.pm b/lib/Vend/Order.pm
index 1eb0690..d857261 100644
--- a/lib/Vend/Order.pm
+++ b/lib/Vend/Order.pm
@@ -2423,9 +2423,13 @@ sub add_items {
 		undef $item;
 		$quantity = defined $quantities[$j] ? $quantities[$j] : 1;
 		$set = $quantity =~ s/^=//;
-		$quantity =~ s/^(-?)\D+/$1/;
-		$quantity =~ s/^(-?\d*)\D.*/$1/
-			unless $Vend::Cfg->{FractionalItems};
+		
+		## Strip any whitespace, letters, etc. but allow digits, decimals, and - signs
+		$quantity =~ s/^[^-.\d]+/$1/;
+
+		## Strip decimal points unless FractionalItems
+		$quantity =~ s/\..*// unless $Vend::Cfg->{FractionalItems};
+
 		($j++,next) unless $quantity;
 		if(! $fly[$j]) {
 			$base = product_code_exists_tag($code, $bases[$j] || undef);