Rev 9881 | Rev 9888 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
from elixir import *from shop2020.config.client.ConfigClient import ConfigClientfrom shop2020.model.v1.catalog.impl import DataServicefrom shop2020.model.v1.catalog.impl.DataService import SnapdealItem, MarketplaceItems, Item, \Category, SourcePercentageMaster, MarketPlaceHistoryfrom shop2020.thriftpy.model.v1.order.ttypes import OrderSourcefrom shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotentialfrom shop2020.clients.CatalogClient import CatalogClientfrom shop2020.clients.InventoryClient import InventoryClientimport urllib2import timefrom datetime import date, datetimeimport simplejson as jsonimport sysconfig_client = ConfigClient()host = config_client.get_property('staging_hostname')DataService.initialize(db_hostname=host)class __Exception:SERVER_SIDE=1class __SnapdealDetails:def __init__(self, ourSp, ourInventory, otherInventory, rank, lowestSellerName, lowestSellerCode,lowestSp,secondLowestSellerName, secondLowestSellerCode,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice, totalSeller):self.ourSp = ourSpself.ourOfferPrice = ourOfferPriceself.ourInventory = ourInventoryself.otherInventory = otherInventoryself.rank = rankself.lowestSellerName = lowestSellerNameself.lowestSellerCode = lowestSellerCodeself.lowestSp = lowestSpself.lowestOfferPrice = lowestOfferPriceself.secondLowestSellerName = secondLowestSellerNameself.secondLowestSellerCode = secondLowestSellerCodeself.secondLowestSellerSp = secondLowestSellerSpself.secondLowestSellerOfferPrice = secondLowestSellerOfferPriceself.secondLowestSellerInventory = secondLowestSellerInventoryself.totalSeller = totalSellerclass __SnapdealItemInfo:def __init__(self, supc, nlc, courierCost, item_id, product_group, brand, model_name, model_number, color, weight, parent_category, risky, warehouseId, vatRate):self.supc = supcself.nlc = nlcself.courierCost = courierCostself.item_id = item_idself.product_group = product_groupself.brand = brandself.model_name = model_nameself.model_number = model_numberself.color = colorself.weight = weightself.parent_category = parent_categoryself.risky = riskyself.warehouseId = warehouseIdself.vatRate = vatRateclass __SnapdealPricing:def __init__(self, ourSp, ourTp, lowestTp, lowestPossibleTp, competitionBasis, secondLowestSellerTp, lowestPossibleSp):self.ourTp = ourTpself.lowestTp = lowestTpself.lowestPossibleTp = lowestPossibleTpself.competitionBasis = competitionBasisself.ourSp = ourSpself.secondLowestSellerTp = secondLowestSellerTpself.lowestPossibleSp = lowestPossibleSpdef fetchDetails(supc_code):url="http://www.snapdeal.com/json/gvbps?supc=%s&catId=91"%(supc_code)print urltime.sleep(1)req = urllib2.Request(url)response = urllib2.urlopen(req)json_input = response.read()vendorInfo = json.loads(json_input)rank ,otherInventory ,ourInventory, ourOfferPrice, ourSp, iterator, secondLowestSellerSp, secondLowestSellerInventory, \lowestOfferPrice, secondLowestSellerOfferPrice = (0,)*10lowestSellerName , lowestSellerCode, secondLowestSellerName, secondLowestSellerCode=('',)*4for vendor in vendorInfo:if iterator == 0:lowestSellerName = vendor['vendorDisplayName']lowestSellerCode = vendor['vendorCode']try:lowestSp = vendor['sellingPriceBefIntCashBack']except:lowestSp = vendor['sellingPrice']lowestOfferPrice = vendor['sellingPrice']if iterator ==1:secondLowestSellerName = vendor['vendorDisplayName']secondLowestSellerCode =vendor['vendorCode']try:secondLowestSellerSp = vendor['sellingPriceBefIntCashBack']except:secondLowestSellerSp = vendor['sellingPrice']secondLowestSellerOfferPrice = vendor['sellingPrice']secondLowestSellerInventory = vendor['buyableInventory']if vendor['vendorDisplayName'] == 'MobilesnMore':ourInventory = vendor['buyableInventory']try:ourSp = vendor['sellingPriceBefIntCashBack']except:ourSp = vendor['sellingPrice']ourOfferPrice = vendor['sellingPrice']rank = iterator +1else:if rank==0:otherInventory = otherInventory +vendor['buyableInventory']iterator+=1snapdealDetails = __SnapdealDetails(ourSp,ourInventory,otherInventory,rank,lowestSellerName, lowestSellerCode,lowestSp,secondLowestSellerName,secondLowestSellerCode,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice,len(vendorInfo))return snapdealDetailsdef populateStuff():itemInfo = []items = session.query(SnapdealItem).all()spm = SourcePercentageMaster.get_by(source=OrderSource.SNAPDEAL)for snapdeal_item in items:it = Item.query.filter_by(id=snapdeal_item.item_id).one()category = Category.query.filter_by(id=it.category).one()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)itemInfo.append(snapdealItemInfo)return itemInfo, spmdef decideCategory(itemInfo,spm):cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargin = [],[],[],[],[],[]catalog_client = CatalogClient().get_client()inventory_client = InventoryClient().get_client()for val in itemInfo:try:snapdealDetails = fetchDetails(val.supc)except:exceptionItems.append(val)continuempItem = MarketplaceItems.get_by(itemId=val.item_id,source=OrderSource.SNAPDEAL)warehouse = inventory_client.getWarehouse(val.warehouseId)if snapdealDetails.rank==0:snapdealDetails.ourSp = mpItem.currentSpsnapdealDetails.ourOfferPrice = mpItem.currentSpourSp = mpItem.currentSpelse:ourSp = snapdealDetails.ourSpvatRate = catalog_client.getVatPercentageForItem(val.item_id, warehouse.stateId, snapdealDetails.ourSp)val.vatRate = vatRateif (snapdealDetails.rank==1):temp=[]temp.append(snapdealDetails)temp.append(val)if (snapdealDetails.secondLowestSellerOfferPrice == snapdealDetails.secondLowestSellerSp) and snapdealDetails.ourOfferPrice==snapdealDetails.ourSp:competitionBasis = 'SP'else:competitionBasis = 'TP'secondLowestTp=0 if snapdealDetails.totalSeller==1 else getOtherTp(snapdealDetails,val,spm)snapdealPricing = __SnapdealPricing(snapdealDetails.ourSp,getOurTp(snapdealDetails,val,spm,mpItem),None,getLowestPossibleTp(snapdealDetails,val,spm,mpItem),competitionBasis,secondLowestTp,getLowestPossibleSp(snapdealDetails,val,spm,mpItem))temp.append(snapdealPricing)temp.append(mpItem)buyBoxItems.append(temp)continuelowestTp = getOtherTp(snapdealDetails,val,spm)ourTp = getOurTp(snapdealDetails,val,spm,mpItem)lowestPossibleTp = getLowestPossibleTp(snapdealDetails,val,spm,mpItem)lowestPossibleSp = getLowestPossibleSp(snapdealDetails,val,spm,mpItem)if (ourTp<lowestPossibleTp):temp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,None,None,None)temp.append(snapdealPricing)negativeMargin.append(temp)continueif (snapdealDetails.lowestOfferPrice == snapdealDetails.lowestSp) and snapdealDetails.ourOfferPrice == snapdealDetails.ourSp:competitionBasis ='SP'else:competitionBasis ='TP'if competitionBasis=='SP':if snapdealDetails.lowestSp > lowestPossibleSp and snapdealDetails.ourInventory!=0:temp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,'SP',None,lowestPossibleSp)temp.append(snapdealPricing)temp.append(mpItem)competitive.append(temp)continueelse:if lowestTp > lowestPossibleTp and snapdealDetails.ourInventory!=0:temp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,'TP',None,lowestPossibleSp)temp.append(snapdealPricing)temp.append(mpItem)competitive.append(temp)continueif competitionBasis=='SP':if snapdealDetails.lowestSp > lowestPossibleSp and snapdealDetails.ourInventory==0:temp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,'SP',None,lowestPossibleSp)temp.append(snapdealPricing)temp.append(mpItem)competitiveNoInventory.append(temp)continueelse:if lowestTp > lowestPossibleTp and snapdealDetails.ourInventory==0:temp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,'TP',None,lowestPossibleSp)temp.append(snapdealPricing)temp.append(mpItem)competitiveNoInventory.append(temp)continuetemp=[]temp.append(snapdealDetails)temp.append(val)snapdealPricing = __SnapdealPricing(ourSp,ourTp,lowestTp,lowestPossibleTp,competitionBasis,None,lowestPossibleSp)temp.append(snapdealPricing)temp.append(mpItem)cantCompete.append(temp)return cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionItems, negativeMargindef commitExceptionList(exceptionList,timestamp):for item in exceptionList:mpHistory = MarketPlaceHistory()mpHistory.item_id =item.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.competitiveCategory = CompetitionCategory.EXCEPTIONmpHistory.risky = item.riskympHistory.timestamp = timestampsession.commit()def commitNegativeMargin(negativeMargin,timestamp):for item in negativeMargin:snapdealDetails = item[0]snapdealItemInfo = item[1]snapdealPricing = item[2]mpHistory = MarketPlaceHistory()mpHistory.item_id = snapdealItemInfo.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.ourOfferPrice = snapdealDetails.ourOfferPricempHistory.ourSellingPrice = snapdealPricing.ourSpmpHistory.ourTp = snapdealPricing.ourTpmpHistory.ourNlc = snapdealItemInfo.nlcmpHistory.ourInventory = snapdealDetails.ourInventorympHistory.otherInventory = snapdealDetails.otherInventorympHistory.ourRank = snapdealDetails.rankmpHistory.competitiveCategory = CompetitionCategory.NEGATIVE_MARGINmpHistory.totalSeller = snapdealDetails.totalSellermpHistory.timestamp = timestampsession.commit()def commitCompetitive(competitive,timestamp):for item in competitive:snapdealDetails = item[0]snapdealItemInfo = item[1]snapdealPricing = item[2]mpItem = item[3]mpHistory = MarketPlaceHistory()mpHistory.item_id = snapdealItemInfo.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.lowestTp = snapdealPricing.lowestTpmpHistory.lowestPossibleTp = snapdealPricing.lowestPossibleTpmpHistory.lowestPossibleSp = snapdealPricing.lowestPossibleSpmpHistory.ourInventory = snapdealDetails.ourInventorympHistory.otherInventory = snapdealDetails.otherInventorympHistory.ourRank = snapdealDetails.rankmpHistory.competitionBasis = CompetitionBasis._NAMES_TO_VALUES.get(snapdealPricing.competitionBasis)mpHistory.competitiveCategory = CompetitionCategory.COMPETITIVEmpHistory.risky = snapdealItemInfo.riskympHistory.lowestOfferPrice = snapdealDetails.lowestOfferPricempHistory.lowestSellingPrice = snapdealDetails.lowestSpmpHistory.lowestSellerName = snapdealDetails.lowestSellerNamempHistory.lowestSellerCode = snapdealDetails.lowestSellerCodempHistory.ourOfferPrice = snapdealDetails.ourOfferPricempHistory.ourSellingPrice = snapdealPricing.ourSpmpHistory.ourTp = snapdealPricing.ourTpmpHistory.ourNlc = snapdealItemInfo.nlcif (snapdealPricing.competitionBasis=='SP'):proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)proposed_tp = getTargetTp(proposed_sp,mpItem)mpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpelse:proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)proposed_sp = getTargetSp(proposed_tp,mpItem)mpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpmpHistory.totalSeller = snapdealDetails.totalSellermpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))mpHistory.timestamp = timestampsession.commit()def commitCompetitiveNoInventory(competitiveNoInventory,timestamp):for item in competitiveNoInventory:snapdealDetails = item[0]snapdealItemInfo = item[1]snapdealPricing = item[2]mpItem = item[3]mpHistory = MarketPlaceHistory()mpHistory.item_id = snapdealItemInfo.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.lowestTp = snapdealPricing.lowestTpmpHistory.lowestPossibleTp = snapdealPricing.lowestPossibleTpmpHistory.lowestPossibleSp = snapdealPricing.lowestPossibleSpmpHistory.ourInventory = snapdealDetails.ourInventorympHistory.otherInventory = snapdealDetails.otherInventorympHistory.ourRank = snapdealDetails.rankmpHistory.competitionBasis = CompetitionBasis._NAMES_TO_VALUES.get(snapdealPricing.competitionBasis)mpHistory.competitiveCategory = CompetitionCategory.COMPETITIVE_NO_INVENTORYmpHistory.risky = snapdealItemInfo.riskympHistory.lowestOfferPrice = snapdealDetails.lowestOfferPricempHistory.lowestSellingPrice = snapdealDetails.lowestSpmpHistory.lowestSellerName = snapdealDetails.lowestSellerNamempHistory.lowestSellerCode = snapdealDetails.lowestSellerCodempHistory.ourOfferPrice = snapdealDetails.ourOfferPricempHistory.ourSellingPrice = snapdealPricing.ourSpmpHistory.ourTp = snapdealPricing.ourTpmpHistory.ourNlc = snapdealItemInfo.nlcif (snapdealPricing.competitionBasis=='SP'):proposed_sp = max(snapdealDetails.lowestSp - max((10, snapdealDetails.lowestSp*0.001)), snapdealPricing.lowestPossibleSp)proposed_tp = getTargetTp(proposed_sp,mpItem)mpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpelse:proposed_tp = max(snapdealPricing.lowestTp - max((10, snapdealPricing.lowestTp*0.001)), snapdealPricing.lowestPossibleTp)proposed_sp = getTargetSp(proposed_tp,mpItem)mpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpmpHistory.totalSeller = snapdealDetails.totalSellermpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))mpHistory.timestamp = timestampsession.commit()def commitCantCompete(cantCompete,timestamp):for item in cantCompete:snapdealDetails = item[0]snapdealItemInfo = item[1]snapdealPricing = item[2]mpItem = item[3]mpHistory = MarketPlaceHistory()mpHistory.item_id = snapdealItemInfo.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.lowestTp = snapdealPricing.lowestTpmpHistory.lowestPossibleTp = snapdealPricing.lowestPossibleTpmpHistory.lowestPossibleSp = snapdealPricing.lowestPossibleSpmpHistory.ourInventory = snapdealDetails.ourInventorympHistory.otherInventory = snapdealDetails.otherInventorympHistory.ourRank = snapdealDetails.rankmpHistory.competitionBasis = CompetitionBasis._NAMES_TO_VALUES.get(snapdealPricing.competitionBasis)mpHistory.competitiveCategory = CompetitionCategory.CANT_COMPETEmpHistory.risky = snapdealItemInfo.riskympHistory.lowestOfferPrice = snapdealDetails.lowestOfferPricempHistory.lowestSellingPrice = snapdealDetails.lowestSpmpHistory.lowestSellerName = snapdealDetails.lowestSellerNamempHistory.lowestSellerCode = snapdealDetails.lowestSellerCodempHistory.ourOfferPrice = snapdealDetails.ourOfferPricempHistory.ourSellingPrice = snapdealPricing.ourSpmpHistory.ourTp = snapdealPricing.ourTpmpHistory.ourNlc = snapdealItemInfo.nlcif (snapdealPricing.competitionBasis=='SP'):proposed_sp = snapdealDetails.lowestSp - max(10, snapdealDetails.lowestSp*0.001)proposed_tp = getTargetTp(proposed_sp,mpItem)target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlcmpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpmpHistory.targetNlc = target_nlcelse:proposed_tp = snapdealPricing.lowestTp - max(10, snapdealPricing.lowestTp*0.001)proposed_sp = getTargetSp(proposed_tp,mpItem)target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlcmpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tpmpHistory.targetNlc = target_nlcmpHistory.totalSeller = snapdealDetails.totalSellermpHistory.salesPotential = SalesPotential._NAMES_TO_VALUES.get(getSalesPotential(snapdealDetails.lowestOfferPrice,snapdealItemInfo.nlc))mpHistory.timestamp = timestampsession.commit()def commitBuyBox(buyBoxItems,timestamp):for item in buyBoxItems:snapdealDetails = item[0]snapdealItemInfo = item[1]snapdealPricing = item[2]mpItem = item[3]mpHistory = MarketPlaceHistory()mpHistory.item_id = snapdealItemInfo.item_idmpHistory.source = OrderSource.SNAPDEALmpHistory.lowestPossibleTp = snapdealPricing.lowestPossibleTpmpHistory.lowestPossibleSp = snapdealPricing.lowestPossibleSpmpHistory.ourInventory = snapdealDetails.ourInventorympHistory.secondLowestInventory = snapdealDetails.secondLowestSellerInventorympHistory.ourRank = snapdealDetails.rankmpHistory.competitionBasis = CompetitionBasis._NAMES_TO_VALUES.get(snapdealPricing.competitionBasis)mpHistory.competitiveCategory = CompetitionCategory.BUY_BOXmpHistory.risky = snapdealItemInfo.riskympHistory.lowestOfferPrice = snapdealDetails.lowestOfferPricempHistory.lowestSellingPrice = snapdealDetails.lowestSpmpHistory.lowestSellerName = snapdealDetails.lowestSellerNamempHistory.lowestSellerCode = snapdealDetails.lowestSellerCodempHistory.ourOfferPrice = snapdealDetails.ourOfferPricempHistory.ourSellingPrice = snapdealPricing.ourSpmpHistory.ourTp = snapdealPricing.ourTpmpHistory.ourNlc = snapdealItemInfo.nlcmpHistory.secondLowestSellerName = snapdealDetails.secondLowestSellerNamempHistory.secondLowestSellerCode = snapdealDetails.secondLowestSellerCodempHistory.secondLowestSellingPrice = snapdealDetails.secondLowestSellerSpmpHistory.secondLowestOfferPrice = snapdealDetails.secondLowestOfferPricempHistory.secondLowestTp = snapdealPricing.secondLowestSellerTpif (snapdealPricing.competitionBasis=='SP'):proposed_sp = max(snapdealDetails.secondLowestSellerSp - max((20, snapdealDetails.secondLowestSellerSp*0.002)), snapdealPricing.lowestPossibleSp)proposed_tp = getTargetTp(proposed_sp,mpItem)#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlcmpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tp#mpHistory.targetNlc = target_nlcelse:proposed_tp = max(snapdealPricing.secondLowestSellerTp - max((20, snapdealPricing.secondLowestSellerTp*0.002)), snapdealPricing.lowestPossibleTp)proposed_sp = getTargetSp(proposed_tp,mpItem)#target_nlc = proposed_tp - snapdealPricing.lowestPossibleTp + snapdealItemInfo.nlcmpHistory.proposedSellingPrice = proposed_spmpHistory.proposedTp = proposed_tp#mpHistory.targetNlc = target_nlcmpHistory.marginIncreasedPotential = proposed_tp - snapdealPricing.ourTpmpHistory.totalSeller = snapdealDetails.totalSellermpHistory.timestamp = timestampsession.commit()def getOtherTp(snapdealDetails,val,spm):if val.parent_category==10011:commissionPercentage = spm.competitorCommissionAccessoryelse:commissionPercentage = spm.competitorCommissionOtherif snapdealDetails.rank==1:return snapdealDetails.secondLowestSellerSp- snapdealDetails.secondLowestSellerSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));return snapdealDetails.lowestSp- snapdealDetails.lowestSp*(commissionPercentage/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost+spm.closingFee)*(1+(spm.serviceTax/100));def getLowestPossibleTp(snapdealDetails,val,spm,mpItem):if snapdealDetails.rank==0:return mpItem.minimumPossibleTpvat = (snapdealDetails.ourSp/(1+(val.vatRate/100))-(val.nlc/(1+(val.vatRate/100))))*(val.vatRate/100);inHouseCost = 15+vat+(mpItem.returnProvision/100)*snapdealDetails.ourSp+mpItem.otherCost;lowest_possible_tp = val.nlc+inHouseCost;return lowest_possible_tpdef getOurTp(snapdealDetails,val,spm,mpItem):if snapdealDetails.rank==0:return mpItem.currentTpreturn snapdealDetails.ourSp- snapdealDetails.ourSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(val.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):if snapdealDetails.rank==0:return mpItem.minimumPossibleSpreturn (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));def getTargetTp(targetSp,mpItem):return targetSp- targetSp*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));def getTargetSp(targetTp,mpItem):return targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))def getSalesPotential(lowestOfferPrice,ourNlc):if lowestOfferPrice - ourNlc < 0:return 'HIGH'elif (lowestOfferPrice - ourNlc)/lowestOfferPrice >=0 and (lowestOfferPrice - ourNlc)/lowestOfferPrice <=.02:return 'MEDIUM'else:return 'LOW'def main():itemInfo,spm= populateStuff()cantCompete, buyBoxItems, competitive, \competitiveNoInventory, exceptionItems, negativeMargin = decideCategory(itemInfo,spm)timestamp = datetime.now()commitExceptionList(exceptionItems,timestamp)commitCantCompete(cantCompete,timestamp)commitBuyBox(buyBoxItems,timestamp)commitCompetitive(competitive,timestamp)commitCompetitiveNoInventory(competitiveNoInventory,timestamp)commitNegativeMargin(negativeMargin,timestamp)if __name__ == '__main__':main()