| 4503 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 29-Jul-2011
|
|
|
3 |
|
|
|
4 |
@author: Chandranshu
|
|
|
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
|
|
|
10 |
from shop2020.thriftpy.purchase.ttypes import Purchase as TPurchase
|
|
|
11 |
from shop2020.utils.Utils import to_java_date
|
|
|
12 |
from sqlalchemy.types import Integer, String, Float, DateTime
|
| 6380 |
amar.kumar |
13 |
import datetime
|
| 4503 |
mandeep.dh |
14 |
|
|
|
15 |
class Purchase(Entity):
|
|
|
16 |
'''
|
|
|
17 |
classdocs
|
|
|
18 |
'''
|
|
|
19 |
id = Field(Integer, primary_key=True, autoincrement=True)
|
|
|
20 |
purchaseOrder = ManyToOne("PurchaseOrder")
|
|
|
21 |
invoiceNumber = Field(String(30))
|
|
|
22 |
receivedOn = Field(DateTime)
|
|
|
23 |
freightCharges = Field(Float)
|
| 11801 |
manish.sha |
24 |
purchaseComments = Field(String(500))
|
| 4503 |
mandeep.dh |
25 |
using_options(shortnames=True)
|
|
|
26 |
using_table_options(mysql_engine="InnoDB")
|
|
|
27 |
|
| 11801 |
manish.sha |
28 |
def __init__(self, purchaseOrder, invoiceNumber, freightCharges, purchaseComments):
|
| 4503 |
mandeep.dh |
29 |
'''
|
|
|
30 |
Constructor
|
|
|
31 |
'''
|
|
|
32 |
self.purchaseOrder = purchaseOrder
|
|
|
33 |
self.invoiceNumber = invoiceNumber
|
|
|
34 |
self.freightCharges = freightCharges
|
| 11801 |
manish.sha |
35 |
self.purchaseComments = purchaseComments
|
| 6380 |
amar.kumar |
36 |
self.receivedOn = datetime.datetime.now()
|
| 4503 |
mandeep.dh |
37 |
|
|
|
38 |
def to_thrift_object(self):
|
|
|
39 |
t_purchase = TPurchase()
|
|
|
40 |
t_purchase.id = self.id
|
|
|
41 |
t_purchase.poId = self.purchaseOrder.id
|
|
|
42 |
t_purchase.invoiceNumber = self.invoiceNumber
|
|
|
43 |
t_purchase.freightCharges = self.freightCharges
|
| 11801 |
manish.sha |
44 |
t_purchase.purchaseComments = self.purchaseComments
|
| 4503 |
mandeep.dh |
45 |
t_purchase.receivedOn = to_java_date(self.receivedOn)
|
|
|
46 |
return t_purchase
|