Subversion Repositories SmartDukaan

Rev

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

Rev 9914 Rev 9919
Line 140... Line 140...
140
    autoIncrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoIncrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
140
    autoIncrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoIncrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
141
    inventory_client = InventoryClient().get_client()
141
    inventory_client = InventoryClient().get_client()
142
    inventoryMap = inventory_client.getInventorySnapshot(0)
142
    inventoryMap = inventory_client.getInventorySnapshot(0)
143
    for autoIncrementItem in autoIncrementItems:
143
    for autoIncrementItem in autoIncrementItems:
144
        mpHistory = MarketPlaceHistory.get_by(source=OrderSource.SNAPDEAL,item_id=autoIncrementItem.itemId,timestamp=time)
144
        mpHistory = MarketPlaceHistory.get_by(source=OrderSource.SNAPDEAL,item_id=autoIncrementItem.itemId,timestamp=time)
145
        if mpHistory.proposedSellingPrice <= mpHistory.ourSellingPrice:
145
        if not mpHistory.competitiveCategory == CompetitionCategory.BUY_BOX:
146
            markReasonForMpItem(mpHistory,'Proposed SP less than current SP',Decision.AUTO_INCREMENT_FAILED)
146
            markReasonForMpItem(mpHistory,'Category is '+CompetitionCategory._VALUES_TO_NAMES.get(mpHistory.competitiveCategory),Decision.AUTO_DECREMENT_FAILED)
147
            continue
147
            continue
148
        if mpHistory.totalSeller==1 and mpHistory.ourRank==1:
148
        if mpHistory.totalSeller==1 and mpHistory.ourRank==1:
149
            markReasonForMpItem(mpHistory,'We are the only seller',Decision.AUTO_INCREMENT_FAILED)
149
            markReasonForMpItem(mpHistory,'We are the only seller',Decision.AUTO_INCREMENT_FAILED)
150
            continue
150
            continue
-
 
151
        if mpHistory.proposedSellingPrice <= mpHistory.ourSellingPrice:
-
 
152
            markReasonForMpItem(mpHistory,'Proposed SP less than current SP',Decision.AUTO_INCREMENT_FAILED)
-
 
153
            continue
151
        oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.itemId,0,3)
154
        oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.itemId,0,3)
152
        count,sale,daysOfStock = 0,0,0
155
        count,sale,daysOfStock = 0,0,0
153
        for obj in oosStatus:
156
        for obj in oosStatus:
154
            if not obj.is_oos:
157
            if not obj.is_oos:
155
                count+=1
158
                count+=1
Line 380... Line 383...
380
        mpHistory.item_id = snapdealItemInfo.item_id
383
        mpHistory.item_id = snapdealItemInfo.item_id
381
        mpHistory.source = OrderSource.SNAPDEAL
384
        mpHistory.source = OrderSource.SNAPDEAL
382
        mpHistory.ourOfferPrice = snapdealDetails.ourOfferPrice
385
        mpHistory.ourOfferPrice = snapdealDetails.ourOfferPrice
383
        mpHistory.ourSellingPrice = snapdealPricing.ourSp
386
        mpHistory.ourSellingPrice = snapdealPricing.ourSp
384
        mpHistory.ourTp = snapdealPricing.ourTp
387
        mpHistory.ourTp = snapdealPricing.ourTp
-
 
388
        mpHistory.lowestPossibleTp = snapdealPricing.lowestPossibleTp
385
        mpHistory.ourNlc = snapdealItemInfo.nlc
389
        mpHistory.ourNlc = snapdealItemInfo.nlc
386
        mpHistory.ourInventory = snapdealDetails.ourInventory
390
        mpHistory.ourInventory = snapdealDetails.ourInventory
387
        mpHistory.otherInventory = snapdealDetails.otherInventory
391
        mpHistory.otherInventory = snapdealDetails.otherInventory
388
        mpHistory.ourRank = snapdealDetails.rank
392
        mpHistory.ourRank = snapdealDetails.rank
-
 
393
        mpHistory.risky = snapdealItemInfo.risky
-
 
394
        mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp  
389
        mpHistory.competitiveCategory = CompetitionCategory.NEGATIVE_MARGIN
395
        mpHistory.competitiveCategory = CompetitionCategory.NEGATIVE_MARGIN
390
        mpHistory.totalSeller = snapdealDetails.totalSeller
396
        mpHistory.totalSeller = snapdealDetails.totalSeller
391
        mpHistory.timestamp = timestamp
397
        mpHistory.timestamp = timestamp
392
    session.commit()
398
    session.commit()
393
        
399
        
Line 425... Line 431...
425
        else:
431
        else:
426
            proposed_tp  = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
432
            proposed_tp  = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
427
            proposed_sp = getTargetSp(proposed_tp,mpItem)
433
            proposed_sp = getTargetSp(proposed_tp,mpItem)
428
            mpHistory.proposedSellingPrice = proposed_sp
434
            mpHistory.proposedSellingPrice = proposed_sp
429
            mpHistory.proposedTp = proposed_tp
435
            mpHistory.proposedTp = proposed_tp
-
 
436
        mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
430
        mpHistory.totalSeller = snapdealDetails.totalSeller
437
        mpHistory.totalSeller = snapdealDetails.totalSeller
431
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
438
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
432
        mpHistory.timestamp = timestamp
439
        mpHistory.timestamp = timestamp
433
    session.commit()
440
    session.commit()
434
 
441
 
Line 466... Line 473...
466
        else:
473
        else:
467
            proposed_tp  = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
474
            proposed_tp  = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
468
            proposed_sp = getTargetSp(proposed_tp,mpItem)
475
            proposed_sp = getTargetSp(proposed_tp,mpItem)
469
            mpHistory.proposedSellingPrice = proposed_sp
476
            mpHistory.proposedSellingPrice = proposed_sp
470
            mpHistory.proposedTp = proposed_tp
477
            mpHistory.proposedTp = proposed_tp
-
 
478
        mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
471
        mpHistory.totalSeller = snapdealDetails.totalSeller
479
        mpHistory.totalSeller = snapdealDetails.totalSeller
472
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
480
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
473
        mpHistory.timestamp = timestamp
481
        mpHistory.timestamp = timestamp
474
    session.commit()
482
    session.commit()
475
 
483
 
Line 511... Line 519...
511
            proposed_sp = getTargetSp(proposed_tp,mpItem)
519
            proposed_sp = getTargetSp(proposed_tp,mpItem)
512
            target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
520
            target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
513
            mpHistory.proposedSellingPrice = proposed_sp
521
            mpHistory.proposedSellingPrice = proposed_sp
514
            mpHistory.proposedTp = proposed_tp
522
            mpHistory.proposedTp = proposed_tp
515
            mpHistory.targetNlc = target_nlc
523
            mpHistory.targetNlc = target_nlc
-
 
524
        mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
516
        mpHistory.totalSeller = snapdealDetails.totalSeller
525
        mpHistory.totalSeller = snapdealDetails.totalSeller
517
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
526
        mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
518
        mpHistory.timestamp = timestamp
527
        mpHistory.timestamp = timestamp
519
    session.commit()
528
    session.commit()
520
 
529
 
Line 560... Line 569...
560
            proposed_sp = getTargetSp(proposed_tp,mpItem)
569
            proposed_sp = getTargetSp(proposed_tp,mpItem)
561
            #target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
570
            #target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
562
            mpHistory.proposedSellingPrice = proposed_sp
571
            mpHistory.proposedSellingPrice = proposed_sp
563
            mpHistory.proposedTp = proposed_tp
572
            mpHistory.proposedTp = proposed_tp
564
            #mpHistory.targetNlc = target_nlc
573
            #mpHistory.targetNlc = target_nlc
-
 
574
        mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
565
        mpHistory.marginIncreasedPotential = proposed_tp - snapdealPricing.ourTp
575
        mpHistory.marginIncreasedPotential = proposed_tp - snapdealPricing.ourTp
566
        mpHistory.totalSeller = snapdealDetails.totalSeller
576
        mpHistory.totalSeller = snapdealDetails.totalSeller
567
        mpHistory.timestamp = timestamp
577
        mpHistory.timestamp = timestamp
568
    session.commit()
578
    session.commit()
569
        
579