diff --git a/Abrechnung/module.php b/Abrechnung/module.php index 7d91974..b9344ae 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -302,7 +302,7 @@ private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type) date_default_timezone_set('Europe/Zurich'); - // 🔹 Filtere relevante Tarife nach Typ + // 🔹 Passende Tarife nach Typ filtern $filteredTariffs = array_filter($tariffs, function ($t) use ($type) { return strtolower(trim($t['unit_type'] ?? '')) === strtolower(trim($type)); }); @@ -312,7 +312,7 @@ private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type) return ['row' => '', 'value' => 0]; } - // 🔹 Normiere Zeiträume + // 🔹 Zeitstempel konvertieren und sortieren foreach ($filteredTariffs as &$t) { $t['start_ts'] = $this->toUnixTs($t['start'], false); $t['end_ts'] = $this->toUnixTs($t['end'], true); @@ -323,7 +323,6 @@ private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type) $currentStart = $from; while ($currentStart < $to) { - // 🔹 Aktiven Tarif suchen $activeTariff = null; foreach ($filteredTariffs as $t) { if (($t['start_ts'] ?? 0) <= $currentStart && $currentStart <= ($t['end_ts'] ?? 0)) { @@ -343,35 +342,32 @@ private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type) $tariffEnd = intval($activeTariff['end_ts']); $tariffPrice = floatval($activeTariff['price']); - $tariffLabel = number_format($tariffPrice, 2, ',', ''); - // 🔹 Werte aus Archiv lesen - $startValue = $this->GetValueAt($varId, $currentStart, true); - $segmentEnd = ($tariffEnd < $to) ? $tariffEnd : $to; - $endValue = $this->GetValueAt($varId, $segmentEnd, true); + $startValue = $this->GetValueAt($varId, $currentStart, true); + $segmentEnd = ($tariffEnd < $to) ? $tariffEnd : $to; + $endValue = $this->GetValueAt($varId, $segmentEnd, true); if ($startValue === null || $endValue === null) break; - $verbrauch = max(0, $endValue - $startValue); - $kosten = round(($tariffPrice / 100) * $verbrauch, 2); - $totalCost += $kosten; + $verbrauch = max(0, $endValue - $startValue); + $kosten = round(($tariffPrice / 100) * $verbrauch, 2); + $totalCost += $kosten; - // 🔹 Kurze Datumsangaben $startDate = date('d.m.Y', $currentStart); $endDate = date('d.m.Y', $segmentEnd); - // 🔹 Tabellenzeile mit sichtbaren Linien + // 🧾 TCPDF-kompatible Tabellenzeile (sichtbare Linien) $rows .= " -