Subversion Repositories SmartDukaan

Rev

Rev 7281 | Rev 7811 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 ,\
7281 kshitij.so 9
    ItemStockPurchaseParams, OOSStatus, AmazonInventorySnapshot as TAmazonInventorySnapshot
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
7330 amit.gupta 38
    t_warehouse.stateId = warehouse.state_id
5944 mandeep.dh 39
    t_warehouse.inventoryType = InventoryType._NAMES_TO_VALUES[warehouse.inventoryType]
40
    t_warehouse.warehouseType = WarehouseType._NAMES_TO_VALUES[warehouse.warehouseType]
41
    if warehouse.vendorString:
42
        t_warehouse.vendorString = warehouse.vendorString
43
    if warehouse.addedOn:
44
        t_warehouse.addedOn = to_java_date(warehouse.addedOn)
45
    if warehouse.lastCheckedOn:
46
        t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
47
    return t_warehouse
48
 
6531 vikram.rag 49
def to_t_itemidwarehouseid(iidwid):
50
    t_iidwid = TIgnoredinventoryupdateitems()
51
    t_iidwid.itemId = iidwid.item_id
52
    t_iidwid.warehouseId = iidwid.warehouse_id
53
    return t_iidwid
54
 
5944 mandeep.dh 55
def to_t_vendor(vendor):
56
    t_vendor = Vendor()
57
    t_vendor.id = vendor.id
58
    t_vendor.name = vendor.name
59
    return t_vendor
60
 
61
def to_t_vendor_item_pricing(vendor_item_pricing):
62
    t_vendor_item_pricing = VendorItemPricing()
63
    t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
64
    t_vendor_item_pricing.itemId = vendor_item_pricing.item_id
65
    t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
6751 amar.kumar 66
    t_vendor_item_pricing.nlc = vendor_item_pricing.nlc
5944 mandeep.dh 67
    t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
68
    t_vendor_item_pricing.mop = vendor_item_pricing.mop
69
    return t_vendor_item_pricing
70
 
71
def to_t_vendor_item_mapping(vendor_item_mapping):
72
    t_vendor_item_mapping = VendorItemMapping()
73
    t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
74
    t_vendor_item_mapping.itemId = vendor_item_mapping.item_id
75
    t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
6821 amar.kumar 76
    return t_vendor_item_mapping
77
 
78
def to_t_item_stock_purchase_params(item_stock_purchase_params):
79
    t_item_stock_purchase_params = ItemStockPurchaseParams()
80
    t_item_stock_purchase_params.item_id = item_stock_purchase_params.item_id
81
    t_item_stock_purchase_params.numOfDaysStock = item_stock_purchase_params.numOfDaysStock
82
    t_item_stock_purchase_params.minStockLevel = item_stock_purchase_params.minStockLevel
6832 amar.kumar 83
    return t_item_stock_purchase_params
84
 
85
def to_t_oos_status(oos_status):
86
    t_oos_status = OOSStatus()
87
    t_oos_status.item_id = oos_status.item_id
88
    t_oos_status.date = to_java_date(oos_status.date)
89
    t_oos_status.is_oos = oos_status.is_oos
90
    t_oos_status.num_orders = oos_status.num_orders
7281 kshitij.so 91
    return t_oos_status
92
 
93
def to_t_amazon_inventory_snapshot(AmazonInventorySnapshot):
94
    t_amazon_inventory_snapshot = TAmazonInventorySnapshot()
95
    t_amazon_inventory_snapshot.item_id = AmazonInventorySnapshot.item_id
96
    t_amazon_inventory_snapshot.availability = AmazonInventorySnapshot.availability
97
    t_amazon_inventory_snapshot.reserved = AmazonInventorySnapshot.reserved
98
    return t_amazon_inventory_snapshot