278 files

This commit is contained in:
Home Assistant Version Control committed 2026-09-13 20:38:58 +00:00
1 parent d7a0a08372
commit 1b4f5f68c6
278 files changed
+36892 -7150

No files matched your search

@@ -8,7 +8,7 @@
import { LitElement, html, css, nothing } from "lit";
import { property, state } from "lit/decorators.js";
import { t, syncLocaleFromHass, DEFAULT_CURRENCY_SYMBOL, langOf, formatNumber, formatCost } from "../styles";
import { t, syncLocaleFromHass, currencySymbolOf, langOf, formatCost, syncCurrencyDecimals} from "../styles";
import { registerCustomCard } from "../helpers/register-card";
import { describeWsError } from "../ws-errors";
import { sectionCardSharedStyles } from "./section-card-shared-styles";
@@ -64,6 +64,7 @@ export class MaintenanceBudgetSectionCard extends LitElement {
type: "maintenance_supporter/budget_status",
});
this._status = r;
syncCurrencyDecimals(r);
this._localMonthly = r.monthly_budget ? String(r.monthly_budget) : "";
this._localYearly = r.yearly_budget ? String(r.yearly_budget) : "";
this._dirty = false;
@@ -107,20 +108,20 @@ export class MaintenanceBudgetSectionCard extends LitElement {
const L = this._lang;
const s = this._status;
if (!s) {
return html`<ha-card><div class="loading">${t("loading", L) || "Loading…"}</div></ha-card>`;
return html`<ha-card><div class="loading">${t("loading", L)}</div></ha-card>`;
}
const sym = s.currency_symbol || DEFAULT_CURRENCY_SYMBOL;
const sym = currencySymbolOf(s);
// The amber step is the CONFIGURED budget_alert_threshold, not a literal 80
// — same rule the panel's budget bar uses (maintenance-panel._renderBudgetBar).
const threshold = s.alert_threshold_pct ?? DEFAULT_ALERT_THRESHOLD_PCT;
const tracks = [
{
label: t("budget_monthly", L) || "Monthly",
label: t("budget_monthly", L),
spent: s.monthly_spent || 0,
budget: s.monthly_budget || 0,
},
{
label: t("budget_yearly", L) || "Yearly",
label: t("budget_yearly", L),
spent: s.yearly_spent || 0,
budget: s.yearly_budget || 0,
},
@@ -132,7 +133,7 @@ export class MaintenanceBudgetSectionCard extends LitElement {
<div class="header">
<div class="title">
<span class="emoji">💰</span>
<span>${this._config.title || t("settings_budget", L) || "Budget"}</span>
<span>${this._config.title || t("settings_budget", L)}</span>
</div>
<span class="currency">${sym}</span>
</div>
@@ -148,7 +149,7 @@ export class MaintenanceBudgetSectionCard extends LitElement {
<div class="track spent-only">
<div class="track-label-row">
<label>${track.label}</label>
<span class="track-numbers ok">${formatCost(track.spent, sym, L, 0)}</span>
<span class="track-numbers ok">${formatCost(track.spent, sym, L)}</span>
</div>
</div>
`;
@@ -160,7 +161,14 @@ export class MaintenanceBudgetSectionCard extends LitElement {
<div class="track-label-row">
<label>${track.label}</label>
<span class="track-numbers ${warn}">
${formatNumber(track.spent, L, 0)} / ${formatCost(track.budget, sym, L, 0)}
${
// Spent and budget must round alike: the spent half was
// pinned to 0 decimals while the budget followed the
// "Decimal places for amounts" setting ("65 / 100.00 €";
// bug audit 2026-09-12). formatCost without a symbol =
// the setting-driven decimals, symbol once at the end.
formatCost(track.spent, undefined, L)
} / ${formatCost(track.budget, sym, L)}
</span>
</div>
<div class="bar"><div class="bar-fill ${warn}" style="width:${pct}%"></div></div>
@@ -172,7 +180,7 @@ export class MaintenanceBudgetSectionCard extends LitElement {
? html`
<div class="inputs-row">
<div class="input-field">
<label>${t("budget_monthly_set", L) || "Set monthly"}</label>
<label>${t("budget_monthly_set", L)}</label>
<div class="input-wrap">
<input type="number" min="0" step="1"
.value=${this._localMonthly}
@@ -185,7 +193,7 @@ export class MaintenanceBudgetSectionCard extends LitElement {
</div>
</div>
<div class="input-field">
<label>${t("budget_yearly_set", L) || "Set yearly"}</label>
<label>${t("budget_yearly_set", L)}</label>
<div class="input-wrap">
<input type="number" min="0" step="1"
.value=${this._localYearly}
@@ -204,17 +212,17 @@ export class MaintenanceBudgetSectionCard extends LitElement {
?disabled=${this._busy || !this._dirty}>
<ha-icon icon="${this._dirty ? "mdi:content-save" : "mdi:check"}"></ha-icon>
${this._dirty
? (t("save", L) || "Save")
: (t("saved", L) || "Saved")}
? t("save", L)
: t("saved", L)}
</button>
<button class="btn link" @click=${this._onDeepLink}>
${t("budget_advanced", L) || "Currency, alerts…"}
${t("budget_advanced", L)}
</button>
</div>
`
: html`
<button class="btn link" @click=${this._onDeepLink}>
${t("budget_open_panel", L) || "Open in panel"}
${t("budget_open_panel", L)}
</button>
`}
</div>