Rev 6591 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 11-Sep-2012@author: mandeep'''from elixir.entity import Entityfrom elixir.fields import Fieldfrom elixir.options import using_options, using_table_optionsfrom sqlalchemy.types import Enum, Integer, DateTime, Stringfrom elixir.relationships import ManyToOneimport datetimefrom shop2020.utils.Utils import to_java_date, to_py_dateimport DigitalTransactionclass BaseOrder(Entity):'''classdocs'''id = Field(Integer, primary_key=True, autoincrement=True)idPrefix = Field(String(8))transaction = ManyToOne("DigitalTransaction")creationTimestamp = Field(DateTime)totalAmount = Field(Integer)walletAmount = Field(Integer)couponAmount = Field(Integer, default=0)couponCode = Field(String(256))userId = Field(Integer)userEmailId = Field(String(256))invoiceNumber = Field(Integer)orderType = Field(Integer)refundTimestamp = Field(DateTime)ipAddress = Field(String(256))using_options(shortnames=True, inheritance='multi')using_table_options(mysql_engine="InnoDB")def __init__(self):'''Constructor'''def to_thrift_object(self, thriftObject):'''Copies attributes to thrift object'''thriftObject.totalAmount = self.totalAmountthriftObject.walletAmount = self.walletAmountthriftObject.couponAmount = self.couponAmountthriftObject.couponCode = self.couponCodethriftObject.creationTimestamp = to_java_date(self.creationTimestamp)thriftObject.userEmailId = self.userEmailIdthriftObject.userId = self.userIdthriftObject.id = self.idthriftObject.displayId = self.idPrefix + str(self.id)thriftObject.invoiceNumber = self.invoiceNumberthriftObject.orderType = self.orderTypethriftObject.transactionId = self.transaction.idthriftObject.refundTimestamp = to_java_date(self.refundTimestamp)thriftObject.ipAddress = self.ipAddressdef from_thrift_object(self, thriftBaseOrder):self.totalAmount = thriftBaseOrder.totalAmountself.walletAmount = thriftBaseOrder.walletAmountself.creationTimestamp = datetime.datetime.now()self.userEmailId = thriftBaseOrder.userEmailIdself.userId = thriftBaseOrder.userIdself.invoiceNumber = thriftBaseOrder.invoiceNumberself.orderType = thriftBaseOrder.orderTypeself.couponAmount = thriftBaseOrder.couponAmountself.couponCode = thriftBaseOrder.couponCodeif thriftBaseOrder.refundTimestamp:self.refundTimestamp = to_py_date(thriftBaseOrder.refundTimestamp)self.ipAddress = thriftBaseOrder.ipAddressdef is_valid(self):return True