Upgraded brick/math to latest version

This commit is contained in:
Jan Böhmer 2026-05-19 21:17:45 +02:00
parent 506d5f8173
commit 527c42c227
11 changed files with 58 additions and 56 deletions

View file

@ -195,10 +195,10 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
#[SerializedName('price_per_unit')]
public function getPricePerUnit(float|string|BigDecimal $multiplier = 1.0): BigDecimal
{
$tmp = BigDecimal::of($multiplier);
$tmp = is_float($multiplier) ? BigDecimal::fromFloatShortest($multiplier) : BigDecimal::of($multiplier);
$tmp = $tmp->multipliedBy($this->price);
return $tmp->dividedBy($this->price_related_quantity, static::PRICE_PRECISION, RoundingMode::HALF_UP);
return $tmp->dividedBy(BigDecimal::fromFloatShortest($this->price_related_quantity), static::PRICE_PRECISION, RoundingMode::HalfUp);
}
/**
@ -317,7 +317,7 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface
*/
public function setPrice(BigDecimal $new_price): self
{
$tmp = $new_price->toScale(self::PRICE_PRECISION, RoundingMode::HALF_UP);
$tmp = $new_price->toScale(self::PRICE_PRECISION, RoundingMode::HalfUp);
//Only change the object, if the value changes, so that doctrine does not detect it as changed.
if ((string) $tmp !== (string) $this->price) {
$this->price = $tmp;