diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index e731c940..733af25f 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -159,7 +159,15 @@ class Supplier extends AbstractCompany */ public function setShippingCosts(?BigDecimal $shipping_costs): self { - $this->shipping_costs = $shipping_costs; + if ($shipping_costs === null) { + $this->shipping_costs = null; + } + + //Only change the object, if the value changes, so that doctrine does not detect it as changed. + if ((string) $shipping_costs !== (string) $this->shipping_costs) { + $this->shipping_costs = $shipping_costs; + } + return $this; } } diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 90aa8f25..70ca7073 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -51,6 +51,7 @@ use Brick\Math\RoundingMode; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use DoctrineExtensions\Query\Mysql\Round; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Validator\Constraints as Assert; @@ -181,7 +182,14 @@ class Currency extends AbstractStructuralDBElement */ public function setExchangeRate(?BigDecimal $exchange_rate): self { - $this->exchange_rate = $exchange_rate; + if ($exchange_rate === null) { + $this->exchange_rate = null; + } + $tmp = $exchange_rate->toScale(self::PRICE_SCALE, RoundingMode::HALF_UP); + //Only change the object, if the value changes, so that doctrine does not detect it as changed. + if ((string) $tmp !== (string) $this->exchange_rate) { + $this->exchange_rate = $exchange_rate; + } return $this; } diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 983361ed..9e391063 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -275,7 +275,11 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface */ public function setPrice(BigDecimal $new_price): self { - $this->price = $new_price->toScale(self::PRICE_PRECISION, RoundingMode::HALF_UP); + $tmp = $new_price->toScale(self::PRICE_PRECISION, RoundingMode::HALF_UP); + //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; + } return $this; }