From 1cb6ebfdec75f085d9942017695dd1c2ee2df113 Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Wed, 24 Apr 2024 15:00:15 +0200 Subject: [PATCH] feat: quiqqer v2 and products v2 compatibility --- composer.json | 10 +++++----- src/QUI/ERP/Discount/Discount.php | 20 ++++++++++---------- src/QUI/ERP/Discount/EventHandling.php | 11 ++--------- src/QUI/ERP/Discount/Handler.php | 4 ++-- src/QUI/ERP/Discount/PriceFactor.php | 5 ----- 5 files changed, 19 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index d9f20c7..ed6f796 100644 --- a/composer.json +++ b/composer.json @@ -18,11 +18,11 @@ "url": "http:\/\/www.pcsg.de" }, "require": { - "php": ">=5.3", - "quiqqer\/quiqqer": "*@dev", - "quiqqer\/areas": "*@dev", - "quiqqer\/products": "^1.6|*@dev", - "quiqqer\/tax": "*@dev" + "php": "^8.2", + "quiqqer\/quiqqer": "^2", + "quiqqer\/areas": "^1", + "quiqqer\/products": "^2", + "quiqqer\/tax": "^1" }, "autoload": { "psr-4": { diff --git a/src/QUI/ERP/Discount/Discount.php b/src/QUI/ERP/Discount/Discount.php index b155d59..adf1717 100644 --- a/src/QUI/ERP/Discount/Discount.php +++ b/src/QUI/ERP/Discount/Discount.php @@ -219,17 +219,17 @@ public function __construct($id, Handler $Factory) /** * @param string $name - * @param mixed $val + * @param mixed $value * @return void */ - public function setAttribute(string $name, mixed $val): void + public function setAttribute(string $name, mixed $value): void { - if ($name === 'lastSumDiscount' && empty($val)) { - $val = null; + if ($name === 'lastSumDiscount' && empty($value)) { + $value = null; } - if ($name === 'lastProductDiscount' && empty($val)) { - $val = null; + if ($name === 'lastProductDiscount' && empty($value)) { + $value = null; } if ( @@ -237,10 +237,10 @@ public function setAttribute(string $name, mixed $val): void $name === 'discount_type' || $name === 'usage_type' ) { - $val = (int)$val; + $value = (int)$value; } - parent::setAttribute($name, $val); + parent::setAttribute($name, $value); } /** @@ -357,7 +357,7 @@ public function canUsedBy(QUI\Interfaces\Users\User $User): bool /* @var $Group QUI\Groups\Group */ foreach ($discountGroups as $gid) { foreach ($groupsOfUser as $Group) { - if ($Group->getId() == $gid) { + if ($Group->getUsers() == $gid) { return true; } @@ -383,7 +383,7 @@ public function canUsedWith(QUI\ERP\Products\Interfaces\ProductInterface $Produc } // coupon - if ($Product->getId() === '-') { + if ($Product->getId() === -1) { return false; } diff --git a/src/QUI/ERP/Discount/EventHandling.php b/src/QUI/ERP/Discount/EventHandling.php index 2adb56d..34a6d43 100644 --- a/src/QUI/ERP/Discount/EventHandling.php +++ b/src/QUI/ERP/Discount/EventHandling.php @@ -168,14 +168,7 @@ public static function onQuiqqerProductsCalcListProduct( return; } - try { - $attributes = $Product->getAttributes(); - } catch (QUI\Exception $Exception) { - QUI\System\Log::writeDebugException($Exception); - - return; - } - + $attributes = $Product->getAttributes(); $PriceFactors = $Product->getPriceFactors(); $productQuantity = $Product->getQuantity(); $productNettoSum = $attributes['calculated_nettoSum']; @@ -190,7 +183,7 @@ public static function onQuiqqerProductsCalcListProduct( continue; } - // check if Pricefactor is already in + // check if price factor is already in $factors = $PriceFactors->toArray(); $Factor = $Discount->toPriceFactor( $Calc->getUser()->getLocale(), diff --git a/src/QUI/ERP/Discount/Handler.php b/src/QUI/ERP/Discount/Handler.php index 293106b..a2f5861 100644 --- a/src/QUI/ERP/Discount/Handler.php +++ b/src/QUI/ERP/Discount/Handler.php @@ -23,7 +23,7 @@ class Handler extends QUI\CRUD\Factory const DISCOUNT_TYPE_PERCENT = 1; /** - * discount type -> crrency + * discount type -> currency */ const DISCOUNT_TYPE_CURRENCY = 2; @@ -50,7 +50,7 @@ class Handler extends QUI\CRUD\Factory const DISCOUNT_SCOPE_GRAND_TOTAL = 4; /** - * pricefactor discount type + * price factor discount type */ const DISCOUNT_PRICEFACTOR_TYPE = 'DISCOUNT_PRICE_FACTOR'; diff --git a/src/QUI/ERP/Discount/PriceFactor.php b/src/QUI/ERP/Discount/PriceFactor.php index b2481db..c18cdb2 100644 --- a/src/QUI/ERP/Discount/PriceFactor.php +++ b/src/QUI/ERP/Discount/PriceFactor.php @@ -22,11 +22,6 @@ class PriceFactor extends QUI\ERP\Products\Utils\PriceFactor implements */ protected string $type = Handler::DISCOUNT_PRICEFACTOR_TYPE; - /** - * @var string|null - */ - protected $vat = null; - /** * PriceFactor constructor. * @param array $params -- GitLab