From 88580aad796b60573ac97c9bf332373874b9a3d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 28 Mar 2020 19:30:57 +0100 Subject: [PATCH] Dont log that shipping costs or price has been changed when just saving a part. Fixes issue #26 --- src/Entity/Parts/Supplier.php | 5 ++++- src/Entity/PriceInformations/Pricedetail.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 0ac3a1ed..0c35d768 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -162,7 +162,10 @@ class Supplier extends AbstractCompany */ public function setShippingCosts(?string $shipping_costs): self { - $this->shipping_costs = $shipping_costs; + /* Just a little hack to ensure that price has 5 digits after decimal point, + so that DB does not detect changes, when something like 0.4 is passed + Third parameter must have the scale value of decimal column. */ + $this->shipping_costs = bcmul($shipping_costs, '1.0', 5); return $this; } diff --git a/src/Entity/PriceInformations/Pricedetail.php b/src/Entity/PriceInformations/Pricedetail.php index 35e05a4f..2ecf5cf8 100644 --- a/src/Entity/PriceInformations/Pricedetail.php +++ b/src/Entity/PriceInformations/Pricedetail.php @@ -275,7 +275,10 @@ class Pricedetail extends AbstractDBElement implements TimeStampableInterface { //Assert::natural($new_price, 'The new price must be positive! Got %s!'); - $this->price = $new_price; + /* Just a little hack to ensure that price has 5 digits after decimal point, + so that DB does not detect changes, when something like 0.4 is passed + Third parameter must have the scale value of decimal column. */ + $this->price = bcmul($new_price, '1.0', static::PRICE_PRECISION); return $this; }