From fe5e97afc292640e017a1af9a5eabda2eabbf894 Mon Sep 17 00:00:00 2001
From: Michael Danielczok <michael@pcsg.de>
Date: Mon, 14 Oct 2024 11:38:45 +0000
Subject: [PATCH] fix: price could not be converted to string

---
 src/QUI/ERP/Money/Price.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/QUI/ERP/Money/Price.php b/src/QUI/ERP/Money/Price.php
index 54d984f..92f44c2 100644
--- a/src/QUI/ERP/Money/Price.php
+++ b/src/QUI/ERP/Money/Price.php
@@ -64,6 +64,10 @@ class Price
      */
     public function __construct($price, QUI\ERP\Currency\Currency $Currency, $User = false)
     {
+        if ($price instanceof Price) {
+            $price = $price->getPrice();
+        }
+
         $this->price    = $price;
         $this->Currency = $Currency;
 
@@ -192,10 +196,14 @@ public function getCurrency(): QUI\ERP\Currency\Currency
      */
     public static function validatePrice($value, $Locale = null)
     {
-        if (is_float($value)) {
+        if (is_float($value) || is_int($value)) {
             return round($value, QUI\ERP\Defaults::getPrecision());
         }
 
+        if ($value instanceof Price) {
+            $value = $value->getPrice();
+        }
+
         $value      = (string)$value;
         $isNegative = substr($value, 0, 1) === '-';
 
-- 
GitLab