Skip to content
Code-Schnipsel Gruppen Projekte
Commit d78492cd erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: missing currency for articles at the article list

Übergeordneter 0967d1a5
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -91,8 +91,17 @@ public function __construct($attributes = [], $User = null)
}
$articles = $attributes['articles'];
$currency = QUI\ERP\Currency\Handler::getDefaultCurrency()->getCode();
if (isset($attributes['calculations']['currencyData']['code'])) {
$currency = $attributes['calculations']['currencyData']['code'];
}
foreach ($articles as $article) {
if (!isset($article['currency'])) {
$article['currency'] = $currency;
}
if (!isset($article['class'])) {
$this->articles[] = new Article($article);
continue;
......
......@@ -437,8 +437,11 @@ public function calcArticlePrice(Article $Article, $callback = false)
$isNetto = QUI\ERP\Utils\User::isNettoUser($this->getUser());
$isEuVatUser = QUI\ERP\Tax\Utils::isUserEuVatUser($this->getUser());
$Currency = $Article->getCurrency();
$Currency = $this->getCurrency();
if (!$Currency) {
$Currency = $this->getCurrency();
}
$nettoPrice = $Article->getUnitPrice()->value();
$vat = $Article->getVat();
......@@ -475,8 +478,8 @@ public function calcArticlePrice(Article $Article, $callback = false)
if (!$isNetto) {
// korrektur rechnung / 1 cent problem
$checkBrutto = $nettoPriceNotRounded * ($vat / 100 + 1);
$checkBrutto = \round($checkBrutto, $Currency->getPrecision());
$checkBrutto = $nettoPriceNotRounded * ($vat / 100 + 1);
$checkBrutto = \round($checkBrutto, $Currency->getPrecision());
$checkVat = $checkBrutto - $nettoPriceNotRounded;
$checkVat = \round($checkVat * $Article->getQuantity(), $Currency->getPrecision());
......
......@@ -154,9 +154,9 @@ public static function getBruttoNettoStatus(): int
/**
* Return the system calculation precision
*
* @return array|int|string
* @return int
*/
public static function getPrecision()
public static function getPrecision(): int
{
try {
$Package = QUI::getPackage('quiqqer/erp');
......@@ -169,7 +169,7 @@ public static function getPrecision()
$precision = $Config->get('general', 'precision');
if ($precision) {
return $precision;
return (int)$precision;
}
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
......
......@@ -47,7 +47,7 @@ class Price
/**
* Price constructor.
*
* @param float|int|double|string $price
* @param float|int|string $price
* @param QUI\ERP\Currency\Currency $Currency
* @param QUI\Users\User|boolean $User - optional, if no user, session user are used
*/
......@@ -68,7 +68,7 @@ public function __construct($price, QUI\ERP\Currency\Currency $Currency, $User =
* Return the price as array notation
* @return array
*/
public function toArray()
public function toArray(): array
{
return [
'price' => $this->value(),
......@@ -113,7 +113,7 @@ public function getValue()
*
* @return string
*/
public function getDisplayPrice()
public function getDisplayPrice(): string
{
return $this->Currency->format($this->getPrice());
}
......@@ -153,7 +153,7 @@ public function addDiscount(Discount $Discount)
*
* @return array [Discount, Discount, Discount]
*/
public function getDiscounts()
public function getDiscounts(): array
{
return $this->discounts;
}
......@@ -163,7 +163,7 @@ public function getDiscounts()
*
* @return QUI\ERP\Currency\Currency
*/
public function getCurrency()
public function getCurrency(): QUI\ERP\Currency\Currency
{
return $this->Currency;
}
......@@ -175,8 +175,8 @@ public function getCurrency()
/**
* Validates a price value
*
* @param number|string $value
* @return float|double|int|null
* @param int|float|string $value
* @return float|int|null
*/
public static function validatePrice($value)
{
......@@ -237,7 +237,7 @@ public static function validatePrice($value)
*
* @return bool
*/
public function isMinimalPrice()
public function isMinimalPrice(): bool
{
return $this->isMinimalPrice;
}
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren