diff --git a/src/QUI/ERP/Accounting/ArticleList.php b/src/QUI/ERP/Accounting/ArticleList.php index d21c96ca43d4349301f6cc3224a707bb851f29de..2f7b1e6d0537d1f5a5d475710088e6a78e8ec954 100644 --- a/src/QUI/ERP/Accounting/ArticleList.php +++ b/src/QUI/ERP/Accounting/ArticleList.php @@ -276,7 +276,13 @@ public function toUniqueList(): ArticleListUnique { $this->calc(); - return new ArticleListUnique($this->toArray(), $this->getUser()); + $List = new ArticleListUnique($this->toArray(), $this->getUser()); + + if ($this->ExchangeCurrency) { + $List->setExchangeCurrency($this->ExchangeCurrency); + } + + return $List; } /** diff --git a/src/QUI/ERP/Accounting/ArticleListUnique.php b/src/QUI/ERP/Accounting/ArticleListUnique.php index 9ead39d2b9b66938bff771cdb0e1268967b84597..3f203a51d02e8ee65b99b1993a22bab4ae8d4f0d 100644 --- a/src/QUI/ERP/Accounting/ArticleListUnique.php +++ b/src/QUI/ERP/Accounting/ArticleListUnique.php @@ -54,6 +54,16 @@ class ArticleListUnique implements \IteratorAggregate */ protected $showExchangeRate = true; + /** + * @var null + */ + protected $ExchangeCurrency = null; + + /** + * @var float + */ + protected $exchangeRate = null; + /** * ArticleList constructor. * @@ -273,6 +283,22 @@ public function hideHeader() $this->showHeader = false; } + /** + * @param QUI\ERP\Currency\Currency $Currency + */ + public function setExchangeCurrency(QUI\ERP\Currency\Currency $Currency) + { + $this->ExchangeCurrency = $Currency; + } + + /** + * @param float $rate + */ + public function setExchangeRate(float $rate) + { + $this->exchangeRate = $rate; + } + /** * Return the Article List as HTML, without CSS * @@ -320,14 +346,18 @@ public function toHTML($template = false): string return $View; }, $this->articles); - $ExchangeCurrency = QUI\ERP\Currency\Conf::getAccountingCurrency(); + $ExchangeCurrency = $this->ExchangeCurrency; $showExchangeRate = $this->showExchangeRate; $exchangeRateText = ''; - if ($ExchangeCurrency->getCode() === $Currency->getCode()) { + if (!$ExchangeCurrency || $ExchangeCurrency->getCode() === $Currency->getCode()) { $showExchangeRate = false; $exchangeRate = false; } else { + if ($this->exchangeRate) { + $Currency->setExchangeRate($this->exchangeRate); + } + $exchangeRate = $Currency->getExchangeRate($ExchangeCurrency); $exchangeRate = $ExchangeCurrency->format($exchangeRate);