From 172ec9042547f2186dcb4073149671aea128f27b Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Wed, 15 Jan 2025 11:24:08 +0000
Subject: [PATCH] fix(ArticleListUnique): no longer format already formatted
 totals

---
 src/QUI/ERP/Accounting/ArticleListUnique.php | 26 +++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/QUI/ERP/Accounting/ArticleListUnique.php b/src/QUI/ERP/Accounting/ArticleListUnique.php
index e25db6c..853c445 100644
--- a/src/QUI/ERP/Accounting/ArticleListUnique.php
+++ b/src/QUI/ERP/Accounting/ArticleListUnique.php
@@ -418,21 +418,23 @@ public function toHTML(
         }
 
         // price display
-        foreach ($vatArray as $key => $vat) {
-            $vatArray[$key]['sum'] = $Currency->format($vat['sum']);
-        }
+        if (is_numeric($this->calculations['sum'])) {
+            foreach ($vatArray as $key => $vat) {
+                $vatArray[$key]['sum'] = $Currency->format($vat['sum']);
+            }
 
-        $this->calculations['sum'] = $Currency->format($this->calculations['sum']);
-        $this->calculations['subSum'] = $Currency->format($this->calculations['subSum']);
+            $this->calculations['sum'] = $Currency->format($this->calculations['sum']);
+            $this->calculations['subSum'] = $Currency->format($this->calculations['subSum']);
 
-        // Fallback for older unique article lists
-        if (!isset($this->calculations['grandSubSum'])) {
-            $this->calculations['grandSubSum'] = $this->calculations['sum'];
-        }
+            // Fallback for older unique article lists
+            if (!isset($this->calculations['grandSubSum'])) {
+                $this->calculations['grandSubSum'] = $this->calculations['sum'];
+            }
 
-        $this->calculations['grandSubSum'] = $Currency->format($this->calculations['grandSubSum']);
-        $this->calculations['nettoSum'] = $Currency->format($this->calculations['nettoSum']);
-        $this->calculations['nettoSubSum'] = $Currency->format($this->calculations['nettoSubSum']);
+            $this->calculations['grandSubSum'] = $Currency->format($this->calculations['grandSubSum']);
+            $this->calculations['nettoSum'] = $Currency->format($this->calculations['nettoSum']);
+            $this->calculations['nettoSubSum'] = $Currency->format($this->calculations['nettoSubSum']);
+        }
 
         $articles = [];
 
-- 
GitLab