Extra usage: afficher le restant en priorite (restant / utilise / plafond)
This commit is contained in:
@@ -72,12 +72,22 @@ class ExtraUsage:
|
|||||||
limit: float | None
|
limit: float | None
|
||||||
currency: str = "EUR"
|
currency: str = "EUR"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def remaining(self) -> float | None:
|
||||||
|
"""Crédits extra encore disponibles avant le plafond mensuel."""
|
||||||
|
if self.limit is None:
|
||||||
|
return None
|
||||||
|
return max(0.0, self.limit - self.used)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def label(self) -> str:
|
def label(self) -> str:
|
||||||
sym = "€" if self.currency == "EUR" else self.currency
|
sym = "€" if self.currency == "EUR" else self.currency
|
||||||
if self.limit:
|
if self.limit:
|
||||||
return f"Extra : {self.used:.0f}{sym} / {self.limit:.0f}{sym}"
|
return (
|
||||||
return f"Extra : {self.used:.0f}{sym}"
|
f"Extra : {self.remaining:.0f}{sym} restant"
|
||||||
|
f" · {self.used:.0f}{sym} utilisé / {self.limit:.0f}{sym}"
|
||||||
|
)
|
||||||
|
return f"Extra : {self.used:.0f}{sym} utilisé"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
Reference in New Issue
Block a user