diff --git a/src/QUI/ERP/Accounting/ArticleView.php b/src/QUI/ERP/Accounting/ArticleView.php index e2f23444786d0a4663ac041c623253e24d803137..52a9bc0a0df49aee7383b8b7705475c0b9cc4d07 100644 --- a/src/QUI/ERP/Accounting/ArticleView.php +++ b/src/QUI/ERP/Accounting/ArticleView.php @@ -7,6 +7,7 @@ namespace QUI\ERP\Accounting; use QUI; +use QUI\ERP\Accounting\Calc as ErpCalc; /** * Class ArticleView @@ -102,6 +103,33 @@ public function getCustomFields(): array $field['custom_calc']['valueText'] = ''; } } + + // Add price addition + $sum = (float)$field['custom_calc']['value']; + + if (!empty($field['custom_calc']['displayDiscounts']) && + (!QUI::isFrontend() || !QUI\ERP\Products\Utils\Package::hidePrice()) && + $sum > 0) { + + if ($sum >= 0) { + $priceAddition = '+'; + } else { + $priceAddition = '-'; + } + + switch ((int)$field['custom_calc']['calculation']) { + case ErpCalc::CALCULATION_PERCENTAGE: + $priceAddition .= $sum.'%'; + break; + + default: + $priceAddition .= $this->getCurrency()->format($sum); + break; + } + + // locale values + $field['custom_calc']['valueText'] .= ' ('.$priceAddition.')'; + } } $customFields[] = $field;