| 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
|
| 13600 |
manish.sha |
9 |
from shop2020.thriftpy.purchase.ttypes import PurchaseReturn as TPurchaseReturn, PurchaseReturnInventoryType, SettlementType, PrReasonType
|
| 6467 |
amar.kumar |
10 |
from shop2020.utils.Utils import to_java_date
|
| 13600 |
manish.sha |
11 |
from sqlalchemy.types import Integer, Float, DateTime, Boolean, Enum, String
|
| 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')
|
| 10864 |
manish.sha |
24 |
returnInventoryType = Field(Enum('GOOD', 'BAD'), default = 'GOOD', server_default='GOOD')
|
| 13600 |
manish.sha |
25 |
currentSettlementType = Field(Enum('CREDIT_NOTE','REPLACEMENT','AGAINST_GRN'))
|
|
|
26 |
latestSettlementDate = Field(DateTime)
|
|
|
27 |
purchaseReturnType = Field(Enum('WRONG_GRN','ACTUAL_PR','REPLACEMENT'))
|
|
|
28 |
reasonText = Field(String(1024))
|
|
|
29 |
documentNumber = Field(String(1024))
|
|
|
30 |
createdBy = Field(String(255))
|
|
|
31 |
unsettledAmount = Field(Float)
|
| 6467 |
amar.kumar |
32 |
using_options(shortnames=True)
|
|
|
33 |
using_table_options(mysql_engine="InnoDB")
|
|
|
34 |
|
|
|
35 |
def __init__(self, vendorId, amount):
|
|
|
36 |
'''
|
|
|
37 |
Constructor
|
|
|
38 |
'''
|
|
|
39 |
self.vendorId = vendorId
|
|
|
40 |
self.amount = amount
|
|
|
41 |
self.returnTimestamp = datetime.datetime.now()
|
|
|
42 |
self.isSettled = False
|
|
|
43 |
|
|
|
44 |
def to_thrift_object(self):
|
|
|
45 |
t_purchaseReturn = TPurchaseReturn()
|
|
|
46 |
t_purchaseReturn.id = self.id
|
|
|
47 |
t_purchaseReturn.vendorId = self.vendorId
|
|
|
48 |
t_purchaseReturn.amount = self.amount
|
|
|
49 |
t_purchaseReturn.returnTimestamp = to_java_date(self.returnTimestamp)
|
|
|
50 |
t_purchaseReturn.isSettled = self.isSettled
|
| 10864 |
manish.sha |
51 |
t_purchaseReturn.returnInventoryType = PurchaseReturnInventoryType._NAMES_TO_VALUES[self.returnInventoryType]
|
| 13600 |
manish.sha |
52 |
if self.currentSettlementType:
|
|
|
53 |
t_purchaseReturn.currentSettlementType = SettlementType._NAMES_TO_VALUES[self.currentSettlementType]
|
|
|
54 |
if self.latestSettlementDate:
|
|
|
55 |
t_purchaseReturn.latestSettlementDate = to_java_date(self.latestSettlementDate)
|
|
|
56 |
if self.purchaseReturnType:
|
|
|
57 |
t_purchaseReturn.purchaseReturnType = PrReasonType._NAMES_TO_VALUES[self.purchaseReturnType]
|
|
|
58 |
if self.reasonText:
|
|
|
59 |
t_purchaseReturn.reasonText = self.reasonText
|
|
|
60 |
if self.documentNumber:
|
|
|
61 |
t_purchaseReturn.documentNumber = self.documentNumber
|
|
|
62 |
if self.createdBy:
|
|
|
63 |
t_purchaseReturn.createdBy = self.createdBy
|
|
|
64 |
if self.unsettledAmount:
|
|
|
65 |
t_purchaseReturn.unsettledAmount = self.unsettledAmount
|
| 6467 |
amar.kumar |
66 |
return t_purchaseReturn
|