diff options
| -rw-r--r-- | generalresearch/managers/thl/cashout_method.py | 30 | ||||
| -rw-r--r-- | generalresearch/models/thl/wallet/cashout_method.py | 2 |
2 files changed, 22 insertions, 10 deletions
diff --git a/generalresearch/managers/thl/cashout_method.py b/generalresearch/managers/thl/cashout_method.py index 32bda88..2b9bb96 100644 --- a/generalresearch/managers/thl/cashout_method.py +++ b/generalresearch/managers/thl/cashout_method.py @@ -3,7 +3,7 @@ from __future__ import annotations from collections.abc import Collection from copy import copy from datetime import UTC, datetime -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, cast from uuid import UUID, uuid4 from pydantic import NonNegativeInt @@ -25,7 +25,9 @@ if TYPE_CHECKING: from generalresearch.models.thl.wallet.cashout_method import ( CashMailCashoutMethodData, CashoutMethod, + GiftbitCashoutMethodData, PaypalCashoutMethodData, + TangoCashoutMethodData, ) @@ -418,14 +420,24 @@ class CashoutMethodManager(PostgresManager): cms = self.get_cashout_methods(user=user) # Filter out by country before bothering w exchange rates - cms = [ - cm - for cm in cms - if ( - cm.type == PayoutType.TANGO and country_iso.lower() in cm.data.countries - ) - or cm.type != PayoutType.TANGO - ] + country_iso = country_iso.lower() + country_cms = [] + for cm in cms: + if cm.type == PayoutType.TANGO: + data = cast("TangoCashoutMethodData", cm.data) + if country_iso in data.countries: + country_cms.append(cm) + continue + + if cm.type == PayoutType.GIFTBIT: + data = cast("GiftbitCashoutMethodData", cm.data) + if data.countries is None or country_iso in data.countries: + country_cms.append(cm) + continue + + country_cms.append(cm) + + cms = country_cms cms = [ self.apply_currency_adjustments(x, product, usd_exchange_rate) for x in cms diff --git a/generalresearch/models/thl/wallet/cashout_method.py b/generalresearch/models/thl/wallet/cashout_method.py index 8ad02f5..b957d9c 100644 --- a/generalresearch/models/thl/wallet/cashout_method.py +++ b/generalresearch/models/thl/wallet/cashout_method.py @@ -350,7 +350,7 @@ class GiftbitCashoutMethodData(BaseModel): min_price_in_cents: int | None = Field(default=None) max_price_in_cents: int | None = Field(default=None) allowed_prices_in_cents: list[int] | None = Field(default=None) - countries: list[str] | None= Field(description="None means global") + countries: list[str] | None = Field(description="None means global") disclaimer: str = Field(default="") |
