| 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,\
|
| 2116 |
ankur.sing |
7 |
ItemInventory, Warehouse, VendorItemPricing, Vendor, Category,\
|
|
|
8 |
VendorItemMapping
|
| 94 |
ashish |
9 |
import time
|
| 122 |
ashish |
10 |
from shop2020.utils.Utils import to_java_date
|
| 94 |
ashish |
11 |
|
|
|
12 |
def to_t_item(item):
|
|
|
13 |
t_item = Item()
|
| 576 |
chandransh |
14 |
if item is None:
|
|
|
15 |
return t_item
|
| 94 |
ashish |
16 |
t_item.id = item.id
|
| 963 |
chandransh |
17 |
t_item.productGroup = item.product_group
|
|
|
18 |
t_item.brand = item.brand
|
| 591 |
chandransh |
19 |
t_item.modelNumber = item.model_number
|
|
|
20 |
t_item.modelName = item.model_name
|
| 609 |
chandransh |
21 |
t_item.color = item.color
|
| 591 |
chandransh |
22 |
t_item.category = item.category
|
| 122 |
ashish |
23 |
t_item.catalogItemId = item.catalog_item_id
|
|
|
24 |
t_item.weight = item.weight
|
|
|
25 |
t_item.featureId = item.feature_id
|
|
|
26 |
t_item.featureDescription = item.feature_description
|
|
|
27 |
if item.startDate:
|
|
|
28 |
t_item.startDate = to_java_date(item.startDate)
|
|
|
29 |
if item.addedOn:
|
|
|
30 |
t_item.addedOn = to_java_date(item.addedOn)
|
| 609 |
chandransh |
31 |
if item.updatedOn:
|
|
|
32 |
t_item.updatedOn = to_java_date(item.updatedOn)
|
| 122 |
ashish |
33 |
t_item.itemStatus = item.status
|
| 2035 |
rajveer |
34 |
t_item.status_description = item.status_description
|
| 609 |
chandransh |
35 |
|
| 501 |
rajveer |
36 |
if item.sellingPrice:
|
| 609 |
chandransh |
37 |
t_item.sellingPrice = item.sellingPrice
|
|
|
38 |
if item.dealerPrice:
|
|
|
39 |
t_item.dealerPrice = item.dealerPrice
|
| 630 |
chandransh |
40 |
if item.mrp:
|
| 501 |
rajveer |
41 |
t_item.mrp = item.mrp
|
| 630 |
chandransh |
42 |
if item.mop:
|
| 501 |
rajveer |
43 |
t_item.mop = item.mop
|
| 724 |
chandransh |
44 |
if item.transfer_price:
|
|
|
45 |
t_item.transferPrice = item.transfer_price
|
| 94 |
ashish |
46 |
t_item.itemInventory = to_t_item_inventory(item.currentInventory, item.id)
|
| 122 |
ashish |
47 |
|
| 2028 |
ankur.sing |
48 |
if item.comments:
|
|
|
49 |
t_item.comments = item.comments
|
| 609 |
chandransh |
50 |
if item.bestDealText:
|
|
|
51 |
t_item.bestDealText = item.bestDealText
|
|
|
52 |
if item.bestDealValue:
|
|
|
53 |
t_item.bestDealValue = item.bestDealValue
|
|
|
54 |
|
| 1910 |
varun.gupt |
55 |
t_item.defaultForEntity = item.defaultForEntity
|
| 122 |
ashish |
56 |
t_item.otherInfo = to_t_other_info(item)
|
| 2065 |
ankur.sing |
57 |
t_item.bestSellingRank = item.bestSellingRank
|
|
|
58 |
|
| 94 |
ashish |
59 |
return t_item
|
| 122 |
ashish |
60 |
|
|
|
61 |
def to_t_other_info(item):
|
|
|
62 |
t_other_info = {}
|
|
|
63 |
for item_info in item.iteminfo:
|
|
|
64 |
t_other_info[item_info.key] = item_info.value
|
| 94 |
ashish |
65 |
|
|
|
66 |
def to_t_item_inventory(item_inventory_list, item_id):
|
|
|
67 |
t_item_inventory = ItemInventory()
|
|
|
68 |
t_item_inventory.id = item_id
|
|
|
69 |
t_item_inventory.availability = {}
|
|
|
70 |
for inventory_item in item_inventory_list:
|
| 122 |
ashish |
71 |
t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availibility
|
| 483 |
rajveer |
72 |
# need review again
|
|
|
73 |
# if inventory_item.checkedOn:
|
|
|
74 |
# t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
|
| 94 |
ashish |
75 |
return t_item_inventory
|
|
|
76 |
|
|
|
77 |
def to_t_warehouse(warehouse):
|
|
|
78 |
t_warehouse = Warehouse()
|
|
|
79 |
t_warehouse.id = warehouse.id
|
| 759 |
chandransh |
80 |
t_warehouse.displayName = warehouse.displayName
|
| 94 |
ashish |
81 |
t_warehouse.location = warehouse.location
|
| 122 |
ashish |
82 |
t_warehouse.warehouseStatus = warehouse.status
|
| 483 |
rajveer |
83 |
t_warehouse.tinNumber = warehouse.tinNumber
|
|
|
84 |
t_warehouse.pincode = warehouse.pincode
|
| 1308 |
chandransh |
85 |
t_warehouse.vendor = warehouse.vendor.name
|
| 494 |
rajveer |
86 |
if warehouse.vendorString:
|
| 483 |
rajveer |
87 |
t_warehouse.vendorString = warehouse.vendorString
|
| 122 |
ashish |
88 |
if warehouse.addedOn:
|
|
|
89 |
t_warehouse.addedOn = to_java_date(warehouse.addedOn)
|
| 483 |
rajveer |
90 |
if warehouse.lastCheckedOn:
|
|
|
91 |
t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
|
| 122 |
ashish |
92 |
return t_warehouse
|
| 1341 |
chandransh |
93 |
|
|
|
94 |
def to_t_vendor(vendor):
|
|
|
95 |
t_vendor = Vendor()
|
|
|
96 |
t_vendor.id = vendor.id
|
|
|
97 |
t_vendor.name = vendor.name
|
| 1348 |
chandransh |
98 |
return t_vendor
|
| 1341 |
chandransh |
99 |
|
|
|
100 |
def to_t_vendor_item_pricing(vendor_item_pricing):
|
|
|
101 |
t_vendor_item_pricing = VendorItemPricing()
|
| 1348 |
chandransh |
102 |
t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
|
|
|
103 |
t_vendor_item_pricing.itemId = vendor_item_pricing.item.id
|
| 1341 |
chandransh |
104 |
t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
|
|
|
105 |
t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
|
| 1348 |
chandransh |
106 |
t_vendor_item_pricing.mop = vendor_item_pricing.mop
|
| 1970 |
rajveer |
107 |
return t_vendor_item_pricing
|
|
|
108 |
|
| 2116 |
ankur.sing |
109 |
def to_t_vendor_item_mapping(vendor_item_mapping):
|
|
|
110 |
t_vendor_item_mapping = VendorItemMapping()
|
|
|
111 |
t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
|
|
|
112 |
t_vendor_item_mapping.itemId = vendor_item_mapping.item.id
|
|
|
113 |
t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
|
|
|
114 |
t_vendor_item_mapping.vendorCategory = vendor_item_mapping.vendor_category
|
| 2120 |
ankur.sing |
115 |
return t_vendor_item_mapping
|
| 2116 |
ankur.sing |
116 |
|
|
|
117 |
|
| 1970 |
rajveer |
118 |
def to_t_category(category):
|
|
|
119 |
t_category = Category()
|
|
|
120 |
t_category.id = category.id
|
|
|
121 |
t_category.label = category.label
|
|
|
122 |
t_category.description = category.description
|
|
|
123 |
t_category.parent_category_id = category.parent_category_id
|
|
|
124 |
return t_category
|