From ad11f6dcdaba6f01355cb54fd39ab65d1f781d0b Mon Sep 17 00:00:00 2001 From: stuppie Date: Fri, 21 Aug 2026 11:10:06 -0600 Subject: put back a dummy create_bp_payout_event method so I dont break all these tests --- generalresearch/managers/thl/payout.py | 48 ++++++++++++++++++++++++++++++++++ generalresearch/models/thl/payout.py | 2 +- test_utils/models/conftest.py | 6 +---- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/generalresearch/managers/thl/payout.py b/generalresearch/managers/thl/payout.py index 551758f..c94065e 100644 --- a/generalresearch/managers/thl/payout.py +++ b/generalresearch/managers/thl/payout.py @@ -1139,6 +1139,54 @@ class BusinessPayoutEventManager(PostgresManagerWithRedis): conn.commit() return None + def create_bp_payout_event( + self, + thl_ledger_manager: ThlLedgerManager, + product: Product, + amount: USDCent, + ext_ref_id: str, + created: datetime | None = None, + ): + """ + This should NOT be called directly normally. It is just a shortcut + for tests. However, instead of just making a naked BP payout, + it created the business payout also, but with just one BP Payout + """ + created = created or datetime.now(tz=timezone.utc) + account = thl_ledger_manager.get_account( + f"{thl_ledger_manager.currency.value}:bp_wallet:{product.uuid}" + ) + bpe = BusinessPayoutEvent( + id=None, + business_id=product.business_uuid, + payout_type=PayoutType.ACH, + amount=amount, + created=created, + ext_ref_id=ext_ref_id, + status=PayoutStatus.APPROVED, + bp_payouts=[ + BrokerageProductPayoutEvent( + created=created, + payout_type=PayoutType.ACH, + status=PayoutStatus.PENDING, + uuid=uuid4().hex, + amount=amount, + ext_ref_id=ext_ref_id, + product_id=product.uuid, + cashout_method_uuid=self.bp_pe_manager.CASHOUT_METHOD_UUID, + debit_account_uuid=account.uuid, + ) + ], + ) + self.create_business_payout_event(bpe=bpe) + self.bp_pe_manager.create_tx_bp_payout_from_payout_event( + thl_ledger_manager=thl_ledger_manager, + bp_pe=bpe.bp_payouts[0], + product=product, + ) + self.update_business_payout_event(pk=bpe.id, status=PayoutStatus.COMPLETE) + return bpe + # import duckdb # conn = duckdb.connect() diff --git a/generalresearch/models/thl/payout.py b/generalresearch/models/thl/payout.py index 2ecc232..4accd49 100644 --- a/generalresearch/models/thl/payout.py +++ b/generalresearch/models/thl/payout.py @@ -228,7 +228,7 @@ class BusinessPayoutEvent(BaseModel): model_config = ConfigDict(validate_assignment=True) - id: SkipJsonSchema[PositiveInt | None] = Field(exclude=True) + id: SkipJsonSchema[PositiveInt | None] = Field(exclude=True, default=None) # Used for holding a *unique*, external, payout-type-specific identifier. ext_ref_id: str = Field(title="Unique external reference ID") diff --git a/test_utils/models/conftest.py b/test_utils/models/conftest.py index 64bdec6..6a8e4cf 100644 --- a/test_utils/models/conftest.py +++ b/test_utils/models/conftest.py @@ -390,8 +390,6 @@ def bp_payout_factory( amount: Optional["USDCent"] = None, ext_ref_id: Optional[str] = None, created: Optional[AwareDatetime] = None, - skip_wallet_balance_check: bool = False, - skip_one_per_day_check: bool = False, ) -> "BrokerageProductPayoutEvent": from generalresearch.currency import USDCent @@ -402,10 +400,8 @@ def bp_payout_factory( thl_ledger_manager=thl_lm, product=product, amount=amount, - ext_ref_id=ext_ref_id, + ext_ref_id=ext_ref_id or uuid4().hex, created=created, - skip_wallet_balance_check=skip_wallet_balance_check, - skip_one_per_day_check=skip_one_per_day_check, ) return _inner -- cgit v1.2.3