| Line 88... |
Line 88... |
| 88 |
def __init__(self, ourSp, lowestPossibleSp):
|
88 |
def __init__(self, ourSp, lowestPossibleSp):
|
| 89 |
self.ourSp = ourSp
|
89 |
self.ourSp = ourSp
|
| 90 |
self.lowestPossibleSp = lowestPossibleSp
|
90 |
self.lowestPossibleSp = lowestPossibleSp
|
| 91 |
|
91 |
|
| 92 |
class __Promotion:
|
92 |
class __Promotion:
|
| 93 |
def __init__(self, promoPrice, subsidy, promotionType):
|
93 |
def __init__(self, promoPrice, subsidy, promotionType,expiryDate):
|
| 94 |
self.promoPrice = promoPrice
|
94 |
self.promoPrice = promoPrice
|
| 95 |
self.subsidy = subsidy
|
95 |
self.subsidy = subsidy
|
| 96 |
self.promotionType = promotionType
|
96 |
self.promotionType = promotionType
|
| - |
|
97 |
self.expiryDate = expiryDate
|
| 97 |
|
98 |
|
| 98 |
|
99 |
|
| 99 |
|
100 |
|
| 100 |
def fetchItemsForAutoDecrease(time):
|
101 |
def fetchItemsForAutoDecrease(time):
|
| 101 |
successfulAutoDecrease = []
|
102 |
successfulAutoDecrease = []
|
| Line 121... |
Line 122... |
| 121 |
except:
|
122 |
except:
|
| 122 |
daysOfStock = float("inf")
|
123 |
daysOfStock = float("inf")
|
| 123 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE:
|
124 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE:
|
| 124 |
if daysOfStock < 20:
|
125 |
if daysOfStock < 20:
|
| 125 |
markReasonForItem(autoDecrementItem,'Days of stock less than 20',Decision.AUTO_DECREMENT_FAILED)
|
126 |
markReasonForItem(autoDecrementItem,'Days of stock less than 20',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
127 |
continue
|
| 126 |
|
128 |
|
| 127 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE:
|
129 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE and not autoDecrementItem.isPromotion:
|
| 128 |
if autoDecrementItem.parentCategoryId in [10006,10009,11001]:
|
130 |
if autoDecrementItem.parentCategoryId in [10006,10009,11001]:
|
| 129 |
if daysOfStock < 1:
|
131 |
if daysOfStock < 1 :
|
| 130 |
markReasonForItem(autoDecrementItem,'Days of stock less than 1',Decision.AUTO_DECREMENT_FAILED)
|
132 |
markReasonForItem(autoDecrementItem,'Days of stock less than 1',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
133 |
continue
|
| - |
|
134 |
|
| 131 |
else:
|
135 |
else:
|
| 132 |
if daysOfStock < 3:
|
136 |
if daysOfStock < 3:
|
| 133 |
markReasonForItem(autoDecrementItem,'Days of stock less than 3',Decision.AUTO_DECREMENT_FAILED)
|
137 |
markReasonForItem(autoDecrementItem,'Days of stock less than 3',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
138 |
continue
|
| - |
|
139 |
|
| - |
|
140 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE and autoDecrementItem.isPromotion:
|
| - |
|
141 |
if autoDecrementItem.parentCategoryId in [10006,10009,11001]:
|
| - |
|
142 |
if (amazonLongTermActivePromotions.get(sku).expiryDate - datetime.now()).days >2 and daysOfStock < 1 :
|
| - |
|
143 |
markReasonForItem(autoDecrementItem,'Promo Item, expiry after 2 days or not enough stock',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
144 |
continue
|
| - |
|
145 |
|
| - |
|
146 |
else:
|
| - |
|
147 |
if (amazonLongTermActivePromotions.get(sku).expiryDate - datetime.now()).days >2 and daysOfStock < 3:
|
| - |
|
148 |
markReasonForItem(autoDecrementItem,'Promo Item, expiry after 2 days or not enough stock',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
149 |
continue
|
| 134 |
|
150 |
|
| 135 |
autoDecrementItem.ourEnoughStock=True
|
151 |
autoDecrementItem.ourEnoughStock=True
|
| 136 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
152 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
| 137 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
153 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
| 138 |
successfulAutoDecrease.append(autoDecrementItem)
|
154 |
successfulAutoDecrease.append(autoDecrementItem)
|
| Line 360... |
Line 376... |
| 360 |
amazonItemInfo = __AmazonItemInfo(None, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id)
|
376 |
amazonItemInfo = __AmazonItemInfo(None, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id)
|
| 361 |
itemInfo.append(amazonItemInfo)
|
377 |
itemInfo.append(amazonItemInfo)
|
| 362 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
378 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 363 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
379 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 364 |
for amPromotion in amPromotions:
|
380 |
for amPromotion in amPromotions:
|
| 365 |
amazonLongTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType)
|
381 |
amazonLongTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
| 366 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
382 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 367 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
383 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 368 |
for amPromotion in amPromotions:
|
384 |
for amPromotion in amPromotions:
|
| 369 |
amazonShortTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType)
|
385 |
amazonShortTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
| 370 |
session.close()
|
386 |
session.close()
|
| 371 |
return itemInfo
|
387 |
return itemInfo
|
| 372 |
|
388 |
|
| 373 |
def getPriceAndAsin(itemInfo):
|
389 |
def getPriceAndAsin(itemInfo):
|
| 374 |
skus = []
|
390 |
skus = []
|
| Line 641... |
Line 657... |
| 641 |
amazonScrapingHistory.totalSeller = amDetails.totalSeller
|
657 |
amazonScrapingHistory.totalSeller = amDetails.totalSeller
|
| 642 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.BUY_BOX
|
658 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.BUY_BOX
|
| 643 |
amazonScrapingHistory.timestamp = timestamp
|
659 |
amazonScrapingHistory.timestamp = timestamp
|
| 644 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
660 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| 645 |
proposed_sp = max(amDetails.secondLowestSellerSp - max((20, amDetails.secondLowestSellerSp*0.002)), amPricing.lowestPossibleSp)
|
661 |
proposed_sp = max(amDetails.secondLowestSellerSp - max((20, amDetails.secondLowestSellerSp*0.002)), amPricing.lowestPossibleSp)
|
| - |
|
662 |
if amazonScrapingHistory.isPromotion:
|
| - |
|
663 |
if amazonLongTermActivePromotions.has_key(val.sku):
|
| - |
|
664 |
proposed_sp = min(proposed_sp,(amazonLongTermActivePromotions.has_key(val.sku)).salePrice)
|
| - |
|
665 |
else:
|
| - |
|
666 |
proposed_sp = min(proposed_sp,(amazonShortTermActivePromotions.has_key(val.sku)).salePrice)
|
| 646 |
proposed_tp = getTargetTp(proposed_sp,spm,val)
|
667 |
proposed_tp = getTargetTp(proposed_sp,spm,val)
|
| 647 |
amazonScrapingHistory.proposedSp = proposed_sp
|
668 |
amazonScrapingHistory.proposedSp = proposed_sp
|
| 648 |
amazonScrapingHistory.proposedTp = proposed_tp
|
669 |
amazonScrapingHistory.proposedTp = proposed_tp
|
| 649 |
amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
|
670 |
amazonScrapingHistory.marginIncreasedPotential = proposed_tp - amPricing.ourTp
|
| 650 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
671 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|