no message

This commit is contained in:
2025-12-11 14:07:26 +01:00
parent 7daa8b7671
commit f3e7d81fb5

View File

@@ -157,7 +157,7 @@ class Abrechnung extends IPSModule
<table width='100%' style='font-size:10px;'>
<tr>
<td width='60%'>
<strong>Zählpunkte:</strong><br>";
<strong>Zählpunkte:</strong><br>";
// Alle Zählerpunkte des Users auflisten
foreach ($power as $m) {
@@ -219,7 +219,7 @@ class Abrechnung extends IPSModule
$grandTotal = $totalPower + $totalAdditional;
$html .= "
<h2 style='text-align:right; margin:5px 0 0 0; font-size:11px;'>
Gesamttotal: <strong>CHF " . number_format($grandTotal, 2) . ".-</strong>
Gesamttotal: <strong>CHF " . number_format($grandTotal, 2) . ".-</strong>
</h2>
";
@@ -305,32 +305,45 @@ class Abrechnung extends IPSModule
$expTotal += $expDelta;
}
}
// Überspringe Fälle, in denen kein Stromverbrauch und keine Einspeisung vorhanden ist
// Logging der Eingangswerte
IPS_LogMessage("KostenModul", "impTotal: $impTotal | expTotal: $expTotal");
// Fall 1: Weder Import noch Export -> nichts zu berechnen
if ($impTotal == 0.0 && $expTotal == 0.0) {
$ratio = 0.0;
$pvCoversAll = true; // Kein Verbrauch => PV deckt "alles"
} else {
// Verhältnis PV / Netz pro User
if ($impTotal == 0.0) {
// Kein Import, nur Export vorhanden
$ratio = 0.0;
$pvCoversAll = true; // PV deckt alles
} elseif ($expTotal == 0.0) {
// Kein Export, nur Import vorhanden
$ratio = 0.0;
$pvCoversAll = false; // PV deckt nichts
} elseif ($impTotal <= $expTotal) {
// PV deckt mehr als Import
$ratio = $impTotal / $expTotal;
$pvCoversAll = true;
} else {
// PV deckt weniger als Import
$ratio = $expTotal / $impTotal;
$pvCoversAll = false;
}
IPS_LogMessage("KostenModul", "Beide Werte sind 0 -> continue()");
continue;
}
// Verhältnis PV / Netz pro User
if ($impTotal == 0.0 && $expTotal > 0.0) {
// Kein Import, aber Export → PV deckt alles
$ratio = 0.0;
$pvCoversAll = true;
IPS_LogMessage("KostenModul", "Fall: impTotal=0, expTotal>0 -> PV deckt alles");
} elseif ($expTotal == 0.0 && $impTotal > 0.0) {
// Kein Export, aber Import → Netz deckt alles
$ratio = 0.0;
$pvCoversAll = false;
IPS_LogMessage("KostenModul", "Fall: expTotal=0, impTotal>0 -> Netz deckt alles");
} elseif ($impTotal <= $expTotal) {
// PV produziert genug oder mehr
$ratio = $expTotal > 0 ? ($impTotal / $expTotal) : 0.0;
$pvCoversAll = true;
IPS_LogMessage("KostenModul", "Fall: impTotal <= expTotal -> PV deckt genug");
} else {
// Import ist größer als Export → Netz deckt den Rest
$ratio = $impTotal > 0 ? ($expTotal / $impTotal) : 0.0;
$pvCoversAll = false;
IPS_LogMessage("KostenModul", "Fall: impTotal > expTotal -> Netz deckt den Rest");
}
IPS_LogMessage("KostenModul", "Ergebnis ratio=$ratio | pvCoversAll=" . ($pvCoversAll ? "true" : "false"));
// Werte pro Zähler verteilen
foreach ($slot as $name => $v) {
$imp = $v['imp'];