From 43c439bc9ec9090220bed809c346dac2f4061871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 1 Sep 2019 12:34:11 +0200 Subject: [PATCH] Use string for price of pricedetails. --- src/Entity/PriceInformations/Pricedetail.php | 16 +++++++++++++--- src/Form/Part/PricedetailType.php | 6 +++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index e03394fd..f85c04c5 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -90,11 +90,11 @@ class Pricedetail extends DBElement protected $orderdetail; /** - * @var float The price related to the detail. (Given in the selected currency) + * @var string The price related to the detail. (Given in the selected currency) * @ORM\Column(type="decimal", precision=11, scale=5) * @Assert\Positive() */ - protected $price = 0.0; + protected $price = "0.0"; /** * @var ?Currency The currency used for the current price information. @@ -147,11 +147,21 @@ class Pricedetail extends DBElement * It is given in current currency and for the price related quantity. * @return float */ - public function getPrice() : float + public function getPriceFloat() : float { return (float) $this->price; } + /** + * Returns the price associated with this pricedetail. + * It is given in current currency and for the price related quantity. + * @return string The price as string, like returned raw from DB. + */ + public function getPrice() : string + { + return $this->price; + } + /** * Get the price for a single unit in the currency associated with this price detail. * diff --git a/src/Form/Part/PricedetailType.php b/src/Form/Part/PricedetailType.php index dcaf9c8d..3044c321 100644 --- a/src/Form/Part/PricedetailType.php +++ b/src/Form/Part/PricedetailType.php @@ -58,7 +58,11 @@ class PricedetailType extends AbstractType 'measurement_unit' => $options['measurement_unit'], 'attr' => ['class' => 'form-control-sm'] ]); - $builder->add("price", NumberType::class); + $builder->add("price", NumberType::class, [ + 'scale' => 5, + 'html5' => true, + 'attr' => ['min' => 0, 'step' => "any"] + ]); $builder->add("currency", CurrencyEntityType::class, ['required' => false]); }