Subversion Repositories SmartDukaan

Rev

Rev 12448 | Rev 12620 | 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
'''
8754 vikram.rag 6
from shop2020.model.v1.catalog.impl.DataService import Insurer, SnapdealItem, Item
6511 kshitij.so 7
from shop2020.thriftpy.model.v1.catalog.ttypes import Item, Category, \
8
    SourceItemPricing, Source, ItemType, \
5110 mandeep.dh 9
    ProductNotificationRequest as TProductNotificationRequest, \
10
    ProductNotificationRequestCount as TProductNotificationRequestCount, \
7281 kshitij.so 11
    VoucherItemMapping, EntityTag as TEntityTag, Banner as TBanner, BannerMap as TBannerMap, \
8182 amar.kumar 12
    Insurer as TInsurer, BrandInfo as TBrandInfo, Amazonlisted as TAmazonlisted, \
8739 vikram.rag 13
    EbayItem as TEbayItem, BannerUriMapping as TBannerUriMapping, Campaign as TCampaign, \
9724 kshitij.so 14
    SnapdealItem as TSnapdealItem, SnapdealItemDetails as TSnapdealItemDetails,ProductFeedSubmit as TProductFeedSubmit, \
9779 kshitij.so 15
    MarketplaceItems as TMarketplaceItems, MarketplacePercentage as TMarketplacePercentage, \
10097 kshitij.so 16
    MarketPlaceItemPrice as TMarketPlaceItemPrice, FlipkartItem as TFlipkartItem,\
11531 vikram.rag 17
    FlipkartItemDetails as TFlipkartItemDetails,MarketplaceHistory as TMarketplaceHistory,\
12363 kshitij.so 18
    PrivateDeal as TPrivateDeal, AmazonOutOfSync as TAmazonOutOfSync, PdPriceComp as TPdPriceComp, CompetitorPricing as TCompetitorPricing, \
19
    AmazonPromotion as TAmazonPromotion
5110 mandeep.dh 20
from shop2020.utils.Utils import to_java_date
12363 kshitij.so 21
import datetime
94 ashish 22
 
23
def to_t_item(item):
24
    t_item = Item()
576 chandransh 25
    if item is None:
26
        return t_item
94 ashish 27
    t_item.id = item.id
963 chandransh 28
    t_item.productGroup = item.product_group
29
    t_item.brand = item.brand
591 chandransh 30
    t_item.modelNumber = item.model_number
31
    t_item.modelName = item.model_name
609 chandransh 32
    t_item.color = item.color
591 chandransh 33
    t_item.category = item.category
122 ashish 34
    t_item.catalogItemId = item.catalog_item_id
35
    t_item.weight = item.weight
36
    t_item.featureId = item.feature_id
37
    t_item.featureDescription = item.feature_description
38
    if item.startDate:
39
        t_item.startDate = to_java_date(item.startDate)
5217 amit.gupta 40
    if item.comingSoonStartDate:
41
        t_item.comingSoonStartDate = to_java_date(item.comingSoonStartDate)
42
    if item.expectedArrivalDate:
43
        t_item.expectedArrivalDate = to_java_date(item.expectedArrivalDate)
122 ashish 44
    if item.addedOn:
45
        t_item.addedOn = to_java_date(item.addedOn)
609 chandransh 46
    if item.updatedOn:
47
        t_item.updatedOn = to_java_date(item.updatedOn)
122 ashish 48
    t_item.itemStatus = item.status
2035 rajveer 49
    t_item.status_description = item.status_description
501 rajveer 50
    if item.sellingPrice:
609 chandransh 51
        t_item.sellingPrice = item.sellingPrice
630 chandransh 52
    if item.mrp:
501 rajveer 53
        t_item.mrp = item.mrp    
122 ashish 54
 
2028 ankur.sing 55
    if item.comments:
56
        t_item.comments = item.comments
609 chandransh 57
    if item.bestDealText:
58
        t_item.bestDealText = item.bestDealText
6777 vikram.rag 59
    if item.bestDealsDetailsText:
60
        t_item.bestDealsDetailsText = item.bestDealsDetailsText
61
    if item.bestDealsDetailsLink:
62
        t_item.bestDealsDetailsLink = item.bestDealsDetailsLink 
609 chandransh 63
    if item.bestDealValue:
64
        t_item.bestDealValue = item.bestDealValue
7291 vikram.rag 65
    if item.asin:
66
        t_item.asin = item.asin    
1910 varun.gupt 67
    t_item.defaultForEntity = item.defaultForEntity
2065 ankur.sing 68
    t_item.bestSellingRank = item.bestSellingRank
2251 ankur.sing 69
    t_item.risky = item.risky
3355 chandransh 70
    t_item.expectedDelay = item.expectedDelay
4406 anupam.sin 71
    t_item.isWarehousePreferenceSticky = item.isWarehousePreferenceSticky
4295 varun.gupt 72
    t_item.warrantyPeriod = item.warranty_period
4506 phani.kuma 73
    t_item.preferredVendor = item.preferredVendor
5110 mandeep.dh 74
    t_item.type = ItemType._NAMES_TO_VALUES[item.type]
5385 phani.kuma 75
    t_item.hasItemNo = item.hasItemNo
7256 rajveer 76
    t_item.activeOnStore = item.activeOnStore
6241 amit.gupta 77
    t_item.showSellingPrice = item.showSellingPrice
6805 anupam.sin 78
    t_item.preferredInsurer = item.preferredInsurer
7291 vikram.rag 79
    t_item.holdInventory = item.holdInventory
80
    t_item.defaultInventory = item.defaultInventory
9841 rajveer 81
    t_item.holdOverride = item.holdOverride
94 ashish 82
    return t_item
122 ashish 83
 
6805 anupam.sin 84
def to_t_insurer(insurer):
85
    t_insurer = TInsurer()
86
    t_insurer.id = insurer.id
87
    t_insurer.name = insurer.name 
88
    t_insurer.address = insurer.address
6903 anupam.sin 89
    t_insurer.declaredAmount = insurer.declaredAmount
90
    t_insurer.creditedAmount = insurer.creditedAmount
6805 anupam.sin 91
    return t_insurer
92
 
5504 phani.kuma 93
def to_t_voucher_item_mapping(voucher):
94
    t_voucher = VoucherItemMapping()
95
    t_voucher.voucherType = voucher.voucherType
96
    t_voucher.itemId = voucher.item.id
97
    t_voucher.amount = voucher.amount
98
    return t_voucher
99
 
1970 rajveer 100
def to_t_category(category):
101
    t_category = Category()
102
    t_category.id = category.id
103
    t_category.label = category.label
104
    t_category.description = category.description
105
    t_category.parent_category_id = category.parent_category_id
4762 phani.kuma 106
    t_category.display_name = category.display_name
3557 rajveer 107
    return t_category
108
 
109
def to_t_source_item_pricing(source_item_pricing):
110
    t_source_item_pricing = SourceItemPricing()
111
    t_source_item_pricing.sourceId = source_item_pricing.source.id
112
    t_source_item_pricing.itemId = source_item_pricing.item.id
113
    t_source_item_pricing.mrp = source_item_pricing.mrp
114
    t_source_item_pricing.sellingPrice = source_item_pricing.sellingPrice
115
    return t_source_item_pricing
116
 
117
def to_t_source(source):
118
    t_source = Source()
119
    t_source.id = source.id
120
    t_source.name = source.name
121
    t_source.identifier = source.identifier
122
    return t_source
4295 varun.gupt 123
 
124
def to_t_product_notification_request(product_notification_request):
125
    t_product_notification_request = TProductNotificationRequest()
126
 
127
    if product_notification_request:
128
        t_product_notification_request.item = to_t_item(product_notification_request.item)
129
        t_product_notification_request.email = product_notification_request.email
130
        t_product_notification_request.addedOn = to_java_date(product_notification_request.addedOn)
131
 
132
    return t_product_notification_request
133
 
134
def to_t_product_notification_request_count(product_notification_request_count):
135
 
136
    t_product_notification_request_count = TProductNotificationRequestCount()
137
 
138
    if product_notification_request_count:
139
        item, count = product_notification_request_count
140
        t_product_notification_request_count.item = to_t_item(item)
141
        t_product_notification_request_count.count = count
142
 
6511 kshitij.so 143
    return t_product_notification_request_count
144
 
145
def to_t_entity_tag(entity_tag):
146
    t_entity_tag = TEntityTag()
147
    t_entity_tag.entityId = entity_tag.entityId
6848 kshitij.so 148
    t_entity_tag.tag = entity_tag.tag
149
 
150
def to_t_banner(banner):
151
    t_banner = TBanner()
152
    t_banner.bannerName = banner.bannerName
153
    t_banner.imageName = banner.imageName
154
    t_banner.link = banner.link
155
    t_banner.priority = banner.priority
156
    t_banner.hasMap = banner.hasMap
9155 kshitij.so 157
    t_banner.bannerType = banner.bannerType
6848 kshitij.so 158
    return t_banner
159
 
8579 kshitij.so 160
def to_t_banner_list(bannerList):
161
    t_banner_list = []
162
    for banner in bannerList:
163
        t_banner = TBanner()
164
        t_banner.bannerName = banner.bannerName
165
        t_banner.imageName = banner.imageName
166
        t_banner.link = banner.link
167
        t_banner.priority = banner.priority
168
        t_banner.hasMap = banner.hasMap
9155 kshitij.so 169
        t_banner.bannerType = banner.bannerType
8579 kshitij.so 170
        t_banner_list.append(t_banner)
171
    return t_banner_list
172
 
173
 
6848 kshitij.so 174
def to_t_banner_map(banner_map):
175
    t_banner_map = TBannerMap()
176
    t_banner_map.bannerName = banner_map.bannerName
177
    t_banner_map.mapLink = banner_map.mapLink
178
    t_banner_map.coordinates = banner_map.coordinates
179
    return t_banner_map
7272 amit.gupta 180
 
8579 kshitij.so 181
def to_t_uri_mapping(uriMapping):
182
    t_uri_mapping =TBannerUriMapping()
183
    t_uri_mapping.bannerName = uriMapping.bannerName
184
    t_uri_mapping.uri = uriMapping.uri
185
    t_uri_mapping.isActive = uriMapping.isActive
10097 kshitij.so 186
    t_uri_mapping.target = uriMapping.target
8579 kshitij.so 187
    return t_uri_mapping
188
 
189
def to_t_campaign(campaign):
190
    t_campaign = TCampaign()
191
    t_campaign.id = campaign.id
192
    t_campaign.campaignName = campaign.campaignName
193
    t_campaign.imageName = campaign.imageName
194
    return t_campaign
195
 
7281 kshitij.so 196
def to_t_Amazonlisted(Amazonlisted):
197
    t_amazonlisted = TAmazonlisted()
8362 kshitij.so 198
    if Amazonlisted is None:
199
        return t_amazonlisted
7281 kshitij.so 200
    t_amazonlisted.asin = Amazonlisted.asin
201
    t_amazonlisted.brand = Amazonlisted.brand 
202
    t_amazonlisted.itemid = Amazonlisted.itemId
203
    t_amazonlisted.model = Amazonlisted.model
204
    t_amazonlisted.manufacturer_name = Amazonlisted.manufacturer_name
205
    t_amazonlisted.upc = Amazonlisted.upc
206
    t_amazonlisted.part_number = Amazonlisted.part_number
207
    t_amazonlisted.name = Amazonlisted.name
208
    t_amazonlisted.ean = Amazonlisted.ean
209
    t_amazonlisted.fbaPrice = Amazonlisted.fbaPrice
10909 vikram.rag 210
    t_amazonlisted.fbbPrice = Amazonlisted.fbbPrice
7281 kshitij.so 211
    t_amazonlisted.sellingPrice = Amazonlisted.sellingPrice
212
    t_amazonlisted.isFba = Amazonlisted.isFba
10909 vikram.rag 213
    t_amazonlisted.isFbb = Amazonlisted.isFbb
7281 kshitij.so 214
    t_amazonlisted.isNonFba = Amazonlisted.isNonFba
215
    t_amazonlisted.isInventoryOverride = Amazonlisted.isInventoryOverride
216
    t_amazonlisted.color = Amazonlisted.color
217
    t_amazonlisted.category = Amazonlisted.category
7367 kshitij.so 218
    t_amazonlisted.handlingTime = Amazonlisted.handlingTime
219
    t_amazonlisted.isCustomTime = Amazonlisted.isCustomTime
7516 vikram.rag 220
    t_amazonlisted.category_code = Amazonlisted.category_code
7770 kshitij.so 221
    t_amazonlisted.mfnPriceLastUpdatedOn = to_java_date(Amazonlisted.mfnPriceLastUpdatedOn)
222
    t_amazonlisted.fbaPriceLastUpdatedOn = to_java_date(Amazonlisted.fbaPriceLastUpdatedOn)
10909 vikram.rag 223
    t_amazonlisted.fbbPriceLastUpdatedOn = to_java_date(Amazonlisted.fbbPriceLastUpdatedOn)
7770 kshitij.so 224
    t_amazonlisted.mfnPriceLastUpdatedOnSc = to_java_date(Amazonlisted.mfnPriceLastUpdatedOnSc)
10909 vikram.rag 225
    t_amazonlisted.fbbPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbbPriceLastUpdatedOnSc)
7770 kshitij.so 226
    t_amazonlisted.fbaPriceLastUpdatedOnSc = to_java_date(Amazonlisted.fbaPriceLastUpdatedOnSc)
8139 kshitij.so 227
    t_amazonlisted.suppressMfnPriceUpdate = Amazonlisted.suppressMfnPriceUpdate
8140 kshitij.so 228
    t_amazonlisted.suppressFbaPriceUpdate = Amazonlisted.suppressFbaPriceUpdate
10909 vikram.rag 229
    t_amazonlisted.suppressFbbPriceUpdate = Amazonlisted.suppressFbbPriceUpdate
8619 kshitij.so 230
    t_amazonlisted.taxCode = Amazonlisted.taxCode
10918 vikram.rag 231
    t_amazonlisted.fbbtaxCode = Amazonlisted.fbbtaxCode
12363 kshitij.so 232
    t_amazonlisted.overrrideWanlc = Amazonlisted.overrrideWanlc
233
    t_amazonlisted.exceptionalWanlc = Amazonlisted.exceptionalWanlc
12396 kshitij.so 234
    t_amazonlisted.autoDecrement = Amazonlisted.autoDecrement
235
    t_amazonlisted.autoIncrement = Amazonlisted.autoIncrement
236
    t_amazonlisted.autoFavourite = Amazonlisted.autoFavourite
237
    t_amazonlisted.manualFavourite = Amazonlisted.manualFavourite
12449 kshitij.so 238
    t_amazonlisted.otherCost = Amazonlisted.otherCost
7291 vikram.rag 239
    return t_amazonlisted
240
 
8182 amar.kumar 241
def to_t_ebay_item(ebay_item):
242
    t_ebay_item = TEbayItem()
243
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
244
    t_ebay_item.itemId = ebay_item.itemId
245
    t_ebay_item.listingName = ebay_item.listingName
246
    t_ebay_item.listingPrice = ebay_item.listingPrice
247
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
248
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 249
    return t_ebay_item
250
 
251
def to_t_brand_info(brand_info):
252
    t_brand_info = TBrandInfo()
253
    t_brand_info.name = brand_info.name
254
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
8739 vikram.rag 255
    return t_brand_info
256
 
257
def to_t_snapdeal_item(snapdealitem):
8754 vikram.rag 258
    if snapdealitem is None:
8746 vikram.rag 259
        t_snapdeal_item = TSnapdealItem()
260
        return t_snapdeal_item
8739 vikram.rag 261
    t_snapdeal_item = TSnapdealItem()
8754 vikram.rag 262
    t_snapdeal_item.item_id = snapdealitem[0].item_id
8739 vikram.rag 263
    t_snapdeal_item.warehouseId = snapdealitem[0].warehouseId
264
    t_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPrice
9242 kshitij.so 265
    t_snapdeal_item.transferPrice = snapdealitem[0].transferPrice
266
    t_snapdeal_item.sellingPrice = snapdealitem[0].sellingPrice
267
    t_snapdeal_item.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 268
    t_snapdeal_item.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 269
    t_snapdeal_item.commission = snapdealitem[0].commission
270
    t_snapdeal_item.serviceTax = snapdealitem[0].serviceTax
271
    t_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
272
    t_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
273
    t_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9404 vikram.rag 274
    t_snapdeal_item.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 275
    t_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 276
    t_snapdeal_item.supc = snapdealitem[0].supc
9724 kshitij.so 277
    t_snapdeal_item.shippingTime = snapdealitem[0].shippingTime
9242 kshitij.so 278
    return t_snapdeal_item
279
 
9724 kshitij.so 280
def to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):
9242 kshitij.so 281
    if snapdealitem is None:
282
        t_snapdeal_item_details = TSnapdealItemDetails()
283
        return t_snapdeal_item_details
284
    t_snapdeal_item_details = TSnapdealItemDetails()
285
    t_snapdeal_item_details.item_id = snapdealitem[0].item_id
286
    t_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseId
287
    t_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPrice
288
    t_snapdeal_item_details.transferPrice = snapdealitem[0].transferPrice
289
    t_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPrice
290
    t_snapdeal_item_details.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 291
    t_snapdeal_item_details.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 292
    t_snapdeal_item_details.commission = snapdealitem[0].commission
293
    t_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTax
294
    t_snapdeal_item_details.brand = snapdealitem[1].brand
295
    t_snapdeal_item_details.model_name = snapdealitem[1].model_name
296
    t_snapdeal_item_details.model_number = snapdealitem[1].model_number
297
    t_snapdeal_item_details.color = snapdealitem[1].color
298
    t_snapdeal_item_details.risky = snapdealitem[1].risky
299
    t_snapdeal_item_details.itemStatus = snapdealitem[1].status
300
    t_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
301
    t_snapdeal_item_details.weight = snapdealitem[1].weight
302
    t_snapdeal_item_details.mrp = snapdealitem[1].mrp
303
    t_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPrice
304
    t_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
305
    t_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9478 kshitij.so 306
    t_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 307
    t_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 308
    t_snapdeal_item_details.supc = snapdealitem[0].supc
9724 kshitij.so 309
    t_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTime
310
    if snapdealItemInventory is not None:
311
        t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availability
312
        t_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdeal 
9242 kshitij.so 313
    return t_snapdeal_item_details
9621 manish.sha 314
 
315
def to_t_product_feed_submit(productfeedsubmit):
316
    if productfeedsubmit is None:
317
        t_product_feed_submit = TProductFeedSubmit()
318
        return t_product_feed_submit
319
    t_product_feed_submit = TProductFeedSubmit()
320
    t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemId
321
    t_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeed
9724 kshitij.so 322
    return t_product_feed_submit
323
 
324
def to_t_marketplace_items(marketplaceItem):
325
    t_marketplace_item = TMarketplaceItems() 
326
    if marketplaceItem is None:
327
        return t_marketplace_item
328
    t_marketplace_item.itemId = marketplaceItem.itemId
329
    t_marketplace_item.source = marketplaceItem.source
330
    t_marketplace_item.emiFee = marketplaceItem.emiFee
331
    t_marketplace_item.courierCost = marketplaceItem.courierCost
11095 kshitij.so 332
    t_marketplace_item.courierCostMarketplace = marketplaceItem.courierCostMarketplace
9724 kshitij.so 333
    t_marketplace_item.closingFee = marketplaceItem.closingFee
334
    t_marketplace_item.commission = marketplaceItem.commission
335
    t_marketplace_item.returnProvision = marketplaceItem.returnProvision
336
    t_marketplace_item.vat = marketplaceItem.vat
337
    t_marketplace_item.packagingCost = marketplaceItem.packagingCost
338
    t_marketplace_item.otherCost = marketplaceItem.otherCost
339
    t_marketplace_item.serviceTax = marketplaceItem.serviceTax
340
    t_marketplace_item.autoIncrement = marketplaceItem.autoIncrement
341
    t_marketplace_item.autoDecrement = marketplaceItem.autoDecrement
342
    t_marketplace_item.autoFavourite = marketplaceItem.autoFavourite
343
    t_marketplace_item.manualFavourite = marketplaceItem.manualFavourite
344
    t_marketplace_item.currentSp = marketplaceItem.currentSp
345
    t_marketplace_item.currentTp = marketplaceItem.currentTp
346
    t_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSp
347
    t_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTp
348
    t_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)
9923 kshitij.so 349
    t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPrice
10287 kshitij.so 350
    t_marketplace_item.pgFee = marketplaceItem.pgFee
9724 kshitij.so 351
    return t_marketplace_item
9776 vikram.rag 352
 
353
def to_t_marketplace_itemprice(marketplaceitemprice):
354
    t_marketplace_priceitem = TMarketPlaceItemPrice()    
355
    t_marketplace_priceitem.item_id = marketplaceitemprice.item_id
356
    t_marketplace_priceitem.source = marketplaceitemprice.source
357
    t_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPrice
358
    t_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)
359
    t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)
360
    t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeed
361
    t_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSource
362
    return t_marketplace_priceitem 
9779 kshitij.so 363
 
364
def to_t_marketplacepercentage(marketplacePercentage):
365
    t_marketplacepercentage = TMarketplacePercentage()
366
    if marketplacePercentage is None:
367
        return t_marketplacepercentage
368
    t_marketplacepercentage.source =  marketplacePercentage.source
369
    t_marketplacepercentage.emiFee =  marketplacePercentage.emiFee
370
    t_marketplacepercentage.closingFee = marketplacePercentage.closingFee
371
    t_marketplacepercentage.returnProvision = marketplacePercentage.returnProvision
372
    t_marketplacepercentage.commission = marketplacePercentage.commission
373
    t_marketplacepercentage.serviceTax = marketplacePercentage.serviceTax
10287 kshitij.so 374
    t_marketplacepercentage.pgFee = marketplacePercentage.pgFee
9779 kshitij.so 375
    return t_marketplacepercentage
9945 vikram.rag 376
 
377
def to_t_flipkart_item(flipkartItem):
378
    t_flipkartitem = TFlipkartItem()
379
    if flipkartItem is None:
380
        return t_flipkartitem
10097 kshitij.so 381
    t_flipkartitem.item_id = flipkartItem[0].item_id  
382
    t_flipkartitem.exceptionPrice = flipkartItem[0].exceptionPrice
383
    t_flipkartitem.warehouseId = flipkartItem[0].warehouseId
384
    t_flipkartitem.commissionValue  =  flipkartItem[0].commissionValue
385
    t_flipkartitem.serviceTaxValue  =  flipkartItem[0].serviceTaxValue
386
    t_flipkartitem.maxNlc = flipkartItem[0].maxNlc
387
    t_flipkartitem.skuAtFlipkart = flipkartItem[0].skuAtFlipkart
388
    t_flipkartitem.isListedOnFlipkart = flipkartItem[0].isListedOnFlipkart
389
    t_flipkartitem.suppressPriceFeed = flipkartItem[0].suppressPriceFeed
390
    t_flipkartitem.suppressInventoryFeed = flipkartItem[0].suppressInventoryFeed
391
    #t_flipkartitem.updatedOn = to_java_date(flipkartItem.updatedOn)
392
    t_flipkartitem.updatedBy = flipkartItem[0].updatedBy
393
    t_flipkartitem.flipkartSerialNumber = flipkartItem[0].flipkartSerialNumber
9945 vikram.rag 394
    return t_flipkartitem
10097 kshitij.so 395
 
396
def to_t_flipkart_item_details(flipkartitem,flipkartItemInventory):
397
    if flipkartitem is None:
398
        t_flipkart_item_details = TFlipkartItemDetails()
399
        return t_flipkart_item_details
400
    t_flipkart_item_details = TFlipkartItemDetails()
401
    t_flipkart_item_details.item_id = flipkartitem[0].item_id
402
    t_flipkart_item_details.warehouseId = flipkartitem[0].warehouseId
403
    t_flipkart_item_details.exceptionPrice = flipkartitem[0].exceptionPrice
404
    t_flipkart_item_details.commission = flipkartitem[0].commissionValue
405
    t_flipkart_item_details.serviceTax = flipkartitem[0].serviceTaxValue
406
    t_flipkart_item_details.brand = flipkartitem[1].brand
407
    t_flipkart_item_details.model_name = flipkartitem[1].model_name
408
    t_flipkart_item_details.model_number = flipkartitem[1].model_number
409
    t_flipkart_item_details.color = flipkartitem[1].color
410
    t_flipkart_item_details.risky = flipkartitem[1].risky
411
    t_flipkart_item_details.itemStatus = flipkartitem[1].status
412
    t_flipkart_item_details.isListedOnFlipkart = flipkartitem[0].isListedOnFlipkart
413
    t_flipkart_item_details.weight = flipkartitem[1].weight
414
    t_flipkart_item_details.mrp = flipkartitem[1].mrp
415
    t_flipkart_item_details.websiteSellingPrice = flipkartitem[1].sellingPrice
416
    t_flipkart_item_details.suppressPriceFeed = flipkartitem[0].suppressPriceFeed
417
    t_flipkart_item_details.suppressInventoryFeed = flipkartitem[0].suppressInventoryFeed
418
    t_flipkart_item_details.maxNlc = flipkartitem[0].maxNlc
419
    t_flipkart_item_details.skuAtFlipkart = flipkartitem[0].skuAtFlipkart
420
    t_flipkart_item_details.flipkartSerialNumber = flipkartitem[0].flipkartSerialNumber
10156 amar.kumar 421
    t_flipkart_item_details.category = flipkartitem[1].category
10097 kshitij.so 422
    if flipkartItemInventory is not None:
423
        t_flipkart_item_details.lastUpdatedInventory = flipkartItemInventory.availability
424
        #t_flipkart_item_details.lastUpdatedInventoryTimestamp = flipkartItemInventory.lastUpdatedOnFlipkart 
425
    return t_flipkart_item_details
11015 kshitij.so 426
 
427
def to_t_market_place_history(marketplaceHistory):
428
    t_marketplace_history = TMarketplaceHistory()
429
    if marketplaceHistory is None:
430
        return t_marketplace_history
431
    t_marketplace_history.item_id = marketplaceHistory.item_id
432
    t_marketplace_history.source = marketplaceHistory.source
433
    t_marketplace_history.timestamp = to_java_date(marketplaceHistory.timestamp)
11076 kshitij.so 434
    if marketplaceHistory.lowestPossibleTp is None:
435
        t_marketplace_history.lowest_possible_tp =0
436
    else:
437
        t_marketplace_history.lowest_possible_tp = int(marketplaceHistory.lowestPossibleTp)
438
    if marketplaceHistory.lowestPossibleSp is None:
439
        t_marketplace_history.lowest_possible_sp = 0
440
    else:
441
        t_marketplace_history.lowest_possible_sp = int(marketplaceHistory.lowestPossibleSp)
11015 kshitij.so 442
    t_marketplace_history.ourInventory = marketplaceHistory.ourInventory
443
    t_marketplace_history.otherInventory = marketplaceHistory.otherInventory
444
    t_marketplace_history.secondLowestInventory = marketplaceHistory.secondLowestInventory
445
    t_marketplace_history.ourRank = marketplaceHistory.ourRank
11076 kshitij.so 446
    if marketplaceHistory.ourOfferPrice is None:
447
        t_marketplace_history.ourOfferPrice = 0
448
    else: 
449
        t_marketplace_history.ourOfferPrice = int(marketplaceHistory.ourOfferPrice)
450
    if marketplaceHistory.ourSellingPrice is None:
451
        t_marketplace_history.ourSellingPrice = 0
452
    else:
453
        t_marketplace_history.ourSellingPrice = int(marketplaceHistory.ourSellingPrice)
454
    if marketplaceHistory.ourTp is None:
455
        t_marketplace_history.ourTp = 0
456
    else:
457
        t_marketplace_history.ourTp = int(marketplaceHistory.ourTp)
458
    if marketplaceHistory.ourNlc is None:
459
        t_marketplace_history.ourNlc = 0
460
    else:
461
        t_marketplace_history.ourNlc = int(marketplaceHistory.ourNlc)
11015 kshitij.so 462
    t_marketplace_history.competitiveCategory = marketplaceHistory.competitiveCategory
463
    t_marketplace_history.risky = marketplaceHistory.risky
11076 kshitij.so 464
    if marketplaceHistory.lowestOfferPrice is None:
465
        t_marketplace_history.lowestOfferPrice = 0
466
    else:
467
        t_marketplace_history.lowestOfferPrice = int(marketplaceHistory.lowestOfferPrice)
468
    if marketplaceHistory.lowestSellingPrice is None:
469
        t_marketplace_history.lowestSellingPrice = 0
470
    else:
471
        t_marketplace_history.lowestSellingPrice = int(marketplaceHistory.lowestSellingPrice)
472
    if marketplaceHistory.lowestTp is None:
473
        t_marketplace_history.lowestTp = 0
474
    else:
475
        t_marketplace_history.lowestTp = int(marketplaceHistory.lowestTp)
11015 kshitij.so 476
    if marketplaceHistory.lowestSellerName is None:
477
        t_marketplace_history.lowestSellerName = ''
478
    else:
479
        t_marketplace_history.lowestSellerName = marketplaceHistory.lowestSellerName
11076 kshitij.so 480
    if marketplaceHistory.proposedSellingPrice is None:
481
        t_marketplace_history.proposedSellingPrice = 0
482
    else:
483
        t_marketplace_history.proposedSellingPrice = int(marketplaceHistory.proposedSellingPrice)
484
    if marketplaceHistory.proposedTp is None:
485
        t_marketplace_history.proposedTp = 0
486
    else:
487
        t_marketplace_history.proposedTp = int(marketplaceHistory.proposedTp)
488
    if marketplaceHistory.targetNlc is None:
489
        t_marketplace_history.targetNlc = 0
490
    else:
491
        t_marketplace_history.targetNlc = int(marketplaceHistory.targetNlc)
11015 kshitij.so 492
    t_marketplace_history.salesPotential = marketplaceHistory.salesPotential
493
    if marketplaceHistory.secondLowestSellerName is None:
494
        t_marketplace_history.secondLowestSellerName = ''
495
    else:
496
        t_marketplace_history.secondLowestSellerName = marketplaceHistory.secondLowestSellerName
11017 kshitij.so 497
    if marketplaceHistory.secondLowestSellingPrice is None:
11076 kshitij.so 498
        t_marketplace_history.secondLowestSellingPrice=0
11017 kshitij.so 499
    else:
11076 kshitij.so 500
        t_marketplace_history.secondLowestSellingPrice = int(marketplaceHistory.secondLowestSellingPrice)
11017 kshitij.so 501
    if marketplaceHistory.secondLowestOfferPrice is None:
11076 kshitij.so 502
        t_marketplace_history.secondLowestOfferPrice = 0
11017 kshitij.so 503
    else:
11076 kshitij.so 504
        t_marketplace_history.secondLowestOfferPrice = int(marketplaceHistory.secondLowestOfferPrice)
11017 kshitij.so 505
    if marketplaceHistory.secondLowestTp is None:
11076 kshitij.so 506
        t_marketplace_history.secondLowestTp=0
11017 kshitij.so 507
    else:
11076 kshitij.so 508
        t_marketplace_history.secondLowestTp = int(marketplaceHistory.secondLowestTp)
11015 kshitij.so 509
    t_marketplace_history.marginIncreasedPotential = marketplaceHistory.marginIncreasedPotential
11076 kshitij.so 510
    if marketplaceHistory.margin is None:
511
        t_marketplace_history.margin = 0
512
    else:
513
        t_marketplace_history.margin = int(marketplaceHistory.margin)
11015 kshitij.so 514
    t_marketplace_history.ourEnoughStock = marketplaceHistory.ourEnoughStock
515
    t_marketplace_history.totalSeller = marketplaceHistory.totalSeller
516
    t_marketplace_history.averageSale = marketplaceHistory.avgSales
517
    t_marketplace_history.toGroup = marketplaceHistory.toGroup
11076 kshitij.so 518
    t_marketplace_history.decision = marketplaceHistory.decision
519
    t_marketplace_history.reason = marketplaceHistory.reason
11015 kshitij.so 520
    return t_marketplace_history
9945 vikram.rag 521
 
11531 vikram.rag 522
def to_t_private_deal(private_deal_item):
523
    if private_deal_item is None:
524
        t_private_deal_item = TPrivateDeal()
525
        return t_private_deal_item
526
    t_private_deal_item = TPrivateDeal()
527
    t_private_deal_item.item_id = private_deal_item.item_id
528
    t_private_deal_item.dealPrice = private_deal_item.dealPrice
529
    t_private_deal_item.dealFreebieItemId = private_deal_item.dealFreebieItemId
11579 vikram.rag 530
    t_private_deal_item.startDate = to_java_date(private_deal_item.startDate)
531
    t_private_deal_item.endDate = to_java_date(private_deal_item.endDate)
11566 vikram.rag 532
    t_private_deal_item.dealTextOption = private_deal_item.dealTextOption
11635 vikram.rag 533
    if private_deal_item.dealText is None: 
11613 vikram.rag 534
        t_private_deal_item.dealText = ''
535
    else:
536
        t_private_deal_item.dealText = private_deal_item.dealText    
11531 vikram.rag 537
    t_private_deal_item.isCod = private_deal_item.isCod
538
    t_private_deal_item.rank = private_deal_item.rank
11566 vikram.rag 539
    t_private_deal_item.dealFreebieOption = private_deal_item.dealFreebieOption
11606 vikram.rag 540
    t_private_deal_item.isActive = private_deal_item.isActive
11905 kshitij.so 541
    return t_private_deal_item
542
 
543
def to_t_amazonoutofsync(amazonOutOfSync):
544
    t_amazonoutofsync = TAmazonOutOfSync()
545
    if amazonOutOfSync is None:
546
        return t_amazonoutofsync
547
    else:
548
        t_amazonoutofsync.item_id = amazonOutOfSync.item_id
549
        t_amazonoutofsync.mfn = amazonOutOfSync.mfn
550
        t_amazonoutofsync.fba = amazonOutOfSync.fba
551
        t_amazonoutofsync.fbb = amazonOutOfSync.fbb
552
        return t_amazonoutofsync
553
 
554
def to_t_private_deals_comparison(item):
555
    xstr = lambda s: s or ""
556
    t_pdcomp = TPdPriceComp()
557
    pdComp = item[0]
558
    catItem  = item[1]
559
    t_pdcomp.item_id = pdComp.item_id
560
    t_pdcomp.dealPrice = pdComp.dealPrice
561
    t_pdcomp.saholicPrice = pdComp.saholicPrice
562
    t_pdcomp.sdPrice = pdComp.sdPrice
563
    t_pdcomp.fkPrice = pdComp.fkPrice
564
    t_pdcomp.amazonPrice = pdComp.amazonPrice
565
    t_pdcomp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
12169 kshitij.so 566
    t_pdcomp.lastProcessedTimestamp = to_java_date(pdComp.lastProcessedTimestamp)
11905 kshitij.so 567
    return t_pdcomp
568
 
12133 kshitij.so 569
def to_t_snapdeal_marketplace_item(item):
570
    mpItem = item[1]
571
    dItem = item[2]
572
    t_sd_item = to_t_snapdeal_item(item)
573
    t_sd_item.marketplaceItems = to_t_marketplace_items(mpItem)
574
    t_sd_item.item = to_t_item(dItem)
575
    return t_sd_item
576
 
577
def to_t_flipkart_marketplace_item(item):
578
    mpItem = item[1]
579
    dItem = item[2]
580
    t_fk_item = to_t_flipkart_item(item)
581
    t_fk_item.marketplaceItems = to_t_marketplace_items(mpItem)
582
    t_fk_item.item = to_t_item(dItem)
583
    return t_fk_item
12243 kshitij.so 584
 
12256 kshitij.so 585
def to_t_competitor_pricing(compPricing):
586
    xstr = lambda s: s or ""
587
    item = compPricing[0]
588
    catItem = compPricing[1]
589
    t_comp = TCompetitorPricing()
590
    t_comp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
591
    t_comp.item_id = item.item_id
592
    t_comp.lowestSnapdealPrice = item.lowestSnapdealPrice
593
    t_comp.lowestFlipkartPrice = item.lowestFlipkartPrice
594
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
595
    t_comp.ourSnapdealPrice = item.ourSnapdealPrice
596
    t_comp.ourSnapdealOfferPrice = item.ourSnapdealOfferPrice
597
    t_comp.ourSnapdealInventory = item.ourSnapdealInventory
598
    t_comp.lowestSnapdealOfferPrice = item.lowestSnapdealOfferPrice
599
    if item.lowestSnapdealSeller is None:
600
        t_comp.lowestSnapdealSeller=''
601
    else:
602
        t_comp.lowestSnapdealSeller = item.lowestSnapdealSeller
603
    t_comp.lowestSnapdealSellerInventory = item.lowestSnapdealSellerInventory
604
    t_comp.ourFlipkartPrice = item.ourFlipkartPrice
605
    t_comp.ourFlipkartInventory = item.ourFlipkartInventory
606
    if item.lowestFlipkartSeller is None:
607
        t_comp.lowestFlipkartSeller=''
608
    else:
609
        t_comp.lowestFlipkartSeller = item.lowestFlipkartSeller
610
    t_comp.ourMfnPrice = item.ourMfnPrice
611
    t_comp.ourFbaPrice = item.ourFbaPrice
612
    t_comp.ourMfnInventory = item.ourMfnInventory
613
    t_comp.ourFbaInventory = item.ourFbaInventory
614
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
615
    if item.lowestAmazonSeller is None:
616
        t_comp.lowestAmazonSeller=''
617
    else:
618
        t_comp.lowestAmazonSeller = item.lowestAmazonSeller
619
    return t_comp
12363 kshitij.so 620
 
621
def to_t_amazon_promotion(amazonPromotion):
622
    t_amazonPromotion = TAmazonPromotion()
623
    t_amazonPromotion.sku = amazonPromotion.sku
624
    t_amazonPromotion.startDate = to_java_date(datetime.datetime.combine(amazonPromotion.startDate, datetime.datetime.min.time()))
625
    t_amazonPromotion.endDate = to_java_date(datetime.datetime.combine(amazonPromotion.endDate, datetime.datetime.min.time()))
626
    t_amazonPromotion.updatedOnMarketplace = to_java_date(amazonPromotion.updatedOnMarketplace)
627
    t_amazonPromotion.promotionActive = amazonPromotion.promotionActive
628
    t_amazonPromotion.addedOn = to_java_date(amazonPromotion.addedOn)
629
    t_amazonPromotion.standardPrice = amazonPromotion.standardPrice
630
    t_amazonPromotion.salePrice = amazonPromotion.salePrice
631
    t_amazonPromotion.stateId = amazonPromotion.stateId
632
    t_amazonPromotion.promotionType = amazonPromotion.promotionType
633
    return t_amazonPromotion
634
 
635
def to_t_Amazonlisted_promo(amazonDetails):
636
    amazonlisted = amazonDetails[0]
637
    fbaPromo = amazonDetails[1]
638
    fbbPromo = amazonDetails[2]
639
    t_amazon = to_t_Amazonlisted(amazonlisted)
640
    if not (fbaPromo is None or len(fbaPromo)==0):
641
        t_amazon.fbaSalePrice = fbaPromo[0].salePrice
642
    if not (fbbPromo is None or len(fbbPromo)==0):
643
        t_amazon.fbbSalePrice = fbbPromo[0].salePrice
644
    return t_amazon
645
 
646
 
12256 kshitij.so 647