no message
This commit is contained in:
+41
-3
@@ -148,11 +148,14 @@ class Abrechnung extends IPSModule
|
|||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
$total = 0.0;
|
$total = 0.0;
|
||||||
|
$usedTariffs = [];
|
||||||
|
|
||||||
foreach ($powerMeters as $m) {
|
foreach ($powerMeters as $m) {
|
||||||
if ($m['user_id'] != $userId) continue;
|
if ($m['user_id'] != $userId) continue;
|
||||||
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, 'Strombezug');
|
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, 'Strombezug');
|
||||||
$html .= $cost['row'];
|
$html .= $cost['row'];
|
||||||
$total += $cost['value'];
|
$total += $cost['value'];
|
||||||
|
$usedTariffs = array_merge($usedTariffs, $cost['tariffs']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "<tr style='background-color:#f9f9f9; font-weight:bold;'>
|
$html .= "<tr style='background-color:#f9f9f9; font-weight:bold;'>
|
||||||
@@ -160,9 +163,20 @@ class Abrechnung extends IPSModule
|
|||||||
<td align='right'>" . number_format($total, 2) . "</td>
|
<td align='right'>" . number_format($total, 2) . "</td>
|
||||||
</tr></table><br>";
|
</tr></table><br>";
|
||||||
|
|
||||||
|
// 👇 Tarifliste anhängen
|
||||||
|
if (!empty($usedTariffs)) {
|
||||||
|
$html .= "<p><strong>Angewendete Stromtarife:</strong></p><ul>";
|
||||||
|
foreach ($usedTariffs as $t) {
|
||||||
|
$html .= "<li>" . date('d.m.Y', $t['start']) . " – " . date('d.m.Y', $t['end']) . ": " .
|
||||||
|
number_format($t['price'], 2) . " Rp/kWh</li>";
|
||||||
|
}
|
||||||
|
$html .= "</ul><br>";
|
||||||
|
}
|
||||||
|
|
||||||
return ['html' => $html, 'sum' => $total];
|
return ['html' => $html, 'sum' => $total];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====================== Nebenkosten ======================
|
// ====================== Nebenkosten ======================
|
||||||
|
|
||||||
private function CalculateAdditionalCosts($waterMeters, $tariffs, $userId, $from, $to)
|
private function CalculateAdditionalCosts($waterMeters, $tariffs, $userId, $from, $to)
|
||||||
@@ -174,12 +188,15 @@ class Abrechnung extends IPSModule
|
|||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
$total = 0.0;
|
$total = 0.0;
|
||||||
|
$usedTariffs = [];
|
||||||
|
|
||||||
foreach ($waterMeters as $m) {
|
foreach ($waterMeters as $m) {
|
||||||
if ($m['user_id'] != $userId) continue;
|
if ($m['user_id'] != $userId) continue;
|
||||||
$type = $m['meter_type'] ?? 'Warmwasser';
|
$type = $m['meter_type'] ?? 'Warmwasser';
|
||||||
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, $type);
|
$cost = $this->AddMeterToPDFRow($m, $tariffs, $from, $to, $type);
|
||||||
$html .= $cost['row'];
|
$html .= $cost['row'];
|
||||||
$total += $cost['value'];
|
$total += $cost['value'];
|
||||||
|
$usedTariffs = array_merge($usedTariffs, $cost['tariffs']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "<tr style='background-color:#f9f9f9; font-weight:bold;'>
|
$html .= "<tr style='background-color:#f9f9f9; font-weight:bold;'>
|
||||||
@@ -187,6 +204,16 @@ class Abrechnung extends IPSModule
|
|||||||
<td align='right'>" . number_format($total, 2) . "</td>
|
<td align='right'>" . number_format($total, 2) . "</td>
|
||||||
</tr></table><br>";
|
</tr></table><br>";
|
||||||
|
|
||||||
|
// 👇 Tarifliste anhängen
|
||||||
|
if (!empty($usedTariffs)) {
|
||||||
|
$html .= "<p><strong>Angewendete Nebenkostentarife:</strong></p><ul>";
|
||||||
|
foreach ($usedTariffs as $t) {
|
||||||
|
$html .= "<li>" . date('d.m.Y', $t['start']) . " – " . date('d.m.Y', $t['end']) . ": " .
|
||||||
|
number_format($t['price'], 2) . " Rp</li>";
|
||||||
|
}
|
||||||
|
$html .= "</ul><br>";
|
||||||
|
}
|
||||||
|
|
||||||
return ['html' => $html, 'sum' => $total];
|
return ['html' => $html, 'sum' => $total];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,9 +223,10 @@ class Abrechnung extends IPSModule
|
|||||||
{
|
{
|
||||||
$rows = '';
|
$rows = '';
|
||||||
$totalCost = 0.0;
|
$totalCost = 0.0;
|
||||||
|
$usedTariffs = []; // 👈 neu: Liste der verwendeten Tarife
|
||||||
$varId = $meter['var_consumption'];
|
$varId = $meter['var_consumption'];
|
||||||
|
|
||||||
if (!IPS_VariableExists($varId)) return ['row' => '', 'value' => 0];
|
if (!IPS_VariableExists($varId)) return ['row' => '', 'value' => 0, 'tariffs' => []];
|
||||||
|
|
||||||
$filteredTariffs = array_filter($tariffs, fn($t) =>
|
$filteredTariffs = array_filter($tariffs, fn($t) =>
|
||||||
strtolower(trim($t['unit_type'] ?? '')) === strtolower(trim($type))
|
strtolower(trim($t['unit_type'] ?? '')) === strtolower(trim($type))
|
||||||
@@ -228,6 +256,16 @@ class Abrechnung extends IPSModule
|
|||||||
$tariffEnd = intval($activeTariff['end_ts']);
|
$tariffEnd = intval($activeTariff['end_ts']);
|
||||||
$tariffPrice = floatval($activeTariff['price']);
|
$tariffPrice = floatval($activeTariff['price']);
|
||||||
|
|
||||||
|
// 👇 Tarif in Liste aufnehmen (nur wenn noch nicht drin)
|
||||||
|
$key = $activeTariff['start_ts'] . '-' . $activeTariff['end_ts'] . '-' . $tariffPrice;
|
||||||
|
if (!isset($usedTariffs[$key])) {
|
||||||
|
$usedTariffs[$key] = [
|
||||||
|
'start' => $activeTariff['start_ts'],
|
||||||
|
'end' => $activeTariff['end_ts'],
|
||||||
|
'price' => $tariffPrice
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$startValue = $this->GetValueAt($varId, $currentStart, true);
|
$startValue = $this->GetValueAt($varId, $currentStart, true);
|
||||||
$segmentEnd = ($tariffEnd < $to) ? $tariffEnd : $to;
|
$segmentEnd = ($tariffEnd < $to) ? $tariffEnd : $to;
|
||||||
$endValue = $this->GetValueAt($varId, $segmentEnd, true);
|
$endValue = $this->GetValueAt($varId, $segmentEnd, true);
|
||||||
@@ -254,9 +292,9 @@ class Abrechnung extends IPSModule
|
|||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows === '') return ['row' => '', 'value' => 0];
|
if ($rows === '') return ['row' => '', 'value' => 0, 'tariffs' => []];
|
||||||
|
|
||||||
return ['row' => $rows, 'value' => $totalCost];
|
return ['row' => $rows, 'value' => $totalCost, 'tariffs' => array_values($usedTariffs)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================== Hilfsfunktionen ======================
|
// ====================== Hilfsfunktionen ======================
|
||||||
|
|||||||
Reference in New Issue
Block a user