Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
94 ashish 1
'''
2
Created on 23-Mar-2010
3
 
4
@author: ashish
5
'''
4295 varun.gupt 6
from shop2020.thriftpy.model.v1.catalog.ttypes import  Item, ItemInventory, Warehouse, VendorItemPricing, Vendor, Category,\
7
    VendorItemMapping, SourceItemPricing, Source, ProductNotificationRequest as TProductNotificationRequest,\
8
    ProductNotificationRequestCount as TProductNotificationRequestCount
94 ashish 9
import time
122 ashish 10
from shop2020.utils.Utils import to_java_date
94 ashish 11
 
12
def to_t_item(item):
13
    t_item = Item()
576 chandransh 14
    if item is None:
15
        return t_item
94 ashish 16
    t_item.id = item.id
963 chandransh 17
    t_item.productGroup = item.product_group
18
    t_item.brand = item.brand
591 chandransh 19
    t_item.modelNumber = item.model_number
20
    t_item.modelName = item.model_name
609 chandransh 21
    t_item.color = item.color
591 chandransh 22
    t_item.category = item.category
122 ashish 23
    t_item.catalogItemId = item.catalog_item_id
24
    t_item.weight = item.weight
25
    t_item.featureId = item.feature_id
26
    t_item.featureDescription = item.feature_description
27
    if item.startDate:
28
        t_item.startDate = to_java_date(item.startDate)
29
    if item.addedOn:
30
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 31
    if item.updatedOn:
32
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 33
    t_item.itemStatus = item.status
2035 rajveer 34
    t_item.status_description = item.status_description
609 chandransh 35
 
501 rajveer 36
    if item.sellingPrice:
609 chandransh 37
        t_item.sellingPrice = item.sellingPrice
630 chandransh 38
    if item.mrp:
501 rajveer 39
        t_item.mrp = item.mrp    
94 ashish 40
    t_item.itemInventory = to_t_item_inventory(item.currentInventory, item.id)
122 ashish 41
 
2028 ankur.sing 42
    if item.comments:
43
        t_item.comments = item.comments
609 chandransh 44
    if item.bestDealText:
45
        t_item.bestDealText = item.bestDealText
46
    if item.bestDealValue:
47
        t_item.bestDealValue = item.bestDealValue
48
 
2497 ankur.sing 49
    t_item.hotspotCategory = item.hotspotCategory
1910 varun.gupt 50
    t_item.defaultForEntity = item.defaultForEntity
122 ashish 51
    t_item.otherInfo = to_t_other_info(item)
2065 ankur.sing 52
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 53
    t_item.risky = item.risky
3355 chandransh 54
    t_item.expectedDelay = item.expectedDelay
3359 chandransh 55
    t_item.preferredWarehouse = item.preferredWarehouse
4295 varun.gupt 56
    t_item.warrantyPeriod = item.warranty_period
2065 ankur.sing 57
 
94 ashish 58
    return t_item
122 ashish 59
 
60
def to_t_other_info(item):
61
    t_other_info = {}
62
    for item_info in item.iteminfo:
63
        t_other_info[item_info.key] = item_info.value
94 ashish 64
 
65
def to_t_item_inventory(item_inventory_list, item_id):
66
    t_item_inventory = ItemInventory()
67
    t_item_inventory.id = item_id
68
    t_item_inventory.availability = {}
69
    for inventory_item in item_inventory_list:
122 ashish 70
        t_item_inventory.availability[inventory_item.warehouse.id] = inventory_item.availibility
483 rajveer 71
#        need review again        
72
#        if inventory_item.checkedOn:
73
#            t_item_inventory.lastCheckedOn = to_java_date(inventory_item.checkedOn)
94 ashish 74
    return t_item_inventory
75
 
76
def to_t_warehouse(warehouse):
77
    t_warehouse = Warehouse()
78
    t_warehouse.id = warehouse.id
759 chandransh 79
    t_warehouse.displayName = warehouse.displayName
94 ashish 80
    t_warehouse.location = warehouse.location
122 ashish 81
    t_warehouse.warehouseStatus = warehouse.status
483 rajveer 82
    t_warehouse.tinNumber = warehouse.tinNumber
83
    t_warehouse.pincode = warehouse.pincode
2841 chandransh 84
    t_warehouse.billingType = warehouse.billingType
494 rajveer 85
    if warehouse.vendorString:
483 rajveer 86
        t_warehouse.vendorString = warehouse.vendorString
122 ashish 87
    if warehouse.addedOn:
88
        t_warehouse.addedOn = to_java_date(warehouse.addedOn)
483 rajveer 89
    if warehouse.lastCheckedOn:
90
        t_warehouse.lastCheckedOn = to_java_date(warehouse.lastCheckedOn)
122 ashish 91
    return t_warehouse
1341 chandransh 92
 
93
def to_t_vendor(vendor):
94
    t_vendor = Vendor()
95
    t_vendor.id = vendor.id
96
    t_vendor.name = vendor.name
1348 chandransh 97
    return t_vendor
1341 chandransh 98
 
99
def to_t_vendor_item_pricing(vendor_item_pricing):
100
    t_vendor_item_pricing = VendorItemPricing()
1348 chandransh 101
    t_vendor_item_pricing.vendorId = vendor_item_pricing.vendor.id
102
    t_vendor_item_pricing.itemId = vendor_item_pricing.item.id
1341 chandransh 103
    t_vendor_item_pricing.transferPrice = vendor_item_pricing.transfer_price
104
    t_vendor_item_pricing.dealerPrice = vendor_item_pricing.dealerPrice
1348 chandransh 105
    t_vendor_item_pricing.mop = vendor_item_pricing.mop
1970 rajveer 106
    return t_vendor_item_pricing
107
 
2116 ankur.sing 108
def to_t_vendor_item_mapping(vendor_item_mapping):
109
    t_vendor_item_mapping = VendorItemMapping()
110
    t_vendor_item_mapping.vendorId = vendor_item_mapping.vendor.id
111
    t_vendor_item_mapping.itemId = vendor_item_mapping.item.id
112
    t_vendor_item_mapping.itemKey = vendor_item_mapping.item_key
113
    t_vendor_item_mapping.vendorCategory = vendor_item_mapping.vendor_category
2120 ankur.sing 114
    return t_vendor_item_mapping
2116 ankur.sing 115
 
116
 
1970 rajveer 117
def to_t_category(category):
118
    t_category = Category()
119
    t_category.id = category.id
120
    t_category.label = category.label
121
    t_category.description = category.description
122
    t_category.parent_category_id = category.parent_category_id
3557 rajveer 123
    return t_category
124
 
125
def to_t_source_item_pricing(source_item_pricing):
126
    t_source_item_pricing = SourceItemPricing()
127
    t_source_item_pricing.sourceId = source_item_pricing.source.id
128
    t_source_item_pricing.itemId = source_item_pricing.item.id
129
    t_source_item_pricing.mrp = source_item_pricing.mrp
130
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
131
    return t_source_item_pricing
132
 
133
def to_t_source(source):
134
    t_source = Source()
135
    t_source.id = source.id
136
    t_source.name = source.name
137
    t_source.identifier = source.identifier
138
    return t_source
4295 varun.gupt 139
 
140
def to_t_product_notification_request(product_notification_request):
141
    t_product_notification_request = TProductNotificationRequest()
142
 
143
    if product_notification_request:
144
        t_product_notification_request.item = to_t_item(product_notification_request.item)
145
        t_product_notification_request.email = product_notification_request.email
146
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
147
 
148
    return t_product_notification_request
149
 
150
def to_t_product_notification_request_count(product_notification_request_count):
151
 
152
    t_product_notification_request_count = TProductNotificationRequestCount()
153
 
154
    if product_notification_request_count:
155
        item, count = product_notification_request_count
156
        t_product_notification_request_count.item = to_t_item(item)
157
        t_product_notification_request_count.count = count
158
 
159
    return t_product_notification_request_count