| 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
|
|
|
11 |
from sqlalchemy.types import Integer, Float, DateTime, Boolean
|
|
|
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)
|
|
|
23 |
using_options(shortnames=True)
|
|
|
24 |
using_table_options(mysql_engine="InnoDB")
|
|
|
25 |
|
|
|
26 |
def __init__(self, vendorId, amount):
|
|
|
27 |
'''
|
|
|
28 |
Constructor
|
|
|
29 |
'''
|
|
|
30 |
self.vendorId = vendorId
|
|
|
31 |
self.amount = amount
|
|
|
32 |
self.returnTimestamp = datetime.datetime.now()
|
|
|
33 |
self.isSettled = False
|
|
|
34 |
|
|
|
35 |
def to_thrift_object(self):
|
|
|
36 |
t_purchaseReturn = TPurchaseReturn()
|
|
|
37 |
t_purchaseReturn.id = self.id
|
|
|
38 |
t_purchaseReturn.vendorId = self.vendorId
|
|
|
39 |
t_purchaseReturn.amount = self.amount
|
|
|
40 |
t_purchaseReturn.returnTimestamp = to_java_date(self.returnTimestamp)
|
|
|
41 |
t_purchaseReturn.isSettled = self.isSettled
|
|
|
42 |
return t_purchaseReturn
|