bootstrap
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from dataclasses import dataclass, field
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
|
||||
@dataclass
|
||||
class Liability:
|
||||
id: UUID = field(default_factory=uuid4)
|
||||
name: str = ""
|
||||
balance: float = 0.0
|
||||
interest: float = 0.0
|
||||
payment: float = 0.0
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
"id": str(self.id),
|
||||
"name": self.name,
|
||||
"balance": self.balance,
|
||||
"interest": self.interest,
|
||||
"payment": self.payment,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict) -> "Liability":
|
||||
return cls(
|
||||
id=UUID(data["id"]),
|
||||
name=data["name"],
|
||||
balance=data.get("balance", 0.0),
|
||||
interest=data.get("interest", 0.0),
|
||||
payment=data.get("payment", 0.0),
|
||||
)
|
||||
Reference in New Issue
Block a user