Skip to content

Commit

Permalink
Fix: migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotheem committed Jan 7, 2025
1 parent cd3d211 commit 5e63db5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
20 changes: 18 additions & 2 deletions app/core/myeclpay/cruds_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,12 @@ async def get_transactions(
schemas_myeclpay.Transaction(
id=transaction.id,
giver_wallet_id=transaction.giver_wallet_id,
giver_wallet_device_id=transaction.giver_wallet_device_id,
receiver_wallet_id=transaction.receiver_wallet_id,
transaction_type=transaction.transaction_type,
seller_user_id=transaction.seller_user_id,
total=transaction.total,
creation=transaction.creation,
status=transaction.status,
store_note=transaction.store_note,
)
for transaction in result.scalars().all()
]
Expand All @@ -502,6 +500,24 @@ async def get_transactions_by_wallet_id(
return result.scalars().all()


async def get_transfers(
db: AsyncSession,
) -> Sequence[schemas_myeclpay.Transfer]:
result = await db.execute(select(models_myeclpay.Transfer))
return [
schemas_myeclpay.Transfer(
id=transfer.id,
type=transfer.type,
transfer_identifier=transfer.transfer_identifier,
approver_user_id=transfer.approver_user_id,
wallet_id=transfer.wallet_id,
total=transfer.total,
creation=transfer.creation,
)
for transfer in result.scalars().all()
]


async def get_transfers_by_wallet_id(
wallet_id: UUID,
db: AsyncSession,
Expand Down
14 changes: 14 additions & 0 deletions app/core/myeclpay/schemas_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
HistoryType,
TransactionStatus,
TransactionType,
TransferType,
WalletDeviceStatus,
WalletType,
)
Expand Down Expand Up @@ -162,3 +163,16 @@ class Transaction(BaseModel):
total: int # Stored in cents
creation: datetime
status: TransactionStatus


class Transfer(BaseModel):
id: UUID
type: TransferType
transfer_identifier: str

# TODO remove if we only accept hello asso
approver_user_id: str | None

wallet_id: UUID
total: int # Stored in cents
creation: datetime
4 changes: 2 additions & 2 deletions migrations/versions/27-MyECLPay.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def upgrade() -> None:
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column(
"type",
sa.Enum(TransferType, name="transferype"),
sa.Enum(TransferType, name="transfertype"),
nullable=False,
),
sa.Column("transfer_identifier", sa.String(), nullable=False),
Expand Down Expand Up @@ -301,7 +301,7 @@ def downgrade() -> None:
sa.Enum(WalletType, name="wallettype").drop(
op.get_bind(),
)
sa.Enum(TransferType, name="transferype").drop(
sa.Enum(TransferType, name="transfertype").drop(
op.get_bind(),
)
sa.Enum(WalletDeviceStatus, name="walletdevicestatus").drop(
Expand Down

0 comments on commit 5e63db5

Please sign in to comment.