| Line 466... |
Line 466... |
| 466 |
temp.append(mpItem)
|
466 |
temp.append(mpItem)
|
| 467 |
cantCompete.append(temp)
|
467 |
cantCompete.append(temp)
|
| 468 |
|
468 |
|
| 469 |
return cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin
|
469 |
return cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin
|
| 470 |
|
470 |
|
| 471 |
def writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp):
|
471 |
def writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp,runType):
|
| 472 |
wbk = xlwt.Workbook()
|
472 |
wbk = xlwt.Workbook()
|
| 473 |
sheet = wbk.add_sheet('Can\'t Compete')
|
473 |
sheet = wbk.add_sheet('Can\'t Compete')
|
| 474 |
xstr = lambda s: s or ""
|
474 |
xstr = lambda s: s or ""
|
| 475 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
475 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 476 |
|
476 |
|
| Line 985... |
Line 985... |
| 985 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
985 |
sheet.write(sheet_iterator, 26, proposed_tp)
|
| 986 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
986 |
sheet.write(sheet_iterator, 27, proposed_sp)
|
| 987 |
sheet.write(sheet_iterator, 28, target_nlc)
|
987 |
sheet.write(sheet_iterator, 28, target_nlc)
|
| 988 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
988 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 989 |
sheet_iterator+=1
|
989 |
sheet_iterator+=1
|
| 990 |
|
990 |
|
| - |
|
991 |
if (runType=='FULL'):
|
| 991 |
sheet = wbk.add_sheet('Auto Favorites')
|
992 |
sheet = wbk.add_sheet('Auto Favorites')
|
| 992 |
|
993 |
|
| 993 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
994 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 994 |
|
995 |
|
| 995 |
excel_integer_format = '0'
|
996 |
excel_integer_format = '0'
|
| 996 |
integer_style = xlwt.XFStyle()
|
997 |
integer_style = xlwt.XFStyle()
|
| 997 |
integer_style.num_format_str = excel_integer_format
|
998 |
integer_style.num_format_str = excel_integer_format
|
| 998 |
xstr = lambda s: s or ""
|
999 |
xstr = lambda s: s or ""
|
| 999 |
|
1000 |
|
| 1000 |
sheet.write(0, 0, "Item ID", heading_xf)
|
1001 |
sheet.write(0, 0, "Item ID", heading_xf)
|
| 1001 |
sheet.write(0, 1, "Brand", heading_xf)
|
1002 |
sheet.write(0, 1, "Brand", heading_xf)
|
| 1002 |
sheet.write(0, 2, "Product Name", heading_xf)
|
1003 |
sheet.write(0, 2, "Product Name", heading_xf)
|
| 1003 |
sheet.write(0, 3, "Auto Favourite", heading_xf)
|
1004 |
sheet.write(0, 3, "Auto Favourite", heading_xf)
|
| 1004 |
sheet.write(0, 4, "Reason", heading_xf)
|
1005 |
sheet.write(0, 4, "Reason", heading_xf)
|
| 1005 |
|
1006 |
|
| 1006 |
sheet_iterator=1
|
1007 |
sheet_iterator=1
|
| 1007 |
for autoFav in nowAutoFav:
|
1008 |
for autoFav in nowAutoFav:
|
| 1008 |
itemId = autoFav[0]
|
1009 |
itemId = autoFav[0]
|
| 1009 |
reason = autoFav[1]
|
1010 |
reason = autoFav[1]
|
| 1010 |
it = Item.query.filter_by(id=itemId).one()
|
1011 |
it = Item.query.filter_by(id=itemId).one()
|
| 1011 |
sheet.write(sheet_iterator, 0, itemId)
|
1012 |
sheet.write(sheet_iterator, 0, itemId)
|
| 1012 |
sheet.write(sheet_iterator, 1, it.brand)
|
1013 |
sheet.write(sheet_iterator, 1, it.brand)
|
| 1013 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
1014 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| 1014 |
sheet.write(sheet_iterator, 3, "True")
|
1015 |
sheet.write(sheet_iterator, 3, "True")
|
| 1015 |
sheet.write(sheet_iterator, 4, reason)
|
1016 |
sheet.write(sheet_iterator, 4, reason)
|
| 1016 |
sheet_iterator+=1
|
1017 |
sheet_iterator+=1
|
| 1017 |
for prevFav in previousAutoFav:
|
1018 |
for prevFav in previousAutoFav:
|
| 1018 |
it = Item.query.filter_by(id=prevFav).one()
|
1019 |
it = Item.query.filter_by(id=prevFav).one()
|
| 1019 |
sheet.write(sheet_iterator, 0, prevFav)
|
1020 |
sheet.write(sheet_iterator, 0, prevFav)
|
| 1020 |
sheet.write(sheet_iterator, 1, it.brand)
|
1021 |
sheet.write(sheet_iterator, 1, it.brand)
|
| 1021 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
1022 |
sheet.write(sheet_iterator, 2, xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color))
|
| 1022 |
sheet.write(sheet_iterator, 3, "False")
|
1023 |
sheet.write(sheet_iterator, 3, "False")
|
| 1023 |
sheet_iterator+=1
|
1024 |
sheet_iterator+=1
|
| 1024 |
|
1025 |
|
| 1025 |
|
1026 |
|
| 1026 |
autoPricingItems = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.decision.in_([1,2,3,4])).all()
|
1027 |
autoPricingItems = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.decision.in_([1,2,3,4])).all()
|
| 1027 |
sheet = wbk.add_sheet('Auto Inc and Dec')
|
1028 |
sheet = wbk.add_sheet('Auto Inc and Dec')
|
| 1028 |
|
1029 |
|
| Line 1053... |
Line 1054... |
| 1053 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.proposedSellingPrice))
|
1054 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.proposedSellingPrice))
|
| 1054 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
1055 |
if Decision._VALUES_TO_NAMES.get(mpHistory.decision) == "AUTO_INCREMENT_SUCCESS":
|
| 1055 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
1056 |
sheet.write(sheet_iterator, 5, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
| 1056 |
sheet_iterator+=1
|
1057 |
sheet_iterator+=1
|
| 1057 |
|
1058 |
|
| 1058 |
filename = "/tmp/snapdeal-auto-" + str(timestamp) + ".xls"
|
1059 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1059 |
wbk.save(filename)
|
1060 |
wbk.save(filename)
|
| 1060 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing " + str(timestamp), "", [get_attachment_part(filename)], ["kshitij.sood@saholic.com"], [])
|
1061 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing " + str(timestamp), "", [get_attachment_part(filename)], ["kshitij.sood@saholic.com"], [])
|
| 1061 |
|
1062 |
|
| 1062 |
def commitExceptionList(exceptionList,timestamp):
|
1063 |
def commitExceptionList(exceptionList,timestamp):
|
| 1063 |
exceptionItems=[]
|
1064 |
exceptionItems=[]
|
| Line 1364... |
Line 1365... |
| 1364 |
negativeMarginItems = commitNegativeMargin(negativeMargin,timestamp)
|
1365 |
negativeMarginItems = commitNegativeMargin(negativeMargin,timestamp)
|
| 1365 |
fetchItemsForAutoDecrease(timestamp)
|
1366 |
fetchItemsForAutoDecrease(timestamp)
|
| 1366 |
fetchItemsForAutoIncrease(timestamp)
|
1367 |
fetchItemsForAutoIncrease(timestamp)
|
| 1367 |
if options.runType=='FULL':
|
1368 |
if options.runType=='FULL':
|
| 1368 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
1369 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
| 1369 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp)
|
1370 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
| 1370 |
|
1371 |
|
| 1371 |
if __name__ == '__main__':
|
1372 |
if __name__ == '__main__':
|
| 1372 |
main()
|
1373 |
main()
|
| 1373 |
|
1374 |
|