Subversion Repositories SmartDukaan

Rev

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