Skip to content

Commit

Permalink
Check if goal_amount is set before formatting it
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelad committed Apr 16, 2024
1 parent f84cfab commit f973cbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pymonzo/pots/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class MonzoPot(BaseModel):
def __rich__(self) -> Table:
"""Pretty printing support for `rich`."""
balance = format_currency(self.balance / 100, self.currency)
goal_amount = format_currency(self.goal_amount / 100, self.currency)

grid = Table.grid(padding=(0, 5))
grid.title = f"Pot '{self.name}' | {balance}"
Expand All @@ -91,7 +90,9 @@ def __rich__(self) -> Table:
grid.add_row("ID:", self.id)
grid.add_row("Name:", self.name)
grid.add_row("Balance:", balance)
grid.add_row("Goal:", goal_amount)
if self.goal_amount:
goal_amount = format_currency(self.goal_amount / 100, self.currency)
grid.add_row("Goal:", goal_amount)
grid.add_row("Currency:", self.currency)
grid.add_row("Type:", self.type)
grid.add_row("Deleted:", "Yes" if self.deleted else "No")
Expand Down

0 comments on commit f973cbe

Please sign in to comment.