diff --git a/Abrechnung/module.php b/Abrechnung/module.php index e7aa366..215f45e 100644 --- a/Abrechnung/module.php +++ b/Abrechnung/module.php @@ -301,6 +301,49 @@ private function CalculatePowerCosts($powerMeters, $tariffs, $userId, $from, $to return ['html'=>$html, 'sum'=>$grand]; } + + + + // ====================== Nebenkosten ====================== + +private function CalculateAdditionalCosts($waterMeters, $tariffs, $userId, $from, $to) +{ + $html = " + + + + "; + + $total = 0.0; + $usedTariffs = []; + + foreach ($waterMeters as $m) { + if ($m['user_id'] != $userId) continue; + $type = $m['meter_type'] ?? 'Warmwasser'; + $cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, $type); + $html .= $cost['row']; + $total += $cost['value']; + $usedTariffs = array_merge($usedTariffs, $cost['tariffs']); + } + + $html .= " + + +
ZählerTypStartEndeZähler StartZähler EndeVerbrauchTarif (Rp)Kosten (CHF)
Total Nebenkosten:" . number_format($total, 2) . "

"; + + // 👇 Tarifliste anhängen + if (!empty($usedTariffs)) { + $html .= "

Angewendete Nebenkostentarife:


"; + } + + return ['html' => $html, 'sum' => $total]; +} + // ====================== Kernberechnung ====================== private function AddMeterToPDFRow($meter, $tariffs, $from, $to, $type)