Subversion Repositories SmartDukaan

Rev

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

Rev 12481 Rev 12483
Line 488... Line 488...
488
                thirdLowestSellerRating = info['rating']
488
                thirdLowestSellerRating = info['rating']
489
                thirdLowestSellerType = info['fulfillmentChannel']
489
                thirdLowestSellerType = info['fulfillmentChannel']
490
            
490
            
491
            iterator += 1
491
            iterator += 1
492
        print "terminating iterator"
492
        print "terminating iterator"
493
        
-
 
494
        
493
 
495
        print "Creating object am details",val.sku
494
        print "Creating object am details",val.sku
496
        amDetails = __AmazonDetails(sku, float(ourSp), ourRank, lowestSellerName,float(lowestSellerSp),secondLowestSellerName, float(secondLowestSellerSp), thirdLowestSellerName, float(thirdLowestSellerSp),len(scrapInfo),multipleListings,promoPrice,isPromo, \
495
        amDetails = __AmazonDetails(sku, float(ourSp), ourRank, lowestSellerName,float(lowestSellerSp),secondLowestSellerName, float(secondLowestSellerSp), thirdLowestSellerName, float(thirdLowestSellerSp),len(scrapInfo),multipleListings,promoPrice,isPromo, \
497
                    lowestSellerShippingTime ,lowestSellerRating, secondLowestSellerShippingTime, secondLowestSellerRating, thirdLowestSellerShippingTime , thirdLowestSellerRating, lowestSellerType, secondLowestSellerType, thirdLowestSellerType)
496
                    lowestSellerShippingTime ,lowestSellerRating, secondLowestSellerShippingTime, secondLowestSellerRating, thirdLowestSellerShippingTime , thirdLowestSellerRating, lowestSellerType, secondLowestSellerType, thirdLowestSellerType)
498
        print "am details obj created"
497
        print "am details obj created"
499
        try:
498
        try:
Line 522... Line 521...
522
            continue
521
            continue
523
        
522
        
524
        lowestPossibleSp = getLowestPossibleSp(amDetails,val,val.sourcePercentage)
523
        lowestPossibleSp = getLowestPossibleSp(amDetails,val,val.sourcePercentage)
525
        print "Creating pricing obj"
524
        print "Creating pricing obj"
526
        amPricing = __AmazonPricing(ourSp,lowestPossibleSp)
525
        amPricing = __AmazonPricing(ourSp,lowestPossibleSp)
-
 
526
        print "sku ",val.sku
-
 
527
        print "oursp ",ourSp
-
 
528
        print "promoPrice ",promoPrice
-
 
529
        print "lowestpossbile sp ",lowestPossibleSp
-
 
530
        print "objlowestPossiblesp ",amPricing.lowestPossibleSp
527
        
531
        
528
        if amDetails.promoPrice < amPricing.lowestPossibleSp:
532
        if amDetails.promoPrice < amPricing.lowestPossibleSp:
529
            temp = []
533
            temp = []
530
            temp.append(val)
534
            temp.append(val)
531
            temp.append(amDetails)
535
            temp.append(amDetails)
532
            temp.append(amPricing)
536
            temp.append(amPricing)
533
            negativeMargin.append(temp)
537
            negativeMargin.append(temp)
-
 
538
            print "val sku cat negative ",val.sku
534
            continue
539
            continue
535
        
540
        
536
        if amDetails.ourRank==1:
541
        if amDetails.ourRank==1:
537
            temp = []
542
            temp = []
538
            temp.append(val)
543
            temp.append(val)
539
            temp.append(amDetails)
544
            temp.append(amDetails)
540
            temp.append(amPricing)
545
            temp.append(amPricing)
541
            cheapest.append(temp)
546
            cheapest.append(temp)
-
 
547
            print "val sku cat cheapest ",val.sku
542
            continue
548
            continue
543
        
549
        
544
        if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp) and ((((float(float(amDetails.promoPrice) - amDetails.lowestSellerSp))/float(amDetails.promoPrice))<=.01) or ((float(amDetails.promoPrice) - amDetails.lowestSellerSp)<=25)):
550
        if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp) and ((((float(float(amDetails.promoPrice) - amDetails.lowestSellerSp))/float(amDetails.promoPrice))<=.01) or ((float(amDetails.promoPrice) - amDetails.lowestSellerSp)<=25)):
545
            temp = []
551
            temp = []
546
            temp.append(val)
552
            temp.append(val)
547
            temp.append(amDetails)
553
            temp.append(amDetails)
548
            temp.append(amPricing)
554
            temp.append(amPricing)
549
            amongCheapestAndCanCompete.append(temp)
555
            amongCheapestAndCanCompete.append(temp)
-
 
556
            print "val sku cat amongCheapestAndCanCompete  ",val.sku
550
            continue
557
            continue
551
        
558
        
552
        if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp):
559
        if (amDetails.lowestSellerSp > amPricing.lowestPossibleSp):
553
            temp = []
560
            temp = []
554
            temp.append(val)
561
            temp.append(val)
555
            temp.append(amDetails)
562
            temp.append(amDetails)
556
            temp.append(amPricing)
563
            temp.append(amPricing)
557
            canCompete.append(temp)
564
            canCompete.append(temp)
-
 
565
            print "val sku cat can compete  ",val.sku
558
            continue
566
            continue
559
        
567
        
560
        if amDetails.lowestSellerSp*(1+.01) >= amPricing.lowestPossibleSp:
568
        if amDetails.lowestSellerSp*(1+.01) >= amPricing.lowestPossibleSp:
561
            temp = []
569
            temp = []
562
            temp.append(val)
570
            temp.append(val)
563
            temp.append(amDetails)
571
            temp.append(amDetails)
564
            temp.append(amPricing)
572
            temp.append(amPricing)
565
            almostCompete.append(temp)
573
            almostCompete.append(temp)
-
 
574
            print "val sku cat almost compete  ",val.sku
566
            continue
575
            continue
567
            
576
            
568
        
577
        
569
        temp = []
578
        temp = []
570
        temp.append(val)
579
        temp.append(val)
571
        temp.append(amDetails)
580
        temp.append(amDetails)
572
        temp.append(amPricing)
581
        temp.append(amPricing)
-
 
582
        print "val sku cat cant compete  ",val.sku
573
        cantCompete.append(temp)
583
        cantCompete.append(temp)
574
    print "Created category..."
584
    print "Created category..."
575
        
585
        
576
    return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
586
    return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
577
 
587
 
Line 996... Line 1006...
996
    sheet.write(0, 28, "Margin", heading_xf)
1006
    sheet.write(0, 28, "Margin", heading_xf)
997
    sheet.write(0, 29, "Risky", heading_xf)
1007
    sheet.write(0, 29, "Risky", heading_xf)
998
    sheet.write(0, 30, "Proposed Sp", heading_xf)
1008
    sheet.write(0, 30, "Proposed Sp", heading_xf)
999
    sheet.write(0, 31, "Avg Sale", heading_xf)
1009
    sheet.write(0, 31, "Avg Sale", heading_xf)
1000
    sheet.write(0, 32, "Sales History", heading_xf)
1010
    sheet.write(0, 32, "Sales History", heading_xf)
1001
    sheet.write(0, 33, "Decision", heading_xf)
-
 
1002
    sheet.write(0, 34, "Reason", heading_xf)
-
 
1003
    sheet.write(0, 35, "Updated Price", heading_xf)
-
 
1004
    
1011
    
1005
    sheet_iterator = 1
1012
    sheet_iterator = 1
1006
    cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
1013
    cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
1007
    for cantCompeteItem in cantCompeteItems:
1014
    for cantCompeteItem in cantCompeteItems:
1008
        amScraping =  cantCompeteItem[0]
1015
        amScraping =  cantCompeteItem[0]
Line 1024... Line 1031...
1024
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1031
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1025
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1032
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1026
        if amScraping.isPromotion:
1033
        if amScraping.isPromotion:
1027
            sheet.write(sheet_iterator, 10, "Yes")
1034
            sheet.write(sheet_iterator, 10, "Yes")
1028
        else:
1035
        else:
1029
            sheet.write(sheet_iterator, 10, "Yes")
1036
            sheet.write(sheet_iterator, 10, "No")
1030
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1037
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1031
        if amScraping.ourRank > 3:
1038
        if amScraping.ourRank > 3:
1032
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1039
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1033
        else:
1040
        else:
1034
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1041
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
Line 1050... Line 1057...
1050
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1057
        sheet.write(sheet_iterator, 28, round(amScraping.ourSellingPrice - amScraping.lowestPossibleSp))
1051
        sheet.write(sheet_iterator, 29, item.risky)
1058
        sheet.write(sheet_iterator, 29, item.risky)
1052
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1059
        sheet.write(sheet_iterator, 30, amScraping.proposedSp)
1053
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1060
        sheet.write(sheet_iterator, 31, amScraping.avgSale)
1054
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1061
        sheet.write(sheet_iterator, 32, getOosString(saleMap.get(sku)))
1055
        if amScraping.decision is None:
-
 
1056
            sheet.write(sheet_iterator, 33, 'Auto Pricing Inactive')
-
 
1057
            sheet_iterator+=1
-
 
1058
            continue
-
 
1059
        sheet.write(sheet_iterator, 33, Decision._VALUES_TO_NAMES.get(amScraping.decision))
-
 
1060
        sheet.write(sheet_iterator, 34, amScraping.reason)
-
 
1061
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
-
 
1062
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.proposedSp))
-
 
1063
        if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
-
 
1064
            sheet.write(sheet_iterator, 35, math.ceil(amScraping.ourSellingPrice+max(10,.01*amScraping.ourSellingPrice)))
-
 
1065
        sheet_iterator+=1
1062
        sheet_iterator+=1
1066
    
1063
    
1067
    sheet = wbk.add_sheet('Competitive')
1064
    sheet = wbk.add_sheet('Competitive')
1068
    xstr = lambda s: s or ""
1065
    xstr = lambda s: s or ""
1069
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
1066
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 1131... Line 1128...
1131
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1128
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1132
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1129
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1133
        if amScraping.isPromotion:
1130
        if amScraping.isPromotion:
1134
            sheet.write(sheet_iterator, 10, "Yes")
1131
            sheet.write(sheet_iterator, 10, "Yes")
1135
        else:
1132
        else:
1136
            sheet.write(sheet_iterator, 10, "Yes")
1133
            sheet.write(sheet_iterator, 10, "No")
1137
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1134
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1138
        if amScraping.ourRank > 3:
1135
        if amScraping.ourRank > 3:
1139
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1136
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1140
        else:
1137
        else:
1141
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1138
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
Line 1246... Line 1243...
1246
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1243
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1247
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1244
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1248
        if amScraping.isPromotion:
1245
        if amScraping.isPromotion:
1249
            sheet.write(sheet_iterator, 10, "Yes")
1246
            sheet.write(sheet_iterator, 10, "Yes")
1250
        else:
1247
        else:
1251
            sheet.write(sheet_iterator, 10, "Yes")
1248
            sheet.write(sheet_iterator, 10, "No")
1252
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1249
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1253
        if amScraping.ourRank > 3:
1250
        if amScraping.ourRank > 3:
1254
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1251
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1255
        else:
1252
        else:
1256
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1253
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
Line 1353... Line 1350...
1353
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1350
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1354
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1351
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1355
        if amScraping.isPromotion:
1352
        if amScraping.isPromotion:
1356
            sheet.write(sheet_iterator, 10, "Yes")
1353
            sheet.write(sheet_iterator, 10, "Yes")
1357
        else:
1354
        else:
1358
            sheet.write(sheet_iterator, 10, "Yes")
1355
            sheet.write(sheet_iterator, 10, "No")
1359
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1356
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1360
        if amScraping.ourRank > 3:
1357
        if amScraping.ourRank > 3:
1361
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1358
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1362
        else:
1359
        else:
1363
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1360
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
Line 1460... Line 1457...
1460
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1457
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1461
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1458
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1462
        if amScraping.isPromotion:
1459
        if amScraping.isPromotion:
1463
            sheet.write(sheet_iterator, 10, "Yes")
1460
            sheet.write(sheet_iterator, 10, "Yes")
1464
        else:
1461
        else:
1465
            sheet.write(sheet_iterator, 10, "Yes")
1462
            sheet.write(sheet_iterator, 10, "No")
1466
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1463
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1467
        if amScraping.ourRank > 3:
1464
        if amScraping.ourRank > 3:
1468
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1465
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1469
        else:
1466
        else:
1470
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1467
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
Line 1562... Line 1559...
1562
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1559
        sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
1563
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1560
        sheet.write(sheet_iterator, 9, amScraping.promoPrice)
1564
        if amScraping.isPromotion:
1561
        if amScraping.isPromotion:
1565
            sheet.write(sheet_iterator, 10, "Yes")
1562
            sheet.write(sheet_iterator, 10, "Yes")
1566
        else:
1563
        else:
1567
            sheet.write(sheet_iterator, 10, "Yes")
1564
            sheet.write(sheet_iterator, 10, "No")
1568
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1565
        sheet.write(sheet_iterator, 11, amScraping.lowestPossibleSp)
1569
        if amScraping.ourRank > 3:
1566
        if amScraping.ourRank > 3:
1570
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1567
            sheet.write(sheet_iterator, 12, 'Greater than 3')
1571
        else:
1568
        else:
1572
            sheet.write(sheet_iterator, 12, amScraping.ourRank)
1569
            sheet.write(sheet_iterator, 12, amScraping.ourRank)