| Line 34... |
Line 34... |
| 34 |
host = config_client.get_property('staging_hostname')
|
34 |
host = config_client.get_property('staging_hostname')
|
| 35 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
35 |
syncPrice=config_client.get_property('sync_price_on_marketplace')
|
| 36 |
|
36 |
|
| 37 |
amazonAsinPrice={}
|
37 |
amazonAsinPrice={}
|
| 38 |
amazonLongTermActivePromotions = []
|
38 |
amazonLongTermActivePromotions = []
|
| - |
|
39 |
amazonShortTermActivePromotions = []
|
| 39 |
saleMap = {}
|
40 |
saleMap = {}
|
| 40 |
DataService.initialize(db_hostname=host)
|
41 |
DataService.initialize(db_hostname=host)
|
| 41 |
|
42 |
|
| 42 |
amScraper = AmazonAsyncScraper.AmazonAsyncScraper()
|
43 |
amScraper = AmazonAsyncScraper.AmazonAsyncScraper()
|
| 43 |
|
44 |
|
| Line 89... |
Line 90... |
| 89 |
self.lowestPossibleTp = lowestPossibleTp
|
90 |
self.lowestPossibleTp = lowestPossibleTp
|
| 90 |
self.ourSp = ourSp
|
91 |
self.ourSp = ourSp
|
| 91 |
self.lowestPossibleSp = lowestPossibleSp
|
92 |
self.lowestPossibleSp = lowestPossibleSp
|
| 92 |
|
93 |
|
| 93 |
|
94 |
|
| - |
|
95 |
def fetchItemsForAutoDecrease(time):
|
| - |
|
96 |
successfulAutoDecrease = []
|
| - |
|
97 |
autoDecrementItems = session.query(AmazonScrapingHistory).join((Amazonlisted,AmazonScrapingHistory.item_id==Amazonlisted.itemId))\
|
| - |
|
98 |
.filter(AmazonScrapingHistory.timestamp==time).filter(or_(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE,AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE, AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE ))\
|
| - |
|
99 |
.filter(Amazonlisted.autoDecrement==True).all()
|
| - |
|
100 |
for autoDecrementItem in autoDecrementItems:
|
| - |
|
101 |
if autoDecrementItem.warehouseLocation == 1:
|
| - |
|
102 |
sku = 'FBA'+str(autoDecrementItem.item_id)
|
| - |
|
103 |
else:
|
| - |
|
104 |
sku = 'FBB'+str(autoDecrementItem.item_id)
|
| - |
|
105 |
if sku in amazonShortTermActivePromotions:
|
| - |
|
106 |
markReasonForItem(autoDecrementItem,'Item in short term promotion',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
107 |
continue
|
| - |
|
108 |
if math.ceil(autoDecrementItem.proposedSp) >= autoDecrementItem.ourSellingPrice:
|
| - |
|
109 |
markReasonForItem(autoDecrementItem,'Proposed SP greater than or equal to current SP',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
110 |
continue
|
| - |
|
111 |
if autoDecrementItem.proposedSellingPrice < autoDecrementItem.lowestPossibleSp:
|
| - |
|
112 |
markReasonForItem(autoDecrementItem,'Proposed SP less than lowest possible SP',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
113 |
continue
|
| - |
|
114 |
try:
|
| - |
|
115 |
daysOfStock = (float(autoDecrementItem.ourInventory))/autoDecrementItem.avgSale
|
| - |
|
116 |
except:
|
| - |
|
117 |
daysOfStock = float("inf")
|
| - |
|
118 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE:
|
| - |
|
119 |
if daysOfStock < 20:
|
| - |
|
120 |
markReasonForItem(autoDecrementItem,'Days of stock less than 20',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
121 |
|
| - |
|
122 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE:
|
| - |
|
123 |
if autoDecrementItem.parentCategoryId in [10006,10009,11001]:
|
| - |
|
124 |
if daysOfStock < 1:
|
| - |
|
125 |
markReasonForItem(autoDecrementItem,'Days of stock less than 1',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
126 |
else:
|
| - |
|
127 |
if daysOfStock < 3:
|
| - |
|
128 |
markReasonForItem(autoDecrementItem,'Days of stock less than 3',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
129 |
|
| - |
|
130 |
autoDecrementItem.ourEnoughStock=True
|
| - |
|
131 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
| - |
|
132 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
| - |
|
133 |
successfulAutoDecrease.append(autoDecrementItem)
|
| - |
|
134 |
session.commit()
|
| - |
|
135 |
session.close()
|
| - |
|
136 |
return successfulAutoDecrease
|
| - |
|
137 |
|
| - |
|
138 |
def fetchItemsForAutoIncrease(time):
|
| - |
|
139 |
successfulAutoIncrease = []
|
| - |
|
140 |
autoIncrementItems = session.query(AmazonScrapingHistory).join((Amazonlisted,AmazonScrapingHistory.item_id==Amazonlisted.itemId))\
|
| - |
|
141 |
.filter(AmazonScrapingHistory.timestamp==time).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX)\
|
| - |
|
142 |
.filter(Amazonlisted.autoIncrement==True).all()
|
| - |
|
143 |
transaction_client = TransactionClient().get_client()
|
| - |
|
144 |
for autoIncrementItem in autoIncrementItems:
|
| - |
|
145 |
if autoIncrementItem.warehouseLocation == 1:
|
| - |
|
146 |
sku = 'FBA'+str(autoIncrementItem.item_id)
|
| - |
|
147 |
else:
|
| - |
|
148 |
sku = 'FBB'+str(autoIncrementItem.item_id)
|
| - |
|
149 |
if sku in amazonShortTermActivePromotions:
|
| - |
|
150 |
markReasonForItem(autoIncrementItem,'Item in short term promotion',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
151 |
continue
|
| - |
|
152 |
if autoIncrementItem.totalSeller==1 and autoIncrementItem.ourRank==1:
|
| - |
|
153 |
markReasonForItem(autoIncrementItem,'We are the only seller',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
154 |
continue
|
| - |
|
155 |
if autoIncrementItem.proposedSp <= autoIncrementItem.ourSellingPrice:
|
| - |
|
156 |
markReasonForItem(autoIncrementItem,'Proposed SP less than current SP',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
157 |
continue
|
| - |
|
158 |
if autoIncrementItem.proposedSellingPrice >=10000 and autoIncrementItem.ourSellingPrice<10000:
|
| - |
|
159 |
markReasonForItem(autoIncrementItem,'Proposed SP is greater than 10,000 and current sp is less than 10,000',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
160 |
continue
|
| - |
|
161 |
|
| - |
|
162 |
if autoIncrementItem.avgSale==0:
|
| - |
|
163 |
markReasonForItem(autoIncrementItem,'Avg sale is 0',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
164 |
continue
|
| - |
|
165 |
|
| - |
|
166 |
daysOfStock = (float(autoIncrementItem.ourInventory))/autoIncrementItem.avgSale
|
| - |
|
167 |
if daysOfStock > 5:
|
| - |
|
168 |
markReasonForItem(autoIncrementItem,'Days of stock greater than 5',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
169 |
continue
|
| - |
|
170 |
antecedentPrice = session.query(AmazonScrapingHistory.ourSellingPrice).filter(AmazonScrapingHistory.item_id==autoIncrementItem.item_id).filter(AmazonScrapingHistory.timestamp>time-timedelta(days=1)).order_by(asc(AmazonScrapingHistory.timestamp)).first()
|
| - |
|
171 |
if antecedentPrice is not None:
|
| - |
|
172 |
if float(math.ceil(autoIncrementItem.ourSellingPrice+max(10,.01*autoIncrementItem.ourSellingPrice))-math.ceil(antecedentPrice[0]+max(10,.01*antecedentPrice[0])))/math.ceil(antecedentPrice[0]+max(10,.01*antecedentPrice[0]))>.02:
|
| - |
|
173 |
markReasonForItem(autoIncrementItem,'Maximum price increase in last 24 hours should be 2%',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
174 |
continue
|
| - |
|
175 |
fbaSaleSnapshot = transaction_client.getAmazonFbaSalesLatestSnapshotForItemLocationWise(autoIncrementItem.item_id,autoIncrementItem.warehouseLocation)
|
| - |
|
176 |
if getLastDaySale(fbaSaleSnapshot,autoIncrementItem.warehouseLocation-1)<=2:
|
| - |
|
177 |
markReasonForItem(autoIncrementItem,'Last day sale is less than 3',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
178 |
continue
|
| - |
|
179 |
|
| - |
|
180 |
autoIncrementItem.ourEnoughStock = False
|
| - |
|
181 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
| - |
|
182 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
| - |
|
183 |
successfulAutoIncrease.append(autoIncrementItem)
|
| - |
|
184 |
session.commit()
|
| - |
|
185 |
return successfulAutoIncrease
|
| - |
|
186 |
|
| - |
|
187 |
|
| - |
|
188 |
def markReasonForItem(amHistory,reason,decision):
|
| - |
|
189 |
amHistory.decision = decision
|
| - |
|
190 |
amHistory.reason = reason
|
| - |
|
191 |
|
| - |
|
192 |
def getOosString(oosStatus):
|
| - |
|
193 |
lastNdaySale=""
|
| - |
|
194 |
for obj in oosStatus:
|
| - |
|
195 |
if obj.is_oos:
|
| - |
|
196 |
lastNdaySale += "X-"
|
| - |
|
197 |
else:
|
| - |
|
198 |
lastNdaySale += str(obj.num_orders) + "-"
|
| - |
|
199 |
return lastNdaySale[:-1]
|
| - |
|
200 |
|
| - |
|
201 |
def getLastDaySale(fbaSaleSnapshot):
|
| - |
|
202 |
if fbaSaleSnapshot.item_id==0:
|
| - |
|
203 |
return 0
|
| - |
|
204 |
else:
|
| - |
|
205 |
return fbaSaleSnapshot.totalSale
|
| - |
|
206 |
|
| 94 |
def syncAsin():
|
207 |
def syncAsin():
|
| 95 |
notListedOnAmazon = []
|
208 |
# notListedOnAmazon = []
|
| 96 |
diffAsins = []
|
209 |
# diffAsins = []
|
| 97 |
# login_url = "https://sellercentral.amazon.in/gp/homepage.html"
|
210 |
login_url = "https://sellercentral.amazon.in/gp/homepage.html"
|
| 98 |
# br = SellerCentralInventoryReport.login(login_url)
|
211 |
br = SellerCentralInventoryReport.login(login_url)
|
| 99 |
# report_url = "https://sellercentral.amazon.in/gp/upload-download-utils/requestReport.html?type=OpenListingReport&marketplaceID=44571&Request+Report="
|
212 |
report_url = "https://sellercentral.amazon.in/gp/upload-download-utils/requestReport.html?type=OpenListingReport&marketplaceID=44571&Request+Report="
|
| 100 |
# br = SellerCentralInventoryReport.requestReport(br,report_url)
|
213 |
br = SellerCentralInventoryReport.requestReport(br,report_url)
|
| 101 |
# status_url="https://sellercentral.amazon.in/gp/upload-download-utils/reportStatusData.html"
|
214 |
status_url="https://sellercentral.amazon.in/gp/upload-download-utils/reportStatusData.html"
|
| 102 |
# br, page = SellerCentralInventoryReport.checkStatus(br,status_url)
|
215 |
br, page = SellerCentralInventoryReport.checkStatus(br,status_url)
|
| 103 |
# br, batchId = SellerCentralInventoryReport.getReportBatchId(br,page)
|
216 |
br, batchId = SellerCentralInventoryReport.getReportBatchId(br,page)
|
| 104 |
# print "*********************************"
|
217 |
print "*********************************"
|
| 105 |
# print "Batch Id for request is ",batchId
|
218 |
print "Batch Id for request is ",batchId
|
| 106 |
# print "*********************************"
|
219 |
print "*********************************"
|
| 107 |
# ready = False
|
220 |
ready = False
|
| 108 |
# retryCount = 0
|
221 |
retryCount = 0
|
| 109 |
# while not ready:
|
222 |
while not ready:
|
| 110 |
# if retryCount == 10:
|
223 |
if retryCount == 10:
|
| 111 |
# print "File not available for download after multiple retries"
|
224 |
print "File not available for download after multiple retries"
|
| 112 |
# sys.exit(1)
|
225 |
sys.exit(1)
|
| 113 |
# br, download_link = SellerCentralInventoryReport.downloadReport(br,batchId,status_url)
|
226 |
br, download_link = SellerCentralInventoryReport.downloadReport(br,batchId,status_url)
|
| 114 |
# if download_link is not None:
|
227 |
if download_link is not None:
|
| 115 |
# ready= True
|
228 |
ready= True
|
| 116 |
# continue
|
229 |
continue
|
| 117 |
# print "File not ready for download yet.Will try again after 30 seconds."
|
230 |
print "File not ready for download yet.Will try again after 30 seconds."
|
| 118 |
# retryCount+=1
|
231 |
retryCount+=1
|
| 119 |
# time.sleep(30)
|
232 |
time.sleep(30)
|
| 120 |
# fPath = SellerCentralInventoryReport.fetchFile(download_link['href'],br,batchId)
|
233 |
fPath = SellerCentralInventoryReport.fetchFile(download_link['href'],br,batchId)
|
| 121 |
fPath = '/tmp/9921129430.txt'
|
- |
|
| 122 |
global amazonAsinPrice
|
234 |
global amazonAsinPrice
|
| 123 |
for line in open(fPath):
|
235 |
for line in open(fPath):
|
| 124 |
l = line.split('\t')
|
236 |
l = line.split('\t')
|
| 125 |
if (str(l[0]).startswith('FBA') or str(l[0]).startswith('FBB')):
|
237 |
if (str(l[0]).startswith('FBA') or str(l[0]).startswith('FBB')):
|
| 126 |
obj = __AmazonAsinPrice(l[1],l[2])
|
238 |
obj = __AmazonAsinPrice(l[1],l[2])
|
| 127 |
amazonAsinPrice[l[0]] = obj
|
239 |
amazonAsinPrice[l[0]] = obj
|
| - |
|
240 |
#Can be used to sync asins, not doing due to multiple asins corresponding to one itemId
|
| 128 |
# systemAsins = session.query(Item,Amazonlisted).join((Amazonlisted,Item.id==Amazonlisted.itemId)).all()
|
241 |
# systemAsins = session.query(Item,Amazonlisted).join((Amazonlisted,Item.id==Amazonlisted.itemId)).all()
|
| 129 |
# for systemAsin in systemAsins:
|
242 |
# for systemAsin in systemAsins:
|
| 130 |
# item = systemAsin[0]
|
243 |
# item = systemAsin[0]
|
| 131 |
# amListed = systemAsin[1]
|
244 |
# amListed = systemAsin[1]
|
| 132 |
# if amazonAsinPrice.get('FBA'+str(item.id)) is None:
|
245 |
# if amazonAsinPrice.get('FBA'+str(item.id)) is None:
|
| Line 183... |
Line 296... |
| 183 |
|
296 |
|
| 184 |
def calculateAverageSale(sku):
|
297 |
def calculateAverageSale(sku):
|
| 185 |
count,sale = 0,0
|
298 |
count,sale = 0,0
|
| 186 |
oosStatus = saleMap.get(sku)
|
299 |
oosStatus = saleMap.get(sku)
|
| 187 |
for obj in oosStatus:
|
300 |
for obj in oosStatus:
|
| 188 |
if not obj.is_oos:
|
301 |
if not obj.isOutOfStock:
|
| 189 |
count+=1
|
302 |
count+=1
|
| 190 |
sale = sale+obj.num_orders
|
303 |
sale = sale+obj.totalSales
|
| 191 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
304 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 192 |
return round(avgSalePerDay,2)
|
305 |
return round(avgSalePerDay,2)
|
| 193 |
|
306 |
|
| 194 |
def computeCourierCost(weight):
|
307 |
def computeCourierCost(weight):
|
| 195 |
try:
|
308 |
try:
|
| Line 202... |
Line 315... |
| 202 |
return 10.0
|
315 |
return 10.0
|
| 203 |
|
316 |
|
| 204 |
|
317 |
|
| 205 |
def populateStuff(time,runType):
|
318 |
def populateStuff(time,runType):
|
| 206 |
global amazonLongTermActivePromotions
|
319 |
global amazonLongTermActivePromotions
|
| - |
|
320 |
global amazonShortTermActivePromotions
|
| 207 |
itemInfo = []
|
321 |
itemInfo = []
|
| 208 |
inventory_client = InventoryClient().get_client()
|
322 |
inventory_client = InventoryClient().get_client()
|
| 209 |
fbaAvailableInventorySnapshot = inventory_client.getAllAvailableAmazonFbaItemInventory()
|
323 |
fbaAvailableInventorySnapshot = inventory_client.getAllAvailableAmazonFbaItemInventory()
|
| 210 |
print "length****"
|
324 |
print "length****"
|
| 211 |
print len(fbaAvailableInventorySnapshot)
|
325 |
print len(fbaAvailableInventorySnapshot)
|
| Line 251... |
Line 365... |
| 251 |
itemInfo.append(amazonItemInfo)
|
365 |
itemInfo.append(amazonItemInfo)
|
| 252 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
366 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 253 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
367 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 254 |
for amPromotion in amPromotions:
|
368 |
for amPromotion in amPromotions:
|
| 255 |
amazonLongTermActivePromotions.append(amPromotion.sku)
|
369 |
amazonLongTermActivePromotions.append(amPromotion.sku)
|
| - |
|
370 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
| - |
|
371 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| - |
|
372 |
for amPromotion in amPromotions:
|
| - |
|
373 |
amazonShortTermActivePromotions.append(amPromotion.sku)
|
| 256 |
session.close()
|
374 |
session.close()
|
| 257 |
print "item info length"
|
375 |
print "item info length"
|
| 258 |
print len(itemInfo)
|
376 |
print len(itemInfo)
|
| 259 |
return itemInfo
|
377 |
return itemInfo
|
| 260 |
|
378 |
|
| Line 436... |
Line 554... |
| 436 |
temp.append(amDetails)
|
554 |
temp.append(amDetails)
|
| 437 |
temp.append(amPricing)
|
555 |
temp.append(amPricing)
|
| 438 |
canCompete.append(temp)
|
556 |
canCompete.append(temp)
|
| 439 |
continue
|
557 |
continue
|
| 440 |
|
558 |
|
| - |
|
559 |
if amDetails.lowestSellerSp(1+.01) >= amPricing.lowestPossibleSp:
|
| - |
|
560 |
temp = []
|
| - |
|
561 |
temp.append(val)
|
| - |
|
562 |
temp.append(amDetails)
|
| - |
|
563 |
temp.append(amPricing)
|
| - |
|
564 |
almostCompete.append(temp)
|
| - |
|
565 |
continue
|
| - |
|
566 |
|
| - |
|
567 |
|
| 441 |
temp = []
|
568 |
temp = []
|
| 442 |
temp.append(val)
|
569 |
temp.append(val)
|
| 443 |
temp.append(amDetails)
|
570 |
temp.append(amDetails)
|
| 444 |
temp.append(amPricing)
|
571 |
temp.append(amPricing)
|
| 445 |
cantCompete.append(temp)
|
572 |
cantCompete.append(temp)
|
| 446 |
|
573 |
|
| 447 |
itemInfo[:]=[]
|
574 |
itemInfo[:]=[]
|
| 448 |
scrapInfo[:]=[]
|
- |
|
| 449 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
575 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
| 450 |
|
576 |
|
| 451 |
def getOurTp(amazonDetails,val,spm):
|
577 |
def getOurTp(amazonDetails,val,spm):
|
| 452 |
ourTp = amazonDetails.ourSp- amazonDetails.ourSp*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))*(1+(spm.serviceTax/100));
|
578 |
ourTp = amazonDetails.ourSp- amazonDetails.ourSp*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))*(1+(spm.serviceTax/100));
|
| 453 |
return round(ourTp,2)
|
579 |
return round(ourTp,2)
|
| 454 |
|
580 |
|
| 455 |
def getLowestPossibleTp(amazonDetails,val,spm):
|
581 |
def getLowestPossibleTp(amazonDetails,val,spm):
|
| Line 471... |
Line 597... |
| 471 |
val = exceptionItem[0]
|
597 |
val = exceptionItem[0]
|
| 472 |
reason = exceptionItem[1]
|
598 |
reason = exceptionItem[1]
|
| 473 |
amazonScrapingHistory = AmazonScrapingHistory()
|
599 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 474 |
amazonScrapingHistory.item_id = val.sku[3:]
|
600 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 475 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
601 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
602 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 476 |
amazonScrapingHistory.reason = reason
|
603 |
amazonScrapingHistory.reason = reason
|
| 477 |
amazonScrapingHistory.runType = RunType._NAMES_TO_VALUES.get(runType)
|
604 |
amazonScrapingHistory.runType = RunType._NAMES_TO_VALUES.get(runType)
|
| 478 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.EXCEPTION
|
605 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.EXCEPTION
|
| 479 |
amazonScrapingHistory.timestamp = timestamp
|
606 |
amazonScrapingHistory.timestamp = timestamp
|
| 480 |
session.commit()
|
607 |
session.commit()
|
| Line 486... |
Line 613... |
| 486 |
amPricing = negativeMarginItem[2]
|
613 |
amPricing = negativeMarginItem[2]
|
| 487 |
spm = val.sourcePercentage
|
614 |
spm = val.sourcePercentage
|
| 488 |
amazonScrapingHistory = AmazonScrapingHistory()
|
615 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 489 |
amazonScrapingHistory.item_id = val.sku[3:]
|
616 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 490 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
617 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
618 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 491 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
619 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| 492 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
620 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| 493 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
621 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| 494 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
622 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 495 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
623 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| Line 522... |
Line 650... |
| 522 |
amPricing = cheapestItem[2]
|
650 |
amPricing = cheapestItem[2]
|
| 523 |
spm = val.sourcePercentage
|
651 |
spm = val.sourcePercentage
|
| 524 |
amazonScrapingHistory = AmazonScrapingHistory()
|
652 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 525 |
amazonScrapingHistory.item_id = val.sku[3:]
|
653 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 526 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
654 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
655 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 527 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
656 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| 528 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
657 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| 529 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
658 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| 530 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
659 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 531 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
660 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| Line 569... |
Line 698... |
| 569 |
amPricing = amongCheapestAndCanCompeteItem[2]
|
698 |
amPricing = amongCheapestAndCanCompeteItem[2]
|
| 570 |
spm = val.sourcePercentage
|
699 |
spm = val.sourcePercentage
|
| 571 |
amazonScrapingHistory = AmazonScrapingHistory()
|
700 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 572 |
amazonScrapingHistory.item_id = val.sku[3:]
|
701 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 573 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
702 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
703 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 574 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
704 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| 575 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
705 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| 576 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
706 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| 577 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
707 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 578 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
708 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| Line 600... |
Line 730... |
| 600 |
amazonScrapingHistory.proposedTp = proposed_tp
|
730 |
amazonScrapingHistory.proposedTp = proposed_tp
|
| 601 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
731 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| 602 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
732 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
| 603 |
session.commit()
|
733 |
session.commit()
|
| 604 |
|
734 |
|
| 605 |
|
- |
|
| 606 |
|
- |
|
| 607 |
def commitCanCompete(canCompete,timestamp,runType):
|
735 |
def commitCanCompete(canCompete,timestamp,runType):
|
| 608 |
for canCompeteItem in canCompete:
|
736 |
for canCompeteItem in canCompete:
|
| 609 |
val = canCompeteItem[0]
|
737 |
val = canCompeteItem[0]
|
| 610 |
amDetails = canCompeteItem[1]
|
738 |
amDetails = canCompeteItem[1]
|
| 611 |
amPricing = canCompeteItem[2]
|
739 |
amPricing = canCompeteItem[2]
|
| 612 |
spm = val.sourcePercentage
|
740 |
spm = val.sourcePercentage
|
| 613 |
amazonScrapingHistory = AmazonScrapingHistory()
|
741 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 614 |
amazonScrapingHistory.item_id = val.sku[3:]
|
742 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 615 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
743 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
744 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 616 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
745 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| 617 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
746 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| 618 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
747 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| 619 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
748 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 620 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
749 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| Line 643... |
Line 772... |
| 643 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
772 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| 644 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
773 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
| 645 |
session.commit()
|
774 |
session.commit()
|
| 646 |
|
775 |
|
| 647 |
def commitAlmostCompete(almostCompete,timestamp,runType):
|
776 |
def commitAlmostCompete(almostCompete,timestamp,runType):
|
| - |
|
777 |
for almostCompeteItem in almostCompete:
|
| - |
|
778 |
val = almostCompeteItem[0]
|
| - |
|
779 |
amDetails = almostCompeteItem[1]
|
| - |
|
780 |
amPricing = almostCompeteItem[2]
|
| - |
|
781 |
spm = val.sourcePercentage
|
| - |
|
782 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| - |
|
783 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| - |
|
784 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
785 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| - |
|
786 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| - |
|
787 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| - |
|
788 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| - |
|
789 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| - |
|
790 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| - |
|
791 |
amazonScrapingHistory.ourInventory = val.ourInventory
|
| - |
|
792 |
amazonScrapingHistory.lowestSellerName = amDetails.lowestSellerName
|
| - |
|
793 |
amazonScrapingHistory.lowestSellerSp = amDetails.lowestSellerSp
|
| - |
|
794 |
amazonScrapingHistory.secondLowestSellerName = amDetails.secondLowestSellerName
|
| - |
|
795 |
amazonScrapingHistory.secondLowestSellerSp = amDetails.secondLowestSellerSp
|
| - |
|
796 |
amazonScrapingHistory.thirdLowestSellerName = amDetails.thirdLowestSellerName
|
| - |
|
797 |
amazonScrapingHistory.thirdLowestSellerSp = amDetails.thirdLowestSellerSp
|
| - |
|
798 |
amazonScrapingHistory.wanlc = val.nlc
|
| - |
|
799 |
amazonScrapingHistory.commission = spm.commission
|
| - |
|
800 |
amazonScrapingHistory.competitorCommission = spm.competitorCommission
|
| - |
|
801 |
amazonScrapingHistory.returnProvision = spm.returnProvision
|
| - |
|
802 |
amazonScrapingHistory.courierCost = val.courierCost
|
| - |
|
803 |
amazonScrapingHistory.risky = val.risky
|
| - |
|
804 |
amazonScrapingHistory.runType = RunType._NAMES_TO_VALUES.get(runType)
|
| - |
|
805 |
amazonScrapingHistory.totalSeller = amDetails.totalSeller
|
| - |
|
806 |
amazonScrapingHistory.competitiveCategory = CompetitionCategory.ALMOST_COMPETE
|
| - |
|
807 |
amazonScrapingHistory.timestamp = timestamp
|
| - |
|
808 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| - |
|
809 |
proposed_sp = min(amDetails.lowestSellerSp(1+.01),amPricing.lowestPossibleSp)
|
| - |
|
810 |
proposed_tp = getTargetTp(proposed_sp,spm,val)
|
| - |
|
811 |
target_nlc = proposed_tp - amPricing.lowestPossibleTp + val.nlc
|
| - |
|
812 |
amazonScrapingHistory.proposedSp = proposed_sp
|
| - |
|
813 |
amazonScrapingHistory.proposedTp = proposed_tp
|
| - |
|
814 |
amazonScrapingHistory.targetNlc = target_nlc
|
| - |
|
815 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| - |
|
816 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
| 648 |
return
|
817 |
session.commit()
|
| - |
|
818 |
|
| 649 |
|
819 |
|
| 650 |
def commitCantCompete(cantCompete, timestamp,runType):
|
820 |
def commitCantCompete(cantCompete, timestamp,runType):
|
| 651 |
for cantCompeteItem in cantCompete:
|
821 |
for cantCompeteItem in cantCompete:
|
| 652 |
val = cantCompeteItem[0]
|
822 |
val = cantCompeteItem[0]
|
| 653 |
amDetails = cantCompeteItem[1]
|
823 |
amDetails = cantCompeteItem[1]
|
| 654 |
amPricing = cantCompeteItem[2]
|
824 |
amPricing = cantCompeteItem[2]
|
| 655 |
spm = val.sourcePercentage
|
825 |
spm = val.sourcePercentage
|
| 656 |
amazonScrapingHistory = AmazonScrapingHistory()
|
826 |
amazonScrapingHistory = AmazonScrapingHistory()
|
| 657 |
amazonScrapingHistory.item_id = val.sku[3:]
|
827 |
amazonScrapingHistory.item_id = val.sku[3:]
|
| 658 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
828 |
amazonScrapingHistory.warehouseLocation = val.state_id
|
| - |
|
829 |
amazonScrapingHistory.parentCategoryId = val.parent_category
|
| 659 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
830 |
amazonScrapingHistory.ourSellingPrice = amDetails.ourSp
|
| 660 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
831 |
amazonScrapingHistory.ourTp = amPricing.ourTp
|
| 661 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
832 |
amazonScrapingHistory.lowestPossibleTp = amPricing.lowestPossibleTp
|
| 662 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
833 |
amazonScrapingHistory.lowestPossibleSp = amPricing.lowestPossibleSp
|
| 663 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
834 |
amazonScrapingHistory.ourRank = amDetails.ourRank
|
| Line 687... |
Line 858... |
| 687 |
amazonScrapingHistory.targetNlc = target_nlc
|
858 |
amazonScrapingHistory.targetNlc = target_nlc
|
| 688 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
859 |
amazonScrapingHistory.multipleListings = amDetails.multipleListings
|
| 689 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
860 |
amazonScrapingHistory.avgSale = calculateAverageSale(val.sku) #Last five days
|
| 690 |
session.commit()
|
861 |
session.commit()
|
| 691 |
|
862 |
|
| - |
|
863 |
def markAutoFavourites(time):
|
| - |
|
864 |
nowAutoFav = []
|
| - |
|
865 |
previouslyAutoFav = []
|
| - |
|
866 |
stockList = []
|
| - |
|
867 |
saleList = []
|
| - |
|
868 |
items = session.query(func.sum(AmazonScrapingHistory.ourInventory),AmazonScrapingHistory.item_id).group_by(AmazonScrapingHistory.item_id).all()
|
| - |
|
869 |
allItems = session.query(Amazonlisted).all()
|
| - |
|
870 |
for item in items:
|
| - |
|
871 |
reason = ""
|
| - |
|
872 |
if item[0]>=5:
|
| - |
|
873 |
stockList.append(item[1])
|
| - |
|
874 |
|
| - |
|
875 |
for sku, val in saleMap.iteritems():
|
| - |
|
876 |
totalSale = 0
|
| - |
|
877 |
item_id = sku.replace('FBA','').replace('FBB','')
|
| - |
|
878 |
val =saleMap.get('FBA'+str(item_id))
|
| - |
|
879 |
if val is not None:
|
| - |
|
880 |
for sale in val:
|
| - |
|
881 |
totalSale += sale.totalOrderCount
|
| - |
|
882 |
val =saleMap.get('FBB'+str(item_id))
|
| - |
|
883 |
if val is not None:
|
| - |
|
884 |
for sale in val:
|
| - |
|
885 |
totalSale += sale.totalOrderCount
|
| - |
|
886 |
if totalSale > 0:
|
| - |
|
887 |
saleList.append(item_id)
|
| - |
|
888 |
|
| - |
|
889 |
for aItem in allItems:
|
| - |
|
890 |
reason = ""
|
| - |
|
891 |
toMark = False
|
| - |
|
892 |
if aItem.itemId in saleList:
|
| - |
|
893 |
toMark = True
|
| - |
|
894 |
reason+="Total FC sale is greater than 1 for last five days.."
|
| - |
|
895 |
if aItem.itemId in stockList:
|
| - |
|
896 |
toMark = True
|
| - |
|
897 |
reason+="Item is present in buy box in last 3 days"
|
| - |
|
898 |
if not aItem.autoFavourite:
|
| - |
|
899 |
print "Item is not under auto favourite"
|
| - |
|
900 |
if toMark:
|
| - |
|
901 |
temp=[]
|
| - |
|
902 |
temp.append(aItem.itemId)
|
| - |
|
903 |
temp.append(reason)
|
| - |
|
904 |
nowAutoFav.append(temp)
|
| - |
|
905 |
if (not toMark) and aItem.autoFavourite:
|
| - |
|
906 |
previouslyAutoFav.append(aItem.itemId)
|
| - |
|
907 |
aItem.autoFavourite = toMark
|
| - |
|
908 |
session.commit()
|
| - |
|
909 |
return previouslyAutoFav, nowAutoFav
|
| - |
|
910 |
|
| - |
|
911 |
def writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav):
|
| - |
|
912 |
wbk = xlwt.Workbook()
|
| - |
|
913 |
sheet = wbk.add_sheet('Can\'t Compete')
|
| - |
|
914 |
xstr = lambda s: s or ""
|
| - |
|
915 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
916 |
|
| - |
|
917 |
excel_integer_format = '0'
|
| - |
|
918 |
integer_style = xlwt.XFStyle()
|
| - |
|
919 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
920 |
|
| - |
|
921 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
922 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
923 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
924 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
925 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
926 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
927 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
928 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
929 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
930 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
931 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
932 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
933 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
934 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
935 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
936 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
937 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
938 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
939 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
940 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
941 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
942 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
943 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
944 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
945 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
946 |
sheet.write(0, 25, "Risky", heading_xf)
|
| - |
|
947 |
sheet.write(0, 26, "Proposed Sp", heading_xf)
|
| - |
|
948 |
sheet.write(0, 27, "Proposed Tp", heading_xf)
|
| - |
|
949 |
sheet.write(0, 28, "Target Nlc", heading_xf)
|
| - |
|
950 |
sheet.write(0, 29, "Avg Sale", heading_xf)
|
| - |
|
951 |
sheet.write(0, 30, "Sales History", heading_xf)
|
| - |
|
952 |
|
| - |
|
953 |
sheet_iterator = 1
|
| - |
|
954 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
|
| - |
|
955 |
for cantCompeteItem in cantCompeteItems:
|
| - |
|
956 |
amScraping = cantCompeteItem[0]
|
| - |
|
957 |
item = cantCompeteItem[1]
|
| - |
|
958 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
959 |
if amScraping.warehouseLocation == 1:
|
| - |
|
960 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
961 |
loc = 'MUMBAI'
|
| - |
|
962 |
else:
|
| - |
|
963 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
964 |
loc = 'BANGLORE'
|
| - |
|
965 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
966 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
967 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
968 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
969 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
970 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
971 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
972 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
973 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
974 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
975 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
976 |
if amScraping.ourRank > 3:
|
| - |
|
977 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
978 |
else:
|
| - |
|
979 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
980 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
981 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
982 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
983 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
984 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
985 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
986 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
987 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
988 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
989 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
990 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
991 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
992 |
sheet.write(sheet_iterator, 25, item.risky)
|
| - |
|
993 |
sheet.write(sheet_iterator, 26, amScraping.proposedSp)
|
| - |
|
994 |
sheet.write(sheet_iterator, 27, amScraping.proposedTp)
|
| - |
|
995 |
sheet.write(sheet_iterator, 28, amScraping.targetNlc)
|
| - |
|
996 |
sheet.write(sheet_iterator, 29, amScraping.avgSale)
|
| - |
|
997 |
sheet.write(sheet_iterator, 30, getOosString(saleMap.get(sku)))
|
| - |
|
998 |
sheet_iterator+=1
|
| - |
|
999 |
|
| - |
|
1000 |
sheet = wbk.add_sheet('Competitive')
|
| - |
|
1001 |
xstr = lambda s: s or ""
|
| - |
|
1002 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1003 |
|
| - |
|
1004 |
excel_integer_format = '0'
|
| - |
|
1005 |
integer_style = xlwt.XFStyle()
|
| - |
|
1006 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1007 |
|
| - |
|
1008 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1009 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1010 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1011 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1012 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1013 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1014 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
1015 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
1016 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
1017 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
1018 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
1019 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
1020 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
1021 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
1022 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
1023 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
1024 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
1025 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
1026 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
1027 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
1028 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
1029 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
1030 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
1031 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
1032 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
1033 |
sheet.write(0, 25, "Risky", heading_xf)
|
| - |
|
1034 |
sheet.write(0, 26, "Proposed Sp", heading_xf)
|
| - |
|
1035 |
sheet.write(0, 27, "Proposed Tp", heading_xf)
|
| - |
|
1036 |
sheet.write(0, 28, "Avg Sale", heading_xf)
|
| - |
|
1037 |
sheet.write(0, 29, "Sales History", heading_xf)
|
| - |
|
1038 |
|
| - |
|
1039 |
sheet_iterator = 1
|
| - |
|
1040 |
competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).all()
|
| - |
|
1041 |
for competitiveItem in competitiveItems:
|
| - |
|
1042 |
amScraping = competitiveItem[0]
|
| - |
|
1043 |
item = competitiveItem[1]
|
| - |
|
1044 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1045 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1046 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1047 |
loc = 'MUMBAI'
|
| - |
|
1048 |
else:
|
| - |
|
1049 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1050 |
loc = 'BANGLORE'
|
| - |
|
1051 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1052 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1053 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1054 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1055 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1056 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
1057 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
1058 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
1059 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
1060 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
1061 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
1062 |
if amScraping.ourRank > 3:
|
| - |
|
1063 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
1064 |
else:
|
| - |
|
1065 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
1066 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
1067 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
1068 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
1069 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
1070 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
1071 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
1072 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
1073 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
1074 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
1075 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
1076 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
1077 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
1078 |
sheet.write(sheet_iterator, 25, item.risky)
|
| - |
|
1079 |
sheet.write(sheet_iterator, 26, amScraping.proposedSp)
|
| - |
|
1080 |
sheet.write(sheet_iterator, 27, amScraping.proposedTp)
|
| - |
|
1081 |
sheet.write(sheet_iterator, 28, amScraping.avgSale)
|
| - |
|
1082 |
sheet.write(sheet_iterator, 29, getOosString(saleMap.get(sku)))
|
| - |
|
1083 |
sheet_iterator+=1
|
| - |
|
1084 |
|
| - |
|
1085 |
sheet = wbk.add_sheet('Almost Competitive')
|
| - |
|
1086 |
xstr = lambda s: s or ""
|
| - |
|
1087 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1088 |
|
| - |
|
1089 |
excel_integer_format = '0'
|
| - |
|
1090 |
integer_style = xlwt.XFStyle()
|
| - |
|
1091 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1092 |
|
| - |
|
1093 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1094 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1095 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1096 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1097 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1098 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1099 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
1100 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
1101 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
1102 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
1103 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
1104 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
1105 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
1106 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
1107 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
1108 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
1109 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
1110 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
1111 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
1112 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
1113 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
1114 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
1115 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
1116 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
1117 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
1118 |
sheet.write(0, 25, "Risky", heading_xf)
|
| - |
|
1119 |
sheet.write(0, 26, "Proposed Sp", heading_xf)
|
| - |
|
1120 |
sheet.write(0, 27, "Proposed Tp", heading_xf)
|
| - |
|
1121 |
sheet.write(0, 28, "Avg Sale", heading_xf)
|
| - |
|
1122 |
sheet.write(0, 29, "Sales History", heading_xf)
|
| - |
|
1123 |
|
| - |
|
1124 |
sheet_iterator = 1
|
| - |
|
1125 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).all()
|
| - |
|
1126 |
for almostCompetitiveItem in almostCompetitiveItems:
|
| - |
|
1127 |
amScraping = almostCompetitiveItem[0]
|
| - |
|
1128 |
item = almostCompetitiveItem[1]
|
| - |
|
1129 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1130 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1131 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1132 |
loc = 'MUMBAI'
|
| - |
|
1133 |
else:
|
| - |
|
1134 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1135 |
loc = 'BANGLORE'
|
| - |
|
1136 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1137 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1138 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1139 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1140 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1141 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
1142 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
1143 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
1144 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
1145 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
1146 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
1147 |
if amScraping.ourRank > 3:
|
| - |
|
1148 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
1149 |
else:
|
| - |
|
1150 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
1151 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
1152 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
1153 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
1154 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
1155 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
1156 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
1157 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
1158 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
1159 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
1160 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
1161 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
1162 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
1163 |
sheet.write(sheet_iterator, 25, item.risky)
|
| - |
|
1164 |
sheet.write(sheet_iterator, 26, amScraping.proposedSp)
|
| - |
|
1165 |
sheet.write(sheet_iterator, 27, amScraping.proposedTp)
|
| - |
|
1166 |
sheet.write(sheet_iterator, 28, amScraping.avgSale)
|
| - |
|
1167 |
sheet.write(sheet_iterator, 29, getOosString(saleMap.get(sku)))
|
| - |
|
1168 |
sheet_iterator+=1
|
| - |
|
1169 |
|
| - |
|
1170 |
sheet = wbk.add_sheet('Among Cheapest')
|
| - |
|
1171 |
xstr = lambda s: s or ""
|
| - |
|
1172 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1173 |
|
| - |
|
1174 |
excel_integer_format = '0'
|
| - |
|
1175 |
integer_style = xlwt.XFStyle()
|
| - |
|
1176 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1177 |
|
| - |
|
1178 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1179 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1180 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1181 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1182 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1183 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1184 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
1185 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
1186 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
1187 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
1188 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
1189 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
1190 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
1191 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
1192 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
1193 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
1194 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
1195 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
1196 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
1197 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
1198 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
1199 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
1200 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
1201 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
1202 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
1203 |
sheet.write(0, 25, "Risky", heading_xf)
|
| - |
|
1204 |
sheet.write(0, 26, "Proposed Sp", heading_xf)
|
| - |
|
1205 |
sheet.write(0, 27, "Proposed Tp", heading_xf)
|
| - |
|
1206 |
sheet.write(0, 28, "Avg Sale", heading_xf)
|
| - |
|
1207 |
sheet.write(0, 29, "Sales History", heading_xf)
|
| - |
|
1208 |
|
| - |
|
1209 |
sheet_iterator = 1
|
| - |
|
1210 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
|
| - |
|
1211 |
for amongCheapestItem in amongCheapestItems:
|
| - |
|
1212 |
amScraping = amongCheapestItem[0]
|
| - |
|
1213 |
item = amongCheapestItem[1]
|
| - |
|
1214 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1215 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1216 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1217 |
loc = 'MUMBAI'
|
| - |
|
1218 |
else:
|
| - |
|
1219 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1220 |
loc = 'BANGLORE'
|
| - |
|
1221 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1222 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1223 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1224 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1225 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1226 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
1227 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
1228 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
1229 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
1230 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
1231 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
1232 |
if amScraping.ourRank > 3:
|
| - |
|
1233 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
1234 |
else:
|
| - |
|
1235 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
1236 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
1237 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
1238 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
1239 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
1240 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
1241 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
1242 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
1243 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
1244 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
1245 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
1246 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
1247 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
1248 |
sheet.write(sheet_iterator, 25, item.risky)
|
| - |
|
1249 |
sheet.write(sheet_iterator, 26, amScraping.proposedSp)
|
| - |
|
1250 |
sheet.write(sheet_iterator, 27, amScraping.proposedTp)
|
| - |
|
1251 |
sheet.write(sheet_iterator, 28, amScraping.avgSale)
|
| - |
|
1252 |
sheet.write(sheet_iterator, 29, getOosString(saleMap.get(sku)))
|
| - |
|
1253 |
sheet_iterator+=1
|
| - |
|
1254 |
|
| - |
|
1255 |
sheet = wbk.add_sheet('Cheapest')
|
| - |
|
1256 |
xstr = lambda s: s or ""
|
| - |
|
1257 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1258 |
|
| - |
|
1259 |
excel_integer_format = '0'
|
| - |
|
1260 |
integer_style = xlwt.XFStyle()
|
| - |
|
1261 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1262 |
|
| - |
|
1263 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1264 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1265 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1266 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1267 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1268 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1269 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
1270 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
1271 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
1272 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
1273 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
1274 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
1275 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
1276 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
1277 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
1278 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
1279 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
1280 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
1281 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
1282 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
1283 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
1284 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
1285 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
1286 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
1287 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
1288 |
sheet.write(0, 25, "Risky", heading_xf)
|
| - |
|
1289 |
sheet.write(0, 26, "Proposed Sp", heading_xf)
|
| - |
|
1290 |
sheet.write(0, 27, "Proposed Tp", heading_xf)
|
| - |
|
1291 |
sheet.write(0, 28, "Margin Increased Potential", heading_xf)
|
| - |
|
1292 |
sheet.write(0, 29, "Avg Sale", heading_xf)
|
| - |
|
1293 |
sheet.write(0, 30, "Sales History", heading_xf)
|
| - |
|
1294 |
|
| - |
|
1295 |
sheet_iterator = 1
|
| - |
|
1296 |
cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
| - |
|
1297 |
for cheapestItem in cheapestItems:
|
| - |
|
1298 |
amScraping = cheapestItem[0]
|
| - |
|
1299 |
item = cheapestItem[1]
|
| - |
|
1300 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1301 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1302 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1303 |
loc = 'MUMBAI'
|
| - |
|
1304 |
else:
|
| - |
|
1305 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1306 |
loc = 'BANGLORE'
|
| - |
|
1307 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1308 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1309 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1310 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1311 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1312 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
1313 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
1314 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
1315 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
1316 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
1317 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
1318 |
if amScraping.ourRank > 3:
|
| - |
|
1319 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
1320 |
else:
|
| - |
|
1321 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
1322 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
1323 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
1324 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
1325 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
1326 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
1327 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
1328 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
1329 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
1330 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
1331 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
1332 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
1333 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
1334 |
sheet.write(sheet_iterator, 25, item.risky)
|
| - |
|
1335 |
sheet.write(sheet_iterator, 26, amScraping.proposedSp)
|
| - |
|
1336 |
sheet.write(sheet_iterator, 27, amScraping.proposedTp)
|
| - |
|
1337 |
sheet.write(sheet_iterator, 28, amScraping.marginIncreasedPotential)
|
| - |
|
1338 |
sheet.write(sheet_iterator, 29, amScraping.avgSale)
|
| - |
|
1339 |
sheet.write(sheet_iterator, 30, getOosString(saleMap.get(sku)))
|
| - |
|
1340 |
sheet_iterator+=1
|
| - |
|
1341 |
|
| - |
|
1342 |
sheet = wbk.add_sheet('Negative Margin')
|
| - |
|
1343 |
xstr = lambda s: s or ""
|
| - |
|
1344 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1345 |
|
| - |
|
1346 |
excel_integer_format = '0'
|
| - |
|
1347 |
integer_style = xlwt.XFStyle()
|
| - |
|
1348 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1349 |
|
| - |
|
1350 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1351 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1352 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1353 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1354 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1355 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1356 |
sheet.write(0, 6, "Weight", heading_xf)
|
| - |
|
1357 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
| - |
|
1358 |
sheet.write(0, 8, "Our SP", heading_xf)
|
| - |
|
1359 |
sheet.write(0, 9, "Our Tp", heading_xf)
|
| - |
|
1360 |
sheet.write(0, 10, "Lowest Possible SP", heading_xf)
|
| - |
|
1361 |
sheet.write(0, 11, "Lowest Possible TP", heading_xf)
|
| - |
|
1362 |
sheet.write(0, 12, "Rank", heading_xf)
|
| - |
|
1363 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
| - |
|
1364 |
sheet.write(0, 14, "Lowest Seller Name", heading_xf)
|
| - |
|
1365 |
sheet.write(0, 15, "Lowest Seller SP", heading_xf)
|
| - |
|
1366 |
sheet.write(0, 16, "Second Lowest Seller Name", heading_xf)
|
| - |
|
1367 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
| - |
|
1368 |
sheet.write(0, 18, "Third Lowest Seller Name", heading_xf)
|
| - |
|
1369 |
sheet.write(0, 19, "Third Lowest Seller SP", heading_xf)
|
| - |
|
1370 |
sheet.write(0, 20, "WANLC", heading_xf)
|
| - |
|
1371 |
sheet.write(0, 21, "Commission", heading_xf)
|
| - |
|
1372 |
sheet.write(0, 22, "Competitor Commission", heading_xf)
|
| - |
|
1373 |
sheet.write(0, 23, "Return Provision", heading_xf)
|
| - |
|
1374 |
sheet.write(0, 24, "Margin", heading_xf)
|
| - |
|
1375 |
sheet.write(0, 25, "Avg Sale", heading_xf)
|
| - |
|
1376 |
sheet.write(0, 26, "Sales History", heading_xf)
|
| - |
|
1377 |
|
| - |
|
1378 |
sheet_iterator = 1
|
| - |
|
1379 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
|
| - |
|
1380 |
for amongCheapestItem in amongCheapestItems:
|
| - |
|
1381 |
amScraping = amongCheapestItem[0]
|
| - |
|
1382 |
item = amongCheapestItem[1]
|
| - |
|
1383 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1384 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1385 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1386 |
loc = 'MUMBAI'
|
| - |
|
1387 |
else:
|
| - |
|
1388 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1389 |
loc = 'BANGLORE'
|
| - |
|
1390 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1391 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1392 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1393 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1394 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1395 |
sheet.write(sheet_iterator, 6, item.weight)
|
| - |
|
1396 |
sheet.write(sheet_iterator, 7, amScraping.courierCost)
|
| - |
|
1397 |
sheet.write(sheet_iterator, 8, amScraping.ourSellingPrice)
|
| - |
|
1398 |
sheet.write(sheet_iterator, 9, amScraping.ourTp)
|
| - |
|
1399 |
sheet.write(sheet_iterator, 10, amScraping.lowestPossibleSp)
|
| - |
|
1400 |
sheet.write(sheet_iterator, 11, amScraping.lowestPossibleTp)
|
| - |
|
1401 |
if amScraping.ourRank > 3:
|
| - |
|
1402 |
sheet.write(sheet_iterator, 12, 'Greater than 3')
|
| - |
|
1403 |
else:
|
| - |
|
1404 |
sheet.write(sheet_iterator, 12, amScraping.ourRank)
|
| - |
|
1405 |
sheet.write(sheet_iterator, 13, amScraping.ourInventory)
|
| - |
|
1406 |
sheet.write(sheet_iterator, 14, amScraping.lowestSellerName)
|
| - |
|
1407 |
sheet.write(sheet_iterator, 15, amScraping.lowestSellerSp)
|
| - |
|
1408 |
sheet.write(sheet_iterator, 16, amScraping.secondLowestSellerName)
|
| - |
|
1409 |
sheet.write(sheet_iterator, 17, amScraping.secondLowestSellerSp)
|
| - |
|
1410 |
sheet.write(sheet_iterator, 18, amScraping.thirdLowestSellerName)
|
| - |
|
1411 |
sheet.write(sheet_iterator, 19, amScraping.thirdLowestSellerSp)
|
| - |
|
1412 |
sheet.write(sheet_iterator, 20, amScraping.wanlc)
|
| - |
|
1413 |
sheet.write(sheet_iterator, 21, amScraping.commission)
|
| - |
|
1414 |
sheet.write(sheet_iterator, 22, amScraping.competitorCommission)
|
| - |
|
1415 |
sheet.write(sheet_iterator, 23, amScraping.returnProvision)
|
| - |
|
1416 |
sheet.write(sheet_iterator, 24, round(amScraping.ourTp - amScraping.lowestPossibleTp))
|
| - |
|
1417 |
sheet.write(sheet_iterator, 25, amScraping.avgSale)
|
| - |
|
1418 |
sheet.write(sheet_iterator, 26, getOosString(saleMap.get(sku)))
|
| - |
|
1419 |
sheet_iterator+=1
|
| - |
|
1420 |
|
| - |
|
1421 |
sheet = wbk.add_sheet('Exception List')
|
| - |
|
1422 |
xstr = lambda s: s or ""
|
| - |
|
1423 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| - |
|
1424 |
|
| - |
|
1425 |
excel_integer_format = '0'
|
| - |
|
1426 |
integer_style = xlwt.XFStyle()
|
| - |
|
1427 |
integer_style.num_format_str = excel_integer_format
|
| - |
|
1428 |
|
| - |
|
1429 |
sheet.write(0, 0, "Item Id", heading_xf)
|
| - |
|
1430 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
| - |
|
1431 |
sheet.write(0, 2, "Asin", heading_xf)
|
| - |
|
1432 |
sheet.write(0, 3, "Location", heading_xf)
|
| - |
|
1433 |
sheet.write(0, 4, "Brand", heading_xf)
|
| - |
|
1434 |
sheet.write(0, 5, "Product Name", heading_xf)
|
| - |
|
1435 |
sheet.write(0, 6, "Reason", heading_xf)
|
| - |
|
1436 |
|
| - |
|
1437 |
sheet_iterator = 1
|
| - |
|
1438 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).all()
|
| - |
|
1439 |
for amongCheapestItem in amongCheapestItems:
|
| - |
|
1440 |
amScraping = amongCheapestItem[0]
|
| - |
|
1441 |
item = amongCheapestItem[1]
|
| - |
|
1442 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| - |
|
1443 |
if amScraping.warehouseLocation == 1:
|
| - |
|
1444 |
sku = 'FBA'+str(amScraping.item_id)
|
| - |
|
1445 |
loc = 'MUMBAI'
|
| - |
|
1446 |
else:
|
| - |
|
1447 |
sku = 'FBB'+str(amScraping.item_id)
|
| - |
|
1448 |
loc = 'BANGLORE'
|
| - |
|
1449 |
sheet.write(sheet_iterator, 1, sku)
|
| - |
|
1450 |
sheet.write(sheet_iterator, 2, (amazonAsinPrice.get(sku).asin))
|
| - |
|
1451 |
sheet.write(sheet_iterator, 3, loc)
|
| - |
|
1452 |
sheet.write(sheet_iterator, 4, item.brand)
|
| - |
|
1453 |
sheet.write(sheet_iterator, 5, xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color))
|
| - |
|
1454 |
sheet.write(sheet_iterator, 6, amScraping.reason)
|
| - |
|
1455 |
sheet_iterator+=1
|
| - |
|
1456 |
|
| - |
|
1457 |
filename = "/tmp/amazon-scraping.xls"
|
| - |
|
1458 |
wbk.save(filename)
|
| - |
|
1459 |
|
| 692 |
def main():
|
1460 |
def main():
|
| 693 |
parser = optparse.OptionParser()
|
1461 |
parser = optparse.OptionParser()
|
| 694 |
parser.add_option("-t", "--type", dest="runType",
|
1462 |
parser.add_option("-t", "--type", dest="runType",
|
| 695 |
default="FULL", type="string",
|
1463 |
default="FULL", type="string",
|
| 696 |
help="Run type FULL or FAVOURITE")
|
1464 |
help="Run type FULL or FAVOURITE")
|
| Line 718... |
Line 1486... |
| 718 |
commitCheapest(cheapest,timestamp,options.runType)
|
1486 |
commitCheapest(cheapest,timestamp,options.runType)
|
| 719 |
commitAmongCheapestAndCanCompete(amongCheapestAndCanCompete,timestamp,options.runType)
|
1487 |
commitAmongCheapestAndCanCompete(amongCheapestAndCanCompete,timestamp,options.runType)
|
| 720 |
commitCanCompete(canCompete,timestamp,options.runType)
|
1488 |
commitCanCompete(canCompete,timestamp,options.runType)
|
| 721 |
commitAlmostCompete(almostCompete,timestamp,options.runType)
|
1489 |
commitAlmostCompete(almostCompete,timestamp,options.runType)
|
| 722 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
1490 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
| 723 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
1491 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
| 724 |
|
- |
|
| - |
|
1492 |
autoDecreaseItems = fetchItemsForAutoDecrease(timestamp)
|
| - |
|
1493 |
autoIncreaseItems = fetchItemsForAutoIncrease(timestamp)
|
| - |
|
1494 |
previousAutoFav, nowAutoFav = markAutoFavourites(timestamp)
|
| - |
|
1495 |
writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav)
|
| 725 |
if __name__=='__main__':
|
1496 |
if __name__=='__main__':
|
| 726 |
main()
|
1497 |
main()
|
| 727 |
|
1498 |
|