Subversion Repositories SmartDukaan

Rev

Rev 20954 | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 19-Sep-2012

@author: mandeep
'''
from elixir.entity import Entity
from elixir.fields import Field
from elixir.options import using_options, using_table_options
from elixir.relationships import OneToMany
from sqlalchemy.types import Integer
from shop2020.thriftpy.model.v1.order.ttypes import UserWallet as tUserWallet

class UserWallet(Entity):
    '''
    classdocs
    '''
    id = Field(Integer, primary_key=True, autoincrement=True)
    userId = Field(Integer)
    amount = Field(Integer)
    refundable_amount = Field(Integer)
    userWalletHistory = OneToMany("UserWalletHistory")
    using_options(shortnames=True)
    using_table_options(mysql_engine="InnoDB")

    def __init__(self):
        '''
        Constructor
        '''

    def to_thrift_object(self, ):
        '''
        Copies attributes to thrift object
        '''
        thriftObject = tUserWallet()
        thriftObject.id = self.id
        thriftObject.userId = self.userId
        thriftObject.amount = self.amount
        thriftObject.refundable_amount = self.refundable_amount
        return thriftObject
        
    def from_thrift_object(self, thriftUserWallet):
        self.id = thriftUserWallet.id
        self.userId = thriftUserWallet.userId
        self.amount = thriftUserWallet.amount
        self.refundable_amount = thriftUserWallet.refundable_amount
        
    def is_valid(self):
        return True