diff --git a/src/QUI/ERP/Accounting/Article.php b/src/QUI/ERP/Accounting/Article.php index 49fa3e3e4d91adb18ffc7cb0946ff358fee4437b..08d4f0730b96cbaec7f24dc882e590a0ae610b6d 100644 --- a/src/QUI/ERP/Accounting/Article.php +++ b/src/QUI/ERP/Accounting/Article.php @@ -10,6 +10,9 @@ use QUI\ERP\Money\Price; use QUI\ERP\Tax\Utils as TaxUtils; +use function floatval; +use function get_called_class; + /** * Class Article * @@ -657,14 +660,14 @@ public function toArray(): array $discount = ''; if (isset($this->attributes['vat']) && $this->attributes['vat'] !== '') { - $vat = (int)$this->attributes['vat']; + $vat = floatval($this->attributes['vat']); } if ($this->hasDiscount()) { $discount = $this->Discount->toJSON(); } - $class = \get_called_class(); + $class = get_called_class(); if (!empty($this->attributes['control'])) { $class = $this->attributes['control']; diff --git a/src/QUI/ERP/Accounting/Calc.php b/src/QUI/ERP/Accounting/Calc.php index 7484fc34e167efbedabd64c0ebf68b6da3ad4c30..ea80a62a90d5fdc08132c0780c6d0f8f15e8a1a1 100644 --- a/src/QUI/ERP/Accounting/Calc.php +++ b/src/QUI/ERP/Accounting/Calc.php @@ -227,12 +227,12 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi continue; } - if (!isset($vatArray[$vat])) { - $vatArray[$vat] = $articleVatArray; - $vatArray[$vat]['sum'] = 0; + if (!isset($vatArray[(string)$vat])) { + $vatArray[(string)$vat] = $articleVatArray; + $vatArray[(string)$vat]['sum'] = 0; } - $vatArray[$vat]['sum'] = $vatArray[$vat]['sum'] + $articleVatArray['sum']; + $vatArray[(string)$vat]['sum'] = $vatArray[(string)$vat]['sum'] + $articleVatArray['sum']; } QUI\ERP\Debug::getInstance()->log('Berechnete Artikelliste MwSt', 'quiqqer/erp'); @@ -329,16 +329,16 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi $vat = $PriceFactor->getVat(); $vatSum = round($PriceFactor->getVatSum(), $precision); - if (!isset($vatArray[$vat])) { - $vatArray[$vat] = [ + if (!isset($vatArray[(string)$vat])) { + $vatArray[(string)$vat] = [ 'vat' => $vat, 'text' => self::getVatText($vat, $this->getUser()) ]; - $vatArray[$vat]['sum'] = 0; + $vatArray[(string)$vat]['sum'] = 0; } - $vatArray[$vat]['sum'] = $vatArray[$vat]['sum'] + $vatSum; + $vatArray[(string)$vat]['sum'] = $vatArray[(string)$vat]['sum'] + $vatSum; } if ($isEuVatUser) { @@ -357,16 +357,16 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi foreach ($vatArray as $vatEntry) { $vat = $vatEntry['vat']; - $vatLists[$vat] = true; // liste für MWST texte - $vatArray[$vat]['sum'] = round($vatEntry['sum'], $precision); + $vatLists[(string)$vat] = true; // liste für MWST texte + $vatArray[(string)$vat]['sum'] = round($vatEntry['sum'], $precision); - $bruttoSum = $bruttoSum + $vatArray[$vat]['sum']; + $bruttoSum = $bruttoSum + $vatArray[(string)$vat]['sum']; } $bruttoSum = round($bruttoSum, $precision); foreach ($vatLists as $vat => $bool) { - $vatText[$vat] = self::getVatText($vat, $this->getUser()); + $vatText[(string)$vat] = self::getVatText($vat, $this->getUser()); } // delete 0 % vat, 0% vat is allowed to calculate more easily @@ -426,10 +426,10 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi $vatSum = $bruttoSum - $netto; $vatSum = round($vatSum, $Currency->getPrecision()); - $diff = abs($vatArray[$vat]['sum'] - $vatSum); + $diff = abs($vatArray[(string)$vat]['sum'] - $vatSum); if ($diff <= 0.019) { - $vatArray[$vat]['sum'] = $vatSum; + $vatArray[(string)$vat]['sum'] = $vatSum; } } } @@ -439,7 +439,7 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi $nettoSum = 0; foreach ($vatArray as $vat => $entry) { - $vatArray[$vat]['sum'] = 0; + $vatArray[(string)$vat]['sum'] = 0; } } @@ -649,7 +649,7 @@ public function getVatTextByUser() * * @return array|string */ - public static function getVatText(int $vat, UserInterface $User, QUI\Locale $Locale = null) + public static function getVatText(float $vat, UserInterface $User, QUI\Locale $Locale = null) { if ($Locale === null) { $Locale = $User->getLocale(); diff --git a/src/QUI/ERP/Accounting/CalculationVatValue.php b/src/QUI/ERP/Accounting/CalculationVatValue.php index 86c6b815d036da482111b956313b89970230970a..e3a2324881840d0ed76c598118bcb27cedbb83df 100644 --- a/src/QUI/ERP/Accounting/CalculationVatValue.php +++ b/src/QUI/ERP/Accounting/CalculationVatValue.php @@ -23,16 +23,16 @@ class CalculationVatValue extends CalculationValue protected string $text = ''; /** - * @var int + * @var float */ - protected int $vat; + protected float $vat; /** * CalculationValue constructor. * * @param int|float $number * @param string $text - * @param int $vat + * @param float $vat * @param QUI\ERP\Currency\Currency|null $Currency * @param int|bool $precision - The optional number of decimal digits to round to. */ @@ -57,9 +57,9 @@ public function getTitle(): string /** * Return the VAT * - * @return int + * @return float */ - public function getVat(): int + public function getVat(): float { return $this->vat; } diff --git a/src/QUI/ERP/Accounting/PriceFactors/Factor.php b/src/QUI/ERP/Accounting/PriceFactors/Factor.php index 7d220cab4fee45df61c737d9271a3a911f36cdf9..4f21a5e2c70f22176bf9383b9f2bdac9180e1595 100644 --- a/src/QUI/ERP/Accounting/PriceFactors/Factor.php +++ b/src/QUI/ERP/Accounting/PriceFactors/Factor.php @@ -11,6 +11,7 @@ use QUI\Utils\Math; use function abs; +use function floatval; use function is_string; use function json_encode; @@ -139,7 +140,7 @@ public function __construct(array $data = []) } if (isset($data['vat'])) { - $this->vat = (int)$data['vat']; + $this->vat = floatval($data['vat']); } if (isset($data['valueText']) && is_string($data['valueText'])) { @@ -242,7 +243,7 @@ public function getVatSum() /** * Return the vat % * - * @return int + * @return float */ public function getVat() {