harshbhatiyaa's picture
Upload 91 files
9fe25e8 verified
Raw
History Blame Contribute Delete
923 Bytes
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from backend.app.models.base import BaseDBModel
class WalletTransaction(BaseDBModel):
__tablename__ = "wallet_transactions"
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), index=True, nullable=False)
booking_id = Column(UUID(as_uuid=True), ForeignKey("bookings.id", ondelete="SET NULL"), nullable=True)
label = Column(String, nullable=False) # e.g. "Wallet top-up via UPI", "Escrow hold for B-2401"
amount = Column(Integer, nullable=False) # positive for credits/refunds, negative for debits/holds
type = Column(String, nullable=False, index=True) # credit, hold, release, refund
# Relationships
user = relationship("User", back_populates="wallet_transactions")
booking = relationship("Booking")