v1.8.15: Abschlags-Tracker zeigt ganze Zahlungen statt Bruchmonate
Berechnung auf geleistete Abschlagszahlungen umgestellt: Anzahl ganzer Monate seit Abrechnungsstart statt Tage/30.4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
name: ShineBridge
|
name: ShineBridge
|
||||||
version: "1.8.14"
|
version: "1.8.15"
|
||||||
slug: shinebridge
|
slug: shinebridge
|
||||||
description: Growatt Wechselrichter lokal in Home Assistant — Modbus TCP via ShineLAN-X, MQTT Discovery, Web UI
|
description: Growatt Wechselrichter lokal in Home Assistant — Modbus TCP via ShineLAN-X, MQTT Discovery, Web UI
|
||||||
url: https://gitea.bitfire.work/retr0/shinebridge
|
url: https://gitea.bitfire.work/retr0/shinebridge
|
||||||
|
|||||||
@@ -509,17 +509,21 @@ def api_period_energy():
|
|||||||
grundpreis = float(State.mqtt_cfg.get("grundpreis_eur_per_month", 0.0))
|
grundpreis = float(State.mqtt_cfg.get("grundpreis_eur_per_month", 0.0))
|
||||||
yr_key = history.period_key("yearly", billing_day, billing_month)
|
yr_key = history.period_key("yearly", billing_day, billing_month)
|
||||||
yr_start = datetime.date.fromisoformat(yr_key)
|
yr_start = datetime.date.fromisoformat(yr_key)
|
||||||
days_elapsed = (datetime.date.today() - yr_start).days
|
today = datetime.date.today()
|
||||||
months_elapsed = round(days_elapsed / 30.4375, 4)
|
# Anzahl geleisteter Abschlagszahlungen (ganze Monate seit Periodenstart)
|
||||||
total_paid = round(months_elapsed * monthly_rate, 2)
|
months_diff = (today.year - yr_start.year) * 12 + (today.month - yr_start.month)
|
||||||
grundpreis_total= round(months_elapsed * grundpreis, 2)
|
if today.day >= yr_start.day:
|
||||||
|
months_diff += 1
|
||||||
|
payments_made = max(0, months_diff)
|
||||||
|
total_paid = round(payments_made * monthly_rate, 2)
|
||||||
|
grundpreis_total= round(payments_made * grundpreis, 2)
|
||||||
energy_cost = result.get("yearly", {}).get("import_cost", 0.0)
|
energy_cost = result.get("yearly", {}).get("import_cost", 0.0)
|
||||||
total_cost = round(energy_cost + grundpreis_total, 2)
|
total_cost = round(energy_cost + grundpreis_total, 2)
|
||||||
nachzahlung = round(total_cost - total_paid, 2)
|
nachzahlung = round(total_cost - total_paid, 2)
|
||||||
result["billing_tracker"] = {
|
result["billing_tracker"] = {
|
||||||
"monthly_rate_eur": monthly_rate,
|
"monthly_rate_eur": monthly_rate,
|
||||||
"grundpreis_eur_per_month": grundpreis,
|
"grundpreis_eur_per_month": grundpreis,
|
||||||
"months_elapsed": round(months_elapsed, 1),
|
"payments_made": payments_made,
|
||||||
"total_paid_eur": total_paid,
|
"total_paid_eur": total_paid,
|
||||||
"grundpreis_total_eur": grundpreis_total,
|
"grundpreis_total_eur": grundpreis_total,
|
||||||
"energy_cost_eur": energy_cost,
|
"energy_cost_eur": energy_cost,
|
||||||
|
|||||||
@@ -673,15 +673,15 @@ function renderEnergy(inverters, aggregates, period, spotData) {
|
|||||||
const nzLabel = isNachzahlung ? 'Voraussichtliche Nachzahlung' : 'Voraussichtliches Guthaben';
|
const nzLabel = isNachzahlung ? 'Voraussichtliche Nachzahlung' : 'Voraussichtliches Guthaben';
|
||||||
const nzSign = isNachzahlung ? '+' : '−';
|
const nzSign = isNachzahlung ? '+' : '−';
|
||||||
return `<div style="margin-top:16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px">
|
return `<div style="margin-top:16px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px">
|
||||||
<div style="font-size:10px;font-weight:700;letter-spacing:.08em;color:var(--text-dim);text-transform:uppercase;margin-bottom:12px">Abschlags-Übersicht · ${bt.months_elapsed} Monate</div>
|
<div style="font-size:10px;font-weight:700;letter-spacing:.08em;color:var(--text-dim);text-transform:uppercase;margin-bottom:12px">Abschlags-Übersicht · ${bt.payments_made} Zahlung${bt.payments_made !== 1 ? 'en' : ''}</div>
|
||||||
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:12px">
|
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:12px">
|
||||||
<div class="kwh-card">
|
<div class="kwh-card">
|
||||||
<div class="kv">${fEur(bt.total_paid_eur)}</div>
|
<div class="kv">${fEur(bt.total_paid_eur)}</div>
|
||||||
<div class="kl">Bereits bezahlt<br><span style="opacity:.6">${bt.months_elapsed} × ${fEur(bt.monthly_rate_eur)}/Monat</span></div>
|
<div class="kl">Bereits bezahlt<br><span style="opacity:.6">${bt.payments_made} × ${fEur(bt.monthly_rate_eur)}</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="kwh-card">
|
<div class="kwh-card">
|
||||||
<div class="kv">${fEur(bt.grundpreis_total_eur)}</div>
|
<div class="kv">${fEur(bt.grundpreis_total_eur)}</div>
|
||||||
<div class="kl">Grundpreis anteilig<br><span style="opacity:.6">${fEur(bt.grundpreis_eur_per_month)}/Monat</span></div>
|
<div class="kl">Grundpreis anteilig<br><span style="opacity:.6">${bt.payments_made} × ${fEur(bt.grundpreis_eur_per_month)}</span></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="kwh-card">
|
<div class="kwh-card">
|
||||||
<div class="kv">${fEur(bt.energy_cost_eur)}</div>
|
<div class="kv">${fEur(bt.energy_cost_eur)}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user