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

fix: ERP Articles have now its currency

Übergeordneter 431ead6d
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -121,6 +121,11 @@ class Article implements ArticleInterface
*/
protected $User = null;
/**
* @var null
*/
protected $Currency = null;
/**
* Article constructor.
*
......@@ -184,6 +189,8 @@ public function __construct($attributes = [])
if (isset($attributes['displayPrice'])) {
$this->displayPrice = (bool)$attributes['displayPrice'];
}
$this->Currency = QUI\ERP\Currency\Handler::getDefaultCurrency();
}
/**
......@@ -310,7 +317,7 @@ public function getUnitPrice()
$unitPrice = $this->attributes['unitPrice'];
}
return new Price($unitPrice, QUI\ERP\Defaults::getCurrency());
return new Price($unitPrice, $this->Currency);
}
/**
......@@ -322,7 +329,7 @@ public function getSum()
{
$this->calc();
return new Price($this->sum, QUI\ERP\Defaults::getCurrency());
return new Price($this->sum, $this->Currency);
}
/**
......@@ -374,6 +381,26 @@ public function setUser(QUI\Interfaces\Users\User $User)
$this->User = $User;
}
/**
* Return the currency of the article
*
* @return QUI\ERP\Currency\Currency|null
*/
public function getCurrency()
{
return $this->Currency;
}
/**
* Set the currency for the article
*
* @param QUI\ERP\Currency\Currency $Currency
*/
public function setCurrency(QUI\ERP\Currency\Currency $Currency)
{
$this->Currency = $Currency;
}
/**
* Returns the article quantity
*
......@@ -397,10 +424,7 @@ public function getPrice()
{
$this->calc();
return new Price(
$this->sum,
QUI\ERP\Currency\Handler::getDefaultCurrency()
);
return new Price($this->sum, $this->Currency);
}
/**
......
......@@ -186,6 +186,12 @@ public function setCurrency(QUI\ERP\Currency\Currency $Currency)
'rate' => $this->Currency->getExchangeRate()
];
}
if (\count($this->articles)) {
foreach ($this->articles as $Article) {
$Article->setCurrency($Currency);
}
}
}
/**
......@@ -321,6 +327,10 @@ public function addArticle(Article $Article)
if ($this->User) {
$Article->setUser($this->User);
}
if ($this->Currency) {
$Article->setCurrency($this->Currency);
}
}
/**
......
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