-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BB-17102: Impossible to buy a product with fractional quantity for lo…
…calizations that use comma as a decimal separator (#24762) - change DecimalValidator to support float values - improve UnitValueFormatter to format decimal value according to current localization - change prices-helper to support localized decimal quantity - format decimal quantity in views - fix inventory level inline editing for localized decimal support - change subscriber event to operate transformed quantity value - fix precision of quantity field on frontend edit quote form - fix QuoteFormSubscriber handling of empty price - fix QuoteFormSubscriber handling of newly created offer - fix number.js input widget to handle empty value - introduct custom events in number input widget to guarantee that they are handled after input value normalization - fix number formatting for quantity field - fix QuoteFormSubscriber dependencies - fix UnitValueFormatter dependencies - fix product-with-fractional-quantity behat fixture - change UnitValueFormatter to operate formatted value - move logic from elements-helper.js into base-product-view.js - fix decimal separator in quantity input issue on admin order and quote creation forms - pass not formatted value into UnitValueFormatter - fix base-product-view elementEvent naming - revert price-helper.js changes - improve behat test coverage - fixes in setPrecision for loaded units data - fixed update product quantity in shopping list. - fixed prices displaying on Quick Order Form when quantity with fractional value used. - fixed quote create in admin area - fixed prices in RFQ on the frontend area - fixed fractional quantity usage on Quote Create form - fix excessive complexity - remove not used functionality - fix frontend quote type - fix quick order prices - fieed QOF EE behat test
- Loading branch information
1 parent
4771360
commit eee9924
Showing
85 changed files
with
1,963 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/Oro/Bundle/ProductBundle/Form/DataTransformer/QuantityTransformer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ProductBundle\Form\DataTransformer; | ||
|
||
use Oro\Bundle\LocaleBundle\Formatter\NumberFormatter; | ||
use Symfony\Component\Form\DataTransformerInterface; | ||
use Symfony\Component\Form\Exception\TransformationFailedException; | ||
|
||
/** | ||
* Specific transformer for product unit quantity. Helps to parse float in the correct localization. | ||
* We could not reuse \Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer | ||
* because it could not work normally with grouping symbols in 'es' locale | ||
*/ | ||
class QuantityTransformer implements DataTransformerInterface | ||
{ | ||
/** | ||
* @var NumberFormatter | ||
*/ | ||
private $numberFormatter; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private $skipTransformation; | ||
|
||
/** | ||
* @param NumberFormatter $formatter | ||
* @param bool $skipTransformation | ||
*/ | ||
public function __construct(NumberFormatter $formatter, bool $skipTransformation = false) | ||
{ | ||
$this->numberFormatter = $formatter; | ||
$this->skipTransformation = $skipTransformation; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function transform($value) | ||
{ | ||
if ($this->skipTransformation) { | ||
return $value; | ||
} | ||
|
||
$formattedValue = $this->numberFormatter->formatDecimal( | ||
$value, | ||
[ | ||
\NumberFormatter::GROUPING_USED => false | ||
] | ||
); | ||
|
||
return $formattedValue; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function reverseTransform($value) | ||
{ | ||
if ($value === '') { | ||
return null; | ||
} | ||
|
||
$parsedValue = $this->numberFormatter->parseFormattedDecimal($value); | ||
if ($parsedValue === false) { | ||
throw new TransformationFailedException( | ||
sprintf('Quantity %s is not a valid decimal number', $value) | ||
); | ||
} | ||
|
||
return $parsedValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.