Subversion Repositories SmartDukaan

Rev

Rev 9505 | Rev 9520 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9505 Rev 9512
Line 25... Line 25...
25
    sys.path.insert(0, os.getcwd())
25
    sys.path.insert(0, os.getcwd())
26
 
26
 
27
 
27
 
28
class _SnapdealItemInfo:
28
class _SnapdealItemInfo:
29
    
29
    
30
    def __init__(self, item_id, product_group, category_name, our_nlc, brand, model_name, model_number, color, weight, parent_category, risky, issue):
30
    def __init__(self, item_id, product_group, category_name, our_nlc, brand, model_name, model_number, color, weight, parent_category, risky, issue, dealerPrice):
31
        self.item_id = item_id
31
        self.item_id = item_id
32
        self.product_group = product_group
32
        self.product_group = product_group
33
        self.category_name = category_name
33
        self.category_name = category_name
34
        self.our_nlc = our_nlc
34
        self.our_nlc = our_nlc
35
        self.brand = brand
35
        self.brand = brand
Line 38... Line 38...
38
        self.color = color
38
        self.color = color
39
        self.weight = weight
39
        self.weight = weight
40
        self.parent_category = parent_category
40
        self.parent_category = parent_category
41
        self.risky = risky
41
        self.risky = risky
42
        self.issue = issue
42
        self.issue = issue
-
 
43
        self.dealerPrice = dealerPrice
43
        
44
        
44
 
45
 
45
class SnapdealDetails:
46
class SnapdealDetails:
46
    def __init__(self, supc, ourSp, offerPrice, ourInventory, otherInventory, rank, lowestSellerName,lowestSp,secondLowestSellerName,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice):
47
    def __init__(self, supc, ourSp, offerPrice, ourInventory, otherInventory, rank, lowestSellerName,lowestSp,secondLowestSellerName,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice):
47
        self.supc = supc
48
        self.supc = supc
Line 131... Line 132...
131
                item_id = sheet.row_values(rownum)[0]
132
                item_id = sheet.row_values(rownum)[0]
132
                snapdeal_item = SnapdealItem.query.filter_by(skuAtSnapdeal=item_id).one()
133
                snapdeal_item = SnapdealItem.query.filter_by(skuAtSnapdeal=item_id).one()
133
                item = Item.query.filter_by(id=snapdeal_item.item_id).one()
134
                item = Item.query.filter_by(id=snapdeal_item.item_id).one()
134
            except Exception as ex:
135
            except Exception as ex:
135
                print ex
136
                print ex
136
                one_line = _SnapdealItemInfo(sheet.row_values(rownum)[0], '', '', 0, '', '','', '', 0, '', False,"item_related")
137
                one_line = _SnapdealItemInfo(sheet.row_values(rownum)[0], '', '', 0, '', '','', '', 0, '', False,"item_related",0)
137
                all_supc.append(supc)
138
                all_supc.append(supc)
138
                all_lines.append(one_line)
139
                all_lines.append(one_line)
139
                continue
140
                continue
140
            
141
            
141
        category = Category.query.filter_by(id=item.category).one()
142
        category = Category.query.filter_by(id=item.category).one()
142
        parent_category = Category.query.filter_by(id=category.parent_category_id).first()
143
        parent_category = Category.query.filter_by(id=category.parent_category_id).first()
143
        try:
144
        try:
144
            snapdeal_item = SnapdealItem.query.filter_by(item_id=item.id).one()
145
            snapdeal_item = SnapdealItem.query.filter_by(item_id=item.id).one()
145
            warehouse = iclient.getWarehouse(snapdeal_item.warehouseId)
146
            warehouse = iclient.getWarehouse(snapdeal_item.warehouseId)
146
            item_pricing = iclient.getItemPricing(item.id, warehouse.vendor.id)
147
            item_pricing = iclient.getItemPricing(item.id, warehouse.vendor.id)
147
            one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"")
148
            one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"",item_pricing.dealerPrice)
148
        except Exception as e:
149
        except Exception as e:
149
            print "Problem with item id ",item.id
150
            print "Problem with item id ",item.id
150
            print e
151
            print e
151
            one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"our_side")
152
            one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"our_side",item_pricing.dealerPrice)
152
            
153
            
153
        #TO BE USED LATER
154
        #TO BE USED LATER
154
        #inventory_snapshot = iclient.getInventorySnapshot(0)
155
        #inventory_snapshot = iclient.getInventorySnapshot(0)
155
        #warehouses_ours = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("OURS"), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
156
        #warehouses_ours = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("OURS"), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
156
        #warehouses_third_party = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("THIRD_PARTY "), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
157
        #warehouses_third_party = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("THIRD_PARTY "), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
Line 229... Line 230...
229
    sheet.write(0, 17, "Lowest TP", heading_xf)
230
    sheet.write(0, 17, "Lowest TP", heading_xf)
230
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
231
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
231
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
232
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
232
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
233
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
233
    sheet.write(0, 21, "Our NLC", heading_xf)
234
    sheet.write(0, 21, "Our NLC", heading_xf)
-
 
235
    sheet.write(0, 22, "Our Dealer Price", heading_xf)
234
    sheet.write(0, 22, "Lowest Possible TP", heading_xf)
236
    sheet.write(0, 23, "Lowest Possible TP", heading_xf)
235
    sheet.write(0, 23, "Lowest Possible SP", heading_xf)
237
    sheet.write(0, 24, "Lowest Possible SP", heading_xf)
236
    sheet.write(0, 24, "Competition Basis ", heading_xf)
238
    sheet.write(0, 25, "Competition Basis ", heading_xf)
237
    sheet.write(0, 25, "Can Compete", heading_xf)
239
    sheet.write(0, 26, "Can Compete", heading_xf)
238
    sheet.write(0, 26, "Target TP", heading_xf)
240
    sheet.write(0, 27, "Target TP", heading_xf)
239
    sheet.write(0, 27, "Target SP", heading_xf)  
241
    sheet.write(0, 28, "Target SP", heading_xf)  
240
    sheet.write(0, 28, "Target NLC", heading_xf)
242
    sheet.write(0, 29, "Target NLC", heading_xf)
241
    sheet.write(0, 29, "Sales Potential", heading_xf)
243
    sheet.write(0, 30, "Sales Potential", heading_xf)
242
    
244
    
243
    i, sheet_iterator=1,1
245
    i, sheet_iterator=1,1
244
    for one_line in all_lines:
246
    for one_line in all_lines:
245
        if len(one_line.issue)!=0:
247
        if len(one_line.issue)!=0:
246
            exceptionItems.append(one_line)
248
            exceptionItems.append(one_line)
Line 285... Line 287...
285
            temp.append(one_line)
287
            temp.append(one_line)
286
            buyBoxItems.append(temp)
288
            buyBoxItems.append(temp)
287
            i+=1
289
            i+=1
288
            continue
290
            continue
289
        
291
        
-
 
292
        if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice == supc_data.ourSp:
-
 
293
            competitionBasis ='SP'
-
 
294
        else:
-
 
295
            competitionBasis ='TP'
290
        
296
        
291
        if (lowestTp > lowest_possible_tp and supc_data.ourInventory!=0):
297
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
292
            temp=[]
-
 
293
            temp.append(supc_data)
-
 
294
            temp.append(one_line)
-
 
295
            competitive.append(temp)
-
 
296
            i+=1
-
 
297
            continue
-
 
298
        
-
 
299
        if (lowestTp > lowest_possible_tp and supc_data.ourInventory==0):
-
 
300
            temp=[]
-
 
301
            temp.append(supc_data)
-
 
302
            temp.append(one_line)
-
 
303
            competitiveNoInventory.append(temp)
-
 
304
            i+=1
-
 
305
            continue
-
 
306
        
298
        
-
 
299
        if competitionBasis=='SP':
-
 
300
            if supc_data.lowestSp > lowest_possible_sp and supc_data.ourInventory!=0:
-
 
301
                temp=[]
-
 
302
                temp.append(supc_data)
-
 
303
                temp.append(one_line)
-
 
304
                competitive.append(temp)
-
 
305
                i+=1
-
 
306
                continue
-
 
307
        else:
-
 
308
            if lowestTp > lowest_possible_tp and supc_data.ourInventory!=0:
-
 
309
                temp=[]
-
 
310
                temp.append(supc_data)
-
 
311
                temp.append(one_line)
-
 
312
                competitive.append(temp)
-
 
313
                i+=1
-
 
314
                continue
307
        
315
        
-
 
316
        if competitionBasis=='SP':
-
 
317
            if supc_data.lowestSp > lowest_possible_sp and supc_data.ourInventory==0:
-
 
318
                temp=[]
-
 
319
                temp.append(supc_data)
-
 
320
                temp.append(one_line)
-
 
321
                competitiveNoInventory.append(temp)
-
 
322
                i+=1
-
 
323
                continue
-
 
324
        else:
-
 
325
            if lowestTp > lowest_possible_tp and supc_data.ourInventory==0:
-
 
326
                temp=[]
-
 
327
                temp.append(supc_data)
-
 
328
                temp.append(one_line)
-
 
329
                competitiveNoInventory.append(temp)
-
 
330
                i+=1
-
 
331
                continue        
-
 
332
 
308
        sheet.write(sheet_iterator, 0, one_line.item_id)
333
        sheet.write(sheet_iterator, 0, one_line.item_id)
309
        sheet.write(sheet_iterator, 1, one_line.category_name)
334
        sheet.write(sheet_iterator, 1, one_line.category_name)
310
        sheet.write(sheet_iterator, 2, one_line.product_group)
335
        sheet.write(sheet_iterator, 2, one_line.product_group)
311
        sheet.write(sheet_iterator, 3, supc)
336
        sheet.write(sheet_iterator, 3, supc)
312
        sheet.write(sheet_iterator, 4, one_line.brand)
337
        sheet.write(sheet_iterator, 4, one_line.brand)
Line 329... Line 354...
329
        sheet.write(sheet_iterator, 17, round(lowestTp))
354
        sheet.write(sheet_iterator, 17, round(lowestTp))
330
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
355
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
331
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
356
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
332
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
357
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
333
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
358
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
-
 
359
        sheet.write(sheet_iterator, 22, one_line.dealerPrice)
334
        if supc_data.rank==1:
360
        if supc_data.rank==1:
335
            i+=1
361
            i+=1
336
            sheet_iterator+=1
362
            sheet_iterator+=1
337
            continue
363
            continue
338
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
364
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
339
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
365
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
340
        sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
366
        sheet.write(sheet_iterator, 23, round(lowest_possible_tp))
341
        sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
367
        sheet.write(sheet_iterator, 24, round(lowest_possible_sp))
342
        competitionBasis ='TP'
368
        competitionBasis ='TP'
343
        if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice == supc_data.ourSp:
369
        if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice == supc_data.ourSp:
344
            competitionBasis ='SP'
370
            competitionBasis ='SP'
345
            sheet.write(sheet_iterator, 24, 'SP')
371
            sheet.write(sheet_iterator, 25, 'SP')
346
        else:
372
        else:
347
            sheet.write(sheet_iterator, 24, 'TP')
373
            sheet.write(sheet_iterator, 25, 'TP')
348
        proposed_tp = 0
374
        proposed_tp = 0
-
 
375
        if competitionBasis=='SP':
349
        if lowestTp > lowest_possible_tp:
376
            if supc_data.lowestSp > lowest_possible_sp:
350
            sheet.write(sheet_iterator, 25, "Yes")
377
                sheet.write(sheet_iterator, 26, "Yes")
-
 
378
            else:
-
 
379
                sheet.write(sheet_iterator, 26, "No")
351
        else:
380
        else:
-
 
381
            if lowestTp > lowest_possible_tp:
-
 
382
                sheet.write(sheet_iterator, 26, "Yes")
-
 
383
            else:
352
            sheet.write(sheet_iterator, 25, "No")
384
                sheet.write(sheet_iterator, 26, "No")
353
        if competitionBasis=='SP':
385
        if competitionBasis=='SP':
354
            proposed_sp = supc_data.lowestSp - max(10, supc_data.lowestSp*0.001)
386
            proposed_sp = supc_data.lowestSp - max(10, supc_data.lowestSp*0.001)
355
            proposed_tp = proposed_sp*0.9597-courierCost
387
            proposed_tp = proposed_sp*0.9597-courierCost
356
            sheet.write(sheet_iterator, 26, round(proposed_tp))
388
            sheet.write(sheet_iterator, 27, round(proposed_tp))
357
            sheet.write(sheet_iterator, 27, round(proposed_sp))
389
            sheet.write(sheet_iterator, 28, round(proposed_sp))
358
            sheet.write(sheet_iterator, 28, round(proposed_tp*0.988-21)) 
390
            sheet.write(sheet_iterator, 29, round(proposed_tp*0.988-21)) 
359
        else:    
391
        else:    
360
            proposed_tp  = lowestTp - max(10, lowestTp*0.001)
392
            proposed_tp  = lowestTp - max(10, lowestTp*0.001)
361
            sheet.write(sheet_iterator, 26, round(proposed_tp))
393
            sheet.write(sheet_iterator, 27, round(proposed_tp))
362
            sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
394
            sheet.write(sheet_iterator, 28, round((proposed_tp+courierCost)/0.9597))
363
            sheet.write(sheet_iterator, 28, round(proposed_tp*0.988-21)) 
395
            sheet.write(sheet_iterator, 29, round(proposed_tp*0.988-21)) 
364
        
396
        
365
        
397
        
366
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
398
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
367
            sheet.write(sheet_iterator, 29, "HIGH")
399
            sheet.write(sheet_iterator, 30, "HIGH")
-
 
400
        elif (supc_data.lowestOfferPrice -
368
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
401
               one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
369
            sheet.write(sheet_iterator, 29, "MEDIUM")
402
            sheet.write(sheet_iterator, 30, "MEDIUM")
370
        else:
403
        else:
371
            sheet.write(sheet_iterator, 29, "LOW")
404
            sheet.write(sheet_iterator, 30, "LOW")
372
        i= i+1
405
        i= i+1
373
        sheet_iterator+=1
406
        sheet_iterator+=1
374
        
407
        
375
    createSheetForBuyBoxItems(buyBoxItems,wbk)
408
    createSheetForBuyBoxItems(buyBoxItems,wbk)
376
    createSheetForCometitiveItems(competitive,wbk)
409
    createSheetForCometitiveItems(competitive,wbk)
Line 414... Line 447...
414
    sheet.write(0, 18, "Second Lowest Offer Price", heading_xf)
447
    sheet.write(0, 18, "Second Lowest Offer Price", heading_xf)
415
    sheet.write(0, 19, "Second Lowest Seller TP", heading_xf)
448
    sheet.write(0, 19, "Second Lowest Seller TP", heading_xf)
416
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
449
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
417
    sheet.write(0, 21, "Second Lowest Seller Inventory", heading_xf)
450
    sheet.write(0, 21, "Second Lowest Seller Inventory", heading_xf)
418
    sheet.write(0, 22, "Our NLC", heading_xf)
451
    sheet.write(0, 22, "Our NLC", heading_xf)
-
 
452
    sheet.write(0, 23, "Our Dealer Price", heading_xf)
419
    sheet.write(0, 23, "Competition Basis", heading_xf)
453
    sheet.write(0, 24, "Competition Basis", heading_xf)
420
    sheet.write(0, 24, "Target TP", heading_xf)
454
    sheet.write(0, 25, "Target TP", heading_xf)
421
    sheet.write(0, 25, "Target SP", heading_xf)
455
    sheet.write(0, 26, "Target SP", heading_xf)
422
    sheet.write(0, 26, "MARGIN INCREASED POTENTIAL", heading_xf)
456
    sheet.write(0, 27, "MARGIN INCREASED POTENTIAL", heading_xf)
423
    
457
    
424
    i=1
458
    i=1
425
    
459
    
426
    for data in buyBoxItems:
460
    for data in buyBoxItems:
427
        supc_data =data[0]
461
        supc_data =data[0]
Line 463... Line 497...
463
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
497
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
464
        sheet.write(i, 19, round(secondlowestTp))
498
        sheet.write(i, 19, round(secondlowestTp))
465
        sheet.write(i, 20, supc_data.ourInventory)
499
        sheet.write(i, 20, supc_data.ourInventory)
466
        sheet.write(i, 21, supc_data.secondLowestSellerInventory)
500
        sheet.write(i, 21, supc_data.secondLowestSellerInventory)
467
        sheet.write(i, 22, one_line.our_nlc)
501
        sheet.write(i, 22, one_line.our_nlc)
-
 
502
        sheet.write(i, 23, one_line.dealerPrice)
468
        
503
        
469
        competitionBasis ='TP'
504
        competitionBasis ='TP'
470
        if (supc_data.secondLowestSellerOfferPrice == supc_data.secondLowestSellerSp) and supc_data.ourOfferPrice==supc_data.ourSp:
505
        if (supc_data.secondLowestSellerOfferPrice == supc_data.secondLowestSellerSp) and supc_data.ourOfferPrice==supc_data.ourSp:
471
            competitionBasis ='SP'
506
            competitionBasis ='SP'
472
            sheet.write(i, 23, 'SP')
507
            sheet.write(i, 24, 'SP')
473
        else:
508
        else:
474
            sheet.write(i, 23, 'TP')
509
            sheet.write(i, 24, 'TP')
475
        
510
        
476
        if competitionBasis=='SP':
511
        if competitionBasis=='SP':
477
            proposed_sp = max(supc_data.secondLowestSellerSp - max((20, supc_data.secondLowestSellerSp*0.002)), lowest_possible_sp)
512
            proposed_sp = max(supc_data.secondLowestSellerSp - max((20, supc_data.secondLowestSellerSp*0.002)), lowest_possible_sp)
478
            proposed_tp = proposed_sp*0.9597-courierCost
513
            proposed_tp = proposed_sp*0.9597-courierCost
479
            sheet.write(i, 24, round(proposed_tp))
514
            sheet.write(i, 25, round(proposed_tp))
480
            sheet.write(i, 25, round(proposed_sp))
515
            sheet.write(i, 26, round(proposed_sp))
481
        else:    
516
        else:    
482
            proposed_tp  = max(secondlowestTp - max((20, secondlowestTp*0.002)), lowest_possible_tp)
517
            proposed_tp  = max(secondlowestTp - max((20, secondlowestTp*0.002)), lowest_possible_tp)
483
            sheet.write(i, 24, round(proposed_tp))
518
            sheet.write(i, 25, round(proposed_tp))
484
            sheet.write(i, 25, round((proposed_tp+courierCost)/0.9597))
519
            sheet.write(i, 26, round((proposed_tp+courierCost)/0.9597))
485
        
520
        
486
        sheet.write(i, 26, round(proposed_tp-(supc_data.ourSp*0.9597-courierCost)))     
521
        sheet.write(i, 27, round(proposed_tp-(supc_data.ourSp*0.9597-courierCost)))     
487
        i+=1
522
        i+=1
488
 
523
 
489
 
524
 
490
def createSheetForCometitiveItems(competitiveItems,wbk):
525
def createSheetForCometitiveItems(competitiveItems,wbk):
491
    sheet = wbk.add_sheet('Can Compete-With Inventory')
526
    sheet = wbk.add_sheet('Can Compete-With Inventory')
Line 516... Line 551...
516
    sheet.write(0, 17, "Lowest TP", heading_xf)
551
    sheet.write(0, 17, "Lowest TP", heading_xf)
517
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
552
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
518
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
553
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
519
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
554
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
520
    sheet.write(0, 21, "Our NLC", heading_xf)
555
    sheet.write(0, 21, "Our NLC", heading_xf)
-
 
556
    sheet.write(0, 22, "Our Dealer Price", heading_xf)
521
    sheet.write(0, 22, "Lowest Possible TP", heading_xf)
557
    sheet.write(0, 23, "Lowest Possible TP", heading_xf)
522
    sheet.write(0, 23, "Lowest Possible SP", heading_xf)
558
    sheet.write(0, 24, "Lowest Possible SP", heading_xf)
523
    sheet.write(0, 24, "Competition Basis ", heading_xf)
559
    sheet.write(0, 25, "Competition Basis ", heading_xf)
524
    sheet.write(0, 25, "Can Compete", heading_xf)
560
    sheet.write(0, 26, "Can Compete", heading_xf)
525
    sheet.write(0, 26, "Target TP", heading_xf)
561
    sheet.write(0, 27, "Target TP", heading_xf)
526
    sheet.write(0, 27, "Target SP", heading_xf)  
562
    sheet.write(0, 28, "Target SP", heading_xf)  
527
    sheet.write(0, 28, "Sales Potential", heading_xf)
563
    sheet.write(0, 29, "Sales Potential", heading_xf)
528
    
564
    
529
    i, sheet_iterator=1,1
565
    i, sheet_iterator=1,1
530
    for data in competitiveItems:
566
    for data in competitiveItems:
531
        supc_data =data[0]
567
        supc_data =data[0]
532
        one_line = data[1]
568
        one_line = data[1]
Line 565... Line 601...
565
        sheet.write(sheet_iterator, 17, round(lowestTp))
601
        sheet.write(sheet_iterator, 17, round(lowestTp))
566
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
602
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
567
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
603
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
568
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
604
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
569
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
605
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
-
 
606
        sheet.write(sheet_iterator, 22, one_line.dealerPrice)
570
        if supc_data.rank==1:
607
        if supc_data.rank==1:
571
            i+=1
608
            i+=1
572
            sheet_iterator+=1
609
            sheet_iterator+=1
573
            continue
610
            continue
574
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
611
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
575
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
612
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
576
        sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
613
        sheet.write(sheet_iterator, 23, round(lowest_possible_tp))
577
        sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
614
        sheet.write(sheet_iterator, 24, round(lowest_possible_sp))
578
        competitionBasis ='TP'
615
        competitionBasis ='TP'
579
        if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice==supc_data.ourSp:
616
        if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice==supc_data.ourSp:
580
            competitionBasis ='SP'
617
            competitionBasis ='SP'
581
            sheet.write(sheet_iterator, 24, 'SP')
618
            sheet.write(sheet_iterator, 25, 'SP')
582
        else:
619
        else:
583
            sheet.write(sheet_iterator, 24, 'TP')
620
            sheet.write(sheet_iterator, 25, 'TP')
584
        proposed_tp = 0
621
        proposed_tp = 0
585
        if lowestTp > lowest_possible_tp:
-
 
586
            sheet.write(sheet_iterator, 25, "Yes")
-
 
-
 
622
 
587
            if competitionBasis=='SP':
623
        if competitionBasis=='SP':
588
                proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
589
                proposed_tp = proposed_sp*.9597-courierCost
624
            if supc_data.lowestSp > lowest_possible_sp:
590
                sheet.write(sheet_iterator, 26, round(proposed_tp))
-
 
591
                sheet.write(sheet_iterator, 27, round(proposed_sp))
625
                sheet.write(sheet_iterator, 26, "Yes")
592
            else:
626
            else:
-
 
627
                sheet.write(sheet_iterator, 26, "No")
593
                proposed_tp  = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
628
            proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
629
            proposed_tp = proposed_sp*.9597-courierCost
594
                sheet.write(sheet_iterator, 26, round(proposed_tp))
630
            sheet.write(sheet_iterator, 27, round(proposed_tp))
595
                sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
631
            sheet.write(sheet_iterator, 28, round(proposed_sp))
596
        else:
632
        else:
-
 
633
            if lowestTp > lowest_possible_tp:
-
 
634
                sheet.write(sheet_iterator, 26, "Yes")
-
 
635
            else:
597
            sheet.write(sheet_iterator, 25, "No")
636
                sheet.write(sheet_iterator, 26, "No")
-
 
637
            proposed_tp  = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
-
 
638
            sheet.write(sheet_iterator, 27, round(proposed_tp))
-
 
639
            sheet.write(sheet_iterator, 28, round((proposed_tp+courierCost)/0.9597))
598
        
640
        
599
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
641
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
600
            sheet.write(sheet_iterator, 28, "HIGH")
642
            sheet.write(sheet_iterator, 29, "HIGH")
601
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
643
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
602
            sheet.write(sheet_iterator, 28, "MEDIUM")
644
            sheet.write(sheet_iterator, 29, "MEDIUM")
603
        else:
645
        else:
604
            sheet.write(sheet_iterator, 28, "LOW")
646
            sheet.write(sheet_iterator, 29, "LOW")
605
        i= i+1
647
        i= i+1
606
        sheet_iterator+=1
648
        sheet_iterator+=1
607
 
649
 
608
 
650
 
609
def createSheetForCometitiveItemsNoInventory(competitiveNoInventoryItems,wbk):
651
def createSheetForCometitiveItemsNoInventory(competitiveNoInventoryItems,wbk):
Line 635... Line 677...
635
    sheet.write(0, 17, "Lowest TP", heading_xf)
677
    sheet.write(0, 17, "Lowest TP", heading_xf)
636
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
678
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
637
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
679
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
638
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
680
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
639
    sheet.write(0, 21, "Our NLC", heading_xf)
681
    sheet.write(0, 21, "Our NLC", heading_xf)
-
 
682
    sheet.write(0, 22, "Our Dealer Price", heading_xf)
640
    sheet.write(0, 22, "Lowest Possible TP", heading_xf)
683
    sheet.write(0, 23, "Lowest Possible TP", heading_xf)
641
    sheet.write(0, 23, "Lowest Possible SP", heading_xf)
684
    sheet.write(0, 24, "Lowest Possible SP", heading_xf)
642
    sheet.write(0, 24, "Competition Basis ", heading_xf)
685
    sheet.write(0, 25, "Competition Basis ", heading_xf)
643
    sheet.write(0, 25, "Can Compete", heading_xf)
686
    sheet.write(0, 26, "Can Compete", heading_xf)
644
    sheet.write(0, 26, "Target TP", heading_xf)
687
    sheet.write(0, 27, "Target TP", heading_xf)
645
    sheet.write(0, 27, "Target SP", heading_xf)  
688
    sheet.write(0, 28, "Target SP", heading_xf)  
646
    sheet.write(0, 28, "Sales Potential", heading_xf)
689
    sheet.write(0, 29, "Sales Potential", heading_xf)
647
    
690
    
648
    i, sheet_iterator=1,1
691
    i, sheet_iterator=1,1
649
    for data in competitiveNoInventoryItems:
692
    for data in competitiveNoInventoryItems:
650
        supc_data =data[0]
693
        supc_data =data[0]
651
        one_line = data[1]
694
        one_line = data[1]
Line 684... Line 727...
684
        sheet.write(sheet_iterator, 17, round(lowestTp))
727
        sheet.write(sheet_iterator, 17, round(lowestTp))
685
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
728
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
686
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
729
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
687
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
730
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
688
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
731
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
-
 
732
        sheet.write(sheet_iterator, 22, one_line.dealerPrice)
689
        if supc_data.rank==1:
733
        if supc_data.rank==1:
690
            i+=1
734
            i+=1
691
            sheet_iterator+=1
735
            sheet_iterator+=1
692
            continue
736
            continue
693
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
737
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
694
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
738
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
695
        sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
739
        sheet.write(sheet_iterator, 23, round(lowest_possible_tp))
696
        sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
740
        sheet.write(sheet_iterator, 24, round(lowest_possible_sp))
697
        competitionBasis ='TP'
-
 
698
        if (supc_data.lowestOfferPrice == supc_data.lowestSp):
741
        if (supc_data.lowestOfferPrice == supc_data.lowestSp):
699
            competitionBasis ='SP'
742
            competitionBasis ='SP'
700
            sheet.write(sheet_iterator, 24, 'SP')
743
            sheet.write(sheet_iterator, 25, 'SP')
701
        else:
744
        else:
702
            sheet.write(sheet_iterator, 24, 'TP')
745
            sheet.write(sheet_iterator, 25, 'TP')
703
        proposed_tp = 0
746
        proposed_tp = 0
704
        if lowestTp > lowest_possible_tp:
-
 
705
            sheet.write(sheet_iterator, 25, "Yes")
-
 
706
            if competitionBasis=='SP':
747
        if competitionBasis=='SP':
707
                proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
708
                proposed_tp = proposed_sp*.9597-courierCost
748
            if supc_data.lowestSp > lowest_possible_sp:
709
                sheet.write(sheet_iterator, 26, round(proposed_tp))
-
 
710
                sheet.write(sheet_iterator, 27, round(proposed_sp))
749
                sheet.write(sheet_iterator, 26, "Yes")
711
            else:
750
            else:
-
 
751
                sheet.write(sheet_iterator, 26, "No")
712
                proposed_tp  = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
752
            proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
753
            proposed_tp = proposed_sp*.9597-courierCost
713
                sheet.write(sheet_iterator, 26, round(proposed_tp))
754
            sheet.write(sheet_iterator, 27, round(proposed_tp))
714
                sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
755
            sheet.write(sheet_iterator, 28, round(proposed_sp))
715
        else:
756
        else:    
-
 
757
            if lowestTp > lowest_possible_tp:
716
            sheet.write(sheet_iterator, 25, "No")
758
                sheet.write(sheet_iterator, 26, "Yes")
-
 
759
                if competitionBasis=='SP':
-
 
760
                    proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
761
                    proposed_tp = proposed_sp*.9597-courierCost
-
 
762
                    sheet.write(sheet_iterator, 27, round(proposed_tp))
-
 
763
                    sheet.write(sheet_iterator, 28, round(proposed_sp))
-
 
764
                else:
-
 
765
                    proposed_tp  = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
-
 
766
                    sheet.write(sheet_iterator, 27, round(proposed_tp))
-
 
767
                    sheet.write(sheet_iterator, 28, round((proposed_tp+courierCost)/0.9597))
717
        
768
        
718
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
769
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
719
            sheet.write(sheet_iterator, 28, "HIGH")
770
            sheet.write(sheet_iterator, 29, "HIGH")
720
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
771
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
721
            sheet.write(sheet_iterator, 28, "MEDIUM")
772
            sheet.write(sheet_iterator, 29, "MEDIUM")
722
        else:
773
        else:
723
            sheet.write(sheet_iterator, 28, "LOW")
774
            sheet.write(sheet_iterator, 29, "LOW")
724
        i= i+1
775
        i= i+1
725
        sheet_iterator+=1
776
        sheet_iterator+=1
726
    
777
    
727
def createSheetForNegativeMargin(negativeMargin,wbk):
778
def createSheetForNegativeMargin(negativeMargin,wbk):
728
    sheet = wbk.add_sheet('Negative Margin')
779
    sheet = wbk.add_sheet('Negative Margin')
Line 747... Line 798...
747
    sheet.write(0, 11, "Our SP", heading_xf)
798
    sheet.write(0, 11, "Our SP", heading_xf)
748
    sheet.write(0, 13, "Our TP", heading_xf)
799
    sheet.write(0, 13, "Our TP", heading_xf)
749
    sheet.write(0, 12, "Our Offer Price", heading_xf)
800
    sheet.write(0, 12, "Our Offer Price", heading_xf)
750
    sheet.write(0, 14, "Our Rank", heading_xf)
801
    sheet.write(0, 14, "Our Rank", heading_xf)
751
    sheet.write(0, 15, "Our NLC", heading_xf)
802
    sheet.write(0, 15, "Our NLC", heading_xf)
-
 
803
    sheet.write(0, 16, "Our Dealer Price", heading_xf)
752
    sheet.write(0, 16, "Margin", heading_xf)
804
    sheet.write(0, 17, "Margin", heading_xf)
753
    
805
    
754
    i, sheet_iterator=1,1
806
    i, sheet_iterator=1,1
755
    for data in negativeMargin:
807
    for data in negativeMargin:
756
        supc_data =data[0]
808
        supc_data =data[0]
757
        one_line = data[1]
809
        one_line = data[1]
Line 787... Line 839...
787
        sheet.write(sheet_iterator, 11, supc_data.ourSp)
839
        sheet.write(sheet_iterator, 11, supc_data.ourSp)
788
        sheet.write(sheet_iterator, 13, round(supc_data.ourSp*0.9597-courierCost))
840
        sheet.write(sheet_iterator, 13, round(supc_data.ourSp*0.9597-courierCost))
789
        sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
841
        sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
790
        sheet.write(sheet_iterator, 14, supc_data.rank)
842
        sheet.write(sheet_iterator, 14, supc_data.rank)
791
        sheet.write(sheet_iterator, 15, one_line.our_nlc)
843
        sheet.write(sheet_iterator, 15, one_line.our_nlc)
-
 
844
        sheet.write(sheet_iterator, 16, one_line.dealerPrice)
792
        sheet.write(sheet_iterator, 16, round((supc_data.ourSp*0.9597-courierCost) - lowest_possible_tp))
845
        sheet.write(sheet_iterator, 17, round((supc_data.ourSp*0.9597-courierCost) - lowest_possible_tp))
793
        i= i+1
846
        i= i+1
794
        sheet_iterator+=1
847
        sheet_iterator+=1
795
       
848
       
796
 
849
 
797
def main():
850
def main():