Subversion Repositories SmartDukaan

Rev

Rev 12256 | Rev 12396 | 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
234
    t_amazonlisted.fcAutoPricing = Amazonlisted.fcAutoPricing 
7291 vikram.rag 235
    return t_amazonlisted
236
 
8182 amar.kumar 237
def to_t_ebay_item(ebay_item):
238
    t_ebay_item = TEbayItem()
239
    t_ebay_item.ebayListingId = ebay_item.ebayListingId
240
    t_ebay_item.itemId = ebay_item.itemId
241
    t_ebay_item.listingName = ebay_item.listingName
242
    t_ebay_item.listingPrice = ebay_item.listingPrice
243
    t_ebay_item.listingExpiryDate = to_java_date(ebay_item.listingExpiryDate)
244
    t_ebay_item.subsidy = ebay_item.subsidy
8274 amit.gupta 245
    return t_ebay_item
246
 
247
def to_t_brand_info(brand_info):
248
    t_brand_info = TBrandInfo()
249
    t_brand_info.name = brand_info.name
250
    t_brand_info.serviceCenterLocatorUrl = brand_info.serviceCenterLocatorUrl
8739 vikram.rag 251
    return t_brand_info
252
 
253
def to_t_snapdeal_item(snapdealitem):
8754 vikram.rag 254
    if snapdealitem is None:
8746 vikram.rag 255
        t_snapdeal_item = TSnapdealItem()
256
        return t_snapdeal_item
8739 vikram.rag 257
    t_snapdeal_item = TSnapdealItem()
8754 vikram.rag 258
    t_snapdeal_item.item_id = snapdealitem[0].item_id
8739 vikram.rag 259
    t_snapdeal_item.warehouseId = snapdealitem[0].warehouseId
260
    t_snapdeal_item.exceptionPrice = snapdealitem[0].exceptionPrice
9242 kshitij.so 261
    t_snapdeal_item.transferPrice = snapdealitem[0].transferPrice
262
    t_snapdeal_item.sellingPrice = snapdealitem[0].sellingPrice
263
    t_snapdeal_item.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 264
    t_snapdeal_item.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 265
    t_snapdeal_item.commission = snapdealitem[0].commission
266
    t_snapdeal_item.serviceTax = snapdealitem[0].serviceTax
267
    t_snapdeal_item.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
268
    t_snapdeal_item.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
269
    t_snapdeal_item.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9404 vikram.rag 270
    t_snapdeal_item.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 271
    t_snapdeal_item.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 272
    t_snapdeal_item.supc = snapdealitem[0].supc
9724 kshitij.so 273
    t_snapdeal_item.shippingTime = snapdealitem[0].shippingTime
9242 kshitij.so 274
    return t_snapdeal_item
275
 
9724 kshitij.so 276
def to_t_snapdeal_item_details(snapdealitem,snapdealItemInventory):
9242 kshitij.so 277
    if snapdealitem is None:
278
        t_snapdeal_item_details = TSnapdealItemDetails()
279
        return t_snapdeal_item_details
280
    t_snapdeal_item_details = TSnapdealItemDetails()
281
    t_snapdeal_item_details.item_id = snapdealitem[0].item_id
282
    t_snapdeal_item_details.warehouseId = snapdealitem[0].warehouseId
283
    t_snapdeal_item_details.exceptionPrice = snapdealitem[0].exceptionPrice
284
    t_snapdeal_item_details.transferPrice = snapdealitem[0].transferPrice
285
    t_snapdeal_item_details.sellingPrice = snapdealitem[0].sellingPrice
286
    t_snapdeal_item_details.courierCost = snapdealitem[0].courierCost
11095 kshitij.so 287
    t_snapdeal_item_details.courierCostMarketplace = snapdealitem[0].courierCostMarketplace
9242 kshitij.so 288
    t_snapdeal_item_details.commission = snapdealitem[0].commission
289
    t_snapdeal_item_details.serviceTax = snapdealitem[0].serviceTax
290
    t_snapdeal_item_details.brand = snapdealitem[1].brand
291
    t_snapdeal_item_details.model_name = snapdealitem[1].model_name
292
    t_snapdeal_item_details.model_number = snapdealitem[1].model_number
293
    t_snapdeal_item_details.color = snapdealitem[1].color
294
    t_snapdeal_item_details.risky = snapdealitem[1].risky
295
    t_snapdeal_item_details.itemStatus = snapdealitem[1].status
296
    t_snapdeal_item_details.isListedOnSnapdeal = snapdealitem[0].isListedOnSnapdeal
297
    t_snapdeal_item_details.weight = snapdealitem[1].weight
298
    t_snapdeal_item_details.mrp = snapdealitem[1].mrp
299
    t_snapdeal_item_details.websiteSellingPrice = snapdealitem[1].sellingPrice
300
    t_snapdeal_item_details.suppressPriceFeed = snapdealitem[0].suppressPriceFeed
301
    t_snapdeal_item_details.suppressInventoryFeed = snapdealitem[0].suppressInventoryFeed
9478 kshitij.so 302
    t_snapdeal_item_details.maxNlc = snapdealitem[0].maxNlc
9456 vikram.rag 303
    t_snapdeal_item_details.skuAtSnapdeal = snapdealitem[0].skuAtSnapdeal
9568 kshitij.so 304
    t_snapdeal_item_details.supc = snapdealitem[0].supc
9724 kshitij.so 305
    t_snapdeal_item_details.shippingTime = snapdealitem[0].shippingTime
306
    if snapdealItemInventory is not None:
307
        t_snapdeal_item_details.lastUpdatedInventory = snapdealItemInventory.availability
308
        t_snapdeal_item_details.lastUpdatedInventoryTimestamp = snapdealItemInventory.lastUpdatedOnSnapdeal 
9242 kshitij.so 309
    return t_snapdeal_item_details
9621 manish.sha 310
 
311
def to_t_product_feed_submit(productfeedsubmit):
312
    if productfeedsubmit is None:
313
        t_product_feed_submit = TProductFeedSubmit()
314
        return t_product_feed_submit
315
    t_product_feed_submit = TProductFeedSubmit()
316
    t_product_feed_submit.catalogItemId = productfeedsubmit.catalogItemId
317
    t_product_feed_submit.stockLinkedFeed = productfeedsubmit.stockLinkedFeed
9724 kshitij.so 318
    return t_product_feed_submit
319
 
320
def to_t_marketplace_items(marketplaceItem):
321
    t_marketplace_item = TMarketplaceItems() 
322
    if marketplaceItem is None:
323
        return t_marketplace_item
324
    t_marketplace_item.itemId = marketplaceItem.itemId
325
    t_marketplace_item.source = marketplaceItem.source
326
    t_marketplace_item.emiFee = marketplaceItem.emiFee
327
    t_marketplace_item.courierCost = marketplaceItem.courierCost
11095 kshitij.so 328
    t_marketplace_item.courierCostMarketplace = marketplaceItem.courierCostMarketplace
9724 kshitij.so 329
    t_marketplace_item.closingFee = marketplaceItem.closingFee
330
    t_marketplace_item.commission = marketplaceItem.commission
331
    t_marketplace_item.returnProvision = marketplaceItem.returnProvision
332
    t_marketplace_item.vat = marketplaceItem.vat
333
    t_marketplace_item.packagingCost = marketplaceItem.packagingCost
334
    t_marketplace_item.otherCost = marketplaceItem.otherCost
335
    t_marketplace_item.serviceTax = marketplaceItem.serviceTax
336
    t_marketplace_item.autoIncrement = marketplaceItem.autoIncrement
337
    t_marketplace_item.autoDecrement = marketplaceItem.autoDecrement
338
    t_marketplace_item.autoFavourite = marketplaceItem.autoFavourite
339
    t_marketplace_item.manualFavourite = marketplaceItem.manualFavourite
340
    t_marketplace_item.currentSp = marketplaceItem.currentSp
341
    t_marketplace_item.currentTp = marketplaceItem.currentTp
342
    t_marketplace_item.minimumPossibleSp = marketplaceItem.minimumPossibleSp
343
    t_marketplace_item.minimumPossibleTp = marketplaceItem.minimumPossibleTp
344
    t_marketplace_item.lastCheckedTimestamp = to_java_date(marketplaceItem.lastCheckedTimestamp)
9923 kshitij.so 345
    t_marketplace_item.maximumSellingPrice = marketplaceItem.maximumSellingPrice
10287 kshitij.so 346
    t_marketplace_item.pgFee = marketplaceItem.pgFee
9724 kshitij.so 347
    return t_marketplace_item
9776 vikram.rag 348
 
349
def to_t_marketplace_itemprice(marketplaceitemprice):
350
    t_marketplace_priceitem = TMarketPlaceItemPrice()    
351
    t_marketplace_priceitem.item_id = marketplaceitemprice.item_id
352
    t_marketplace_priceitem.source = marketplaceitemprice.source
353
    t_marketplace_priceitem.sellingPrice = marketplaceitemprice.sellingPrice
354
    t_marketplace_priceitem.lastUpdatedOn = to_java_date(marketplaceitemprice.lastUpdatedOn)
355
    t_marketplace_priceitem.lastUpdatedOnMarketplace = to_java_date(marketplaceitemprice.lastUpdatedOnMarketplace)
356
    t_marketplace_priceitem.isPriceOverride = marketplaceitemprice.suppressPriceFeed
357
    t_marketplace_priceitem.isListedOnSource = marketplaceitemprice.isListedOnSource
358
    return t_marketplace_priceitem 
9779 kshitij.so 359
 
360
def to_t_marketplacepercentage(marketplacePercentage):
361
    t_marketplacepercentage = TMarketplacePercentage()
362
    if marketplacePercentage is None:
363
        return t_marketplacepercentage
364
    t_marketplacepercentage.source =  marketplacePercentage.source
365
    t_marketplacepercentage.emiFee =  marketplacePercentage.emiFee
366
    t_marketplacepercentage.closingFee = marketplacePercentage.closingFee
367
    t_marketplacepercentage.returnProvision = marketplacePercentage.returnProvision
368
    t_marketplacepercentage.commission = marketplacePercentage.commission
369
    t_marketplacepercentage.serviceTax = marketplacePercentage.serviceTax
10287 kshitij.so 370
    t_marketplacepercentage.pgFee = marketplacePercentage.pgFee
9779 kshitij.so 371
    return t_marketplacepercentage
9945 vikram.rag 372
 
373
def to_t_flipkart_item(flipkartItem):
374
    t_flipkartitem = TFlipkartItem()
375
    if flipkartItem is None:
376
        return t_flipkartitem
10097 kshitij.so 377
    t_flipkartitem.item_id = flipkartItem[0].item_id  
378
    t_flipkartitem.exceptionPrice = flipkartItem[0].exceptionPrice
379
    t_flipkartitem.warehouseId = flipkartItem[0].warehouseId
380
    t_flipkartitem.commissionValue  =  flipkartItem[0].commissionValue
381
    t_flipkartitem.serviceTaxValue  =  flipkartItem[0].serviceTaxValue
382
    t_flipkartitem.maxNlc = flipkartItem[0].maxNlc
383
    t_flipkartitem.skuAtFlipkart = flipkartItem[0].skuAtFlipkart
384
    t_flipkartitem.isListedOnFlipkart = flipkartItem[0].isListedOnFlipkart
385
    t_flipkartitem.suppressPriceFeed = flipkartItem[0].suppressPriceFeed
386
    t_flipkartitem.suppressInventoryFeed = flipkartItem[0].suppressInventoryFeed
387
    #t_flipkartitem.updatedOn = to_java_date(flipkartItem.updatedOn)
388
    t_flipkartitem.updatedBy = flipkartItem[0].updatedBy
389
    t_flipkartitem.flipkartSerialNumber = flipkartItem[0].flipkartSerialNumber
9945 vikram.rag 390
    return t_flipkartitem
10097 kshitij.so 391
 
392
def to_t_flipkart_item_details(flipkartitem,flipkartItemInventory):
393
    if flipkartitem is None:
394
        t_flipkart_item_details = TFlipkartItemDetails()
395
        return t_flipkart_item_details
396
    t_flipkart_item_details = TFlipkartItemDetails()
397
    t_flipkart_item_details.item_id = flipkartitem[0].item_id
398
    t_flipkart_item_details.warehouseId = flipkartitem[0].warehouseId
399
    t_flipkart_item_details.exceptionPrice = flipkartitem[0].exceptionPrice
400
    t_flipkart_item_details.commission = flipkartitem[0].commissionValue
401
    t_flipkart_item_details.serviceTax = flipkartitem[0].serviceTaxValue
402
    t_flipkart_item_details.brand = flipkartitem[1].brand
403
    t_flipkart_item_details.model_name = flipkartitem[1].model_name
404
    t_flipkart_item_details.model_number = flipkartitem[1].model_number
405
    t_flipkart_item_details.color = flipkartitem[1].color
406
    t_flipkart_item_details.risky = flipkartitem[1].risky
407
    t_flipkart_item_details.itemStatus = flipkartitem[1].status
408
    t_flipkart_item_details.isListedOnFlipkart = flipkartitem[0].isListedOnFlipkart
409
    t_flipkart_item_details.weight = flipkartitem[1].weight
410
    t_flipkart_item_details.mrp = flipkartitem[1].mrp
411
    t_flipkart_item_details.websiteSellingPrice = flipkartitem[1].sellingPrice
412
    t_flipkart_item_details.suppressPriceFeed = flipkartitem[0].suppressPriceFeed
413
    t_flipkart_item_details.suppressInventoryFeed = flipkartitem[0].suppressInventoryFeed
414
    t_flipkart_item_details.maxNlc = flipkartitem[0].maxNlc
415
    t_flipkart_item_details.skuAtFlipkart = flipkartitem[0].skuAtFlipkart
416
    t_flipkart_item_details.flipkartSerialNumber = flipkartitem[0].flipkartSerialNumber
10156 amar.kumar 417
    t_flipkart_item_details.category = flipkartitem[1].category
10097 kshitij.so 418
    if flipkartItemInventory is not None:
419
        t_flipkart_item_details.lastUpdatedInventory = flipkartItemInventory.availability
420
        #t_flipkart_item_details.lastUpdatedInventoryTimestamp = flipkartItemInventory.lastUpdatedOnFlipkart 
421
    return t_flipkart_item_details
11015 kshitij.so 422
 
423
def to_t_market_place_history(marketplaceHistory):
424
    t_marketplace_history = TMarketplaceHistory()
425
    if marketplaceHistory is None:
426
        return t_marketplace_history
427
    t_marketplace_history.item_id = marketplaceHistory.item_id
428
    t_marketplace_history.source = marketplaceHistory.source
429
    t_marketplace_history.timestamp = to_java_date(marketplaceHistory.timestamp)
11076 kshitij.so 430
    if marketplaceHistory.lowestPossibleTp is None:
431
        t_marketplace_history.lowest_possible_tp =0
432
    else:
433
        t_marketplace_history.lowest_possible_tp = int(marketplaceHistory.lowestPossibleTp)
434
    if marketplaceHistory.lowestPossibleSp is None:
435
        t_marketplace_history.lowest_possible_sp = 0
436
    else:
437
        t_marketplace_history.lowest_possible_sp = int(marketplaceHistory.lowestPossibleSp)
11015 kshitij.so 438
    t_marketplace_history.ourInventory = marketplaceHistory.ourInventory
439
    t_marketplace_history.otherInventory = marketplaceHistory.otherInventory
440
    t_marketplace_history.secondLowestInventory = marketplaceHistory.secondLowestInventory
441
    t_marketplace_history.ourRank = marketplaceHistory.ourRank
11076 kshitij.so 442
    if marketplaceHistory.ourOfferPrice is None:
443
        t_marketplace_history.ourOfferPrice = 0
444
    else: 
445
        t_marketplace_history.ourOfferPrice = int(marketplaceHistory.ourOfferPrice)
446
    if marketplaceHistory.ourSellingPrice is None:
447
        t_marketplace_history.ourSellingPrice = 0
448
    else:
449
        t_marketplace_history.ourSellingPrice = int(marketplaceHistory.ourSellingPrice)
450
    if marketplaceHistory.ourTp is None:
451
        t_marketplace_history.ourTp = 0
452
    else:
453
        t_marketplace_history.ourTp = int(marketplaceHistory.ourTp)
454
    if marketplaceHistory.ourNlc is None:
455
        t_marketplace_history.ourNlc = 0
456
    else:
457
        t_marketplace_history.ourNlc = int(marketplaceHistory.ourNlc)
11015 kshitij.so 458
    t_marketplace_history.competitiveCategory = marketplaceHistory.competitiveCategory
459
    t_marketplace_history.risky = marketplaceHistory.risky
11076 kshitij.so 460
    if marketplaceHistory.lowestOfferPrice is None:
461
        t_marketplace_history.lowestOfferPrice = 0
462
    else:
463
        t_marketplace_history.lowestOfferPrice = int(marketplaceHistory.lowestOfferPrice)
464
    if marketplaceHistory.lowestSellingPrice is None:
465
        t_marketplace_history.lowestSellingPrice = 0
466
    else:
467
        t_marketplace_history.lowestSellingPrice = int(marketplaceHistory.lowestSellingPrice)
468
    if marketplaceHistory.lowestTp is None:
469
        t_marketplace_history.lowestTp = 0
470
    else:
471
        t_marketplace_history.lowestTp = int(marketplaceHistory.lowestTp)
11015 kshitij.so 472
    if marketplaceHistory.lowestSellerName is None:
473
        t_marketplace_history.lowestSellerName = ''
474
    else:
475
        t_marketplace_history.lowestSellerName = marketplaceHistory.lowestSellerName
11076 kshitij.so 476
    if marketplaceHistory.proposedSellingPrice is None:
477
        t_marketplace_history.proposedSellingPrice = 0
478
    else:
479
        t_marketplace_history.proposedSellingPrice = int(marketplaceHistory.proposedSellingPrice)
480
    if marketplaceHistory.proposedTp is None:
481
        t_marketplace_history.proposedTp = 0
482
    else:
483
        t_marketplace_history.proposedTp = int(marketplaceHistory.proposedTp)
484
    if marketplaceHistory.targetNlc is None:
485
        t_marketplace_history.targetNlc = 0
486
    else:
487
        t_marketplace_history.targetNlc = int(marketplaceHistory.targetNlc)
11015 kshitij.so 488
    t_marketplace_history.salesPotential = marketplaceHistory.salesPotential
489
    if marketplaceHistory.secondLowestSellerName is None:
490
        t_marketplace_history.secondLowestSellerName = ''
491
    else:
492
        t_marketplace_history.secondLowestSellerName = marketplaceHistory.secondLowestSellerName
11017 kshitij.so 493
    if marketplaceHistory.secondLowestSellingPrice is None:
11076 kshitij.so 494
        t_marketplace_history.secondLowestSellingPrice=0
11017 kshitij.so 495
    else:
11076 kshitij.so 496
        t_marketplace_history.secondLowestSellingPrice = int(marketplaceHistory.secondLowestSellingPrice)
11017 kshitij.so 497
    if marketplaceHistory.secondLowestOfferPrice is None:
11076 kshitij.so 498
        t_marketplace_history.secondLowestOfferPrice = 0
11017 kshitij.so 499
    else:
11076 kshitij.so 500
        t_marketplace_history.secondLowestOfferPrice = int(marketplaceHistory.secondLowestOfferPrice)
11017 kshitij.so 501
    if marketplaceHistory.secondLowestTp is None:
11076 kshitij.so 502
        t_marketplace_history.secondLowestTp=0
11017 kshitij.so 503
    else:
11076 kshitij.so 504
        t_marketplace_history.secondLowestTp = int(marketplaceHistory.secondLowestTp)
11015 kshitij.so 505
    t_marketplace_history.marginIncreasedPotential = marketplaceHistory.marginIncreasedPotential
11076 kshitij.so 506
    if marketplaceHistory.margin is None:
507
        t_marketplace_history.margin = 0
508
    else:
509
        t_marketplace_history.margin = int(marketplaceHistory.margin)
11015 kshitij.so 510
    t_marketplace_history.ourEnoughStock = marketplaceHistory.ourEnoughStock
511
    t_marketplace_history.totalSeller = marketplaceHistory.totalSeller
512
    t_marketplace_history.averageSale = marketplaceHistory.avgSales
513
    t_marketplace_history.toGroup = marketplaceHistory.toGroup
11076 kshitij.so 514
    t_marketplace_history.decision = marketplaceHistory.decision
515
    t_marketplace_history.reason = marketplaceHistory.reason
11015 kshitij.so 516
    return t_marketplace_history
9945 vikram.rag 517
 
11531 vikram.rag 518
def to_t_private_deal(private_deal_item):
519
    if private_deal_item is None:
520
        t_private_deal_item = TPrivateDeal()
521
        return t_private_deal_item
522
    t_private_deal_item = TPrivateDeal()
523
    t_private_deal_item.item_id = private_deal_item.item_id
524
    t_private_deal_item.dealPrice = private_deal_item.dealPrice
525
    t_private_deal_item.dealFreebieItemId = private_deal_item.dealFreebieItemId
11579 vikram.rag 526
    t_private_deal_item.startDate = to_java_date(private_deal_item.startDate)
527
    t_private_deal_item.endDate = to_java_date(private_deal_item.endDate)
11566 vikram.rag 528
    t_private_deal_item.dealTextOption = private_deal_item.dealTextOption
11635 vikram.rag 529
    if private_deal_item.dealText is None: 
11613 vikram.rag 530
        t_private_deal_item.dealText = ''
531
    else:
532
        t_private_deal_item.dealText = private_deal_item.dealText    
11531 vikram.rag 533
    t_private_deal_item.isCod = private_deal_item.isCod
534
    t_private_deal_item.rank = private_deal_item.rank
11566 vikram.rag 535
    t_private_deal_item.dealFreebieOption = private_deal_item.dealFreebieOption
11606 vikram.rag 536
    t_private_deal_item.isActive = private_deal_item.isActive
11905 kshitij.so 537
    return t_private_deal_item
538
 
539
def to_t_amazonoutofsync(amazonOutOfSync):
540
    t_amazonoutofsync = TAmazonOutOfSync()
541
    if amazonOutOfSync is None:
542
        return t_amazonoutofsync
543
    else:
544
        t_amazonoutofsync.item_id = amazonOutOfSync.item_id
545
        t_amazonoutofsync.mfn = amazonOutOfSync.mfn
546
        t_amazonoutofsync.fba = amazonOutOfSync.fba
547
        t_amazonoutofsync.fbb = amazonOutOfSync.fbb
548
        return t_amazonoutofsync
549
 
550
def to_t_private_deals_comparison(item):
551
    xstr = lambda s: s or ""
552
    t_pdcomp = TPdPriceComp()
553
    pdComp = item[0]
554
    catItem  = item[1]
555
    t_pdcomp.item_id = pdComp.item_id
556
    t_pdcomp.dealPrice = pdComp.dealPrice
557
    t_pdcomp.saholicPrice = pdComp.saholicPrice
558
    t_pdcomp.sdPrice = pdComp.sdPrice
559
    t_pdcomp.fkPrice = pdComp.fkPrice
560
    t_pdcomp.amazonPrice = pdComp.amazonPrice
561
    t_pdcomp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
12169 kshitij.so 562
    t_pdcomp.lastProcessedTimestamp = to_java_date(pdComp.lastProcessedTimestamp)
11905 kshitij.so 563
    return t_pdcomp
564
 
12133 kshitij.so 565
def to_t_snapdeal_marketplace_item(item):
566
    mpItem = item[1]
567
    dItem = item[2]
568
    t_sd_item = to_t_snapdeal_item(item)
569
    t_sd_item.marketplaceItems = to_t_marketplace_items(mpItem)
570
    t_sd_item.item = to_t_item(dItem)
571
    return t_sd_item
572
 
573
def to_t_flipkart_marketplace_item(item):
574
    mpItem = item[1]
575
    dItem = item[2]
576
    t_fk_item = to_t_flipkart_item(item)
577
    t_fk_item.marketplaceItems = to_t_marketplace_items(mpItem)
578
    t_fk_item.item = to_t_item(dItem)
579
    return t_fk_item
12243 kshitij.so 580
 
12256 kshitij.so 581
def to_t_competitor_pricing(compPricing):
582
    xstr = lambda s: s or ""
583
    item = compPricing[0]
584
    catItem = compPricing[1]
585
    t_comp = TCompetitorPricing()
586
    t_comp.productName = xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)
587
    t_comp.item_id = item.item_id
588
    t_comp.lowestSnapdealPrice = item.lowestSnapdealPrice
589
    t_comp.lowestFlipkartPrice = item.lowestFlipkartPrice
590
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
591
    t_comp.ourSnapdealPrice = item.ourSnapdealPrice
592
    t_comp.ourSnapdealOfferPrice = item.ourSnapdealOfferPrice
593
    t_comp.ourSnapdealInventory = item.ourSnapdealInventory
594
    t_comp.lowestSnapdealOfferPrice = item.lowestSnapdealOfferPrice
595
    if item.lowestSnapdealSeller is None:
596
        t_comp.lowestSnapdealSeller=''
597
    else:
598
        t_comp.lowestSnapdealSeller = item.lowestSnapdealSeller
599
    t_comp.lowestSnapdealSellerInventory = item.lowestSnapdealSellerInventory
600
    t_comp.ourFlipkartPrice = item.ourFlipkartPrice
601
    t_comp.ourFlipkartInventory = item.ourFlipkartInventory
602
    if item.lowestFlipkartSeller is None:
603
        t_comp.lowestFlipkartSeller=''
604
    else:
605
        t_comp.lowestFlipkartSeller = item.lowestFlipkartSeller
606
    t_comp.ourMfnPrice = item.ourMfnPrice
607
    t_comp.ourFbaPrice = item.ourFbaPrice
608
    t_comp.ourMfnInventory = item.ourMfnInventory
609
    t_comp.ourFbaInventory = item.ourFbaInventory
610
    t_comp.lowestAmazonPrice = item.lowestAmazonPrice
611
    if item.lowestAmazonSeller is None:
612
        t_comp.lowestAmazonSeller=''
613
    else:
614
        t_comp.lowestAmazonSeller = item.lowestAmazonSeller
615
    return t_comp
12363 kshitij.so 616
 
617
def to_t_amazon_promotion(amazonPromotion):
618
    t_amazonPromotion = TAmazonPromotion()
619
    t_amazonPromotion.sku = amazonPromotion.sku
620
    t_amazonPromotion.startDate = to_java_date(datetime.datetime.combine(amazonPromotion.startDate, datetime.datetime.min.time()))
621
    t_amazonPromotion.endDate = to_java_date(datetime.datetime.combine(amazonPromotion.endDate, datetime.datetime.min.time()))
622
    t_amazonPromotion.updatedOnMarketplace = to_java_date(amazonPromotion.updatedOnMarketplace)
623
    t_amazonPromotion.promotionActive = amazonPromotion.promotionActive
624
    t_amazonPromotion.addedOn = to_java_date(amazonPromotion.addedOn)
625
    t_amazonPromotion.standardPrice = amazonPromotion.standardPrice
626
    t_amazonPromotion.salePrice = amazonPromotion.salePrice
627
    t_amazonPromotion.stateId = amazonPromotion.stateId
628
    t_amazonPromotion.promotionType = amazonPromotion.promotionType
629
    return t_amazonPromotion
630
 
631
def to_t_Amazonlisted_promo(amazonDetails):
632
    amazonlisted = amazonDetails[0]
633
    fbaPromo = amazonDetails[1]
634
    fbbPromo = amazonDetails[2]
635
    t_amazon = to_t_Amazonlisted(amazonlisted)
636
    if not (fbaPromo is None or len(fbaPromo)==0):
637
        t_amazon.fbaSalePrice = fbaPromo[0].salePrice
638
    if not (fbbPromo is None or len(fbbPromo)==0):
639
        t_amazon.fbbSalePrice = fbbPromo[0].salePrice
640
    return t_amazon
641
 
642
 
12256 kshitij.so 643