| Line 3... |
Line 3... |
| 3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
3 |
from shop2020.config.client.ConfigClient import ConfigClient
|
| 4 |
from shop2020.model.v1.catalog.impl import DataService
|
4 |
from shop2020.model.v1.catalog.impl import DataService
|
| 5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
5 |
from shop2020.model.v1.catalog.impl.DataService import Amazonlisted, Item, \
|
| 6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory, \
|
6 |
Category, SourcePercentageMaster,SourceCategoryPercentage, SourceItemPercentage, AmazonPromotion, AmazonScrapingHistory, \
|
| 7 |
ItemVatMaster, CategoryVatMaster
|
7 |
ItemVatMaster, CategoryVatMaster
|
| 8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource, AmazonFCWarehouseLocation
|
| 9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, \
|
9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, \
|
| 10 |
Decision, RunType, AmazonPromotionType
|
10 |
Decision, RunType, AmazonPromotionType
|
| 11 |
from shop2020.model.v1.catalog.script import AmazonAsyncScraper
|
11 |
from shop2020.model.v1.catalog.script import AmazonAsyncScraper
|
| - |
|
12 |
from shop2020.model.v1.order.script import MongoService
|
| 12 |
from shop2020.clients.InventoryClient import InventoryClient
|
13 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 13 |
from shop2020.clients.TransactionClient import TransactionClient
|
14 |
from shop2020.utils.Utils import to_py_date
|
| 14 |
import time
|
15 |
import time
|
| 15 |
from time import sleep
|
16 |
from time import sleep
|
| 16 |
from datetime import date, datetime, timedelta
|
17 |
from datetime import date, datetime, timedelta
|
| 17 |
import math
|
18 |
import math
|
| 18 |
import simplejson as json
|
19 |
import simplejson as json
|
| Line 38... |
Line 39... |
| 38 |
amazonLongTermActivePromotions = {}
|
39 |
amazonLongTermActivePromotions = {}
|
| 39 |
amazonShortTermActivePromotions = {}
|
40 |
amazonShortTermActivePromotions = {}
|
| 40 |
wpiTodayExpiry = {}
|
41 |
wpiTodayExpiry = {}
|
| 41 |
notListed = []
|
42 |
notListed = []
|
| 42 |
saleMap = {}
|
43 |
saleMap = {}
|
| - |
|
44 |
monthlySaleMap = {}
|
| 43 |
categoryMap = {}
|
45 |
categoryMap = {}
|
| - |
|
46 |
latestHourlySnapshot = {}
|
| 44 |
exceptionMap = {1:'WANLC is 0',2:'Unable to fetch our price',3:'No other seller or Unable to fetch competitive pricing',
|
47 |
exceptionMap = {1:'WANLC is 0',2:'Unable to fetch our price',3:'No other seller or Unable to fetch competitive pricing',
|
| 45 |
4:'Promo misconfigured',5:'Unable to calculate competitive pricing',6:'Vat not available'}
|
48 |
4:'Promo misconfigured',5:'Unable to calculate competitive pricing',6:'Vat not available'}
|
| 46 |
DataService.initialize(db_hostname=host)
|
49 |
DataService.initialize(db_hostname=host)
|
| 47 |
|
50 |
|
| 48 |
amScraper = AmazonAsyncScraper.Products("AKIAII3SGRXBJDPCHSGQ", "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg", "AF6E3O0VE0X4D")
|
51 |
amScraper = AmazonAsyncScraper.Products("AKIAII3SGRXBJDPCHSGQ", "B92xTbNBTYygbGs98w01nFQUhbec1pNCkCsKVfpg", "AF6E3O0VE0X4D")
|
| Line 189... |
Line 192... |
| 189 |
def fetchItemsForAutoIncrease(time):
|
192 |
def fetchItemsForAutoIncrease(time):
|
| 190 |
successfulAutoIncrease = []
|
193 |
successfulAutoIncrease = []
|
| 191 |
autoIncrementItems = session.query(AmazonScrapingHistory).join((Amazonlisted,AmazonScrapingHistory.item_id==Amazonlisted.itemId))\
|
194 |
autoIncrementItems = session.query(AmazonScrapingHistory).join((Amazonlisted,AmazonScrapingHistory.item_id==Amazonlisted.itemId))\
|
| 192 |
.filter(AmazonScrapingHistory.timestamp==time).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX)\
|
195 |
.filter(AmazonScrapingHistory.timestamp==time).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX)\
|
| 193 |
.filter(Amazonlisted.autoIncrement==True).all()
|
196 |
.filter(Amazonlisted.autoIncrement==True).all()
|
| 194 |
transaction_client = TransactionClient().get_client()
|
- |
|
| 195 |
print len(autoIncrementItems)
|
197 |
print len(autoIncrementItems)
|
| 196 |
for autoIncrementItem in autoIncrementItems:
|
198 |
for autoIncrementItem in autoIncrementItems:
|
| 197 |
if autoIncrementItem.warehouseLocation == 1:
|
199 |
if autoIncrementItem.warehouseLocation == 1:
|
| 198 |
sku = 'FBA'+str(autoIncrementItem.item_id)
|
200 |
sku = 'FBA'+str(autoIncrementItem.item_id)
|
| 199 |
elif autoIncrementItem.warehouseLocation == 2:
|
201 |
elif autoIncrementItem.warehouseLocation == 2:
|
| Line 255... |
Line 257... |
| 255 |
fcLocation = 1
|
257 |
fcLocation = 1
|
| 256 |
elif autoIncrementItem.warehouseLocation==3:
|
258 |
elif autoIncrementItem.warehouseLocation==3:
|
| 257 |
fcLocation = 2
|
259 |
fcLocation = 2
|
| 258 |
else:
|
260 |
else:
|
| 259 |
pass
|
261 |
pass
|
| 260 |
fbaSaleSnapshot = transaction_client.getAmazonFbaSalesLatestSnapshotForItemLocationWise(autoIncrementItem.item_id,fcLocation)
|
262 |
fbaSaleSnapshot = MongoService.getAmazonFbaSalesLatestSnapshotForItemLocationWise(autoIncrementItem.item_id,fcLocation)
|
| 261 |
if getLastDaySale(fbaSaleSnapshot)<=2:
|
263 |
if getLastDaySale(fbaSaleSnapshot)<=2:
|
| 262 |
markReasonForItem(autoIncrementItem,'Last day sale is less than 3',Decision.AUTO_INCREMENT_FAILED)
|
264 |
markReasonForItem(autoIncrementItem,'Last day sale is less than 3',Decision.AUTO_INCREMENT_FAILED)
|
| 263 |
continue
|
265 |
continue
|
| 264 |
|
266 |
|
| 265 |
autoIncrementItem.ourEnoughStock = False
|
267 |
autoIncrementItem.ourEnoughStock = False
|
| Line 283... |
Line 285... |
| 283 |
if not obj.isOutOfStock:
|
285 |
if not obj.isOutOfStock:
|
| 284 |
count+=1
|
286 |
count+=1
|
| 285 |
sale = sale+obj.totalOrderCount
|
287 |
sale = sale+obj.totalOrderCount
|
| 286 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
288 |
avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 287 |
return round(avgSalePerDay,2)
|
289 |
return round(avgSalePerDay,2)
|
| - |
|
290 |
|
| - |
|
291 |
def get30DaysStats(sku):
|
| - |
|
292 |
count,sale = 0,0
|
| - |
|
293 |
oosStatus = monthlySaleMap.get(sku)
|
| - |
|
294 |
if oosStatus is None:
|
| - |
|
295 |
return 0,0
|
| - |
|
296 |
for obj in oosStatus:
|
| - |
|
297 |
if not obj.isOutOfStock:
|
| - |
|
298 |
count+=1
|
| - |
|
299 |
sale = sale+obj.totalOrderCount
|
| - |
|
300 |
return sale, count
|
| - |
|
301 |
|
| - |
|
302 |
def getInStockStats(item_id, warehouseLocation):
|
| - |
|
303 |
if warehouseLocation==1:
|
| - |
|
304 |
fcLocation = 0
|
| - |
|
305 |
elif warehouseLocation==2:
|
| - |
|
306 |
fcLocation = 1
|
| - |
|
307 |
elif warehouseLocation==3:
|
| - |
|
308 |
fcLocation = 2
|
| - |
|
309 |
return MongoService.getLastOutOfStock(item_id, fcLocation)
|
| 288 |
|
310 |
|
| 289 |
|
311 |
|
| 290 |
def getOosString(oosStatus):
|
312 |
def getOosString(oosStatus):
|
| 291 |
if oosStatus is None:
|
313 |
if oosStatus is None:
|
| 292 |
return ""
|
314 |
return ""
|
| Line 382... |
Line 404... |
| 382 |
## item.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
404 |
## item.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
| 383 |
## amListed.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
405 |
## amListed.asin = ((amazonAsinPrice.get('FBA'+str(item.id))).asin).strip()
|
| 384 |
## session.commit()
|
406 |
## session.commit()
|
| 385 |
## session.close()
|
407 |
## session.close()
|
| 386 |
|
408 |
|
| - |
|
409 |
|
| - |
|
410 |
def fetchMonthSale():
|
| - |
|
411 |
global monthlymonthlySaleMap
|
| - |
|
412 |
fbaSaleSnapshot = MongoService.getAmazonFbaSalesSnapshotForDays(29)
|
| - |
|
413 |
for saleSnapshot in fbaSaleSnapshot:
|
| - |
|
414 |
if saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(0):
|
| - |
|
415 |
if monthlySaleMap.has_key('FBA'+str(saleSnapshot.item_id)):
|
| - |
|
416 |
temp = []
|
| - |
|
417 |
val = monthlySaleMap.get('FBA'+str(saleSnapshot.item_id))
|
| - |
|
418 |
for l in val:
|
| - |
|
419 |
temp.append(l)
|
| - |
|
420 |
temp.append(saleSnapshot)
|
| - |
|
421 |
monthlySaleMap['FBA'+str(saleSnapshot.item_id)]=temp
|
| - |
|
422 |
else:
|
| - |
|
423 |
temp = []
|
| - |
|
424 |
temp.append(saleSnapshot)
|
| - |
|
425 |
monthlySaleMap['FBA'+str(saleSnapshot.item_id)] = temp
|
| - |
|
426 |
elif saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(1):
|
| - |
|
427 |
if monthlySaleMap.has_key('FBB'+str(saleSnapshot.item_id)):
|
| - |
|
428 |
temp = []
|
| - |
|
429 |
val = monthlySaleMap.get('FBB'+str(saleSnapshot.item_id))
|
| - |
|
430 |
for l in val:
|
| - |
|
431 |
temp.append(l)
|
| - |
|
432 |
temp.append(saleSnapshot)
|
| - |
|
433 |
monthlySaleMap['FBB'+str(saleSnapshot.item_id)]=temp
|
| - |
|
434 |
else:
|
| - |
|
435 |
temp = []
|
| - |
|
436 |
temp.append(saleSnapshot)
|
| - |
|
437 |
monthlySaleMap['FBB'+str(saleSnapshot.item_id)] = temp
|
| - |
|
438 |
elif saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(2):
|
| - |
|
439 |
if monthlySaleMap.has_key('FBG'+str(saleSnapshot.item_id)):
|
| - |
|
440 |
temp = []
|
| - |
|
441 |
val = monthlySaleMap.get('FBG'+str(saleSnapshot.item_id))
|
| - |
|
442 |
for l in val:
|
| - |
|
443 |
temp.append(l)
|
| - |
|
444 |
temp.append(saleSnapshot)
|
| - |
|
445 |
monthlySaleMap['FBG'+str(saleSnapshot.item_id)]=temp
|
| - |
|
446 |
else:
|
| - |
|
447 |
temp = []
|
| - |
|
448 |
temp.append(saleSnapshot)
|
| - |
|
449 |
monthlySaleMap['FBG'+str(saleSnapshot.item_id)] = temp
|
| - |
|
450 |
else:
|
| - |
|
451 |
continue
|
| - |
|
452 |
def populateHourlySnapshot():
|
| - |
|
453 |
global latestHourlySnapshot
|
| - |
|
454 |
fbaHourlySnapshot = MongoService.getLatestHourlySnapshot()
|
| - |
|
455 |
for sale in fbaHourlySnapshot:
|
| - |
|
456 |
if sale.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(0):
|
| - |
|
457 |
latestHourlySnapshot['FBA'+str(sale.item_id)] = sale
|
| - |
|
458 |
elif sale.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(1):
|
| - |
|
459 |
latestHourlySnapshot['FBB'+str(sale.item_id)] = sale
|
| - |
|
460 |
elif sale.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(2):
|
| - |
|
461 |
latestHourlySnapshot['FBG'+str(sale.item_id)] = sale
|
| - |
|
462 |
else:
|
| - |
|
463 |
continue
|
| - |
|
464 |
|
| - |
|
465 |
def getTodaysSale(sku):
|
| - |
|
466 |
sale = latestHourlySnapshot.get(sku)
|
| - |
|
467 |
if sale is None:
|
| - |
|
468 |
return '', 0
|
| - |
|
469 |
return (to_py_date(sale.snapshotTime)).strftime("%Y-%m-%d %H:%M"), sale.totalOrderCount
|
| - |
|
470 |
|
| 387 |
def fetchFbaSale():
|
471 |
def fetchFbaSale():
|
| 388 |
global saleMap
|
472 |
global saleMap
|
| 389 |
transaction_client = TransactionClient().get_client()
|
- |
|
| 390 |
fbaSaleSnapshot = transaction_client.getAmazonFbaSalesSnapshotForDays(4)
|
473 |
fbaSaleSnapshot = MongoService.getAmazonFbaSalesSnapshotForDays(4)
|
| 391 |
for saleSnapshot in fbaSaleSnapshot:
|
474 |
for saleSnapshot in fbaSaleSnapshot:
|
| 392 |
if saleSnapshot.fcLocation == 0:
|
475 |
if saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(0):
|
| 393 |
if saleMap.has_key('FBA'+str(saleSnapshot.item_id)):
|
476 |
if saleMap.has_key('FBA'+str(saleSnapshot.item_id)):
|
| 394 |
temp = []
|
477 |
temp = []
|
| 395 |
val = saleMap.get('FBA'+str(saleSnapshot.item_id))
|
478 |
val = saleMap.get('FBA'+str(saleSnapshot.item_id))
|
| 396 |
for l in val:
|
479 |
for l in val:
|
| 397 |
temp.append(l)
|
480 |
temp.append(l)
|
| Line 399... |
Line 482... |
| 399 |
saleMap['FBA'+str(saleSnapshot.item_id)]=temp
|
482 |
saleMap['FBA'+str(saleSnapshot.item_id)]=temp
|
| 400 |
else:
|
483 |
else:
|
| 401 |
temp = []
|
484 |
temp = []
|
| 402 |
temp.append(saleSnapshot)
|
485 |
temp.append(saleSnapshot)
|
| 403 |
saleMap['FBA'+str(saleSnapshot.item_id)] = temp
|
486 |
saleMap['FBA'+str(saleSnapshot.item_id)] = temp
|
| 404 |
elif saleSnapshot.fcLocation == 1:
|
487 |
elif saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(1):
|
| 405 |
if saleMap.has_key('FBB'+str(saleSnapshot.item_id)):
|
488 |
if saleMap.has_key('FBB'+str(saleSnapshot.item_id)):
|
| 406 |
temp = []
|
489 |
temp = []
|
| 407 |
val = saleMap.get('FBB'+str(saleSnapshot.item_id))
|
490 |
val = saleMap.get('FBB'+str(saleSnapshot.item_id))
|
| 408 |
for l in val:
|
491 |
for l in val:
|
| 409 |
temp.append(l)
|
492 |
temp.append(l)
|
| Line 411... |
Line 494... |
| 411 |
saleMap['FBB'+str(saleSnapshot.item_id)]=temp
|
494 |
saleMap['FBB'+str(saleSnapshot.item_id)]=temp
|
| 412 |
else:
|
495 |
else:
|
| 413 |
temp = []
|
496 |
temp = []
|
| 414 |
temp.append(saleSnapshot)
|
497 |
temp.append(saleSnapshot)
|
| 415 |
saleMap['FBB'+str(saleSnapshot.item_id)] = temp
|
498 |
saleMap['FBB'+str(saleSnapshot.item_id)] = temp
|
| 416 |
elif saleSnapshot.fcLocation == 2:
|
499 |
elif saleSnapshot.fcLocation == AmazonFCWarehouseLocation._VALUES_TO_NAMES.get(2):
|
| 417 |
if saleMap.has_key('FBG'+str(saleSnapshot.item_id)):
|
500 |
if saleMap.has_key('FBG'+str(saleSnapshot.item_id)):
|
| 418 |
temp = []
|
501 |
temp = []
|
| 419 |
val = saleMap.get('FBG'+str(saleSnapshot.item_id))
|
502 |
val = saleMap.get('FBG'+str(saleSnapshot.item_id))
|
| 420 |
for l in val:
|
503 |
for l in val:
|
| 421 |
temp.append(l)
|
504 |
temp.append(l)
|
| Line 1407... |
Line 1490... |
| 1407 |
sheet.write(0, 40, "Margin", heading_xf)
|
1490 |
sheet.write(0, 40, "Margin", heading_xf)
|
| 1408 |
sheet.write(0, 41, "Proposed Sp", heading_xf)
|
1491 |
sheet.write(0, 41, "Proposed Sp", heading_xf)
|
| 1409 |
sheet.write(0, 42, "Avg Sale", heading_xf)
|
1492 |
sheet.write(0, 42, "Avg Sale", heading_xf)
|
| 1410 |
sheet.write(0, 43, "NOD", heading_xf)
|
1493 |
sheet.write(0, 43, "NOD", heading_xf)
|
| 1411 |
sheet.write(0, 44, "Sales History", heading_xf)
|
1494 |
sheet.write(0, 44, "Sales History", heading_xf)
|
| - |
|
1495 |
sheet.write(0, 45, "Last 30 days sale", heading_xf)
|
| - |
|
1496 |
sheet.write(0, 46, "No of days InStock in last 30 days", heading_xf)
|
| - |
|
1497 |
sheet.write(0, 47, "Avg 30 Days Sale", heading_xf)
|
| - |
|
1498 |
sheet.write(0, 48, "Last OOS Date", heading_xf)
|
| - |
|
1499 |
sheet.write(0, 49, "Total Sale Since InStock (Excluding Today)", heading_xf)
|
| - |
|
1500 |
sheet.write(0, 50, "Total Days Since InStock (Excluding Today)", heading_xf)
|
| - |
|
1501 |
sheet.write(0, 51, "Avg Sale Since InStock (Excluding Today)", heading_xf)
|
| - |
|
1502 |
sheet.write(0, 52, "Todays Sale Snapshot Time", heading_xf)
|
| - |
|
1503 |
sheet.write(0, 53, "Todays Sale", heading_xf)
|
| 1412 |
sheet.write(0, 45, "Decision", heading_xf)
|
1504 |
sheet.write(0, 54, "Decision", heading_xf)
|
| 1413 |
sheet.write(0, 46, "Reason", heading_xf)
|
1505 |
sheet.write(0, 55, "Reason", heading_xf)
|
| 1414 |
sheet.write(0, 47, "Updated Price", heading_xf)
|
1506 |
sheet.write(0, 56, "Updated Price", heading_xf)
|
| 1415 |
sheet.write(0, 48, "Proposed Margin", heading_xf)
|
1507 |
sheet.write(0, 57, "Proposed Margin", heading_xf)
|
| 1416 |
sheet.write(0, 49, "Inventory Movement Status", heading_xf)
|
1508 |
sheet.write(0, 58, "Inventory Movement Status", heading_xf)
|
| 1417 |
|
1509 |
|
| 1418 |
def getPackagingCost(data):
|
1510 |
def getPackagingCost(data):
|
| 1419 |
#TODO : Get packagingCost from marketplaceitems table
|
1511 |
#TODO : Get packagingCost from marketplaceitems table
|
| 1420 |
return 15
|
1512 |
return 15
|
| 1421 |
|
1513 |
|
| Line 1530... |
Line 1622... |
| 1530 |
if(myVat<0):
|
1622 |
if(myVat<0):
|
| 1531 |
return 0
|
1623 |
return 0
|
| 1532 |
else:
|
1624 |
else:
|
| 1533 |
return round(myVat)
|
1625 |
return round(myVat)
|
| 1534 |
|
1626 |
|
| - |
|
1627 |
def getAvgSale(days, sale):
|
| - |
|
1628 |
avgSalePerDay=0 if days==0 else (float(sale)/days)
|
| - |
|
1629 |
return round(avgSalePerDay,2)
|
| 1535 |
|
1630 |
|
| 1536 |
def getCategory(data):
|
1631 |
def getCategory(data):
|
| 1537 |
return categoryMap[data.category]
|
1632 |
return categoryMap[data.category]
|
| 1538 |
|
1633 |
|
| 1539 |
def writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,runType):
|
1634 |
def writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,runType):
|
| Line 1544... |
Line 1639... |
| 1544 |
|
1639 |
|
| 1545 |
excel_integer_format = '0'
|
1640 |
excel_integer_format = '0'
|
| 1546 |
integer_style = xlwt.XFStyle()
|
1641 |
integer_style = xlwt.XFStyle()
|
| 1547 |
integer_style.num_format_str = excel_integer_format
|
1642 |
integer_style.num_format_str = excel_integer_format
|
| 1548 |
writeheaders(sheet,heading_xf)
|
1643 |
writeheaders(sheet,heading_xf)
|
| 1549 |
'''
|
1644 |
|
| 1550 |
sheet.write(0, 0, "Item Id", heading_xf)
|
- |
|
| 1551 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
- |
|
| 1552 |
sheet.write(0, 2, "Asin", heading_xf)
|
- |
|
| 1553 |
sheet.write(0, 3, "Location", heading_xf)
|
- |
|
| 1554 |
sheet.write(0, 4, "Brand", heading_xf)
|
- |
|
| 1555 |
sheet.write(0, 5, "Product Name", heading_xf)
|
- |
|
| 1556 |
sheet.write(0, 6, "Weight", heading_xf)
|
- |
|
| 1557 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
- |
|
| 1558 |
sheet.write(0, 8, "Our SP", heading_xf)
|
- |
|
| 1559 |
sheet.write(0, 9, "Promo Price", heading_xf)
|
- |
|
| 1560 |
sheet.write(0, 10, "Is Promotion", heading_xf)
|
- |
|
| 1561 |
sheet.write(0, 11, "Lowest Possible SP", heading_xf)
|
- |
|
| 1562 |
sheet.write(0, 12, "Rank", heading_xf)
|
- |
|
| 1563 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
- |
|
| 1564 |
sheet.write(0, 14, "Lowest Seller SP", heading_xf)
|
- |
|
| 1565 |
sheet.write(0, 15, "Lowest Seller Rating", heading_xf)
|
- |
|
| 1566 |
sheet.write(0, 16, "Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1567 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
- |
|
| 1568 |
sheet.write(0, 18, "Second Lowest Seller Rating", heading_xf)
|
- |
|
| 1569 |
sheet.write(0, 19, "Second Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1570 |
sheet.write(0, 20, "Third Lowest Seller SP", heading_xf)
|
- |
|
| 1571 |
sheet.write(0, 21, "Third Lowest Seller Rating", heading_xf)
|
- |
|
| 1572 |
sheet.write(0, 22, "Third Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1573 |
sheet.write(0, 23, "Other Cost", heading_xf)
|
- |
|
| 1574 |
sheet.write(0, 24, "WANLC", heading_xf)
|
- |
|
| 1575 |
sheet.write(0, 25, "Subsidy", heading_xf)
|
- |
|
| 1576 |
sheet.write(0, 26, "Commission", heading_xf)
|
- |
|
| 1577 |
sheet.write(0, 27, "Competitor Commission", heading_xf)
|
- |
|
| 1578 |
sheet.write(0, 28, "Return Provision", heading_xf)
|
- |
|
| 1579 |
sheet.write(0, 29, "Vat Rate", heading_xf)
|
- |
|
| 1580 |
sheet.write(0, 30, "Margin", heading_xf)
|
- |
|
| 1581 |
sheet.write(0, 31, "Risky", heading_xf)
|
- |
|
| 1582 |
sheet.write(0, 32, "Proposed Sp", heading_xf)
|
- |
|
| 1583 |
sheet.write(0, 33, "Avg Sale", heading_xf)
|
- |
|
| 1584 |
sheet.write(0, 34, "Sales History", heading_xf)
|
- |
|
| 1585 |
'''
|
- |
|
| 1586 |
sheet_iterator = 1
|
1645 |
sheet_iterator = 1
|
| 1587 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1646 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 1588 |
for cantCompeteItem in cantCompeteItems:
|
1647 |
for cantCompeteItem in cantCompeteItems:
|
| 1589 |
amScraping = cantCompeteItem[0]
|
1648 |
amScraping = cantCompeteItem[0]
|
| 1590 |
item = cantCompeteItem[1]
|
1649 |
item = cantCompeteItem[1]
|
| Line 1656... |
Line 1715... |
| 1656 |
if str(daysOfStock)=='inf':
|
1715 |
if str(daysOfStock)=='inf':
|
| 1657 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
1716 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 1658 |
else:
|
1717 |
else:
|
| 1659 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
1718 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 1660 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
1719 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
1720 |
sale, count = get30DaysStats(sku)
|
| - |
|
1721 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
1722 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
1723 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
1724 |
|
| - |
|
1725 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
1726 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
1727 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
1728 |
else:
|
| - |
|
1729 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
1730 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
1731 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
1732 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
1733 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
1734 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
1735 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| - |
|
1736 |
|
| 1661 |
#sheet.write(sheet_iterator, 44, round(amScraping.proposedSp - getNewLowestPossibleSp(amScraping,12.36,getNewVatRate(amScraping.item_id,amScraping.warehouseLocation,amScraping.proposedSp))))
|
1737 |
#sheet.write(sheet_iterator, 44, round(amScraping.proposedSp - getNewLowestPossibleSp(amScraping,12.36,getNewVatRate(amScraping.item_id,amScraping.warehouseLocation,amScraping.proposedSp))))
|
| 1662 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1738 |
sheet.write(sheet_iterator, 56, getInventoryMovementStatus(amScraping))
|
| 1663 |
sheet_iterator+=1
|
1739 |
sheet_iterator+=1
|
| 1664 |
#TODO : Take excell sheet generation code inside a function
|
1740 |
#TODO : Take excell sheet generation code inside a function
|
| 1665 |
competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1741 |
competitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.COMPETITIVE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 1666 |
for competitiveItem in competitiveItems:
|
1742 |
for competitiveItem in competitiveItems:
|
| 1667 |
amScraping = competitiveItem[0]
|
1743 |
amScraping = competitiveItem[0]
|
| Line 1734... |
Line 1810... |
| 1734 |
if str(daysOfStock)=='inf':
|
1810 |
if str(daysOfStock)=='inf':
|
| 1735 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
1811 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 1736 |
else:
|
1812 |
else:
|
| 1737 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
1813 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 1738 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
1814 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
1815 |
sale, count = get30DaysStats(sku)
|
| - |
|
1816 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
1817 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
1818 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
1819 |
|
| - |
|
1820 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
1821 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
1822 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
1823 |
else:
|
| - |
|
1824 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
1825 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
1826 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
1827 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
1828 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
1829 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
1830 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 1739 |
if amScraping.decision is None:
|
1831 |
if amScraping.decision is None:
|
| 1740 |
sheet.write(sheet_iterator, 45, 'Auto Pricing Inactive')
|
1832 |
sheet.write(sheet_iterator, 54, 'Auto Pricing Inactive')
|
| 1741 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1833 |
sheet.write(sheet_iterator, 55, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1742 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1834 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1743 |
sheet_iterator+=1
|
1835 |
sheet_iterator+=1
|
| 1744 |
continue
|
1836 |
continue
|
| 1745 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
1837 |
sheet.write(sheet_iterator, 54, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1746 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
1838 |
sheet.write(sheet_iterator, 55, amScraping.reason)
|
| 1747 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
1839 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1748 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
1840 |
sheet.write(sheet_iterator, 56, math.ceil(amScraping.proposedSp))
|
| 1749 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
1841 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1750 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
1842 |
sheet.write(sheet_iterator, 56, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
| 1751 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1843 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1752 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1844 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1753 |
sheet_iterator+=1
|
1845 |
sheet_iterator+=1
|
| 1754 |
|
1846 |
|
| 1755 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1847 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 1756 |
for almostCompetitiveItem in almostCompetitiveItems:
|
1848 |
for almostCompetitiveItem in almostCompetitiveItems:
|
| 1757 |
amScraping = almostCompetitiveItem[0]
|
1849 |
amScraping = almostCompetitiveItem[0]
|
| Line 1824... |
Line 1916... |
| 1824 |
if str(daysOfStock)=='inf':
|
1916 |
if str(daysOfStock)=='inf':
|
| 1825 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
1917 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 1826 |
else:
|
1918 |
else:
|
| 1827 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
1919 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 1828 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
1920 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
1921 |
sale, count = get30DaysStats(sku)
|
| - |
|
1922 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
1923 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
1924 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
1925 |
|
| - |
|
1926 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
1927 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
1928 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
1929 |
else:
|
| - |
|
1930 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
1931 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
1932 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
1933 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
1934 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
1935 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
1936 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 1829 |
if amScraping.decision is None:
|
1937 |
if amScraping.decision is None:
|
| 1830 |
sheet.write(sheet_iterator, 45, 'Auto Pricing Inactive')
|
1938 |
sheet.write(sheet_iterator, 54, 'Auto Pricing Inactive')
|
| 1831 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1939 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1832 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1940 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1833 |
sheet_iterator+=1
|
1941 |
sheet_iterator+=1
|
| 1834 |
continue
|
1942 |
continue
|
| 1835 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
1943 |
sheet.write(sheet_iterator, 54, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1836 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
1944 |
sheet.write(sheet_iterator, 55, amScraping.reason)
|
| 1837 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
1945 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1838 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
1946 |
sheet.write(sheet_iterator, 56, math.ceil(amScraping.proposedSp))
|
| 1839 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
1947 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1840 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
1948 |
sheet.write(sheet_iterator, 56, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
| 1841 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
1949 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1842 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
1950 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1843 |
sheet_iterator+=1
|
1951 |
sheet_iterator+=1
|
| 1844 |
|
1952 |
|
| 1845 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1953 |
amongCheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.AMONG_CHEAPEST_CAN_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 1846 |
for amongCheapestItem in amongCheapestItems:
|
1954 |
for amongCheapestItem in amongCheapestItems:
|
| 1847 |
amScraping = amongCheapestItem[0]
|
1955 |
amScraping = amongCheapestItem[0]
|
| Line 1914... |
Line 2022... |
| 1914 |
if str(daysOfStock)=='inf':
|
2022 |
if str(daysOfStock)=='inf':
|
| 1915 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
2023 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 1916 |
else:
|
2024 |
else:
|
| 1917 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
2025 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 1918 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
2026 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
2027 |
sale, count = get30DaysStats(sku)
|
| - |
|
2028 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
2029 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
2030 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
2031 |
|
| - |
|
2032 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
2033 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
2034 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
2035 |
else:
|
| - |
|
2036 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
2037 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
2038 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
2039 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
2040 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2041 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
2042 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 1919 |
if amScraping.decision is None:
|
2043 |
if amScraping.decision is None:
|
| 1920 |
sheet.write(sheet_iterator, 45, 'Auto Pricing Inactive')
|
2044 |
sheet.write(sheet_iterator, 54, 'Auto Pricing Inactive')
|
| 1921 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
2045 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1922 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2046 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1923 |
sheet_iterator+=1
|
2047 |
sheet_iterator+=1
|
| 1924 |
continue
|
2048 |
continue
|
| 1925 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
2049 |
sheet.write(sheet_iterator, 54, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 1926 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
2050 |
sheet.write(sheet_iterator, 55, amScraping.reason)
|
| 1927 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
2051 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 1928 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
2052 |
sheet.write(sheet_iterator, 56, math.ceil(amScraping.proposedSp))
|
| 1929 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
2053 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1930 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
2054 |
sheet.write(sheet_iterator, 56, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
| 1931 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
2055 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 1932 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2056 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 1933 |
sheet_iterator+=1
|
2057 |
sheet_iterator+=1
|
| 1934 |
|
2058 |
|
| 1935 |
|
2059 |
|
| 1936 |
# sheet = wbk.add_sheet('Cheapest')
|
2060 |
# sheet = wbk.add_sheet('Cheapest')
|
| 1937 |
# xstr = lambda s: s or ""
|
2061 |
# xstr = lambda s: s or ""
|
| Line 2051... |
Line 2175... |
| 2051 |
if str(daysOfStock)=='inf':
|
2175 |
if str(daysOfStock)=='inf':
|
| 2052 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
2176 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 2053 |
else:
|
2177 |
else:
|
| 2054 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
2178 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 2055 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
2179 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
2180 |
sale, count = get30DaysStats(sku)
|
| - |
|
2181 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
2182 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
2183 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
2184 |
|
| - |
|
2185 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
2186 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
2187 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
2188 |
else:
|
| - |
|
2189 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
2190 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
2191 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
2192 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
2193 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2194 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
2195 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 2056 |
if amScraping.decision is None:
|
2196 |
if amScraping.decision is None:
|
| 2057 |
sheet.write(sheet_iterator, 45, 'Auto Pricing Inactive')
|
2197 |
sheet.write(sheet_iterator, 54, 'Auto Pricing Inactive')
|
| 2058 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,amScraping.proposedSp))
|
2198 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,amScraping.proposedSp))
|
| 2059 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2199 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 2060 |
sheet_iterator+=1
|
2200 |
sheet_iterator+=1
|
| 2061 |
continue
|
2201 |
continue
|
| 2062 |
sheet.write(sheet_iterator, 45, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
2202 |
sheet.write(sheet_iterator, 54, Decision._VALUES_TO_NAMES.get(amScraping.decision))
|
| 2063 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
2203 |
sheet.write(sheet_iterator, 55, amScraping.reason)
|
| 2064 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
2204 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_DECREMENT_SUCCESS":
|
| 2065 |
sheet.write(sheet_iterator, 47, math.ceil(amScraping.proposedSp))
|
2205 |
sheet.write(sheet_iterator, 56, math.ceil(amScraping.proposedSp))
|
| 2066 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
2206 |
if Decision._VALUES_TO_NAMES.get(amScraping.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 2067 |
sheet.write(sheet_iterator, 47, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
2207 |
sheet.write(sheet_iterator, 56, min(math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice)),amScraping.proposedSp))
|
| 2068 |
sheet.write(sheet_iterator, 48, getNewMargin(amScraping,math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))))
|
2208 |
sheet.write(sheet_iterator, 57, getNewMargin(amScraping,math.ceil(amScraping.promoPrice+max(10,.01*amScraping.promoPrice))))
|
| 2069 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2209 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 2070 |
sheet_iterator+=1
|
2210 |
sheet_iterator+=1
|
| 2071 |
|
2211 |
|
| 2072 |
exceptionCheapItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp)\
|
2212 |
exceptionCheapItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp)\
|
| 2073 |
.filter(or_(AmazonScrapingHistory.exceptionType==3,AmazonScrapingHistory.exceptionType==5)).all()
|
2213 |
.filter(or_(AmazonScrapingHistory.exceptionType==3,AmazonScrapingHistory.exceptionType==5)).all()
|
| 2074 |
|
2214 |
|
| Line 2143... |
Line 2283... |
| 2143 |
if str(daysOfStock)=='inf':
|
2283 |
if str(daysOfStock)=='inf':
|
| 2144 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
2284 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 2145 |
else:
|
2285 |
else:
|
| 2146 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
2286 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 2147 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
2287 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
2288 |
sale, count = get30DaysStats(sku)
|
| - |
|
2289 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
2290 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
2291 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
2292 |
|
| - |
|
2293 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
2294 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
2295 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
2296 |
else:
|
| - |
|
2297 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
2298 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
2299 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
2300 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
2301 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2302 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
2303 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 2148 |
sheet.write(sheet_iterator, 45, 'AUTO_INCREMENT_FAILED')
|
2304 |
sheet.write(sheet_iterator, 54, 'AUTO_INCREMENT_FAILED')
|
| 2149 |
if amScraping.exceptionType==3:
|
2305 |
if amScraping.exceptionType==3:
|
| 2150 |
sheet.write(sheet_iterator, 46, 'We are the only seller')
|
2306 |
sheet.write(sheet_iterator, 55, 'We are the only seller')
|
| 2151 |
else:
|
2307 |
else:
|
| 2152 |
sheet.write(sheet_iterator, 46, amScraping.reason)
|
2308 |
sheet.write(sheet_iterator, 55, amScraping.reason)
|
| 2153 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2309 |
sheet.write(sheet_iterator, 58, getInventoryMovementStatus(amScraping))
|
| 2154 |
sheet_iterator+=1
|
2310 |
sheet_iterator+=1
|
| 2155 |
|
2311 |
|
| 2156 |
|
2312 |
|
| 2157 |
# sheet = wbk.add_sheet('Negative Margin')
|
2313 |
# sheet = wbk.add_sheet('Negative Margin')
|
| 2158 |
# xstr = lambda s: s or ""
|
2314 |
# xstr = lambda s: s or ""
|
| Line 2268... |
Line 2424... |
| 2268 |
if str(daysOfStock)=='inf':
|
2424 |
if str(daysOfStock)=='inf':
|
| 2269 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
2425 |
sheet.write(sheet_iterator, 43, str(daysOfStock))
|
| 2270 |
else:
|
2426 |
else:
|
| 2271 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
2427 |
sheet.write(sheet_iterator, 43, str(round(daysOfStock,1)))
|
| 2272 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
2428 |
sheet.write(sheet_iterator, 44, getOosString(saleMap.get(sku)))
|
| - |
|
2429 |
sale, count = get30DaysStats(sku)
|
| - |
|
2430 |
sheet.write(sheet_iterator, 45, sale)
|
| - |
|
2431 |
sheet.write(sheet_iterator, 46, count)
|
| - |
|
2432 |
sheet.write(sheet_iterator, 47, getAvgSale(count, sale))
|
| - |
|
2433 |
|
| - |
|
2434 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
2435 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
2436 |
sheet.write(sheet_iterator, 48, 'No History available')
|
| - |
|
2437 |
else:
|
| - |
|
2438 |
sheet.write(sheet_iterator, 48, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
2439 |
sheet.write(sheet_iterator, 49, str(inStockStats[1]))
|
| - |
|
2440 |
sheet.write(sheet_iterator, 50, str(inStockStats[2]))
|
| - |
|
2441 |
sheet.write(sheet_iterator, 51, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
2442 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2443 |
sheet.write(sheet_iterator, 52, toDaysSale[0])
|
| - |
|
2444 |
sheet.write(sheet_iterator, 53, str(toDaysSale[1]))
|
| 2273 |
sheet.write(sheet_iterator, 49, getInventoryMovementStatus(amScraping))
|
2445 |
sheet.write(sheet_iterator, 56, getInventoryMovementStatus(amScraping))
|
| 2274 |
sheet_iterator+=1
|
2446 |
sheet_iterator+=1
|
| 2275 |
|
2447 |
|
| 2276 |
sheet = wbk.add_sheet('Exception List')
|
2448 |
sheet = wbk.add_sheet('Exception List')
|
| 2277 |
xstr = lambda s: s or ""
|
2449 |
xstr = lambda s: s or ""
|
| 2278 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
2450 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| Line 2294... |
Line 2466... |
| 2294 |
sheet.write(0, 10, "Promo Price", heading_xf)
|
2466 |
sheet.write(0, 10, "Promo Price", heading_xf)
|
| 2295 |
sheet.write(0, 11, "Inventory", heading_xf)
|
2467 |
sheet.write(0, 11, "Inventory", heading_xf)
|
| 2296 |
sheet.write(0, 12, "Avg Sale", heading_xf)
|
2468 |
sheet.write(0, 12, "Avg Sale", heading_xf)
|
| 2297 |
sheet.write(0, 13, "NOD", heading_xf)
|
2469 |
sheet.write(0, 13, "NOD", heading_xf)
|
| 2298 |
sheet.write(0, 14, "Sales History", heading_xf)
|
2470 |
sheet.write(0, 14, "Sales History", heading_xf)
|
| - |
|
2471 |
sheet.write(0, 15, "Last 30 days sale", heading_xf)
|
| - |
|
2472 |
sheet.write(0, 16, "No of days InStock in last 30 days", heading_xf)
|
| - |
|
2473 |
sheet.write(0, 17, "Avg 30 Days Sale", heading_xf)
|
| - |
|
2474 |
sheet.write(0, 18, "Last OOS Date", heading_xf)
|
| - |
|
2475 |
sheet.write(0, 19, "Total Sale Since InStock (Excluding Today)", heading_xf)
|
| - |
|
2476 |
sheet.write(0, 20, "Total Days Since InStock (Excluding Today)", heading_xf)
|
| - |
|
2477 |
sheet.write(0, 21, "Avg Sale Since InStock (Excluding Today)", heading_xf)
|
| - |
|
2478 |
sheet.write(0, 22, "Todays Sale Snapshot Time", heading_xf)
|
| - |
|
2479 |
sheet.write(0, 23, "Todays Sale", heading_xf)
|
| 2299 |
sheet.write(0, 15, "Inventory Movement Status", heading_xf)
|
2480 |
sheet.write(0, 24, "Inventory Movement Status", heading_xf)
|
| 2300 |
sheet.write(0, 16, "Reason", heading_xf)
|
2481 |
sheet.write(0, 25, "Reason", heading_xf)
|
| 2301 |
|
2482 |
|
| 2302 |
sheet_iterator = 1
|
2483 |
sheet_iterator = 1
|
| 2303 |
exceptionListItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
2484 |
exceptionListItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 2304 |
for exceptionListItem in exceptionListItems:
|
2485 |
for exceptionListItem in exceptionListItems:
|
| 2305 |
amScraping = exceptionListItem[0]
|
2486 |
amScraping = exceptionListItem[0]
|
| Line 2335... |
Line 2516... |
| 2335 |
if str(daysOfStock)=='inf':
|
2516 |
if str(daysOfStock)=='inf':
|
| 2336 |
sheet.write(sheet_iterator, 13, str(daysOfStock))
|
2517 |
sheet.write(sheet_iterator, 13, str(daysOfStock))
|
| 2337 |
else:
|
2518 |
else:
|
| 2338 |
sheet.write(sheet_iterator, 13, str(round(daysOfStock,1)))
|
2519 |
sheet.write(sheet_iterator, 13, str(round(daysOfStock,1)))
|
| 2339 |
sheet.write(sheet_iterator, 14, getOosString(saleMap.get(sku)))
|
2520 |
sheet.write(sheet_iterator, 14, getOosString(saleMap.get(sku)))
|
| - |
|
2521 |
sale, count = get30DaysStats(sku)
|
| - |
|
2522 |
sheet.write(sheet_iterator, 15, sale)
|
| - |
|
2523 |
sheet.write(sheet_iterator, 16, count)
|
| - |
|
2524 |
sheet.write(sheet_iterator, 17, getAvgSale(count, sale))
|
| - |
|
2525 |
|
| - |
|
2526 |
inStockStats = getInStockStats(amScraping.item_id, amScraping.warehouseLocation)
|
| - |
|
2527 |
if inStockStats[0].dateOfSale == 0:
|
| - |
|
2528 |
sheet.write(sheet_iterator, 18, 'No History available')
|
| - |
|
2529 |
else:
|
| - |
|
2530 |
sheet.write(sheet_iterator, 18, str(to_py_date(inStockStats[0].dateOfSale).date()))
|
| - |
|
2531 |
sheet.write(sheet_iterator, 19, str(inStockStats[1]))
|
| - |
|
2532 |
sheet.write(sheet_iterator, 20, str(inStockStats[2]))
|
| - |
|
2533 |
sheet.write(sheet_iterator, 21, getAvgSale(inStockStats[1], inStockStats[2]))
|
| - |
|
2534 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2535 |
sheet.write(sheet_iterator, 22, toDaysSale[0])
|
| - |
|
2536 |
sheet.write(sheet_iterator, 23, str(toDaysSale[1]))
|
| 2340 |
sheet.write(sheet_iterator, 15, getInventoryMovementStatus(amScraping))
|
2537 |
sheet.write(sheet_iterator, 24, getInventoryMovementStatus(amScraping))
|
| 2341 |
sheet.write(sheet_iterator, 16, amScraping.reason)
|
2538 |
sheet.write(sheet_iterator, 25, amScraping.reason)
|
| 2342 |
sheet_iterator+=1
|
2539 |
sheet_iterator+=1
|
| 2343 |
|
2540 |
|
| 2344 |
|
2541 |
|
| 2345 |
if (runType in ('FULL','FULL-OTHER')):
|
2542 |
if (runType in ('FULL','FULL-OTHER')):
|
| 2346 |
sheet = wbk.add_sheet('Auto Favorites')
|
2543 |
sheet = wbk.add_sheet('Auto Favorites')
|
| Line 2419... |
Line 2616... |
| 2419 |
vatRate = vatMaster.vatPercent
|
2616 |
vatRate = vatMaster.vatPercent
|
| 2420 |
else:
|
2617 |
else:
|
| 2421 |
vatRate = itemVatMaster.vatPercentage
|
2618 |
vatRate = itemVatMaster.vatPercentage
|
| 2422 |
return vatRate
|
2619 |
return vatRate
|
| 2423 |
|
2620 |
|
| 2424 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
|
2621 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease,timestamp):
|
| 2425 |
if len(successfulAutoDecrease)==0 and len(successfulAutoIncrease)==0 :
|
2622 |
if len(successfulAutoDecrease)==0 and len(successfulAutoIncrease)==0 :
|
| 2426 |
return
|
2623 |
return
|
| 2427 |
xstr = lambda s: s or ""
|
2624 |
xstr = lambda s: s or ""
|
| 2428 |
message="""<html>
|
2625 |
message="""<html>
|
| 2429 |
<body>
|
2626 |
<body>
|
| Line 2440... |
Line 2637... |
| 2440 |
<th>New Margin</th>
|
2637 |
<th>New Margin</th>
|
| 2441 |
<th>Commission %</th>
|
2638 |
<th>Commission %</th>
|
| 2442 |
<th>Return Provision %</th>
|
2639 |
<th>Return Provision %</th>
|
| 2443 |
<th>Inventory</th>
|
2640 |
<th>Inventory</th>
|
| 2444 |
<th>Sales History</th>
|
2641 |
<th>Sales History</th>
|
| - |
|
2642 |
<th>30 Days Sale</th>
|
| - |
|
2643 |
<th>Todays Sale</th>
|
| - |
|
2644 |
<th>Todays Sale Snapshot Time</th>
|
| 2445 |
<th>Category</th>
|
2645 |
<th>Category</th>
|
| 2446 |
<th>isListed</th>
|
2646 |
<th>isListed</th>
|
| 2447 |
<th>Price Feed Suppressed</th>
|
2647 |
<th>Price Feed Suppressed</th>
|
| 2448 |
</tr></thead>
|
2648 |
</tr></thead>
|
| 2449 |
<tbody>"""
|
2649 |
<tbody>"""
|
| Line 2497... |
Line 2697... |
| 2497 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
2697 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
| 2498 |
elif amazonShortTermActivePromotions.has_key(sku):
|
2698 |
elif amazonShortTermActivePromotions.has_key(sku):
|
| 2499 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
2699 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
| 2500 |
else:
|
2700 |
else:
|
| 2501 |
subsidy = 0
|
2701 |
subsidy = 0
|
| - |
|
2702 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2703 |
sale, count = get30DaysStats(sku)
|
| 2502 |
message+="""<tr>
|
2704 |
message+="""<tr>
|
| 2503 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
2705 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| 2504 |
<td style="text-align:center">"""+sku+"""</td>
|
2706 |
<td style="text-align:center">"""+sku+"""</td>
|
| 2505 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
2707 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| 2506 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
2708 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
| Line 2510... |
Line 2712... |
| 2510 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSp)*100,1))+"%)"+"""</td>
|
2712 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSp)*100,1))+"%)"+"""</td>
|
| 2511 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
2713 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
| 2512 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
2714 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
| 2513 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
2715 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| 2514 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
2716 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
| - |
|
2717 |
<td style="text-align:center">"""+str(sale)+"""</td>
|
| - |
|
2718 |
<td style="text-align:center">"""+str(toDaysSale[1])+"""</td>
|
| - |
|
2719 |
<td style="text-align:center">"""+toDaysSale[0]+"""</td>
|
| 2515 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
2720 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
| 2516 |
<td style="text-align:center">"""+isListed+"""</td>
|
2721 |
<td style="text-align:center">"""+isListed+"""</td>
|
| 2517 |
<td style="text-align:center">"""+priceSuppress+"""</td>
|
2722 |
<td style="text-align:center">"""+priceSuppress+"""</td>
|
| 2518 |
</tr>"""
|
2723 |
</tr>"""
|
| 2519 |
message+="""</tbody></table><h3>Auto Increase Items</h3><table border="1" style="width:100%;">
|
2724 |
message+="""</tbody></table><h3>Auto Increase Items</h3><table border="1" style="width:100%;">
|
| Line 2528... |
Line 2733... |
| 2528 |
<th>New Margin</th>
|
2733 |
<th>New Margin</th>
|
| 2529 |
<th>Commission %</th>
|
2734 |
<th>Commission %</th>
|
| 2530 |
<th>Return Provision %</th>
|
2735 |
<th>Return Provision %</th>
|
| 2531 |
<th>Inventory</th>
|
2736 |
<th>Inventory</th>
|
| 2532 |
<th>Sales History</th>
|
2737 |
<th>Sales History</th>
|
| - |
|
2738 |
<th>30 Days Sale</th>
|
| - |
|
2739 |
<th>Todays Sale</th>
|
| - |
|
2740 |
<th>Todays Sale Snapshot Time</th>
|
| 2533 |
<th>Category</th>
|
2741 |
<th>Category</th>
|
| 2534 |
<th>isListed</th>
|
2742 |
<th>isListed</th>
|
| 2535 |
<th>Price Feed Suppressed</th>
|
2743 |
<th>Price Feed Suppressed</th>
|
| 2536 |
</tr></thead>
|
2744 |
</tr></thead>
|
| 2537 |
<tbody>"""
|
2745 |
<tbody>"""
|
| Line 2585... |
Line 2793... |
| 2585 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
2793 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
| 2586 |
elif amazonShortTermActivePromotions.has_key(sku):
|
2794 |
elif amazonShortTermActivePromotions.has_key(sku):
|
| 2587 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
2795 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
| 2588 |
else:
|
2796 |
else:
|
| 2589 |
subsidy = 0
|
2797 |
subsidy = 0
|
| - |
|
2798 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2799 |
sale, count = get30DaysStats(sku)
|
| 2590 |
message+="""<tr>
|
2800 |
message+="""<tr>
|
| 2591 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
2801 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| 2592 |
<td style="text-align:center">"""+sku+"""</td>
|
2802 |
<td style="text-align:center">"""+sku+"""</td>
|
| 2593 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
2803 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| 2594 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
2804 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
| Line 2598... |
Line 2808... |
| 2598 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))))*100,1))+"%)"+"""</td>
|
2808 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(math.ceil(min(math.ceil(item.promoPrice+max(10,.01*item.promoPrice)),item.proposedSp))))*100,1))+"%)"+"""</td>
|
| 2599 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
2809 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
| 2600 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
2810 |
<td style="text-align:center">"""+str(item.returnProvision)+" %"+"""</td>
|
| 2601 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
2811 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| 2602 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
2812 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
| - |
|
2813 |
<td style="text-align:center">"""+str(sale)+"""</td>
|
| - |
|
2814 |
<td style="text-align:center">"""+str(toDaysSale[1])+"""</td>
|
| - |
|
2815 |
<td style="text-align:center">"""+toDaysSale[0]+"""</td>
|
| 2603 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
2816 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(item.competitiveCategory))+"""</td>
|
| 2604 |
<td style="text-align:center">"""+isListed+"""</td>
|
2817 |
<td style="text-align:center">"""+isListed+"""</td>
|
| 2605 |
<td style="text-align:center">"""+priceSuppress+"""</td>
|
2818 |
<td style="text-align:center">"""+priceSuppress+"""</td>
|
| 2606 |
</tr>"""
|
2819 |
</tr>"""
|
| - |
|
2820 |
|
| 2607 |
message+="""</tbody></table><h3>Create Listing On Our Dashboard - Stock is present in FC</h3><table border="1" style="width:100%;">
|
2821 |
message+="""</tbody></table><h3>Create Listing On Our Dashboard - Stock present in FC</h3><table border="1" style="width:100%;">
|
| 2608 |
<thead>
|
2822 |
<thead>
|
| 2609 |
<tr><th>Item Id</th>
|
2823 |
<tr><th>Item Id</th>
|
| 2610 |
<th>Amazon SKU</th>
|
2824 |
<th>Amazon SKU</th>
|
| 2611 |
<th>Product Name</th></tr></thead>
|
2825 |
<th>Product Name</th></tr></thead>
|
| 2612 |
<tbody>
|
2826 |
<tbody>
|
| Line 2621... |
Line 2835... |
| 2621 |
message+="""<tr>
|
2835 |
message+="""<tr>
|
| 2622 |
<td style="text-align:center">"""+sku[3:]+"""</td>
|
2836 |
<td style="text-align:center">"""+sku[3:]+"""</td>
|
| 2623 |
<td style="text-align:center">"""+sku+"""</td>
|
2837 |
<td style="text-align:center">"""+sku+"""</td>
|
| 2624 |
<td style="text-align:center">"""+productName+"""</td>
|
2838 |
<td style="text-align:center">"""+productName+"""</td>
|
| 2625 |
</tr>"""
|
2839 |
</tr>"""
|
| - |
|
2840 |
|
| - |
|
2841 |
exceptionListItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.EXCEPTION).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| - |
|
2842 |
message+="""</tbody></table><h3 style="color:red;">Exception Items</h3><table border="1" style="width:100%;">
|
| - |
|
2843 |
<thead>
|
| - |
|
2844 |
<tr><th>Item Id</th>
|
| - |
|
2845 |
<th>Amazon SKU</th>
|
| - |
|
2846 |
<th>Product Name</th>
|
| - |
|
2847 |
<th>Selling Price</th>
|
| - |
|
2848 |
<th>Promo Price</th>
|
| - |
|
2849 |
<th>Inventory</th>
|
| - |
|
2850 |
<th>30 Days Sale</th>
|
| - |
|
2851 |
<th>Todays Sale</th>
|
| - |
|
2852 |
<th>Todays Sale Snapshot Time</th>
|
| - |
|
2853 |
<th>Sales History</th>
|
| - |
|
2854 |
<th>Reason</th>
|
| - |
|
2855 |
</tr></thead>
|
| - |
|
2856 |
<tbody>
|
| - |
|
2857 |
"""
|
| - |
|
2858 |
for exceptionListItem in exceptionListItems:
|
| - |
|
2859 |
amScraping = exceptionListItem[0]
|
| - |
|
2860 |
if amScraping.exceptionType in (3,5):
|
| - |
|
2861 |
continue
|
| - |
|
2862 |
item = exceptionListItem[1]
|
| - |
|
2863 |
sku = ''
|
| - |
|
2864 |
if amScraping.warehouseLocation==1:
|
| - |
|
2865 |
sku='FBA'+str(item.id)
|
| - |
|
2866 |
elif amScraping.warehouseLocation==2:
|
| - |
|
2867 |
sku='FBB'+str(item.id)
|
| - |
|
2868 |
else:
|
| - |
|
2869 |
sku='FBG'+str(item.id)
|
| - |
|
2870 |
toDaysSale = getTodaysSale(sku)
|
| - |
|
2871 |
sale, count = get30DaysStats(sku)
|
| - |
|
2872 |
message+="""<tr>
|
| - |
|
2873 |
<td style="text-align:center">"""+str(item.id)+"""</td>
|
| - |
|
2874 |
<td style="text-align:center">"""+sku+"""</td>
|
| - |
|
2875 |
<td style="text-align:center">"""+xstr(item.brand)+" "+xstr(item.model_name)+" "+xstr(item.model_number)+" "+xstr(item.color)+"""</td>
|
| - |
|
2876 |
<td style="text-align:center">"""+str(amScraping.ourSellingPrice)+"""</td>
|
| - |
|
2877 |
<td style="text-align:center">"""+str(amScraping.promoPrice)+"""</td>
|
| - |
|
2878 |
<td style="text-align:center">"""+str(amScraping.ourInventory)+"""</td>
|
| - |
|
2879 |
<td style="text-align:center">"""+str(sale)+"""</td>
|
| - |
|
2880 |
<td style="text-align:center">"""+str(toDaysSale[1])+"""</td>
|
| - |
|
2881 |
<td style="text-align:center">"""+toDaysSale[0]+"""</td>
|
| - |
|
2882 |
<td style="text-align:center">"""+getOosString(saleMap.get(sku))+"""</td>
|
| - |
|
2883 |
<td style="text-align:center">"""+amScraping.reason+"""</td>
|
| - |
|
2884 |
</tr>"""
|
| - |
|
2885 |
|
| 2626 |
message+="""</tbody></table></body></html>"""
|
2886 |
message+="""</tbody></table></body></html>"""
|
| 2627 |
print message
|
2887 |
print message
|
| 2628 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
2888 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| 2629 |
mailServer.ehlo()
|
2889 |
mailServer.ehlo()
|
| 2630 |
mailServer.starttls()
|
2890 |
mailServer.starttls()
|
| Line 2932... |
Line 3192... |
| 2932 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
3192 |
commitCantCompete(cantCompete, timestamp,options.runType)
|
| 2933 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
3193 |
exceptionList[:], negativeMargin[:], cheapest[:], amongCheapestAndCanCompete[:], canCompete[:], almostCompete[:], cantCompete[:] =[],[],[],[],[],[],[]
|
| 2934 |
autoDecreaseItems = fetchItemsForAutoDecrease(timestamp)
|
3194 |
autoDecreaseItems = fetchItemsForAutoDecrease(timestamp)
|
| 2935 |
autoIncreaseItems = fetchItemsForAutoIncrease(timestamp)
|
3195 |
autoIncreaseItems = fetchItemsForAutoIncrease(timestamp)
|
| 2936 |
previousAutoFav, nowAutoFav = markAutoFavourites(timestamp)
|
3196 |
previousAutoFav, nowAutoFav = markAutoFavourites(timestamp)
|
| - |
|
3197 |
fetchMonthSale()
|
| - |
|
3198 |
populateHourlySnapshot()
|
| 2937 |
writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,options.runType)
|
3199 |
writeReport(timestamp,autoDecreaseItems,autoIncreaseItems,previousAutoFav,nowAutoFav,options.runType)
|
| 2938 |
commitPricing(autoDecreaseItems,autoIncreaseItems)
|
3200 |
commitPricing(autoDecreaseItems,autoIncreaseItems)
|
| 2939 |
sendAutoPricingMail(autoDecreaseItems,autoIncreaseItems)
|
3201 |
sendAutoPricingMail(autoDecreaseItems,autoIncreaseItems, timestamp)
|
| 2940 |
if options.runType == 'FULL-OTHER':
|
3202 |
if options.runType == 'FULL-OTHER':
|
| 2941 |
sendAlertForNegativeMargins(timestamp)
|
3203 |
sendAlertForNegativeMargins(timestamp)
|
| 2942 |
sendAlertForCantCompete(timestamp)
|
3204 |
sendAlertForCantCompete(timestamp)
|
| 2943 |
if __name__=='__main__':
|
3205 |
if __name__=='__main__':
|
| 2944 |
main()
|
3206 |
main()
|