Subversion Repositories SmartDukaan

Rev

Rev 22049 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6031 rajveer 1
'''
2
Created on 19-Sep-2012
3
 
4
@author: rajveer
5
'''
6
from elixir.entity import Entity
7
from elixir.fields import Field
8
from elixir.options import using_options, using_table_options
9
from elixir.relationships import ManyToOne
22047 amit.gupta 10
from shop2020.thriftpy.model.v1.order.ttypes import \
11
    UserWalletHistory as tUserWalletHistory, WalletReferenceType
6031 rajveer 12
from shop2020.utils.Utils import to_py_date, to_java_date
22047 amit.gupta 13
from sqlalchemy.types import Integer, DateTime, String
6031 rajveer 14
 
15
class UserWalletHistory(Entity):
16
    '''
17
    classdocs
18
    '''
19
    id = Field(Integer, primary_key=True, autoincrement=True)
20
    amount = Field(Integer)
20927 kshitij.so 21
    refundable_amount = Field(Integer)
6031 rajveer 22
    wallet = ManyToOne("UserWallet")
20927 kshitij.so 23
    reference = Field(Integer)
24
    reference_type = Field(String(20))
25
    wallet_type = Field(String(20))
21367 amit.gupta 26
    description = Field(String(192))
6031 rajveer 27
    timestamp = Field(DateTime)
28
    using_options(shortnames=True)
29
    using_table_options(mysql_engine="InnoDB")
30
 
31
    def __init__(self):
32
        '''
33
        Constructor
34
        '''
35
 
36
 
37
    def to_thrift_object(self, ):
38
        '''
39
        Copies attributes to thrift object
40
        '''
41
        thriftObject = tUserWalletHistory()
42
        thriftObject.id = self.id
43
        thriftObject.amount = self.amount
22058 amit.gupta 44
        thriftObject.refundableAmount = self.refundable_amount
6031 rajveer 45
        thriftObject.walletId = self.wallet.id
46
        thriftObject.timestamp = to_java_date(self.timestamp)
22043 amit.gupta 47
        thriftObject.referenceNumber = self.reference
22049 amit.gupta 48
        thriftObject.referenceType = WalletReferenceType._NAMES_TO_VALUES.get(self.reference_type)
49
        thriftObject.description = self.description
6031 rajveer 50
        return thriftObject
51
 
52
    def from_thrift_object(self, thriftUserWalletHistory):
53
        self.id = thriftUserWalletHistory.id
54
        self.amount = thriftUserWalletHistory.amount
55
        self.orderId = thriftUserWalletHistory.orderId
56
        self.wallet.id = thriftUserWalletHistory.walletId
57
        self.timestamp = to_py_date(thriftUserWalletHistory.timestamp)
58
 
59
 
60
    def is_valid(self):
61
        return True