| Line 17... |
Line 17... |
| 17 |
import math
|
17 |
import math
|
| 18 |
import simplejson as json
|
18 |
import simplejson as json
|
| 19 |
import xlwt
|
19 |
import xlwt
|
| 20 |
import optparse
|
20 |
import optparse
|
| 21 |
import sys
|
21 |
import sys
|
| - |
|
22 |
import smtplib
|
| - |
|
23 |
from email import encoders
|
| - |
|
24 |
from email.mime.text import MIMEText
|
| - |
|
25 |
from email.mime.base import MIMEBase
|
| - |
|
26 |
from email.mime.multipart import MIMEMultipart
|
| - |
|
27 |
|
| - |
|
28 |
|
| 22 |
|
29 |
|
| 23 |
config_client = ConfigClient()
|
30 |
config_client = ConfigClient()
|
| 24 |
host = config_client.get_property('staging_hostname')
|
31 |
host = config_client.get_property('staging_hostname')
|
| 25 |
DataService.initialize(db_hostname=host)
|
32 |
DataService.initialize(db_hostname=host)
|
| 26 |
import logging
|
33 |
import logging
|
| Line 87... |
Line 94... |
| 87 |
self.ourSp = ourSp
|
94 |
self.ourSp = ourSp
|
| 88 |
self.secondLowestSellerTp = secondLowestSellerTp
|
95 |
self.secondLowestSellerTp = secondLowestSellerTp
|
| 89 |
self.lowestPossibleSp = lowestPossibleSp
|
96 |
self.lowestPossibleSp = lowestPossibleSp
|
| 90 |
|
97 |
|
| 91 |
def fetchItemsForAutoDecrease(time):
|
98 |
def fetchItemsForAutoDecrease(time):
|
| - |
|
99 |
successfulAutoDecrease = []
|
| 92 |
autoDecrementItems = session.query(MarketPlaceHistory).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId))\
|
100 |
autoDecrementItems = session.query(MarketPlaceHistory).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId))\
|
| 93 |
.filter(MarketPlaceHistory.timestamp==time).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.COMPETITIVE)\
|
101 |
.filter(MarketPlaceHistory.timestamp==time).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.COMPETITIVE)\
|
| 94 |
.filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketplaceItems.autoDecrement==True).all()
|
102 |
.filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketplaceItems.autoDecrement==True).all()
|
| 95 |
#autoDecrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoDecrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
103 |
#autoDecrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoDecrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
| 96 |
inventory_client = InventoryClient().get_client()
|
104 |
inventory_client = InventoryClient().get_client()
|
| Line 151... |
Line 159... |
| 151 |
autoDecrementItem.competitorEnoughStock = True
|
159 |
autoDecrementItem.competitorEnoughStock = True
|
| 152 |
autoDecrementItem.ourEnoughStock = True
|
160 |
autoDecrementItem.ourEnoughStock = True
|
| 153 |
#autoDecrementItem.avgSales = avgSalePerDay
|
161 |
#autoDecrementItem.avgSales = avgSalePerDay
|
| 154 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
162 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
| 155 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
163 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
| - |
|
164 |
successfulAutoDecrease.append(autoDecrementItem)
|
| 156 |
lgr.info("Auto decrement success for itemId "+str(autoDecrementItem.item_id)+" Days of stock "+str(daysOfStock)+" avg sales "+str(avgSalePerDay))
|
165 |
lgr.info("Auto decrement success for itemId "+str(autoDecrementItem.item_id)+" Days of stock "+str(daysOfStock)+" avg sales "+str(avgSalePerDay))
|
| 157 |
session.commit()
|
166 |
session.commit()
|
| - |
|
167 |
return successfulAutoDecrease
|
| 158 |
|
168 |
|
| 159 |
def fetchItemsForAutoIncrease(time):
|
169 |
def fetchItemsForAutoIncrease(time):
|
| - |
|
170 |
successfulAutoIncrease = []
|
| 160 |
autoIncrementItems = session.query(MarketPlaceHistory).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId))\
|
171 |
autoIncrementItems = session.query(MarketPlaceHistory).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId))\
|
| 161 |
.filter(MarketPlaceHistory.timestamp==time).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX)\
|
172 |
.filter(MarketPlaceHistory.timestamp==time).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX)\
|
| 162 |
.filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketplaceItems.autoIncrement==True).all()
|
173 |
.filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketplaceItems.autoIncrement==True).all()
|
| 163 |
#autoIncrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoIncrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
174 |
#autoIncrementItems = MarketplaceItems.query.filter(MarketplaceItems.autoIncrement==True).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
| 164 |
#inventory_client = InventoryClient().get_client()
|
175 |
#inventory_client = InventoryClient().get_client()
|
| Line 209... |
Line 220... |
| 209 |
|
220 |
|
| 210 |
autoIncrementItem.ourEnoughStock = False
|
221 |
autoIncrementItem.ourEnoughStock = False
|
| 211 |
#autoIncrementItem.avgSales = avgSalePerDay
|
222 |
#autoIncrementItem.avgSales = avgSalePerDay
|
| 212 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
223 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
| 213 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
224 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
| - |
|
225 |
successfulAutoIncrease.append(autoIncrementItem)
|
| 214 |
lgr.info("Auto increment success for itemId "+str(autoIncrementItem.item_id)+" Days of stock "+str(daysOfStock)+" avg sales "+str(avgSalePerDay))
|
226 |
lgr.info("Auto increment success for itemId "+str(autoIncrementItem.item_id)+" Days of stock "+str(daysOfStock)+" avg sales "+str(avgSalePerDay))
|
| 215 |
session.commit()
|
227 |
session.commit()
|
| - |
|
228 |
return successfulAutoIncrease
|
| 216 |
|
229 |
|
| 217 |
def calculateAverageSale(oosStatus):
|
230 |
def calculateAverageSale(oosStatus):
|
| 218 |
count,sale = 0,0
|
231 |
count,sale = 0,0
|
| 219 |
for obj in oosStatus:
|
232 |
for obj in oosStatus:
|
| 220 |
if not obj.is_oos:
|
233 |
if not obj.is_oos:
|
| 221 |
count+=1
|
234 |
count+=1
|
| 222 |
sale = sale+obj.num_orders
|
235 |
sale = sale+obj.num_orders
|
| 223 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
236 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 224 |
return avgSalePerDay
|
237 |
return round(avgSalePerDay,2)
|
| 225 |
|
238 |
|
| 226 |
def getNetAvailability(itemInventory):
|
239 |
def getNetAvailability(itemInventory):
|
| 227 |
totalAvailability, totalReserved = 0,0
|
240 |
totalAvailability, totalReserved = 0,0
|
| 228 |
availableMap = itemInventory.availability
|
241 |
availableMap = itemInventory.availability
|
| 229 |
reserveMap = itemInventory.reserved
|
242 |
reserveMap = itemInventory.reserved
|
| Line 242... |
Line 255... |
| 242 |
for obj in oosStatus:
|
255 |
for obj in oosStatus:
|
| 243 |
if obj.is_oos:
|
256 |
if obj.is_oos:
|
| 244 |
lastNdaySale += "X-"
|
257 |
lastNdaySale += "X-"
|
| 245 |
else:
|
258 |
else:
|
| 246 |
lastNdaySale += str(obj.num_orders) + "-"
|
259 |
lastNdaySale += str(obj.num_orders) + "-"
|
| 247 |
return lastNdaySale
|
260 |
return lastNdaySale[:-1]
|
| 248 |
|
261 |
|
| 249 |
def markAutoFavourite():
|
262 |
def markAutoFavourite():
|
| 250 |
previouslyAutoFav = []
|
263 |
previouslyAutoFav = []
|
| 251 |
nowAutoFav = []
|
264 |
nowAutoFav = []
|
| 252 |
marketplaceItems = session.query(MarketplaceItems).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
265 |
marketplaceItems = session.query(MarketplaceItems).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).all()
|
| 253 |
fromDate = datetime.now()-timedelta(days = 3, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
266 |
fromDate = datetime.now()-timedelta(days = 3, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
| 254 |
toDate = datetime.now()-timedelta(days = 0, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
267 |
toDate = datetime.now()-timedelta(days = 0, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
| 255 |
items = session.query(MarketPlaceHistory.item_id,func.max(MarketPlaceHistory.timestamp)).group_by(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.run==RunType.FULL).filter(MarketPlaceHistory.timestamp.between (fromDate,toDate)).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
268 |
items = session.query(MarketPlaceHistory.item_id,func.max(MarketPlaceHistory.timestamp)).group_by(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.timestamp.between (fromDate,toDate)).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
| 256 |
toUpdate = [key for key, value in itemSaleMap.items() if value[3] >= 3]
|
269 |
toUpdate = [key for key, value in itemSaleMap.items() if value[3] >= 3]
|
| 257 |
buyBoxLast3days = []
|
270 |
buyBoxLast3days = []
|
| 258 |
for item in items:
|
271 |
for item in items:
|
| 259 |
buyBoxLast3days.append(item[0])
|
272 |
buyBoxLast3days.append(item[0])
|
| 260 |
for marketplaceItem in marketplaceItems:
|
273 |
for marketplaceItem in marketplaceItems:
|
| Line 549... |
Line 562... |
| 549 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
562 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 550 |
else:
|
563 |
else:
|
| 551 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
564 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 552 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
565 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 553 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
566 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 554 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
567 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 555 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
568 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 556 |
sheet.write(sheet_iterator, 28, target_nlc)
|
569 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 557 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
570 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 558 |
sheet_iterator+=1
|
571 |
sheet_iterator+=1
|
| 559 |
|
572 |
|
| 560 |
sheet = wbk.add_sheet('Lowest')
|
573 |
sheet = wbk.add_sheet('Lowest')
|
| 561 |
|
574 |
|
| Line 635... |
Line 648... |
| 635 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
648 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 636 |
else:
|
649 |
else:
|
| 637 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
650 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
| 638 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
651 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 639 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
652 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 640 |
sheet.write(sheet_iterator, 25, proposed_tp)
|
653 |
sheet.write(sheet_iterator, 25, round(proposed_tp,2))
|
| 641 |
sheet.write(sheet_iterator, 26, proposed_sp)
|
654 |
sheet.write(sheet_iterator, 26, round(proposed_sp,2))
|
| 642 |
sheet.write(sheet_iterator, 27, proposed_tp - snapdealPricing.ourTp)
|
655 |
sheet.write(sheet_iterator, 27, round((proposed_tp - snapdealPricing.ourTp),2))
|
| 643 |
sheet_iterator+=1
|
656 |
sheet_iterator+=1
|
| 644 |
|
657 |
|
| 645 |
sheet = wbk.add_sheet('Can Compete-With Inventory')
|
658 |
sheet = wbk.add_sheet('Can Compete-With Inventory')
|
| 646 |
|
659 |
|
| 647 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
660 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 720... |
Line 733... |
| 720 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
733 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
| 721 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
734 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 722 |
else:
|
735 |
else:
|
| 723 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
736 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 724 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
737 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 725 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
738 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 726 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
739 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 727 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
740 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 728 |
sheet_iterator+=1
|
741 |
sheet_iterator+=1
|
| 729 |
|
742 |
|
| 730 |
sheet = wbk.add_sheet('Negative Margin')
|
743 |
sheet = wbk.add_sheet('Negative Margin')
|
| 731 |
|
744 |
|
| Line 782... |
Line 795... |
| 782 |
else:
|
795 |
else:
|
| 783 |
sheet.write(sheet_iterator, 15, getNetAvailability(inventoryMap.get(snapdealItemInfo.item_id)))
|
796 |
sheet.write(sheet_iterator, 15, getNetAvailability(inventoryMap.get(snapdealItemInfo.item_id)))
|
| 784 |
sheet.write(sheet_iterator, 16, getOosString((itemSaleMap.get(snapdealItemInfo.item_id))[1]))
|
797 |
sheet.write(sheet_iterator, 16, getOosString((itemSaleMap.get(snapdealItemInfo.item_id))[1]))
|
| 785 |
sheet.write(sheet_iterator, 17, (itemSaleMap.get(snapdealItemInfo.item_id))[3])
|
798 |
sheet.write(sheet_iterator, 17, (itemSaleMap.get(snapdealItemInfo.item_id))[3])
|
| 786 |
sheet.write(sheet_iterator, 18, snapdealItemInfo.nlc)
|
799 |
sheet.write(sheet_iterator, 18, snapdealItemInfo.nlc)
|
| 787 |
sheet.write(sheet_iterator, 19, snapdealPricing.ourTp - snapdealPricing.lowestPossibleTp)
|
800 |
sheet.write(sheet_iterator, 19, round((snapdealPricing.ourTp - snapdealPricing.lowestPossibleTp),2))
|
| 788 |
sheet_iterator+=1
|
801 |
sheet_iterator+=1
|
| 789 |
|
802 |
|
| 790 |
sheet = wbk.add_sheet('Exception Item List')
|
803 |
sheet = wbk.add_sheet('Exception Item List')
|
| 791 |
|
804 |
|
| 792 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
805 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 890... |
Line 903... |
| 890 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
903 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 891 |
else:
|
904 |
else:
|
| 892 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
905 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 893 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
906 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 894 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
907 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 895 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
908 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 896 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
909 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 897 |
sheet.write(sheet_iterator, 28, target_nlc)
|
910 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 898 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
911 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 899 |
sheet_iterator+=1
|
912 |
sheet_iterator+=1
|
| 900 |
|
913 |
|
| 901 |
sheet = wbk.add_sheet('Can Compete-No Inv On SD')
|
914 |
sheet = wbk.add_sheet('Can Compete-No Inv On SD')
|
| 902 |
|
915 |
|
| Line 980... |
Line 993... |
| 980 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
993 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 981 |
else:
|
994 |
else:
|
| 982 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
995 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 983 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
996 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 984 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
997 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 985 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
998 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 986 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
999 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 987 |
sheet.write(sheet_iterator, 28, target_nlc)
|
1000 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 988 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
1001 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 989 |
sheet_iterator+=1
|
1002 |
sheet_iterator+=1
|
| 990 |
|
1003 |
|
| 991 |
if (runType=='FULL'):
|
1004 |
if (runType=='FULL'):
|
| 992 |
sheet = wbk.add_sheet('Auto Favorites')
|
1005 |
sheet = wbk.add_sheet('Auto Favorites')
|
| Line 1037... |
Line 1050... |
| 1037 |
sheet.write(0, 0, "Item ID", heading_xf)
|
1050 |
sheet.write(0, 0, "Item ID", heading_xf)
|
| 1038 |
sheet.write(0, 1, "Brand", heading_xf)
|
1051 |
sheet.write(0, 1, "Brand", heading_xf)
|
| 1039 |
sheet.write(0, 2, "Product Name", heading_xf)
|
1052 |
sheet.write(0, 2, "Product Name", heading_xf)
|
| 1040 |
sheet.write(0, 3, "Decision", heading_xf)
|
1053 |
sheet.write(0, 3, "Decision", heading_xf)
|
| 1041 |
sheet.write(0, 4, "Reason", heading_xf)
|
1054 |
sheet.write(0, 4, "Reason", heading_xf)
|
| - |
|
1055 |
sheet.write(0, 5, "Old Selling Price", heading_xf)
|
| 1042 |
sheet.write(0, 5, "Selling Price Updated",heading_xf)
|
1056 |
sheet.write(0, 6, "Selling Price Updated",heading_xf)
|
| 1043 |
|
1057 |
|
| 1044 |
sheet_iterator=1
|
1058 |
sheet_iterator=1
|
| 1045 |
for autoPricingItem in autoPricingItems:
|
1059 |
for autoPricingItem in autoPricingItems:
|
| 1046 |
mpHistory = autoPricingItem[0]
|
1060 |
mpHistory = autoPricingItem[0]
|
| 1047 |
item = autoPricingItem[1]
|
1061 |
item = autoPricingItem[1]
|
| - |
|
1062 |
it = Item.query.filter_by(id=item.id).one()
|
| 1048 |
sheet.write(sheet_iterator, 0, item.id)
|
1063 |
sheet.write(sheet_iterator, 0, item.id)
|
| 1049 |
sheet.write(sheet_iterator, 1, it.brand)
|
1064 |
sheet.write(sheet_iterator, 1, it.brand)
|
| 1050 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
1065 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| 1051 |
sheet.write(sheet_iterator, 3, Decision._VALUES_TO_NAMES.get(mpHistory.decision))
|
1066 |
sheet.write(sheet_iterator, 3, Decision._VALUES_TO_NAMES.get(mpHistory.decision))
|
| 1052 |
sheet.write(sheet_iterator, 4, mpHistory.reason)
|
1067 |
sheet.write(sheet_iterator, 4, mpHistory.reason)
|
| 1053 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_DECREMENT_SUCCESS":
|
1068 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_DECREMENT_SUCCESS":
|
| - |
|
1069 |
sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
| 1054 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.proposedSellingPrice))
|
1070 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.proposedSellingPrice))
|
| 1055 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
1071 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
| - |
|
1072 |
sheet.write(sheet_iterator, 5, mpHistory.ourSellingPrice)
|
| 1056 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
1073 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
| 1057 |
sheet_iterator+=1
|
1074 |
sheet_iterator+=1
|
| 1058 |
|
1075 |
|
| 1059 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
1076 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1060 |
wbk.save(filename)
|
1077 |
wbk.save(filename)
|
| 1061 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing " + str(timestamp), "", [get_attachment_part(filename)], ["kshitij.sood@saholic.com"], [])
|
1078 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","kshitij.sood@saholic.com"], " Snapdeal Auto Pricing " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
| - |
|
1079 |
|
| - |
|
1080 |
|
| - |
|
1081 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
|
| - |
|
1082 |
xstr = lambda s: s or ""
|
| - |
|
1083 |
message="""<html>
|
| - |
|
1084 |
<body>
|
| - |
|
1085 |
<h4>Auto Decrease Items</h4>
|
| - |
|
1086 |
<table border="1">
|
| - |
|
1087 |
<thead>
|
| - |
|
1088 |
<tr><th>Item Id</th>
|
| - |
|
1089 |
<th>Product Name</th>
|
| - |
|
1090 |
<th>Old Price</th>
|
| - |
|
1091 |
<th>New Price</th>
|
| - |
|
1092 |
</tr></thead>
|
| - |
|
1093 |
<tbody>"""
|
| - |
|
1094 |
for item in successfulAutoDecrease:
|
| - |
|
1095 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1096 |
message+="""<tr>
|
| - |
|
1097 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
1098 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
1099 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
1100 |
<td style="text-align:center">"""+str(item.proposedSellingPrice)+"""</td></tr>"""
|
| - |
|
1101 |
message+="""</tbody></table><h4>Auto Increase Items</h4><table border="1" style="width: 40%;">
|
| - |
|
1102 |
<thead>
|
| - |
|
1103 |
<tr><th>Item Id</th>
|
| - |
|
1104 |
<th>Product Name</th>
|
| - |
|
1105 |
<th>Old Price</th>
|
| - |
|
1106 |
<th>New Price</th>
|
| - |
|
1107 |
</tr></thead>
|
| - |
|
1108 |
<tbody>"""
|
| - |
|
1109 |
for item in successfulAutoIncrease:
|
| - |
|
1110 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1111 |
message+="""<tr>
|
| - |
|
1112 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
1113 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
1114 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
1115 |
<td style="text-align:center">"""+str(item.proposedSellingPrice)+"""</td></tr>"""
|
| - |
|
1116 |
message+="""</tbody></table></body></html>"""
|
| - |
|
1117 |
print message
|
| - |
|
1118 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
1119 |
mailServer.ehlo()
|
| - |
|
1120 |
mailServer.starttls()
|
| - |
|
1121 |
mailServer.ehlo()
|
| - |
|
1122 |
|
| - |
|
1123 |
# Create the container (outer) email message.
|
| - |
|
1124 |
msg = MIMEMultipart()
|
| - |
|
1125 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
1126 |
msg['From'] = ""
|
| - |
|
1127 |
msg['To'] = 'sku-recipients@saholic.com'
|
| - |
|
1128 |
msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
1129 |
html_msg = MIMEText(message, 'html')
|
| - |
|
1130 |
msg.attach(html_msg)
|
| - |
|
1131 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
1132 |
mailServer.sendmail("cafe@nes", ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','kshitij.sood@saholic.com'], msg.as_string())
|
| 1062 |
|
1133 |
|
| 1063 |
def commitExceptionList(exceptionList,timestamp):
|
1134 |
def commitExceptionList(exceptionList,timestamp):
|
| 1064 |
exceptionItems=[]
|
1135 |
exceptionItems=[]
|
| 1065 |
for item in exceptionList:
|
1136 |
for item in exceptionList:
|
| 1066 |
mpHistory = MarketPlaceHistory()
|
1137 |
mpHistory = MarketPlaceHistory()
|
| Line 1130... |
Line 1201... |
| 1130 |
mpHistory.ourTp = snapdealPricing.ourTp
|
1201 |
mpHistory.ourTp = snapdealPricing.ourTp
|
| 1131 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
1202 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
| 1132 |
if (snapdealPricing.competitionBasis=='SP'):
|
1203 |
if (snapdealPricing.competitionBasis=='SP'):
|
| 1133 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
1204 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
| 1134 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1205 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1135 |
mpHistory.proposedSellingPrice = proposed_sp
|
1206 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1136 |
mpHistory.proposedTp = proposed_tp
|
1207 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1137 |
else:
|
1208 |
else:
|
| 1138 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
1209 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 1139 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1210 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 1140 |
mpHistory.proposedSellingPrice = proposed_sp
|
1211 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1141 |
mpHistory.proposedTp = proposed_tp
|
1212 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1142 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1213 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1143 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1214 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1144 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1215 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| 1145 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
1216 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 1146 |
mpHistory.timestamp = timestamp
|
1217 |
mpHistory.timestamp = timestamp
|
| Line 1177... |
Line 1248... |
| 1177 |
mpHistory.ourTp = snapdealPricing.ourTp
|
1248 |
mpHistory.ourTp = snapdealPricing.ourTp
|
| 1178 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
1249 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
| 1179 |
if (snapdealPricing.competitionBasis=='SP'):
|
1250 |
if (snapdealPricing.competitionBasis=='SP'):
|
| 1180 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
1251 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
| 1181 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1252 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1182 |
mpHistory.proposedSellingPrice = proposed_sp
|
1253 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1183 |
mpHistory.proposedTp = proposed_tp
|
1254 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1184 |
else:
|
1255 |
else:
|
| 1185 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
1256 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 1186 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1257 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 1187 |
mpHistory.proposedSellingPrice = proposed_sp
|
1258 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1188 |
mpHistory.proposedTp = proposed_tp
|
1259 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1189 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1260 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1190 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1261 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1191 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1262 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| 1192 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
1263 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 1193 |
mpHistory.timestamp = timestamp
|
1264 |
mpHistory.timestamp = timestamp
|
| Line 1225... |
Line 1296... |
| 1225 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
1296 |
mpHistory.ourNlc = snapdealItemInfo.nlc
|
| 1226 |
if (snapdealPricing.competitionBasis=='SP'):
|
1297 |
if (snapdealPricing.competitionBasis=='SP'):
|
| 1227 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
1298 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
| 1228 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1299 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1229 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1300 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1230 |
mpHistory.proposedSellingPrice = proposed_sp
|
1301 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1231 |
mpHistory.proposedTp = proposed_tp
|
1302 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1232 |
mpHistory.targetNlc = target_nlc
|
1303 |
mpHistory.targetNlc = round(target_nlc,2)
|
| 1233 |
else:
|
1304 |
else:
|
| 1234 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
1305 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 1235 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1306 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 1236 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1307 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1237 |
mpHistory.proposedSellingPrice = proposed_sp
|
1308 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1238 |
mpHistory.proposedTp = proposed_tp
|
1309 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1239 |
mpHistory.targetNlc = target_nlc
|
1310 |
mpHistory.targetNlc = round(target_nlc,2)
|
| 1240 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1311 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1241 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1312 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1242 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1313 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| 1243 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
1314 |
mpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 1244 |
mpHistory.timestamp = timestamp
|
1315 |
mpHistory.timestamp = timestamp
|
| Line 1280... |
Line 1351... |
| 1280 |
mpHistory.secondLowestTp = snapdealPricing.secondLowestSellerTp
|
1351 |
mpHistory.secondLowestTp = snapdealPricing.secondLowestSellerTp
|
| 1281 |
if (snapdealPricing.competitionBasis=='SP'):
|
1352 |
if (snapdealPricing.competitionBasis=='SP'):
|
| 1282 |
proposed_sp = max(snapdealDetails.secondLowestSellerSp - max((20, snapdealDetails.secondLowestSellerSp*0.002)), snapdealPricing.lowestPossibleSp)
|
1353 |
proposed_sp = max(snapdealDetails.secondLowestSellerSp - max((20, snapdealDetails.secondLowestSellerSp*0.002)), snapdealPricing.lowestPossibleSp)
|
| 1283 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1354 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1284 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1355 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1285 |
mpHistory.proposedSellingPrice = proposed_sp
|
1356 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1286 |
mpHistory.proposedTp = proposed_tp
|
1357 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1287 |
#mpHistory.targetNlc = target_nlc
|
1358 |
#mpHistory.targetNlc = target_nlc
|
| 1288 |
else:
|
1359 |
else:
|
| 1289 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
1360 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
| 1290 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1361 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
| 1291 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1362 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1292 |
mpHistory.proposedSellingPrice = proposed_sp
|
1363 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1293 |
mpHistory.proposedTp = proposed_tp
|
1364 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1294 |
#mpHistory.targetNlc = target_nlc
|
1365 |
#mpHistory.targetNlc = target_nlc
|
| 1295 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1366 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1296 |
mpHistory.marginIncreasedPotential = proposed_tp - snapdealPricing.ourTp
|
1367 |
mpHistory.marginIncreasedPotential = proposed_tp - snapdealPricing.ourTp
|
| 1297 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1368 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1298 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1369 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| Line 1307... |
Line 1378... |
| 1307 |
if val.parent_category==10011:
|
1378 |
if val.parent_category==10011:
|
| 1308 |
commissionPercentage = spm.competitorCommissionAccessory
|
1379 |
commissionPercentage = spm.competitorCommissionAccessory
|
| 1309 |
else:
|
1380 |
else:
|
| 1310 |
commissionPercentage = spm.competitorCommissionOther
|
1381 |
commissionPercentage = spm.competitorCommissionOther
|
| 1311 |
if snapdealDetails.rank==1:
|
1382 |
if snapdealDetails.rank==1:
|
| 1312 |
return snapdealDetails.secondLowestSellerSp- snapdealDetails.secondLowestSellerSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
1383 |
otherTp = snapdealDetails.secondLowestSellerSp- snapdealDetails.secondLowestSellerSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
| - |
|
1384 |
return round(otherTp,2)
|
| 1313 |
return snapdealDetails.lowestSp- snapdealDetails.lowestSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
1385 |
otherTp = snapdealDetails.lowestSp- snapdealDetails.lowestSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
| - |
|
1386 |
return round(otherTp,2)
|
| 1314 |
|
1387 |
|
| 1315 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
1388 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
| 1316 |
if snapdealDetails.rank==0:
|
1389 |
if snapdealDetails.rank==0:
|
| 1317 |
return mpItem.minimumPossibleTp
|
1390 |
return mpItem.minimumPossibleTp
|
| 1318 |
vat = (snapdealDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100);
|
1391 |
vat = (snapdealDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100);
|
| 1319 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*snapdealDetails.ourSp+mpItem.otherCost;
|
1392 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*snapdealDetails.ourSp+mpItem.otherCost;
|
| 1320 |
lowest_possible_tp = val.nlc+inHouseCost;
|
1393 |
lowest_possible_tp = val.nlc+inHouseCost;
|
| 1321 |
return lowest_possible_tp
|
1394 |
return round(lowest_possible_tp,2)
|
| 1322 |
|
1395 |
|
| 1323 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
1396 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
| 1324 |
if snapdealDetails.rank==0:
|
1397 |
if snapdealDetails.rank==0:
|
| 1325 |
return mpItem.currentTp
|
1398 |
return mpItem.currentTp
|
| 1326 |
return snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1399 |
ourTp = snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
| - |
|
1400 |
return round(ourTp,2)
|
| 1327 |
|
1401 |
|
| 1328 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
1402 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
| 1329 |
if snapdealDetails.rank==0:
|
1403 |
if snapdealDetails.rank==0:
|
| 1330 |
return mpItem.minimumPossibleSp
|
1404 |
return mpItem.minimumPossibleSp
|
| - |
|
1405 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
| 1331 |
return (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
1406 |
return round(lowestPossibleSp,2)
|
| 1332 |
|
1407 |
|
| 1333 |
def getTargetTp(targetSp,mpItem):
|
1408 |
def getTargetTp(targetSp,mpItem):
|
| 1334 |
return targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1409 |
targetTp = targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
| - |
|
1410 |
return round(targetTp,2)
|
| 1335 |
|
1411 |
|
| 1336 |
def getTargetSp(targetTp,mpItem):
|
1412 |
def getTargetSp(targetTp,mpItem):
|
| 1337 |
return float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
1413 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
| - |
|
1414 |
return round(targetSp,2)
|
| 1338 |
|
1415 |
|
| 1339 |
def getSalesPotential(lowestOfferPrice,ourNlc):
|
1416 |
def getSalesPotential(lowestOfferPrice,ourNlc):
|
| 1340 |
if lowestOfferPrice - ourNlc < 0:
|
1417 |
if lowestOfferPrice - ourNlc < 0:
|
| 1341 |
return 'HIGH'
|
1418 |
return 'HIGH'
|
| 1342 |
elif (float(lowestOfferPrice - ourNlc))/lowestOfferPrice >=0 and (float(lowestOfferPrice - ourNlc))/lowestOfferPrice <=.02:
|
1419 |
elif (float(lowestOfferPrice - ourNlc))/lowestOfferPrice >=0 and (float(lowestOfferPrice - ourNlc))/lowestOfferPrice <=.02:
|
| Line 1361... |
Line 1438... |
| 1361 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
1438 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
| 1362 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
1439 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
| 1363 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
1440 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
| 1364 |
competitiveNoInventoryItems = commitCompetitiveNoInventory(competitiveNoInventory,timestamp)
|
1441 |
competitiveNoInventoryItems = commitCompetitiveNoInventory(competitiveNoInventory,timestamp)
|
| 1365 |
negativeMarginItems = commitNegativeMargin(negativeMargin,timestamp)
|
1442 |
negativeMarginItems = commitNegativeMargin(negativeMargin,timestamp)
|
| 1366 |
fetchItemsForAutoDecrease(timestamp)
|
1443 |
successfulAutoDecrease = fetchItemsForAutoDecrease(timestamp)
|
| 1367 |
fetchItemsForAutoIncrease(timestamp)
|
1444 |
successfulAutoIncrease = fetchItemsForAutoIncrease(timestamp)
|
| 1368 |
if options.runType=='FULL':
|
1445 |
if options.runType=='FULL':
|
| 1369 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
1446 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
| - |
|
1447 |
if options.runType=='FULL':
|
| 1370 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
1448 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
| - |
|
1449 |
else:
|
| - |
|
1450 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
| - |
|
1451 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| 1371 |
|
1452 |
|
| 1372 |
if __name__ == '__main__':
|
1453 |
if __name__ == '__main__':
|
| 1373 |
main()
|
1454 |
main()
|
| 1374 |
|
1455 |
|