| Line 214... |
Line 214... |
| 214 |
continue
|
214 |
continue
|
| 215 |
if autoIncrementItem.proposedSp >=10000 and autoIncrementItem.promoPrice<10000:
|
215 |
if autoIncrementItem.proposedSp >=10000 and autoIncrementItem.promoPrice<10000:
|
| 216 |
markReasonForItem(autoIncrementItem,'Proposed SP is greater than 10,000 and current sp is less than 10,000',Decision.AUTO_INCREMENT_FAILED)
|
216 |
markReasonForItem(autoIncrementItem,'Proposed SP is greater than 10,000 and current sp is less than 10,000',Decision.AUTO_INCREMENT_FAILED)
|
| 217 |
continue
|
217 |
continue
|
| 218 |
|
218 |
|
| 219 |
if autoIncrementItem.isPromotion and (math.ceil(autoIncrementItem.promoPrice+max(10,.01*autoIncrementItem.promoPrice)) > (amazonLongTermActivePromotions.get(sku)).promoPrice):
|
219 |
if autoIncrementItem.isPromotion and (min(math.ceil(autoIncrementItem.promoPrice+max(10,.01*autoIncrementItem.promoPrice),autoIncrementItem.proposedSp)) > (amazonLongTermActivePromotions.get(sku)).promoPrice):
|
| 220 |
markReasonForItem(autoIncrementItem,'Proposed SP cant be greater than promo price',Decision.AUTO_INCREMENT_FAILED)
|
220 |
markReasonForItem(autoIncrementItem,'Proposed SP cant be greater than promo price',Decision.AUTO_INCREMENT_FAILED)
|
| 221 |
continue
|
221 |
continue
|
| 222 |
|
- |
|
| 223 |
|
222 |
|
| 224 |
if autoIncrementItem.avgSale==0:
|
223 |
if autoIncrementItem.avgSale==0:
|
| 225 |
markReasonForItem(autoIncrementItem,'Avg sale is 0',Decision.AUTO_INCREMENT_FAILED)
|
224 |
markReasonForItem(autoIncrementItem,'Avg sale is 0',Decision.AUTO_INCREMENT_FAILED)
|
| 226 |
continue
|
225 |
continue
|
| 227 |
|
226 |
|
| Line 1745... |
Line 1744... |
| 1745 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
1744 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1746 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
1745 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
| 1747 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
1746 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1748 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
1747 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
| 1749 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
1748 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1750 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)))
|
1749 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))),amScraping.proposedSp)
|
| 1751 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1750 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1752 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1751 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
| 1753 |
sheet_iterator+=1
|
1752 |
sheet_iterator+=1
|
| 1754 |
|
1753 |
|
| 1755 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1754 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| Line 1835... |
Line 1834... |
| 1835 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
1834 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1836 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
1835 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
| 1837 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
1836 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1838 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
1837 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
| 1839 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
1838 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1840 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)))
|
1839 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))),amScraping.proposedSp)
|
| 1841 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1840 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1842 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1841 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
| 1843 |
sheet_iterator+=1
|
1842 |
sheet_iterator+=1
|
| 1844 |
|
1843 |
|
| 1845 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1844 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| Line 1925... |
Line 1924... |
| 1925 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
1924 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1926 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
1925 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
| 1927 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
1926 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1928 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
1927 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
| 1929 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
1928 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1930 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)))
|
1929 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))),amScraping.proposedSp)
|
| 1931 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1930 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1932 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1931 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
| 1933 |
sheet_iterator+=1
|
1932 |
sheet_iterator+=1
|
| 1934 |
|
1933 |
|
| 1935 |
# sheet = wbk.add_sheet('Cheapest')
|
1934 |
# sheet = wbk.add_sheet('Cheapest')
|
| Line 2061... |
Line 2060... |
| 2061 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
2060 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 2062 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
2061 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
| 2063 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
2062 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 2064 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
2063 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
| 2065 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
2064 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 2066 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)))
|
2065 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))),amScraping.proposedSp)
|
| 2067 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))))
|
2066 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))))
|
| 2068 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2067 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
| 2069 |
sheet_iterator+=1
|
2068 |
sheet_iterator+=1
|
| 2070 |
|
2069 |
|
| 2071 |
exceptionCheapItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp)\
|
2070 |
exceptionCheapItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp)\
|
| Line 2570... |
Line 2569... |
| 2570 |
continue
|
2569 |
continue
|
| 2571 |
#vatRate = getNewVatRate(item.item_id,item.warehouseLocation,math.ceil(item.promoPrice+max(10,.01*item.promoPrice)))
|
2570 |
#vatRate = getNewVatRate(item.item_id,item.warehouseLocation,math.ceil(item.promoPrice+max(10,.01*item.promoPrice)))
|
| 2572 |
#oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
2571 |
#oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
| 2573 |
oldMargin = getMargin(item)
|
2572 |
oldMargin = getMargin(item)
|
| 2574 |
#newMargin = round(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)) - getNewLowestPossibleSp(item,12.36,vatRate))
|
2573 |
#newMargin = round(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)) - getNewLowestPossibleSp(item,12.36,vatRate))
|
| 2575 |
newMargin = getNewMargin(item,math.ceil(item.promoPrice+max(10,.01*item.promoPrice)))
|
2574 |
newMargin = getNewMargin(item,math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp)))
|
| 2576 |
sku = ''
|
2575 |
sku = ''
|
| 2577 |
if item.warehouseLocation==1:
|
2576 |
if item.warehouseLocation==1:
|
| 2578 |
sku='FBA'+str(item.item_id)
|
2577 |
sku='FBA'+str(item.item_id)
|
| 2579 |
elif item.warehouseLocation==2:
|
2578 |
elif item.warehouseLocation==2:
|
| 2580 |
sku='FBB'+str(item.item_id)
|
2579 |
sku='FBB'+str(item.item_id)
|
| Line 2589... |
Line 2588... |
| 2589 |
message+="""<tr>
|
2588 |
message+="""<tr>
|
| 2590 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
2589 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| 2591 |
<td style="text-align:center">"""+sku+"""</td>
|
2590 |
<td style="text-align:center">"""+sku+"""</td>
|
| 2592 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
2591 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| 2593 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
2592 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
| 2594 |
<td style="text-align:center">"""+str(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)))+"""</td>
|
2593 |
<td style="text-align:center">"""+str(math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp)))+"""</td>
|
| 2595 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
2594 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
| 2596 |
<td style="text-align:center">"""+str(round((oldMargin),1))+" ("+str(round((oldMargin/item.promoPrice)*100,1))+"%)"+"""</td>
|
2595 |
<td style="text-align:center">"""+str(round((oldMargin),1))+" ("+str(round((oldMargin/item.promoPrice)*100,1))+"%)"+"""</td>
|
| 2597 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(item.promoPrice+max(10,.01*item.promoPrice)))*100,1))+"%)"+"""</td>
|
2596 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))))*100,1))+"%)"+"""</td>
|
| 2598 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
2597 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
| 2599 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
2598 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
| 2600 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
2599 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| 2601 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
2600 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
| 2602 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
2601 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
| Line 2866... |
Line 2865... |
| 2866 |
session.commit()
|
2865 |
session.commit()
|
| 2867 |
for item in successfulAutoIncrease:
|
2866 |
for item in successfulAutoIncrease:
|
| 2868 |
amItem = Amazonlisted.get_by(itemId=item.item_id)
|
2867 |
amItem = Amazonlisted.get_by(itemId=item.item_id)
|
| 2869 |
if item.warehouseLocation==1:
|
2868 |
if item.warehouseLocation==1:
|
| 2870 |
if item.isPromotion:
|
2869 |
if item.isPromotion:
|
| 2871 |
amItem.fbaPromoPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2870 |
amItem.fbaPromoPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2872 |
else:
|
2871 |
else:
|
| 2873 |
amItem.fbaPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2872 |
amItem.fbaPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2874 |
amItem.fbaPriceLastUpdatedOn = datetime.now()
|
2873 |
amItem.fbaPriceLastUpdatedOn = datetime.now()
|
| 2875 |
elif item.warehouseLocation==2:
|
2874 |
elif item.warehouseLocation==2:
|
| 2876 |
if item.isPromotion:
|
2875 |
if item.isPromotion:
|
| 2877 |
amItem.fbbPromoPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2876 |
amItem.fbbPromoPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2878 |
else:
|
2877 |
else:
|
| 2879 |
amItem.fbbPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2878 |
amItem.fbbPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2880 |
amItem.fbbPriceLastUpdatedOn = datetime.now()
|
2879 |
amItem.fbbPriceLastUpdatedOn = datetime.now()
|
| 2881 |
elif item.warehouseLocation==3:
|
2880 |
elif item.warehouseLocation==3:
|
| 2882 |
if item.isPromotion:
|
2881 |
if item.isPromotion:
|
| 2883 |
amItem.fbgPromoPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2882 |
amItem.fbgPromoPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2884 |
else:
|
2883 |
else:
|
| 2885 |
amItem.fbgPrice = math.ceil(item.promoPrice+max(10,.01*item.promoPrice))
|
2884 |
amItem.fbgPrice = math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))
|
| 2886 |
amItem.fbgPriceLastUpdatedOn = datetime.now()
|
2885 |
amItem.fbgPriceLastUpdatedOn = datetime.now()
|
| 2887 |
else:
|
2886 |
else:
|
| 2888 |
continue
|
2887 |
continue
|
| 2889 |
session.commit()
|
2888 |
session.commit()
|
| 2890 |
|
2889 |
|