Subversion Repositories SmartDukaan

Rev

Rev 6467 | Rev 10864 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6467 amar.kumar 1
'''
2
Created on 03-Dec-2012
3
 
4
@author: Amar
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 shop2020.thriftpy.purchase.ttypes import PurchaseReturn as TPurchaseReturn
10
from shop2020.utils.Utils import to_java_date
6821 amar.kumar 11
from sqlalchemy.types import Integer, Float, DateTime, Boolean, Enum
6467 amar.kumar 12
import datetime
13
 
14
class PurchaseReturn(Entity):
15
    '''
16
    classdocs
17
    '''
18
    id = Field(Integer, primary_key=True, autoincrement=True)
19
    vendorId = Field(Integer)
20
    amount = Field(Float)
21
    returnTimestamp = Field(DateTime)
22
    isSettled = Field(Boolean)
6821 amar.kumar 23
    type = Field(Enum('REAL', 'VIRTUAL'), default = 'REAL', server_default='REAL')
6467 amar.kumar 24
    using_options(shortnames=True)
25
    using_table_options(mysql_engine="InnoDB")
26
 
27
    def __init__(self, vendorId, amount):
28
        '''
29
        Constructor
30
        '''
31
        self.vendorId = vendorId
32
        self.amount = amount
33
        self.returnTimestamp = datetime.datetime.now()
34
        self.isSettled = False
35
 
36
    def to_thrift_object(self):
37
        t_purchaseReturn = TPurchaseReturn()
38
        t_purchaseReturn.id = self.id
39
        t_purchaseReturn.vendorId = self.vendorId
40
        t_purchaseReturn.amount = self.amount
41
        t_purchaseReturn.returnTimestamp = to_java_date(self.returnTimestamp)
42
        t_purchaseReturn.isSettled = self.isSettled
43
        return t_purchaseReturn