Subversion Repositories SmartDukaan

Rev

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