Rev 22049 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 19-Sep-2012@author: rajveer'''from elixir.entity import Entityfrom elixir.fields import Fieldfrom elixir.options import using_options, using_table_optionsfrom elixir.relationships import ManyToOnefrom shop2020.thriftpy.model.v1.order.ttypes import \UserWalletHistory as tUserWalletHistory, WalletReferenceTypefrom shop2020.utils.Utils import to_py_date, to_java_datefrom sqlalchemy.types import Integer, DateTime, Stringclass UserWalletHistory(Entity):'''classdocs'''id = Field(Integer, primary_key=True, autoincrement=True)amount = Field(Integer)refundable_amount = Field(Integer)wallet = ManyToOne("UserWallet")reference = Field(Integer)reference_type = Field(String(20))wallet_type = Field(String(20))description = Field(String(192))timestamp = Field(DateTime)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 = tUserWalletHistory()thriftObject.id = self.idthriftObject.amount = self.amountthriftObject.refundableAmount = self.refundable_amountthriftObject.walletId = self.wallet.idthriftObject.timestamp = to_java_date(self.timestamp)thriftObject.referenceNumber = self.referencethriftObject.referenceType = WalletReferenceType._NAMES_TO_VALUES.get(self.reference_type)thriftObject.description = self.descriptionreturn thriftObjectdef from_thrift_object(self, thriftUserWalletHistory):self.id = thriftUserWalletHistory.idself.amount = thriftUserWalletHistory.amountself.orderId = thriftUserWalletHistory.orderIdself.wallet.id = thriftUserWalletHistory.walletIdself.timestamp = to_py_date(thriftUserWalletHistory.timestamp)def is_valid(self):return True