| Line 1... |
Line 1... |
| 1 |
from elixir import *
|
1 |
from elixir import *
|
| 2 |
from sqlalchemy.sql import or_ ,func, asc
|
2 |
from sqlalchemy.sql import or_ ,func, asc
|
| 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 SnapdealItem, MarketplaceItems, Item, \
|
5 |
from shop2020.model.v1.catalog.impl.DataService import SnapdealItem, MarketplaceItems, Item, \
|
| 6 |
Category, SourcePercentageMaster, MarketPlaceHistory, MarketPlaceUpdateHistory, MarketPlaceItemPrice
|
6 |
Category, SourcePercentageMaster, MarketPlaceHistory, MarketPlaceUpdateHistory, MarketPlaceItemPrice, \
|
| - |
|
7 |
SourceCategoryPercentage, SourceItemPercentage
|
| 7 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
8 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 8 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
9 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
| 9 |
Decision, RunType
|
10 |
Decision, RunType
|
| 10 |
from shop2020.clients.CatalogClient import CatalogClient
|
11 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 11 |
from shop2020.clients.InventoryClient import InventoryClient
|
12 |
from shop2020.clients.InventoryClient import InventoryClient
|
| Line 22... |
Line 23... |
| 22 |
import smtplib
|
23 |
import smtplib
|
| 23 |
from email.mime.text import MIMEText
|
24 |
from email.mime.text import MIMEText
|
| 24 |
import email
|
25 |
import email
|
| 25 |
from email.mime.multipart import MIMEMultipart
|
26 |
from email.mime.multipart import MIMEMultipart
|
| 26 |
import email.encoders
|
27 |
import email.encoders
|
| 27 |
import urllib2
|
- |
|
| 28 |
import mechanize
|
28 |
import mechanize
|
| 29 |
import cookielib
|
29 |
import cookielib
|
| 30 |
|
30 |
|
| 31 |
|
31 |
|
| 32 |
config_client = ConfigClient()
|
32 |
config_client = ConfigClient()
|
| Line 69... |
Line 69... |
| 69 |
self.secondLowestSellerInventory = secondLowestSellerInventory
|
69 |
self.secondLowestSellerInventory = secondLowestSellerInventory
|
| 70 |
self.totalSeller = totalSeller
|
70 |
self.totalSeller = totalSeller
|
| 71 |
|
71 |
|
| 72 |
class __SnapdealItemInfo:
|
72 |
class __SnapdealItemInfo:
|
| 73 |
|
73 |
|
| 74 |
def __init__(self, supc, nlc, courierCost, item_id, product_group, brand, model_name, model_number, color, weight, parent_category, risky, warehouseId, vatRate, runType, parent_category_name):
|
74 |
def __init__(self, supc, nlc, courierCost, item_id, product_group, brand, model_name, model_number, color, weight, parent_category, risky, warehouseId, vatRate, runType, parent_category_name, sourcePercentage):
|
| 75 |
self.supc = supc
|
75 |
self.supc = supc
|
| 76 |
self.nlc = nlc
|
76 |
self.nlc = nlc
|
| 77 |
self.courierCost = courierCost
|
77 |
self.courierCost = courierCost
|
| 78 |
self.item_id = item_id
|
78 |
self.item_id = item_id
|
| 79 |
self.product_group = product_group
|
79 |
self.product_group = product_group
|
| Line 86... |
Line 86... |
| 86 |
self.risky = risky
|
86 |
self.risky = risky
|
| 87 |
self.warehouseId = warehouseId
|
87 |
self.warehouseId = warehouseId
|
| 88 |
self.vatRate = vatRate
|
88 |
self.vatRate = vatRate
|
| 89 |
self.runType = runType
|
89 |
self.runType = runType
|
| 90 |
self.parent_category_name = parent_category_name
|
90 |
self.parent_category_name = parent_category_name
|
| - |
|
91 |
self.sourcePercentage = sourcePercentage
|
| 91 |
|
92 |
|
| 92 |
class __SnapdealPricing:
|
93 |
class __SnapdealPricing:
|
| 93 |
|
94 |
|
| 94 |
def __init__(self, ourSp, ourTp, lowestTp, lowestPossibleTp, competitionBasis, secondLowestSellerTp, lowestPossibleSp):
|
95 |
def __init__(self, ourSp, ourTp, lowestTp, lowestPossibleTp, competitionBasis, secondLowestSellerTp, lowestPossibleSp):
|
| 95 |
self.ourTp = ourTp
|
96 |
self.ourTp = ourTp
|
| Line 398... |
Line 399... |
| 398 |
iterator+=1
|
399 |
iterator+=1
|
| 399 |
snapdealDetails = __SnapdealDetails(ourSp,ourInventory,otherInventory,rank,lowestSellerName, lowestSellerCode,lowestSp,secondLowestSellerName,secondLowestSellerCode,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice,len(vendorInfo))
|
400 |
snapdealDetails = __SnapdealDetails(ourSp,ourInventory,otherInventory,rank,lowestSellerName, lowestSellerCode,lowestSp,secondLowestSellerName,secondLowestSellerCode,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice,len(vendorInfo))
|
| 400 |
return snapdealDetails
|
401 |
return snapdealDetails
|
| 401 |
|
402 |
|
| 402 |
|
403 |
|
| 403 |
def populateStuff(runType):
|
404 |
def populateStuff(runType,time):
|
| 404 |
itemInfo = []
|
405 |
itemInfo = []
|
| 405 |
if runType=='FAVOURITE':
|
406 |
if runType=='FAVOURITE':
|
| 406 |
items = session.query(SnapdealItem).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).\
|
407 |
items = session.query(SnapdealItem).join((MarketplaceItems,SnapdealItem.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).\
|
| 407 |
filter(or_(MarketplaceItems.autoFavourite==True, MarketplaceItems.manualFavourite==True)).all()
|
408 |
filter(or_(MarketplaceItems.autoFavourite==True, MarketplaceItems.manualFavourite==True)).all()
|
| 408 |
else:
|
409 |
else:
|
| 409 |
items = session.query(SnapdealItem).all()
|
410 |
items = session.query(SnapdealItem).all()
|
| 410 |
spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)
|
411 |
#spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)
|
| - |
|
412 |
|
| 411 |
for snapdeal_item in items:
|
413 |
for snapdeal_item in items:
|
| 412 |
it = Item.query.filter_by(id=snapdeal_item.item_id).one()
|
414 |
it = Item.query.filter_by(id=snapdeal_item.item_id).one()
|
| 413 |
category = Category.query.filter_by(id=it.category).one()
|
415 |
category = Category.query.filter_by(id=it.category).one()
|
| 414 |
parent_category = Category.query.filter_by(id=category.parent_category_id).first()
|
416 |
parent_category = Category.query.filter_by(id=category.parent_category_id).first()
|
| - |
|
417 |
sip = SourceItemPercentage.query.filter(SourceItemPercentage.item_id==itemId).filter(SourceItemPercentage.source==OrderSource.SNAPDEAL).filter(SourceItemPercentage.startDate<=time).filter(SourceItemPercentage.expiryDate>=time).first()
|
| - |
|
418 |
sourcePercentage = None
|
| - |
|
419 |
if sip is not None:
|
| - |
|
420 |
sourcePercentage = sip
|
| - |
|
421 |
else:
|
| - |
|
422 |
scp = SourceCategoryPercentage.query.filter(SourceCategoryPercentage.category_id==it.category).filter(SourceCategoryPercentage.source==OrderSource.SNAPDEAL).filter(SourceCategoryPercentage.startDate<=time).filter(SourceCategoryPercentage.expiryDate>=time).first()
|
| - |
|
423 |
if scp is not None:
|
| - |
|
424 |
sourcePercentage = scp
|
| - |
|
425 |
else:
|
| - |
|
426 |
spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)
|
| - |
|
427 |
sourcePercentage = spm
|
| 415 |
snapdealItemInfo = __SnapdealItemInfo(snapdeal_item.supc, snapdeal_item.maxNlc,snapdeal_item.courierCost, it.id, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, snapdeal_item.warehouseId, None, runType, parent_category.display_name)
|
428 |
snapdealItemInfo = __SnapdealItemInfo(snapdeal_item.supc, snapdeal_item.maxNlc,snapdeal_item.courierCost, it.id, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, snapdeal_item.warehouseId, None, runType, parent_category.display_name,sourcePercentage)
|
| 416 |
itemInfo.append(snapdealItemInfo)
|
429 |
itemInfo.append(snapdealItemInfo)
|
| 417 |
return itemInfo, spm
|
430 |
return itemInfo
|
| 418 |
|
431 |
|
| 419 |
|
432 |
|
| 420 |
def decideCategory(itemInfo,spm):
|
433 |
def decideCategory(itemInfo):
|
| 421 |
global itemSaleMap
|
434 |
global itemSaleMap
|
| 422 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin = [],[],[],[],[],[]
|
435 |
cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin = [],[],[],[],[],[]
|
| 423 |
catalog_client = CatalogClient().get_client()
|
436 |
catalog_client = CatalogClient().get_client()
|
| 424 |
inventory_client = InventoryClient().get_client()
|
437 |
inventory_client = InventoryClient().get_client()
|
| 425 |
|
438 |
|
| 426 |
for val in itemInfo:
|
439 |
for val in itemInfo:
|
| - |
|
440 |
spm = itemInfo.sourcePercentage
|
| 427 |
try:
|
441 |
try:
|
| 428 |
snapdealDetails = fetchDetails(val.supc)
|
442 |
snapdealDetails = fetchDetails(val.supc)
|
| 429 |
except:
|
443 |
except:
|
| 430 |
exceptionItems.append(val)
|
444 |
exceptionItems.append(val)
|
| 431 |
continue
|
445 |
continue
|
| Line 618... |
Line 632... |
| 618 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
632 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
| 619 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
633 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 620 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
634 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 621 |
else:
|
635 |
else:
|
| 622 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
636 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 623 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
637 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 624 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
638 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 625 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
639 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 626 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
640 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 627 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
641 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 628 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
642 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| Line 704... |
Line 718... |
| 704 |
proposed_sp = max(snapdealDetails.secondLowestSellerSp - max((20, snapdealDetails.secondLowestSellerSp*0.002)), snapdealPricing.lowestPossibleSp)
|
718 |
proposed_sp = max(snapdealDetails.secondLowestSellerSp - max((20, snapdealDetails.secondLowestSellerSp*0.002)), snapdealPricing.lowestPossibleSp)
|
| 705 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
719 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 706 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
720 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 707 |
else:
|
721 |
else:
|
| 708 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
722 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
| 709 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
723 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 710 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
724 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 711 |
sheet.write(sheet_iterator, 25, round(proposed_tp,2))
|
725 |
sheet.write(sheet_iterator, 25, round(proposed_tp,2))
|
| 712 |
sheet.write(sheet_iterator, 26, round(proposed_sp,2))
|
726 |
sheet.write(sheet_iterator, 26, round(proposed_sp,2))
|
| 713 |
sheet.write(sheet_iterator, 27, round((proposed_tp - snapdealPricing.ourTp),2))
|
727 |
sheet.write(sheet_iterator, 27, round((proposed_tp - snapdealPricing.ourTp),2))
|
| 714 |
sheet_iterator+=1
|
728 |
sheet_iterator+=1
|
| Line 790... |
Line 804... |
| 790 |
if (snapdealPricing.competitionBasis=='SP'):
|
804 |
if (snapdealPricing.competitionBasis=='SP'):
|
| 791 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
805 |
proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)
|
| 792 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
806 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 793 |
else:
|
807 |
else:
|
| 794 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
808 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 795 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
809 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 796 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
810 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 797 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
811 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 798 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
812 |
sheet.write(sheet_iterator, 28, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| 799 |
sheet_iterator+=1
|
813 |
sheet_iterator+=1
|
| 800 |
|
814 |
|
| Line 959... |
Line 973... |
| 959 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
973 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
| 960 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
974 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 961 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
975 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 962 |
else:
|
976 |
else:
|
| 963 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
977 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 964 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
978 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 965 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
979 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 966 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
980 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 967 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
981 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 968 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
982 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 969 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
983 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| Line 1049... |
Line 1063... |
| 1049 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
1063 |
proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)
|
| 1050 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1064 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1051 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1065 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1052 |
else:
|
1066 |
else:
|
| 1053 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
1067 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 1054 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1068 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 1055 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1069 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1056 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
1070 |
sheet.write(sheet_iterator, 26, round(proposed_tp,2))
|
| 1057 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
1071 |
sheet.write(sheet_iterator, 27, round(proposed_sp,2))
|
| 1058 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
1072 |
sheet.write(sheet_iterator, 28, round(target_nlc,2))
|
| 1059 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
1073 |
sheet.write(sheet_iterator, 29, getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))
|
| Line 1132... |
Line 1146... |
| 1132 |
sheet_iterator+=1
|
1146 |
sheet_iterator+=1
|
| 1133 |
|
1147 |
|
| 1134 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
1148 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1135 |
wbk.save(filename)
|
1149 |
wbk.save(filename)
|
| 1136 |
try:
|
1150 |
try:
|
| 1137 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
1151 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
| 1138 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["chandan.kumar@saholic.com","manoj.kumar@saholic.com","yukti.jain@saholic.com","ankush.dhingra@saholic.com","manoj.pal@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
|
1152 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["chandan.kumar@saholic.com","manoj.kumar@saholic.com","yukti.jain@saholic.com","ankush.dhingra@saholic.com","manoj.pal@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
|
| 1139 |
except Exception as e:
|
1153 |
except Exception as e:
|
| 1140 |
print e
|
1154 |
print e
|
| 1141 |
print "Unable to send report.Trying with local SMTP"
|
1155 |
print "Unable to send report.Trying with local SMTP"
|
| 1142 |
smtpServer = smtplib.SMTP('localhost')
|
1156 |
smtpServer = smtplib.SMTP('localhost')
|
| 1143 |
smtpServer.set_debuglevel(1)
|
1157 |
smtpServer.set_debuglevel(1)
|
| 1144 |
sender = 'support@shop2020.in'
|
1158 |
sender = 'support@shop2020.in'
|
| 1145 |
#recipients = ['kshitij.sood@saholic.com']
|
1159 |
recipients = ['kshitij.sood@saholic.com']
|
| 1146 |
msg = MIMEMultipart()
|
1160 |
msg = MIMEMultipart()
|
| 1147 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
1161 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| 1148 |
msg['From'] = sender
|
1162 |
msg['From'] = sender
|
| 1149 |
recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
|
1163 |
#recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
|
| 1150 |
msg['To'] = ",".join(recipients)
|
1164 |
msg['To'] = ",".join(recipients)
|
| 1151 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
1165 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
| 1152 |
fileMsg.set_payload(file(filename).read())
|
1166 |
fileMsg.set_payload(file(filename).read())
|
| 1153 |
email.encoders.encode_base64(fileMsg)
|
1167 |
email.encoders.encode_base64(fileMsg)
|
| 1154 |
fileMsg.add_header('Content-Disposition','attachment;filename=snapdeal.xls')
|
1168 |
fileMsg.add_header('Content-Disposition','attachment;filename=snapdeal.xls')
|
| Line 1234... |
Line 1248... |
| 1234 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1248 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1235 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1249 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1236 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1250 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1237 |
else:
|
1251 |
else:
|
| 1238 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
1252 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 1239 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1253 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 1240 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1254 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1241 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1255 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1242 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1256 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1243 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1257 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1244 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1258 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| Line 1281... |
Line 1295... |
| 1281 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
1295 |
proposed_tp = getTargetTp(proposed_sp,mpItem)
|
| 1282 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1296 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1283 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1297 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1284 |
else:
|
1298 |
else:
|
| 1285 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
1299 |
proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)
|
| 1286 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1300 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 1287 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1301 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1288 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1302 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1289 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1303 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| 1290 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
1304 |
mpHistory.totalSeller = snapdealDetails.totalSeller
|
| 1291 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
1305 |
mpHistory.avgSales = (itemSaleMap.get(snapdealItemInfo.item_id))[2]
|
| Line 1330... |
Line 1344... |
| 1330 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1344 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1331 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1345 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1332 |
mpHistory.targetNlc = round(target_nlc,2)
|
1346 |
mpHistory.targetNlc = round(target_nlc,2)
|
| 1333 |
else:
|
1347 |
else:
|
| 1334 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
1348 |
proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)
|
| 1335 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1349 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 1336 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1350 |
target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1337 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1351 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1338 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1352 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1339 |
mpHistory.targetNlc = round(target_nlc,2)
|
1353 |
mpHistory.targetNlc = round(target_nlc,2)
|
| 1340 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1354 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| Line 1385... |
Line 1399... |
| 1385 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1399 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1386 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1400 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1387 |
#mpHistory.targetNlc = target_nlc
|
1401 |
#mpHistory.targetNlc = target_nlc
|
| 1388 |
else:
|
1402 |
else:
|
| 1389 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
1403 |
proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)
|
| 1390 |
proposed_sp = getTargetSp(proposed_tp,mpItem)
|
1404 |
proposed_sp = getTargetSp(proposed_tp,mpItem,snapdealPricing.ourSp)
|
| 1391 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
1405 |
#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlc
|
| 1392 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
1406 |
mpHistory.proposedSellingPrice = round(proposed_sp,2)
|
| 1393 |
mpHistory.proposedTp = round(proposed_tp,2)
|
1407 |
mpHistory.proposedTp = round(proposed_tp,2)
|
| 1394 |
#mpHistory.targetNlc = target_nlc
|
1408 |
#mpHistory.targetNlc = target_nlc
|
| 1395 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
1409 |
mpHistory.margin = mpHistory.ourTp - mpHistory.lowestPossibleTp
|
| Line 1468... |
Line 1482... |
| 1468 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
1482 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| 1469 |
mailServer.ehlo()
|
1483 |
mailServer.ehlo()
|
| 1470 |
mailServer.starttls()
|
1484 |
mailServer.starttls()
|
| 1471 |
mailServer.ehlo()
|
1485 |
mailServer.ehlo()
|
| 1472 |
|
1486 |
|
| 1473 |
#recipients = ['kshitij.sood@saholic.com']
|
1487 |
recipients = ['kshitij.sood@saholic.com']
|
| 1474 |
recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
|
1488 |
#recipients = ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
|
| 1475 |
msg = MIMEMultipart()
|
1489 |
msg = MIMEMultipart()
|
| 1476 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
1490 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| 1477 |
msg['From'] = ""
|
1491 |
msg['From'] = ""
|
| 1478 |
msg['To'] = ",".join(recipients)
|
1492 |
msg['To'] = ",".join(recipients)
|
| 1479 |
msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
1493 |
msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| Line 1688... |
Line 1702... |
| 1688 |
if val.parent_category==10011:
|
1702 |
if val.parent_category==10011:
|
| 1689 |
commissionPercentage = spm.competitorCommissionAccessory
|
1703 |
commissionPercentage = spm.competitorCommissionAccessory
|
| 1690 |
else:
|
1704 |
else:
|
| 1691 |
commissionPercentage = spm.competitorCommissionOther
|
1705 |
commissionPercentage = spm.competitorCommissionOther
|
| 1692 |
if snapdealDetails.rank==1:
|
1706 |
if snapdealDetails.rank==1:
|
| 1693 |
otherTp = snapdealDetails.secondLowestSellerSp- snapdealDetails.secondLowestSellerSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
1707 |
otherTp = snapdealDetails.secondLowestSellerSp- snapdealDetails.secondLowestSellerSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100))-(max(20,(spm.pgFee/100)*snapdealDetails.secondLowestSellerSp)*(1+(spm.serviceTax/100)));
|
| 1694 |
return round(otherTp,2)
|
1708 |
return round(otherTp,2)
|
| 1695 |
otherTp = snapdealDetails.lowestSp- snapdealDetails.lowestSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));
|
1709 |
otherTp = snapdealDetails.lowestSp- snapdealDetails.lowestSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100))-(max(20,(spm.pgFee/100)*snapdealDetails.lowestSp)*(1+(spm.serviceTax/100)));
|
| 1696 |
return round(otherTp,2)
|
1710 |
return round(otherTp,2)
|
| 1697 |
|
1711 |
|
| 1698 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
1712 |
def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):
|
| 1699 |
if snapdealDetails.rank==0:
|
1713 |
if snapdealDetails.rank==0:
|
| 1700 |
return mpItem.minimumPossibleTp
|
1714 |
return mpItem.minimumPossibleTp
|
| Line 1704... |
Line 1718... |
| 1704 |
return round(lowest_possible_tp,2)
|
1718 |
return round(lowest_possible_tp,2)
|
| 1705 |
|
1719 |
|
| 1706 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
1720 |
def getOurTp(snapdealDetails,val,spm,mpItem):
|
| 1707 |
if snapdealDetails.rank==0:
|
1721 |
if snapdealDetails.rank==0:
|
| 1708 |
return mpItem.currentTp
|
1722 |
return mpItem.currentTp
|
| 1709 |
ourTp = snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1723 |
ourTp = snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(spm.pgFee/100)*snapdealDetails.ourSp)*(1+(spm.serviceTax/100)));
|
| 1710 |
return round(ourTp,2)
|
1724 |
return round(ourTp,2)
|
| 1711 |
|
1725 |
|
| 1712 |
def getNewLowestPossibleTp(mpItem,nlc,vatRate,proposedSellingPrice):
|
1726 |
def getNewLowestPossibleTp(mpItem,nlc,vatRate,proposedSellingPrice):
|
| 1713 |
vat = (proposedSellingPrice/(1+(vatRate/100))-(nlc/(1+(vatRate/100))))*(vatRate/100);
|
1727 |
vat = (proposedSellingPrice/(1+(vatRate/100))-(nlc/(1+(vatRate/100))))*(vatRate/100);
|
| 1714 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*proposedSellingPrice+mpItem.otherCost;
|
1728 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*proposedSellingPrice+mpItem.otherCost;
|
| 1715 |
lowest_possible_tp = nlc+inHouseCost;
|
1729 |
lowest_possible_tp = nlc+inHouseCost;
|
| 1716 |
return round(lowest_possible_tp,2)
|
1730 |
return round(lowest_possible_tp,2)
|
| 1717 |
|
1731 |
|
| 1718 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
1732 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
| 1719 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1733 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*proposedSellingPrice)*(1+(mpItem.serviceTax/100)));
|
| 1720 |
return round(ourTp,2)
|
1734 |
return round(ourTp,2)
|
| 1721 |
|
1735 |
|
| 1722 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
1736 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
| - |
|
1737 |
if (mpItem.pgFee/100)*mpItem.ourSp>=20:
|
| 1723 |
lowestPossibleSp = (nlc+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
1738 |
lowestPossibleSp = (nlc+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
| - |
|
1739 |
else:
|
| - |
|
1740 |
lowestPossibleSp = (nlc+(mpItem.courierCost+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
| 1724 |
return round(lowestPossibleSp,2)
|
1741 |
return round(lowestPossibleSp,2)
|
| 1725 |
|
1742 |
|
| 1726 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
1743 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
| 1727 |
if snapdealDetails.rank==0:
|
1744 |
if snapdealDetails.rank==0:
|
| 1728 |
return mpItem.minimumPossibleSp
|
1745 |
return mpItem.minimumPossibleSp
|
| 1729 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
1746 |
#lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate/100))+(15+mpItem.otherCost)*(1+(val.vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(val.vatRate)/100)-(mpItem.returnProvision/100)*(1+(val.vatRate)/100));
|
| - |
|
1747 |
if (mpItem.pgFee/100)*snapdealDetails.ourSp>=20:
|
| - |
|
1748 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(15+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
| - |
|
1749 |
else:
|
| - |
|
1750 |
lowestPossibleSp = (val.nlc+(val.courierCost+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat/100))+(15+mpItem.otherCost)*(1+(mpItem.vat)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(mpItem.vat)/100)-(mpItem.returnProvision/100)*(1+(mpItem.vat)/100))
|
| 1730 |
return round(lowestPossibleSp,2)
|
1751 |
return round(lowestPossibleSp,2)
|
| 1731 |
|
1752 |
|
| 1732 |
def getTargetTp(targetSp,mpItem):
|
1753 |
def getTargetTp(targetSp,mpItem):
|
| 1733 |
targetTp = targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1754 |
targetTp = targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))-(max(20,(mpItem.pgFee/100)*targetSp)*(1+(mpItem.serviceTax/100)))
|
| 1734 |
return round(targetTp,2)
|
1755 |
return round(targetTp,2)
|
| 1735 |
|
1756 |
|
| 1736 |
def getTargetSp(targetTp,mpItem):
|
1757 |
def getTargetSp(targetTp,mpItem,ourSp):
|
| - |
|
1758 |
if ourSp.pgFee/100 < 20:
|
| 1737 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
1759 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee+20)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
| - |
|
1760 |
else:
|
| - |
|
1761 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100+mpItem.pgFee/100)*(1+(mpItem.serviceTax/100))))
|
| 1738 |
return round(targetSp,2)
|
1762 |
return round(targetSp,2)
|
| 1739 |
|
1763 |
|
| 1740 |
def getSalesPotential(lowestOfferPrice,ourNlc):
|
1764 |
def getSalesPotential(lowestOfferPrice,ourNlc):
|
| 1741 |
if lowestOfferPrice - ourNlc < 0:
|
1765 |
if lowestOfferPrice - ourNlc < 0:
|
| 1742 |
return 'HIGH'
|
1766 |
return 'HIGH'
|
| Line 1752... |
Line 1776... |
| 1752 |
help="Run type FULL or FAVOURITE")
|
1776 |
help="Run type FULL or FAVOURITE")
|
| 1753 |
(options, args) = parser.parse_args()
|
1777 |
(options, args) = parser.parse_args()
|
| 1754 |
if options.runType not in ('FULL','FAVOURITE'):
|
1778 |
if options.runType not in ('FULL','FAVOURITE'):
|
| 1755 |
print "Run type argument illegal."
|
1779 |
print "Run type argument illegal."
|
| 1756 |
sys.exit(1)
|
1780 |
sys.exit(1)
|
| 1757 |
itemInfo,spm= populateStuff(options.runType)
|
- |
|
| 1758 |
cantCompete, buyBoxItems, competitive, \
|
- |
|
| 1759 |
competitiveNoInventory, exceptionList, negativeMargin = decideCategory(itemInfo,spm)
|
- |
|
| 1760 |
timestamp = datetime.now()
|
1781 |
timestamp = datetime.now()
|
| - |
|
1782 |
itemInfo= populateStuff(options.runType,timestamp)
|
| - |
|
1783 |
cantCompete, buyBoxItems, competitive, \
|
| - |
|
1784 |
competitiveNoInventory, exceptionList, negativeMargin = decideCategory(itemInfo)
|
| 1761 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==7).one()
|
1785 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==7).one()
|
| 1762 |
exceptionItems = commitExceptionList(exceptionList,timestamp)
|
1786 |
exceptionItems = commitExceptionList(exceptionList,timestamp)
|
| 1763 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
1787 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
| 1764 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
1788 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
| 1765 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
1789 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
| Line 1771... |
Line 1795... |
| 1771 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
1795 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
| 1772 |
if options.runType=='FULL':
|
1796 |
if options.runType=='FULL':
|
| 1773 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
1797 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
| 1774 |
else:
|
1798 |
else:
|
| 1775 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
1799 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
| 1776 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
1800 |
#commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
| 1777 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
1801 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| 1778 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
1802 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| 1779 |
updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
|
1803 |
#updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
|
| 1780 |
|
1804 |
|
| 1781 |
if __name__ == '__main__':
|
1805 |
if __name__ == '__main__':
|
| 1782 |
main()
|
1806 |
main()
|
| 1783 |
|
1807 |
|