Source code for pay.types

from __future__ import annotations

from typing import Literal, TYPE_CHECKING
if TYPE_CHECKING:
    from decimal import Decimal
    from onegov.core.orm import Base
    from onegov.pay.models import Payable, PayableManyTimes
    from typing import type_check_only, Protocol, TypeAlias, TypedDict

[docs] class PriceDict(TypedDict):
[docs] amount: float
[docs] currency: str | None
[docs] fee: float
[docs] credit_card_payment: bool
class FeePolicy(Protocol): def from_amount(self, amount: Decimal | float, /) -> Decimal | float: ... def compensate(self, amount: Decimal | float, /) -> Decimal | float: ... # NOTE: We would like to use intersections here than pseudo classes @type_check_only class PayableBase(Base, Payable): pass @type_check_only class PayableManyTimesBase(Base, PayableManyTimes): pass AnyPayableBase: TypeAlias = PayableBase | PayableManyTimesBase
[docs] PaymentMethod: TypeAlias = Literal['free', 'cc', 'manual']
[docs] PaymentState: TypeAlias = Literal[ 'open', 'paid', 'failed', 'cancelled', 'invoiced']