Loading poolpay/model/Person.py 0 → 100644 +34 −0 Original line number Diff line number Diff line from babel.numbers import format_currency from sqlalchemy.orm import Mapped, mapped_column from poolpay.model.Base import Base class Person(Base): """ A person that uses the PoolPay system. They have the following properties: - The name the person is adressed with (e.g. "Max"). This will usually be the first name, but could also be a nickname, or some other sequence, as long as it identifies the person within the Coli context. - The name of the CL account (e.g. "mustermann"). Will usually be the last name in lowercase. Can be used to send mails to the person, and must be unique. - The balance of the account of that person, in cents. Might be negative (which means the person owes us money). """ name: Mapped[str] cl_account_name: Mapped[str] = mapped_column(unique=True) balance_cents: int = 0 @property def balance_str(self) -> str: """ :return: the balance formatted as a string, e.g. "2,50 €" or "-4,40 €". """ return format_currency(self.balance_cents / 100, "EUR", locale="de_DE") def __str__(self) -> str: return f"{self.name} ({self.cl_account_name}@cl): {self.balance_str}" Loading
poolpay/model/Person.py 0 → 100644 +34 −0 Original line number Diff line number Diff line from babel.numbers import format_currency from sqlalchemy.orm import Mapped, mapped_column from poolpay.model.Base import Base class Person(Base): """ A person that uses the PoolPay system. They have the following properties: - The name the person is adressed with (e.g. "Max"). This will usually be the first name, but could also be a nickname, or some other sequence, as long as it identifies the person within the Coli context. - The name of the CL account (e.g. "mustermann"). Will usually be the last name in lowercase. Can be used to send mails to the person, and must be unique. - The balance of the account of that person, in cents. Might be negative (which means the person owes us money). """ name: Mapped[str] cl_account_name: Mapped[str] = mapped_column(unique=True) balance_cents: int = 0 @property def balance_str(self) -> str: """ :return: the balance formatted as a string, e.g. "2,50 €" or "-4,40 €". """ return format_currency(self.balance_cents / 100, "EUR", locale="de_DE") def __str__(self) -> str: return f"{self.name} ({self.cl_account_name}@cl): {self.balance_str}"