| 94 |
ashish |
1 |
'''
|
|
|
2 |
Created on 23-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 122 |
ashish |
6 |
from shop2020.thriftpy.model.v1.catalog.ttypes import Item,\
|
|
|
7 |
ItemInventory, Warehouse
|
| 94 |
ashish |
8 |
import time
|
| 122 |
ashish |
9 |
from shop2020.utils.Utils import to_java_date
|
| 94 |
ashish |
10 |
|
|
|
11 |
def to_t_item(item):
|
|
|
12 |
t_item = Item()
|
|
|
13 |
t_item.id = item.id
|
| 122 |
ashish |
14 |
t_item.catalogItemId = item.catalog_item_id
|
|
|
15 |
t_item.vendorItemId = item.vendor_item_id
|
|
|
16 |
t_item.weight = item.weight
|
|
|
17 |
t_item.featureId = item.feature_id
|
|
|
18 |
t_item.featureDescription = item.feature_description
|
|
|
19 |
if item.startDate:
|
|
|
20 |
t_item.startDate = to_java_date(item.startDate)
|
|
|
21 |
if item.addedOn:
|
|
|
22 |
t_item.addedOn = to_java_date(item.addedOn)
|
|
|
23 |
t_item.itemStatus = item.status
|
| 501 |
rajveer |
24 |
if item.sellingPrice:
|
|
|
25 |
t_item.sellingPrice = item.sellingPrice
|
|
|
26 |
if item.sellingPrice:
|
|
|
27 |
t_item.mrp = item.mrp
|
|
|
28 |
if item.sellingPrice:
|
|
|
29 |
t_item.mop = item.mop
|
| 94 |
ashish |
30 |
t_item.itemInventory = to_t_item_inventory(item.currentInventory, item.id)
|
| 122 |
ashish |
31 |
|
|
|
32 |
t_item.otherInfo = to_t_other_info(item)
|
| 94 |
ashish |
33 |
return t_item
|
| 122 |
ashish |
34 |
|
|
|
35 |
def to_t_other_info(item):
|
|
|
36 |
t_other_info = {}
|
|
|
37 |
for item_info in item.iteminfo:
|
|
|
38 |
t_other_info[item_info.key] = item_info.value
|
| 94 |
ashish |
39 |
|
|
|
40 |
def to_t_item_inventory(item_inventory_list, item_id):
|
|
|
41 |
t_item_inventory = ItemInventory()
|
|
|
42 |
t_item_inventory.id = item_id
|
|
|
43 |
t_item_inventory.availability = {}
|
|
|
44 |
for inventory_item in item_inventory_list:
|
| 122 |
ashish |
45 |
t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availibility
|
| 483 |
rajveer |
46 |
# need review again
|
|
|
47 |
# if inventory_item.checkedOn:
|
|
|
48 |
# t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
|
| 94 |
ashish |
49 |
return t_item_inventory
|
|
|
50 |
|
|
|
51 |
def to_t_warehouse(warehouse):
|
|
|
52 |
t_warehouse = Warehouse()
|
|
|
53 |
t_warehouse.id = warehouse.id
|
|
|
54 |
t_warehouse.location = warehouse.location
|
| 122 |
ashish |
55 |
t_warehouse.warehouseStatus = warehouse.status
|
| 483 |
rajveer |
56 |
t_warehouse.tinNumber = warehouse.tinNumber
|
|
|
57 |
t_warehouse.pincode = warehouse.pincode
|
| 494 |
rajveer |
58 |
if warehouse.vendorString:
|
| 483 |
rajveer |
59 |
t_warehouse.vendorString = warehouse.vendorString
|
| 122 |
ashish |
60 |
if warehouse.addedOn:
|
|
|
61 |
t_warehouse.addedOn = to_java_date(warehouse.addedOn)
|
| 483 |
rajveer |
62 |
if warehouse.lastCheckedOn:
|
|
|
63 |
t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
|
| 122 |
ashish |
64 |
return t_warehouse
|
|
|
65 |
|
| 94 |
ashish |
66 |
|