| 6000 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 11-Sep-2012
|
|
|
3 |
|
|
|
4 |
@author: mandeep
|
|
|
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 sqlalchemy.types import Enum, Integer, DateTime, String
|
| 6031 |
rajveer |
10 |
from elixir.relationships import ManyToOne
|
|
|
11 |
import datetime
|
|
|
12 |
from shop2020.utils.Utils import to_java_date
|
| 6147 |
rajveer |
13 |
import DigitalTransaction
|
| 6000 |
mandeep.dh |
14 |
|
|
|
15 |
class BaseOrder(Entity):
|
|
|
16 |
'''
|
|
|
17 |
classdocs
|
|
|
18 |
'''
|
|
|
19 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
20 |
idPrefix = Field(String(8))
|
| 6031 |
rajveer |
21 |
transaction = ManyToOne("DigitalTransaction")
|
| 6000 |
mandeep.dh |
22 |
creationTimestamp = Field(DateTime)
|
| 6031 |
rajveer |
23 |
totalAmount = Field(Integer)
|
|
|
24 |
walletAmount = Field(Integer)
|
|
|
25 |
userId = Field(Integer)
|
|
|
26 |
userEmailId = Field(String(256))
|
| 6000 |
mandeep.dh |
27 |
invoiceNumber = Field(Integer)
|
| 6031 |
rajveer |
28 |
orderType = Field(Integer)
|
| 6000 |
mandeep.dh |
29 |
using_options(shortnames=True, inheritance='multi')
|
|
|
30 |
using_table_options(mysql_engine="InnoDB")
|
|
|
31 |
|
|
|
32 |
def __init__(self):
|
|
|
33 |
'''
|
|
|
34 |
Constructor
|
|
|
35 |
'''
|
|
|
36 |
|
|
|
37 |
def to_thrift_object(self, thriftObject):
|
|
|
38 |
'''
|
|
|
39 |
Copies attributes to thrift object
|
|
|
40 |
'''
|
| 6031 |
rajveer |
41 |
thriftObject.totalAmount = self.totalAmount
|
|
|
42 |
thriftObject.walletAmount = self.walletAmount
|
|
|
43 |
thriftObject.creationTimestamp = to_java_date(self.creationTimestamp)
|
|
|
44 |
thriftObject.userEmailId = self.userEmailId
|
|
|
45 |
thriftObject.userId = self.userId
|
|
|
46 |
thriftObject.id = self.id
|
|
|
47 |
thriftObject.displayId = self.idPrefix + str(self.id)
|
| 6000 |
mandeep.dh |
48 |
thriftObject.invoiceNumber = self.invoiceNumber
|
|
|
49 |
thriftObject.orderType = self.orderType
|
| 6031 |
rajveer |
50 |
thriftObject.transactionId = self.transaction.id
|
| 6000 |
mandeep.dh |
51 |
|
|
|
52 |
def from_thrift_object(self, thriftBaseOrder):
|
| 6031 |
rajveer |
53 |
self.totalAmount = thriftBaseOrder.totalAmount
|
|
|
54 |
self.walletAmount = thriftBaseOrder.walletAmount
|
|
|
55 |
self.creationTimestamp = datetime.datetime.now()
|
|
|
56 |
self.userEmailId = thriftBaseOrder.userEmailId
|
|
|
57 |
self.userId = thriftBaseOrder.userId
|
| 6000 |
mandeep.dh |
58 |
self.invoiceNumber = thriftBaseOrder.invoiceNumber
|
|
|
59 |
self.orderType = thriftBaseOrder.orderType
|
|
|
60 |
|
|
|
61 |
def is_valid(self):
|
|
|
62 |
return True
|