Use string for price of pricedetails.

This commit is contained in:
Jan Böhmer 2019-09-01 12:34:11 +02:00
parent 42399b5517
commit 43c439bc9e
2 changed files with 18 additions and 4 deletions

View file

@ -90,11 +90,11 @@ class Pricedetail extends DBElement
protected $orderdetail; 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) * @ORM\Column(type="decimal", precision=11, scale=5)
* @Assert\Positive() * @Assert\Positive()
*/ */
protected $price = 0.0; protected $price = "0.0";
/** /**
* @var ?Currency The currency used for the current price information. * @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. * It is given in current currency and for the price related quantity.
* @return float * @return float
*/ */
public function getPrice() : float public function getPriceFloat() : float
{ {
return (float) $this->price; 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. * Get the price for a single unit in the currency associated with this price detail.
* *

View file

@ -58,7 +58,11 @@ class PricedetailType extends AbstractType
'measurement_unit' => $options['measurement_unit'], 'measurement_unit' => $options['measurement_unit'],
'attr' => ['class' => 'form-control-sm'] '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]); $builder->add("currency", CurrencyEntityType::class, ['required' => false]);
} }