From 0d168301bc2e8b37e6224461ab2ed6c86c959eaf Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Mon, 16 Mar 2020 11:39:21 +0100 Subject: [PATCH] fix: candyman-gmbh/projektplanung#97 --- locale.xml | 8 ++++---- src/QUI/ERP/Money/Price.php | 8 ++++++-- src/QUI/ERP/User.php | 6 +++--- src/QUI/ERP/Utils/Shop.php | 28 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/locale.xml b/locale.xml index eabadf9..cc46b2d 100644 --- a/locale.xml +++ b/locale.xml @@ -112,12 +112,12 @@ <en><![CDATA[Price calculation basis]]></en> </locale> <locale name="user.settings.userNettoStatus.netto"> - <de><![CDATA[netto]]></de> - <en><![CDATA[netto]]></en> + <de><![CDATA[gewerblich (netto / zzgl. MwSt.)]]></de> + <en><![CDATA[business (netto / incl. vat)]]></en> </locale> <locale name="user.settings.userNettoStatus.brutto"> - <de><![CDATA[brutto]]></de> - <en><![CDATA[brutto]]></en> + <de><![CDATA[privat (brutto / inkl. MwSt.)]]></de> + <en><![CDATA[private (gross / incl. vat)]]></en> </locale> <locale name="user.profile.title"> diff --git a/src/QUI/ERP/Money/Price.php b/src/QUI/ERP/Money/Price.php index 124c390..414dd72 100644 --- a/src/QUI/ERP/Money/Price.php +++ b/src/QUI/ERP/Money/Price.php @@ -181,7 +181,7 @@ public function getCurrency() public static function validatePrice($value) { if (\is_float($value)) { - return \round($value, 4); + return \round($value, QUI\ERP\Defaults::getPrecision()); } $value = (string)$value; @@ -225,7 +225,11 @@ public static function validatePrice($value) $value = \str_replace($decimalSeparator, '.', $value); } - return \round(\floatval($value), 4) * $negativeTurn; + $value = \floatval($value); + $value = \round($value, QUI\ERP\Defaults::getPrecision()); + $value = $value * $negativeTurn; + + return $value; } /** diff --git a/src/QUI/ERP/User.php b/src/QUI/ERP/User.php index 594ed4d..6af2bb9 100644 --- a/src/QUI/ERP/User.php +++ b/src/QUI/ERP/User.php @@ -447,15 +447,15 @@ public function isCompany() public function isNetto() { if ($this->existsAttribute('erp.isNettoUser')) { - return $this->existsAttribute('erp.isNettoUser'); + return (int)$this->getAttribute('erp.isNettoUser') === QUI\ERP\Utils\User::IS_NETTO_USER; } if ($this->existsAttribute('quiqqer.erp.isNettoUser')) { - return $this->existsAttribute('quiqqer.erp.isNettoUser'); + return (int)$this->getAttribute('quiqqer.erp.isNettoUser') === QUI\ERP\Utils\User::IS_NETTO_USER; } if ($this->isNetto === null) { - $this->isNetto = QUI\ERP\Utils\User::getBruttoNettoUserStatus($this); + $this->isNetto = QUI\ERP\Utils\User::getBruttoNettoUserStatus($this) === QUI\ERP\Utils\User::IS_NETTO_USER; } return $this->isNetto; diff --git a/src/QUI/ERP/Utils/Shop.php b/src/QUI/ERP/Utils/Shop.php index 0217112..95754e4 100644 --- a/src/QUI/ERP/Utils/Shop.php +++ b/src/QUI/ERP/Utils/Shop.php @@ -79,6 +79,34 @@ public static function isB2C() return \strpos(self::getBusinessType(), 'B2C') !== false; } + /** + * Is the shop an b2c and b2b shop, but b2c is more important + * + * @return bool + */ + public static function isB2BPrioritized() + { + if (self::isB2B() === false) { + return false; + } + + return \strpos(self::getBusinessType(), 'B2B') === 0; + } + + /** + * Is the shop an b2c and b2b shop, but b2c is more important + * + * @return bool + */ + public static function isB2CPrioritized() + { + if (self::isB2C() === false) { + return false; + } + + return \strpos(self::getBusinessType(), 'B2C') === 0; + } + /** * Is the shop only b2b? * -- GitLab