Extra usage: afficher le restant en priorite (restant / utilise / plafond)
This commit is contained in:
@@ -72,12 +72,22 @@ class ExtraUsage:
|
||||
limit: float | None
|
||||
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
|
||||
def label(self) -> str:
|
||||
sym = "€" if self.currency == "EUR" else self.currency
|
||||
if self.limit:
|
||||
return f"Extra : {self.used:.0f}{sym} / {self.limit:.0f}{sym}"
|
||||
return f"Extra : {self.used:.0f}{sym}"
|
||||
return (
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user