Subversion Repositories SmartDukaan

Rev

Rev 11711 | Rev 12357 | 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, \
12
    FlipkartInventorySnapshot as TFlipkartInventorySnapshot
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)
53
    return t_warehouse
54
 
6531 vikram.rag 55
def to_t_itemidwarehouseid(iidwid):
56
    t_iidwid = TIgnoredinventoryupdateitems()
57
    t_iidwid.itemId = iidwid.item_id
58
    t_iidwid.warehouseId = iidwid.warehouse_id
59
    return t_iidwid
60
 
12280 amit.gupta 61
def to_t_state(state):
62
    t_state = StateInfo()
63
    t_state.id = state.id
64
    t_state.stateName = state.name
65
    t_state.vatType = state.vatType
66
    return t_state
67
 
5944 mandeep.dh 68
def to_t_vendor(vendor):
69
    t_vendor = Vendor()
70
    t_vendor.id = vendor.id
71
    t_vendor.name = vendor.name
72
    return t_vendor
73
 
74
def to_t_vendor_item_pricing(vendor_item_pricing):
75
    t_vendor_item_pricing = VendorItemPricing()
76
    t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
77
    t_vendor_item_pricing.itemId = vendor_item_pricing.item_id
78
    t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
6751 amar.kumar 79
    t_vendor_item_pricing.nlc = vendor_item_pricing.nlc
5944 mandeep.dh 80
    t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
81
    t_vendor_item_pricing.mop = vendor_item_pricing.mop
82
    return t_vendor_item_pricing
83
 
84
def to_t_vendor_item_mapping(vendor_item_mapping):
85
    t_vendor_item_mapping = VendorItemMapping()
86
    t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
87
    t_vendor_item_mapping.itemId = vendor_item_mapping.item_id
88
    t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
6821 amar.kumar 89
    return t_vendor_item_mapping
90
 
91
def to_t_item_stock_purchase_params(item_stock_purchase_params):
92
    t_item_stock_purchase_params = ItemStockPurchaseParams()
11711 vikram.rag 93
    if item_stock_purchase_params is None:
94
        return t_item_stock_purchase_params 
6821 amar.kumar 95
    t_item_stock_purchase_params.item_id = item_stock_purchase_params.item_id
96
    t_item_stock_purchase_params.numOfDaysStock = item_stock_purchase_params.numOfDaysStock
97
    t_item_stock_purchase_params.minStockLevel = item_stock_purchase_params.minStockLevel
6832 amar.kumar 98
    return t_item_stock_purchase_params
99
 
100
def to_t_oos_status(oos_status):
101
    t_oos_status = OOSStatus()
102
    t_oos_status.item_id = oos_status.item_id
103
    t_oos_status.date = to_java_date(oos_status.date)
104
    t_oos_status.is_oos = oos_status.is_oos
105
    t_oos_status.num_orders = oos_status.num_orders
8220 amar.kumar 106
    t_oos_status.rto_orders = oos_status.rto_orders
10126 amar.kumar 107
    t_oos_status.sourceId = oos_status.sourceId
7281 kshitij.so 108
    return t_oos_status
109
 
110
def to_t_amazon_inventory_snapshot(AmazonInventorySnapshot):
111
    t_amazon_inventory_snapshot = TAmazonInventorySnapshot()
112
    t_amazon_inventory_snapshot.item_id = AmazonInventorySnapshot.item_id
113
    t_amazon_inventory_snapshot.availability = AmazonInventorySnapshot.availability
114
    t_amazon_inventory_snapshot.reserved = AmazonInventorySnapshot.reserved
8282 kshitij.so 115
    return t_amazon_inventory_snapshot
116
 
117
def to_t_amazon_fba_inventory_snapshot(AmazonFbaInventorySnapshot):
118
    t_amazon_inventory_snapshot = TAmazonFbaInventorySnapshot()
11173 vikram.rag 119
    if AmazonFbaInventorySnapshot is None:
120
        return t_amazon_inventory_snapshot 
8282 kshitij.so 121
    t_amazon_inventory_snapshot.item_id = AmazonFbaInventorySnapshot.item_id
122
    t_amazon_inventory_snapshot.availability = AmazonFbaInventorySnapshot.availability
11173 vikram.rag 123
    t_amazon_inventory_snapshot.location = AmazonFbaInventorySnapshot.location
124
    t_amazon_inventory_snapshot.reserved = AmazonFbaInventorySnapshot.reserved
125
    t_amazon_inventory_snapshot.inbound = AmazonFbaInventorySnapshot.inbound
126
    t_amazon_inventory_snapshot.unfulfillable = AmazonFbaInventorySnapshot.unfulfillable
9404 vikram.rag 127
    return t_amazon_inventory_snapshot
128
 
129
def to_t_snapdeal_inventory_snapshot(snapdealInventoryItem):
130
    t_snapdeal_inventory_snapshot = TSnapdealInventoryItem()
131
    if snapdealInventoryItem is None:
132
        return t_snapdeal_inventory_snapshot 
133
    t_snapdeal_inventory_snapshot.item_id = snapdealInventoryItem.item_id 
134
    t_snapdeal_inventory_snapshot.availability = snapdealInventoryItem.availability
9495 vikram.rag 135
    t_snapdeal_inventory_snapshot.pendingOrders = snapdealInventoryItem.pendingOrders
9404 vikram.rag 136
    t_snapdeal_inventory_snapshot.lastUpdatedOnSnapdeal = to_java_date(snapdealInventoryItem.lastUpdatedOnSnapdeal)
9761 amar.kumar 137
    return t_snapdeal_inventory_snapshot
138
 
139
def to_t_hold_inventory_detail(holdInventoryDetail):
140
    t_hold_inventory_detail = THoldInventoryDetail()
141
    if holdInventoryDetail:
142
        t_hold_inventory_detail.item_id = holdInventoryDetail.item_id
143
        t_hold_inventory_detail.warehouse_id = holdInventoryDetail.warehouse_id
144
        t_hold_inventory_detail.source = holdInventoryDetail.source
145
        t_hold_inventory_detail.held = holdInventoryDetail.held
146
    return t_hold_inventory_detail
10050 vikram.rag 147
 
148
def to_t_flipkart_inventory_snapshot(flipkartInventoryItem):
149
    t_flipkart_inventory_snapshot = TFlipkartInventorySnapshot()
150
    if flipkartInventoryItem is None:
151
        return t_flipkart_inventory_snapshot 
152
    t_flipkart_inventory_snapshot.item_id = flipkartInventoryItem.item_id 
153
    t_flipkart_inventory_snapshot.availability = flipkartInventoryItem.availability
154
    t_flipkart_inventory_snapshot.heldOrders = flipkartInventoryItem.heldOrders
155
    t_flipkart_inventory_snapshot.createdOrders = flipkartInventoryItem.createdOrders
156
    return t_flipkart_inventory_snapshot
9761 amar.kumar 157