| 5944 |
mandeep.dh |
1 |
'''
|
|
|
2 |
Created on 23-Mar-2010
|
|
|
3 |
|
|
|
4 |
@author: ashish
|
|
|
5 |
'''
|
|
|
6 |
from shop2020.thriftpy.model.v1.inventory.ttypes import ItemInventory, \
|
|
|
7 |
Warehouse, VendorItemPricing, Vendor, VendorItemMapping, \
|
| 6821 |
amar.kumar |
8 |
InventoryType, WarehouseType, IgnoredInventoryUpdateItems as TIgnoredinventoryupdateitems ,\
|
|
|
9 |
ItemStockPurchaseParams
|
| 5944 |
mandeep.dh |
10 |
from shop2020.utils.Utils import to_java_date
|
|
|
11 |
|
|
|
12 |
def to_t_item_inventory(item_inventory_list, item_id):
|
|
|
13 |
t_item_inventory = ItemInventory()
|
|
|
14 |
t_item_inventory.id = item_id
|
|
|
15 |
t_item_inventory.availability = {}
|
|
|
16 |
t_item_inventory.reserved = {}
|
|
|
17 |
for inventory_item in item_inventory_list:
|
|
|
18 |
t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availability
|
|
|
19 |
t_item_inventory.reserved[inventory_item.warehouse.id] = inventory_item.reserved
|
|
|
20 |
# need review again
|
|
|
21 |
# if inventory_item.checkedOn:
|
|
|
22 |
# t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
|
|
|
23 |
return t_item_inventory
|
|
|
24 |
|
|
|
25 |
def to_t_warehouse(warehouse):
|
|
|
26 |
t_warehouse = Warehouse()
|
|
|
27 |
t_warehouse.id = warehouse.id
|
|
|
28 |
t_warehouse.displayName = warehouse.displayName
|
|
|
29 |
t_warehouse.location = warehouse.location
|
|
|
30 |
t_warehouse.tinNumber = warehouse.tinNumber
|
|
|
31 |
t_warehouse.pincode = warehouse.pincode
|
|
|
32 |
t_warehouse.billingType = warehouse.billingType
|
|
|
33 |
t_warehouse.vendor = to_t_vendor(warehouse.vendor)
|
|
|
34 |
t_warehouse.billingWarehouseId = warehouse.billingWarehouseId
|
|
|
35 |
t_warehouse.shippingWarehouseId = warehouse.shippingWarehouseId
|
|
|
36 |
t_warehouse.isAvailabilityMonitored = warehouse.isAvailabilityMonitored
|
|
|
37 |
t_warehouse.transferDelayInHours = warehouse.transferDelayInHours
|
|
|
38 |
t_warehouse.inventoryType = InventoryType._NAMES_TO_VALUES[warehouse.inventoryType]
|
|
|
39 |
t_warehouse.warehouseType = WarehouseType._NAMES_TO_VALUES[warehouse.warehouseType]
|
|
|
40 |
if warehouse.vendorString:
|
|
|
41 |
t_warehouse.vendorString = warehouse.vendorString
|
|
|
42 |
if warehouse.addedOn:
|
|
|
43 |
t_warehouse.addedOn = to_java_date(warehouse.addedOn)
|
|
|
44 |
if warehouse.lastCheckedOn:
|
|
|
45 |
t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
|
|
|
46 |
return t_warehouse
|
|
|
47 |
|
| 6531 |
vikram.rag |
48 |
def to_t_itemidwarehouseid(iidwid):
|
|
|
49 |
t_iidwid = TIgnoredinventoryupdateitems()
|
|
|
50 |
t_iidwid.itemId = iidwid.item_id
|
|
|
51 |
t_iidwid.warehouseId = iidwid.warehouse_id
|
|
|
52 |
return t_iidwid
|
|
|
53 |
|
| 5944 |
mandeep.dh |
54 |
def to_t_vendor(vendor):
|
|
|
55 |
t_vendor = Vendor()
|
|
|
56 |
t_vendor.id = vendor.id
|
|
|
57 |
t_vendor.name = vendor.name
|
|
|
58 |
return t_vendor
|
|
|
59 |
|
|
|
60 |
def to_t_vendor_item_pricing(vendor_item_pricing):
|
|
|
61 |
t_vendor_item_pricing = VendorItemPricing()
|
|
|
62 |
t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
|
|
|
63 |
t_vendor_item_pricing.itemId = vendor_item_pricing.item_id
|
|
|
64 |
t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
|
| 6751 |
amar.kumar |
65 |
t_vendor_item_pricing.nlc = vendor_item_pricing.nlc
|
| 5944 |
mandeep.dh |
66 |
t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
|
|
|
67 |
t_vendor_item_pricing.mop = vendor_item_pricing.mop
|
|
|
68 |
return t_vendor_item_pricing
|
|
|
69 |
|
|
|
70 |
def to_t_vendor_item_mapping(vendor_item_mapping):
|
|
|
71 |
t_vendor_item_mapping = VendorItemMapping()
|
|
|
72 |
t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
|
|
|
73 |
t_vendor_item_mapping.itemId = vendor_item_mapping.item_id
|
|
|
74 |
t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
|
| 6821 |
amar.kumar |
75 |
return t_vendor_item_mapping
|
|
|
76 |
|
|
|
77 |
def to_t_item_stock_purchase_params(item_stock_purchase_params):
|
|
|
78 |
t_item_stock_purchase_params = ItemStockPurchaseParams()
|
|
|
79 |
t_item_stock_purchase_params.item_id = item_stock_purchase_params.item_id
|
|
|
80 |
t_item_stock_purchase_params.numOfDaysStock = item_stock_purchase_params.numOfDaysStock
|
|
|
81 |
t_item_stock_purchase_params.minStockLevel = item_stock_purchase_params.minStockLevel
|
|
|
82 |
return t_item_stock_purchase_params
|