Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 964d005a erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix(Calc): main calc has its own locale

Übergeordneter 0c18d5a1
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!150Next 3.x,!140Update 'next-4.x' with latest changes from 'main'
Pipeline-Nr. 12186 mit Warnungen bestanden
......@@ -99,14 +99,10 @@ class Calc
const TRANSACTION_ATTR_TARGET_CURRENCY_EXCHANGE_RATE = 'tx_target_currency_exchange_rate';
const TRANSACTION_ATTR_SHOP_CURRENCY_EXCHANGE_RATE = 'tx_shop_currency_exchange_rate';
/**
* @var ?UserInterface
*/
protected ?UserInterface $User = null;
/**
* @var null|QUI\ERP\Currency\Currency
*/
protected ?QUI\Locale $Locale = null;
protected ?QUI\ERP\Currency\Currency $Currency = null;
/**
......@@ -121,6 +117,7 @@ public function __construct(?UserInterface $User = null)
}
$this->User = $User;
$this->Locale = QUI::getLocale();
}
/**
......@@ -163,6 +160,25 @@ public function getUser(): ?UserInterface
return $this->User;
}
//region locale
public function getLocale(): ?Locale
{
return $this->Locale;
}
public function setLocale(QUI\Locale $Locale): void
{
$this->Locale = $Locale;
}
public function resetLocale(): void
{
$this->Locale = QUI::getLocale();
}
//endregion
/**
* Return the currency
*
......@@ -184,7 +200,7 @@ public function getCurrency(): ?QUI\ERP\Currency\Currency
* @param callable|boolean $callback - optional, callback function for the data array
* @return ArticleList
*/
public function calcArticleList(ArticleList $List, $callback = false): ArticleList
public function calcArticleList(ArticleList $List, callable|bool $callback = false): ArticleList
{
// calc data
if (!is_callable($callback)) {
......@@ -360,7 +376,7 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi
if (!isset($vatArray[(string)$vat])) {
$vatArray[(string)$vat] = [
'vat' => $vat,
'text' => self::getVatText($vat, $this->getUser())
'text' => $this->getVatText($vat, $this->getUser(), $this->Locale)
];
$vatArray[(string)$vat]['sum'] = 0;
......@@ -394,7 +410,7 @@ public function calcArticleList(ArticleList $List, $callback = false): ArticleLi
$bruttoSum = round($bruttoSum, $precision);
foreach ($vatLists as $vat => $bool) {
$vatText[(string)$vat] = self::getVatText((float)$vat, $this->getUser());
$vatText[(string)$vat] = $this->getVatText((float)$vat, $this->getUser(), $this->Locale);
}
// delete 0 % vat, 0% vat is allowed to calculate more easily
......@@ -634,7 +650,7 @@ public function calcArticlePrice(Article $Article, $callback = false)
$vatArray = [
'vat' => $vat,
'sum' => $vatSum,
'text' => $this->getVatText($vat, $this->getUser())
'text' => $this->getVatText($vat, $this->getUser(), $this->Locale)
];
QUI\ERP\Debug::getInstance()->log(
......@@ -702,7 +718,7 @@ public function getVatTextByUser(): string
return '';
}
return $this->getVatText($Tax->getValue(), $this->getUser());
return $this->getVatText($Tax->getValue(), $this->getUser(), $this->Locale);
}
/**
......@@ -715,10 +731,13 @@ public function getVatTextByUser(): string
*
* @return string
*/
public static function getVatText(float|int $vat, UserInterface $User, QUI\Locale $Locale = null): string
{
public static function getVatText(
float|int $vat,
UserInterface $User,
QUI\Locale $Locale = null
): string {
if ($Locale === null) {
$Locale = $User->getLocale();
$Locale = QUI::getLocale();
}
if (QUI\ERP\Utils\User::isNettoUser($User)) {
......
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