| 5944 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 23-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
| 19413 |
amit.gupta |
6 |
from shop2020.thriftpy.model.v1.inventory.ttypes import ItemInventory, Warehouse, \
|
|
|
7 |
VendorItemPricing, Vendor, VendorItemMapping, StateInfo, InventoryType, \
|
|
|
8 |
WarehouseType, IgnoredInventoryUpdateItems as TIgnoredinventoryupdateitems, \
|
|
|
9 |
ItemStockPurchaseParams, OOSStatus, \
|
|
|
10 |
AmazonInventorySnapshot as TAmazonInventorySnapshot, \
|
|
|
11 |
AmazonFbaInventorySnapshot as TAmazonFbaInventorySnapshot, \
|
|
|
12 |
SnapdealInventoryItem as TSnapdealInventoryItem, \
|
|
|
13 |
HoldInventoryDetail as THoldInventoryDetail, \
|
|
|
14 |
ItemLocationAvailability as TItemLocationAvailability, \
|
|
|
15 |
FlipkartInventorySnapshot as TFlipkartInventorySnapshot, \
|
|
|
16 |
StockWeightedNlcInfo as TStockWeightedNlcInfo
|
| 5944 |
mandeep.dh |
17 |
from shop2020.utils.Utils import to_java_date
|
|
|
18 |
|
|
|
19 |
def to_t_item_inventory(item_inventory_list, item_id):
|
|
|
20 |
t_item_inventory = ItemInventory()
|
|
|
21 |
t_item_inventory.id = item_id
|
|
|
22 |
t_item_inventory.availability = {}
|
|
|
23 |
t_item_inventory.reserved = {}
|
| 8182 |
amar.kumar |
24 |
t_item_inventory.held = {}
|
| 5944 |
mandeep.dh |
25 |
for inventory_item in item_inventory_list:
|
|
|
26 |
t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availability
|
|
|
27 |
t_item_inventory.reserved[inventory_item.warehouse.id] = inventory_item.reserved
|
| 8182 |
amar.kumar |
28 |
t_item_inventory.held[inventory_item.warehouse.id] = inventory_item.held
|
| 5944 |
mandeep.dh |
29 |
# need review again
|
|
|
30 |
# if inventory_item.checkedOn:
|
|
|
31 |
# t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
|
|
|
32 |
return t_item_inventory
|
|
|
33 |
|
|
|
34 |
def to_t_warehouse(warehouse):
|
|
|
35 |
t_warehouse = Warehouse()
|
|
|
36 |
t_warehouse.id = warehouse.id
|
|
|
37 |
t_warehouse.displayName = warehouse.displayName
|
|
|
38 |
t_warehouse.location = warehouse.location
|
|
|
39 |
t_warehouse.tinNumber = warehouse.tinNumber
|
| 21844 |
amit.gupta |
40 |
t_warehouse.gstin = warehouse.gstin
|
| 5944 |
mandeep.dh |
41 |
t_warehouse.pincode = warehouse.pincode
|
|
|
42 |
t_warehouse.billingType = warehouse.billingType
|
|
|
43 |
t_warehouse.vendor = to_t_vendor(warehouse.vendor)
|
|
|
44 |
t_warehouse.billingWarehouseId = warehouse.billingWarehouseId
|
|
|
45 |
t_warehouse.shippingWarehouseId = warehouse.shippingWarehouseId
|
|
|
46 |
t_warehouse.isAvailabilityMonitored = warehouse.isAvailabilityMonitored
|
|
|
47 |
t_warehouse.transferDelayInHours = warehouse.transferDelayInHours
|
| 23617 |
amit.gupta |
48 |
t_warehouse.stateId = warehouse.state.id
|
| 7811 |
anupam.sin |
49 |
t_warehouse.logisticsLocation = warehouse.logisticsLocation
|
| 5944 |
mandeep.dh |
50 |
t_warehouse.inventoryType = InventoryType._NAMES_TO_VALUES[warehouse.inventoryType]
|
|
|
51 |
t_warehouse.warehouseType = WarehouseType._NAMES_TO_VALUES[warehouse.warehouseType]
|
|
|
52 |
if warehouse.vendorString:
|
|
|
53 |
t_warehouse.vendorString = warehouse.vendorString
|
|
|
54 |
if warehouse.addedOn:
|
|
|
55 |
t_warehouse.addedOn = to_java_date(warehouse.addedOn)
|
|
|
56 |
if warehouse.lastCheckedOn:
|
|
|
57 |
t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
|
| 12357 |
manish.sha |
58 |
t_warehouse.source = warehouse.source
|
| 5944 |
mandeep.dh |
59 |
return t_warehouse
|
|
|
60 |
|
| 6531 |
vikram.rag |
61 |
def to_t_itemidwarehouseid(iidwid):
|
|
|
62 |
t_iidwid = TIgnoredinventoryupdateitems()
|
|
|
63 |
t_iidwid.itemId = iidwid.item_id
|
|
|
64 |
t_iidwid.warehouseId = iidwid.warehouse_id
|
|
|
65 |
return t_iidwid
|
|
|
66 |
|
| 12280 |
amit.gupta |
67 |
def to_t_state(state):
|
|
|
68 |
t_state = StateInfo()
|
|
|
69 |
t_state.id = state.id
|
|
|
70 |
t_state.stateName = state.name
|
| 21841 |
amit.gupta |
71 |
t_state.vatType = 0
|
| 21839 |
amit.gupta |
72 |
t_state.stateCode = state.stateCode
|
| 21841 |
amit.gupta |
73 |
t_state.shortName = state.shortName
|
| 12280 |
amit.gupta |
74 |
return t_state
|
|
|
75 |
|
| 5944 |
mandeep.dh |
76 |
def to_t_vendor(vendor):
|
|
|
77 |
t_vendor = Vendor()
|
|
|
78 |
t_vendor.id = vendor.id
|
|
|
79 |
t_vendor.name = vendor.name
|
|
|
80 |
return t_vendor
|
|
|
81 |
|
|
|
82 |
def to_t_vendor_item_pricing(vendor_item_pricing):
|
|
|
83 |
t_vendor_item_pricing = VendorItemPricing()
|
|
|
84 |
t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
|
|
|
85 |
t_vendor_item_pricing.itemId = vendor_item_pricing.item_id
|
|
|
86 |
t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
|
| 6751 |
amar.kumar |
87 |
t_vendor_item_pricing.nlc = vendor_item_pricing.nlc
|
| 5944 |
mandeep.dh |
88 |
t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
|
|
|
89 |
t_vendor_item_pricing.mop = vendor_item_pricing.mop
|
|
|
90 |
return t_vendor_item_pricing
|
|
|
91 |
|
|
|
92 |
def to_t_vendor_item_mapping(vendor_item_mapping):
|
|
|
93 |
t_vendor_item_mapping = VendorItemMapping()
|
|
|
94 |
t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
|
|
|
95 |
t_vendor_item_mapping.itemId = vendor_item_mapping.item_id
|
|
|
96 |
t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
|
| 6821 |
amar.kumar |
97 |
return t_vendor_item_mapping
|
|
|
98 |
|
|
|
99 |
def to_t_item_stock_purchase_params(item_stock_purchase_params):
|
|
|
100 |
t_item_stock_purchase_params = ItemStockPurchaseParams()
|
| 11711 |
vikram.rag |
101 |
if item_stock_purchase_params is None:
|
|
|
102 |
return t_item_stock_purchase_params
|
| 6821 |
amar.kumar |
103 |
t_item_stock_purchase_params.item_id = item_stock_purchase_params.item_id
|
|
|
104 |
t_item_stock_purchase_params.numOfDaysStock = item_stock_purchase_params.numOfDaysStock
|
|
|
105 |
t_item_stock_purchase_params.minStockLevel = item_stock_purchase_params.minStockLevel
|
| 6832 |
amar.kumar |
106 |
return t_item_stock_purchase_params
|
|
|
107 |
|
|
|
108 |
def to_t_oos_status(oos_status):
|
|
|
109 |
t_oos_status = OOSStatus()
|
|
|
110 |
t_oos_status.item_id = oos_status.item_id
|
|
|
111 |
t_oos_status.date = to_java_date(oos_status.date)
|
|
|
112 |
t_oos_status.is_oos = oos_status.is_oos
|
|
|
113 |
t_oos_status.num_orders = oos_status.num_orders
|
| 8220 |
amar.kumar |
114 |
t_oos_status.rto_orders = oos_status.rto_orders
|
| 10126 |
amar.kumar |
115 |
t_oos_status.sourceId = oos_status.sourceId
|
| 7281 |
kshitij.so |
116 |
return t_oos_status
|
|
|
117 |
|
|
|
118 |
def to_t_amazon_inventory_snapshot(AmazonInventorySnapshot):
|
|
|
119 |
t_amazon_inventory_snapshot = TAmazonInventorySnapshot()
|
|
|
120 |
t_amazon_inventory_snapshot.item_id = AmazonInventorySnapshot.item_id
|
|
|
121 |
t_amazon_inventory_snapshot.availability = AmazonInventorySnapshot.availability
|
|
|
122 |
t_amazon_inventory_snapshot.reserved = AmazonInventorySnapshot.reserved
|
| 8282 |
kshitij.so |
123 |
return t_amazon_inventory_snapshot
|
|
|
124 |
|
|
|
125 |
def to_t_amazon_fba_inventory_snapshot(AmazonFbaInventorySnapshot):
|
|
|
126 |
t_amazon_inventory_snapshot = TAmazonFbaInventorySnapshot()
|
| 11173 |
vikram.rag |
127 |
if AmazonFbaInventorySnapshot is None:
|
|
|
128 |
return t_amazon_inventory_snapshot
|
| 8282 |
kshitij.so |
129 |
t_amazon_inventory_snapshot.item_id = AmazonFbaInventorySnapshot.item_id
|
|
|
130 |
t_amazon_inventory_snapshot.availability = AmazonFbaInventorySnapshot.availability
|
| 11173 |
vikram.rag |
131 |
t_amazon_inventory_snapshot.location = AmazonFbaInventorySnapshot.location
|
|
|
132 |
t_amazon_inventory_snapshot.reserved = AmazonFbaInventorySnapshot.reserved
|
|
|
133 |
t_amazon_inventory_snapshot.inbound = AmazonFbaInventorySnapshot.inbound
|
|
|
134 |
t_amazon_inventory_snapshot.unfulfillable = AmazonFbaInventorySnapshot.unfulfillable
|
| 9404 |
vikram.rag |
135 |
return t_amazon_inventory_snapshot
|
|
|
136 |
|
|
|
137 |
def to_t_snapdeal_inventory_snapshot(snapdealInventoryItem):
|
|
|
138 |
t_snapdeal_inventory_snapshot = TSnapdealInventoryItem()
|
|
|
139 |
if snapdealInventoryItem is None:
|
|
|
140 |
return t_snapdeal_inventory_snapshot
|
|
|
141 |
t_snapdeal_inventory_snapshot.item_id = snapdealInventoryItem.item_id
|
|
|
142 |
t_snapdeal_inventory_snapshot.availability = snapdealInventoryItem.availability
|
| 9495 |
vikram.rag |
143 |
t_snapdeal_inventory_snapshot.pendingOrders = snapdealInventoryItem.pendingOrders
|
| 9404 |
vikram.rag |
144 |
t_snapdeal_inventory_snapshot.lastUpdatedOnSnapdeal = to_java_date(snapdealInventoryItem.lastUpdatedOnSnapdeal)
|
| 9761 |
amar.kumar |
145 |
return t_snapdeal_inventory_snapshot
|
|
|
146 |
|
|
|
147 |
def to_t_hold_inventory_detail(holdInventoryDetail):
|
|
|
148 |
t_hold_inventory_detail = THoldInventoryDetail()
|
|
|
149 |
if holdInventoryDetail:
|
|
|
150 |
t_hold_inventory_detail.item_id = holdInventoryDetail.item_id
|
|
|
151 |
t_hold_inventory_detail.warehouse_id = holdInventoryDetail.warehouse_id
|
|
|
152 |
t_hold_inventory_detail.source = holdInventoryDetail.source
|
|
|
153 |
t_hold_inventory_detail.held = holdInventoryDetail.held
|
|
|
154 |
return t_hold_inventory_detail
|
| 10050 |
vikram.rag |
155 |
|
|
|
156 |
def to_t_flipkart_inventory_snapshot(flipkartInventoryItem):
|
|
|
157 |
t_flipkart_inventory_snapshot = TFlipkartInventorySnapshot()
|
|
|
158 |
if flipkartInventoryItem is None:
|
|
|
159 |
return t_flipkart_inventory_snapshot
|
|
|
160 |
t_flipkart_inventory_snapshot.item_id = flipkartInventoryItem.item_id
|
|
|
161 |
t_flipkart_inventory_snapshot.availability = flipkartInventoryItem.availability
|
|
|
162 |
t_flipkart_inventory_snapshot.heldOrders = flipkartInventoryItem.heldOrders
|
|
|
163 |
t_flipkart_inventory_snapshot.createdOrders = flipkartInventoryItem.createdOrders
|
|
|
164 |
return t_flipkart_inventory_snapshot
|
| 12357 |
manish.sha |
165 |
|
|
|
166 |
def to_t_stock_weighted_nlc_info(stockWeightedNlcInfo):
|
|
|
167 |
t_stock_weighted_nlc_info = TStockWeightedNlcInfo()
|
|
|
168 |
t_stock_weighted_nlc_info.itemId = stockWeightedNlcInfo.itemId
|
|
|
169 |
t_stock_weighted_nlc_info.source = stockWeightedNlcInfo.source
|
|
|
170 |
t_stock_weighted_nlc_info.updatedTimestamp = to_java_date(stockWeightedNlcInfo.updatedTimestamp)
|
|
|
171 |
t_stock_weighted_nlc_info.stockQuantity = stockWeightedNlcInfo.stockQuantity
|
|
|
172 |
t_stock_weighted_nlc_info.grnDetail = stockWeightedNlcInfo.grnDetail
|
|
|
173 |
t_stock_weighted_nlc_info.avgWeightedNlc = stockWeightedNlcInfo.avgWeightedNlc
|
|
|
174 |
return t_stock_weighted_nlc_info
|
| 12363 |
kshitij.so |
175 |
|
| 19413 |
amit.gupta |
176 |
def to_t_item_location_availability(itemLocationAvailabilityCache):
|
|
|
177 |
t_item_location_availability = TItemLocationAvailability()
|
|
|
178 |
t_item_location_availability.itemId = itemLocationAvailabilityCache.item_id
|
|
|
179 |
t_item_location_availability.locationId = itemLocationAvailabilityCache.location_id
|
|
|
180 |
t_item_location_availability.physicalQty = itemLocationAvailabilityCache.physical_availability
|
|
|
181 |
t_item_location_availability.virtualQty = itemLocationAvailabilityCache.virtual_availability
|
|
|
182 |
t_item_location_availability.minTransferDelay = itemLocationAvailabilityCache.min_transfer_delay
|
|
|
183 |
t_item_location_availability.virtualQty = itemLocationAvailabilityCache.max_transfer_delay
|
|
|
184 |
return t_item_location_availability
|
|
|
185 |
|