| Line 416... |
Line 416... |
| 416 |
continue
|
416 |
continue
|
| 417 |
cc = computeCourierCost(it.weight)
|
417 |
cc = computeCourierCost(it.weight)
|
| 418 |
|
418 |
|
| 419 |
amazonItemInfo = __AmazonItemInfo(None, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id,d_amazon_listed.otherCost)
|
419 |
amazonItemInfo = __AmazonItemInfo(None, wanlc,cc, sku, it.product_group, it.brand, it.model_name, it.model_number, it.color, it.weight, category.parent_category_id, it.risky, None, runType, parent_category.display_name,sourcePercentage,fbaInventoryItem.availability,state_id,d_amazon_listed.otherCost)
|
| 420 |
itemInfo.append(amazonItemInfo)
|
420 |
itemInfo.append(amazonItemInfo)
|
| - |
|
421 |
#amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
| - |
|
422 |
#.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 421 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
423 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.LONGTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 422 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
424 |
.order_by(desc(AmazonPromotion.addedOn)).all()
|
| 423 |
for amPromotion in amPromotions:
|
425 |
for amPromotion in amPromotions:
|
| 424 |
amazonLongTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
426 |
amazonLongTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
| - |
|
427 |
#amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
| - |
|
428 |
#.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
| 425 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
429 |
amPromotions = AmazonPromotion.query.filter(AmazonPromotion.startDate<=time).filter(AmazonPromotion.endDate>=time).filter(AmazonPromotion.promotionType==AmazonPromotionType.SHORTTERM).filter(AmazonPromotion.promotionActive==True) \
|
| 426 |
.group_by(AmazonPromotion.sku).order_by(desc(AmazonPromotion.addedOn)).all()
|
430 |
.order_by(desc(AmazonPromotion.addedOn)).all()
|
| 427 |
for amPromotion in amPromotions:
|
431 |
for amPromotion in amPromotions:
|
| 428 |
amazonShortTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
432 |
amazonShortTermActivePromotions[amPromotion.sku] = __Promotion(amPromotion.salePrice,amPromotion.subsidy,amPromotion.promotionType,amPromotion.endDate)
|
| 429 |
session.close()
|
433 |
session.close()
|
| 430 |
print "No of items populated ",len(itemInfo)
|
434 |
print "No of items populated ",len(itemInfo)
|
| 431 |
sleep(5)
|
435 |
sleep(5)
|
| Line 617... |
Line 621... |
| 617 |
cantCompete.append(temp)
|
621 |
cantCompete.append(temp)
|
| 618 |
print "Created category..."
|
622 |
print "Created category..."
|
| 619 |
|
623 |
|
| 620 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
624 |
return exceptionList, negativeMargin, cheapest, amongCheapestAndCanCompete, canCompete, almostCompete, cantCompete
|
| 621 |
|
625 |
|
| - |
|
626 |
def getBreakevenPrice(item,val,spm):
|
| - |
|
627 |
breakEvenPrice = (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15.0+val.otherCost)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
| - |
|
628 |
return round(breakEvenPrice,2)
|
| 622 |
|
629 |
|
| 623 |
def getLowestPossibleSp(amazonDetails,val,spm):
|
630 |
def getLowestPossibleSp(amazonDetails,val,spm):
|
| 624 |
lowestPossibleSp = (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15.0+val.otherCost)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
631 |
lowestPossibleSp = (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15.0+val.otherCost)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
| 625 |
if val.isPromo:
|
632 |
if val.isPromo:
|
| 626 |
if amazonLongTermActivePromotions.has_key(val.sku):
|
633 |
if amazonLongTermActivePromotions.has_key(val.sku):
|
| 627 |
subsidy = (amazonLongTermActivePromotions.get(val.sku)).subsidy
|
634 |
subsidy = (amazonLongTermActivePromotions.get(val.sku)).subsidy
|
| 628 |
else:
|
635 |
else:
|
| 629 |
subsidy = (amazonShortTermActivePromotions.get(val.sku)).subsidy
|
636 |
subsidy = (amazonShortTermActivePromotions.get(val.sku)).subsidy
|
| 630 |
lowestPossibleSp = lowestPossibleSp - subsidy
|
- |
|
| 631 |
print "subsidy ",subsidy
|
637 |
print "subsidy ",subsidy
|
| 632 |
print (val.nlc+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15+val.otherCost)*(1+(val.vatRate)/100))
|
638 |
lowestPossibleSp = (val.nlc-subsidy+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15.0+val.otherCost)*(1+(val.vatRate)/100))/(1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100));
|
| - |
|
639 |
|
| - |
|
640 |
#print (val.nlc-subsidy+(val.courierCost)*(1+(spm.serviceTax/100))*(1+(val.vatRate/100))+(15+val.otherCost)*(1+(val.vatRate)/100))
|
| 633 |
print (1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100))
|
641 |
#print (1-(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))*(1+(val.vatRate)/100)-(spm.returnProvision/100)*(1+(val.vatRate)/100))
|
| 634 |
return round(lowestPossibleSp,2)
|
642 |
return round(lowestPossibleSp,2)
|
| 635 |
|
643 |
|
| 636 |
def getNewLowestPossibleSp(item,serviceTax,newVatRate):
|
644 |
def getNewLowestPossibleSp(item,serviceTax,newVatRate):
|
| 637 |
lowestPossibleSp = (item.wanlc+(item.courierCost)*(1+(serviceTax/100))*(1+(newVatRate/100))+(15+item.otherCost)*(1+(newVatRate)/100))/(1-(item.commission/100)*(1+(serviceTax/100))*(1+(newVatRate)/100)-(item.returnProvision/100)*(1+(newVatRate)/100));
|
645 |
lowestPossibleSp = (item.wanlc+(item.courierCost)*(1+(serviceTax/100))*(1+(newVatRate/100))+(15+item.otherCost)*(1+(newVatRate)/100))/(1-(item.commission/100)*(1+(serviceTax/100))*(1+(newVatRate)/100)-(item.returnProvision/100)*(1+(newVatRate)/100));
|
| 638 |
if item.isPromotion:
|
646 |
if item.isPromotion:
|
| Line 643... |
Line 651... |
| 643 |
sku='FBB'+str(item.item_id)
|
651 |
sku='FBB'+str(item.item_id)
|
| 644 |
if amazonLongTermActivePromotions.has_key(sku):
|
652 |
if amazonLongTermActivePromotions.has_key(sku):
|
| 645 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
653 |
subsidy = (amazonLongTermActivePromotions.get(sku)).subsidy
|
| 646 |
else:
|
654 |
else:
|
| 647 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
655 |
subsidy = (amazonShortTermActivePromotions.get(sku)).subsidy
|
| - |
|
656 |
print "subsidy ",subsidy
|
| 648 |
lowestPossibleSp = lowestPossibleSp - subsidy
|
657 |
lowestPossibleSp = (item.wanlc-subsidy+(item.courierCost)*(1+(serviceTax/100))*(1+(newVatRate/100))+(15+item.otherCost)*(1+(newVatRate)/100))/(1-(item.commission/100)*(1+(serviceTax/100))*(1+(newVatRate)/100)-(item.returnProvision/100)*(1+(newVatRate)/100));
|
| 649 |
return round(lowestPossibleSp,2)
|
658 |
return round(lowestPossibleSp,2)
|
| 650 |
|
659 |
|
| 651 |
|
- |
|
| 652 |
def getTargetTp(targetSp,spm,val):
|
660 |
def getTargetTp(targetSp,spm,val):
|
| 653 |
targetTp = targetSp- targetSp*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))
|
661 |
targetTp = targetSp- targetSp*(spm.commission/100+spm.emiFee/100)*(1+(spm.serviceTax/100))-(val.courierCost)*(1+(spm.serviceTax/100))
|
| 654 |
return round(targetTp,2)
|
662 |
return round(targetTp,2)
|
| 655 |
|
663 |
|
| 656 |
def commitExceptionList(exceptionList,timestamp,runType):
|
664 |
def commitExceptionList(exceptionList,timestamp,runType):
|
| Line 1116... |
Line 1124... |
| 1116 |
#TODO : Get service tax from marketplaceitems table
|
1124 |
#TODO : Get service tax from marketplaceitems table
|
| 1117 |
return 12.36
|
1125 |
return 12.36
|
| 1118 |
|
1126 |
|
| 1119 |
def getClosingFee(data):
|
1127 |
def getClosingFee(data):
|
| 1120 |
myClosingFee = 0
|
1128 |
myClosingFee = 0
|
| 1121 |
return round(myClosingFee*(1+getServiceTax(data)/100))
|
1129 |
return myClosingFee*(1+getServiceTax(data)/100)
|
| 1122 |
|
1130 |
|
| 1123 |
def getCommission(data):
|
1131 |
def getCommission(data):
|
| 1124 |
return round((data.commission * data.promoPrice/100)*(1+getServiceTax(data)/100))
|
1132 |
return (data.commission * data.promoPrice/100)*(1+getServiceTax(data)/100)
|
| 1125 |
|
1133 |
|
| 1126 |
def getCourierCost(data):
|
1134 |
def getCourierCost(data):
|
| 1127 |
return round((data.courierCost)*(1+getServiceTax(data)/100))
|
1135 |
return data.courierCost*(1+getServiceTax(data)/100)
|
| - |
|
1136 |
|
| - |
|
1137 |
def getCostToAmazon(data):
|
| - |
|
1138 |
myCostToAmazon = round(data.promoPrice*data.commission/100*(1+getServiceTax(data)/100)+getCourierCost(data)*(1+getServiceTax(data)/100))
|
| - |
|
1139 |
return myCostToAmazon
|
| 1128 |
|
1140 |
|
| 1129 |
def getMargin(amScraping):
|
1141 |
def getMargin(amScraping):
|
| 1130 |
#sheet.write(sheet_iterator, 30, round(amScraping.promoPrice - amScraping.lowestPossibleSp))
|
1142 |
#sheet.write(sheet_iterator, 30, round(amScraping.promoPrice - amScraping.lowestPossibleSp))
|
| 1131 |
#Promo Price minus costs plus subsidy
|
1143 |
#Promo Price minus costs plus subsidy
|
| 1132 |
#costs = WANLC (actual or overrrde whichever is applicable) + Courier cost + Closing fee + Commission + Packaging + VAT + Returns Cost + other cost.
|
1144 |
#costs = WANLC (actual or overrrde whichever is applicable) + Courier cost + Closing fee + Commission + Packaging + VAT + Returns Cost + other cost.
|
| - |
|
1145 |
'''
|
| 1133 |
if(amScraping.ourSellingPrice >= amScraping.promoPrice):
|
1146 |
if(amScraping.ourSellingPrice >= amScraping.promoPrice):
|
| 1134 |
mySubsidy = amScraping.subsidy
|
1147 |
mySubsidy = amScraping.subsidy
|
| 1135 |
else:
|
1148 |
else:
|
| 1136 |
mySubsidy = 0
|
1149 |
mySubsidy = 0
|
| - |
|
1150 |
'''
|
| 1137 |
print 'promo price ',amScraping.promoPrice
|
1151 |
print 'promo price ',amScraping.promoPrice
|
| 1138 |
print 'mySubsidy ',mySubsidy
|
1152 |
#print 'mySubsidy ',mySubsidy
|
| 1139 |
print 'wanlc ',amScraping.wanlc
|
1153 |
print 'wanlc ',amScraping.wanlc
|
| 1140 |
print 'courier cost ',getCourierCost(amScraping)
|
1154 |
print 'courier cost ',getCourierCost(amScraping)
|
| 1141 |
print 'closing fee ',getClosingFee(amScraping)
|
1155 |
print 'closing fee ',getClosingFee(amScraping)
|
| 1142 |
print 'commission ',getCommission(amScraping)
|
1156 |
print 'commission ',getCommission(amScraping)
|
| 1143 |
print 'packaging ',getPackagingCost(amScraping)
|
1157 |
print 'packaging ',getPackagingCost(amScraping)
|
| 1144 |
print 'vat ',getVat(amScraping)
|
1158 |
print 'vat ',getVat(amScraping)
|
| 1145 |
print 'return cost ',getReturnCost(amScraping)
|
1159 |
print 'return cost ',getReturnCost(amScraping)
|
| 1146 |
print 'other cost ',amScraping.otherCost
|
1160 |
print 'other cost ',amScraping.otherCost
|
| - |
|
1161 |
print 'cost to amazon ',getCostToAmazon(amScraping)
|
| 1147 |
myCosts = amScraping.wanlc + getCourierCost(amScraping) + getClosingFee(amScraping) + getCommission(amScraping) + getPackagingCost(amScraping) + getVat(amScraping) + getReturnCost(amScraping) + amScraping.otherCost
|
1162 |
myCosts = amScraping.wanlc + getCourierCost(amScraping) + getClosingFee(amScraping) + getCommission(amScraping) + getPackagingCost(amScraping) + getVat(amScraping) + getReturnCost(amScraping) + amScraping.otherCost
|
| 1148 |
margin = amScraping.promoPrice - myCosts + mySubsidy
|
1163 |
margin = amScraping.promoPrice - myCosts + amScraping.subsidy
|
| - |
|
1164 |
print 'margin for ',amScraping.item_id,' is ',margin
|
| 1149 |
return round(margin)
|
1165 |
return round(margin)
|
| 1150 |
|
1166 |
|
| 1151 |
def getVat(data):
|
1167 |
def getVat(data):
|
| 1152 |
#VAT amount = Promo Price/(1+Vat Rate)*VAT Rate minus NLC/(1+VAT Rate)*VAT Rate
|
1168 |
#VAT amount = Promo Price/(1+Vat Rate)*VAT Rate minus NLC/(1+VAT Rate)*VAT Rate
|
| 1153 |
myVatPercentage = data.vatRate/100
|
1169 |
myVatPercentage = data.vatRate/100
|
| Line 1211... |
Line 1227... |
| 1211 |
sheet_iterator = 1
|
1227 |
sheet_iterator = 1
|
| 1212 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1228 |
cantCompeteItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| 1213 |
for cantCompeteItem in cantCompeteItems:
|
1229 |
for cantCompeteItem in cantCompeteItems:
|
| 1214 |
amScraping = cantCompeteItem[0]
|
1230 |
amScraping = cantCompeteItem[0]
|
| 1215 |
item = cantCompeteItem[1]
|
1231 |
item = cantCompeteItem[1]
|
| 1216 |
print item
|
1232 |
print "Item = ",item
|
| 1217 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
1233 |
sheet.write(sheet_iterator, 0, amScraping.item_id)
|
| 1218 |
if amScraping.warehouseLocation == 1:
|
1234 |
if amScraping.warehouseLocation == 1:
|
| 1219 |
sku = 'FBA'+str(amScraping.item_id)
|
1235 |
sku = 'FBA'+str(amScraping.item_id)
|
| 1220 |
loc = 'MUMBAI'
|
1236 |
loc = 'MUMBAI'
|
| 1221 |
else:
|
1237 |
else:
|
| Line 1271... |
Line 1287... |
| 1271 |
excel_integer_format = '0'
|
1287 |
excel_integer_format = '0'
|
| 1272 |
integer_style = xlwt.XFStyle()
|
1288 |
integer_style = xlwt.XFStyle()
|
| 1273 |
integer_style.num_format_str = excel_integer_format
|
1289 |
integer_style.num_format_str = excel_integer_format
|
| 1274 |
|
1290 |
|
| 1275 |
writeheaders(sheet,heading_xf)
|
1291 |
writeheaders(sheet,heading_xf)
|
| 1276 |
'''
|
- |
|
| 1277 |
sheet.write(0, 0, "Item Id", heading_xf)
|
- |
|
| 1278 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
- |
|
| 1279 |
sheet.write(0, 2, "Asin", heading_xf)
|
- |
|
| 1280 |
sheet.write(0, 3, "Location", heading_xf)
|
- |
|
| 1281 |
sheet.write(0, 4, "Brand", heading_xf)
|
- |
|
| 1282 |
sheet.write(0, 5, "Product Name", heading_xf)
|
- |
|
| 1283 |
sheet.write(0, 6, "Weight", heading_xf)
|
- |
|
| 1284 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
- |
|
| 1285 |
sheet.write(0, 8, "Our SP", heading_xf)
|
- |
|
| 1286 |
sheet.write(0, 9, "Promo Price", heading_xf)
|
- |
|
| 1287 |
sheet.write(0, 10, "Is Promotion", heading_xf)
|
- |
|
| 1288 |
sheet.write(0, 11, "Lowest Possible SP", heading_xf)
|
- |
|
| 1289 |
sheet.write(0, 12, "Rank", heading_xf)
|
- |
|
| 1290 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
- |
|
| 1291 |
sheet.write(0, 14, "Lowest Seller SP", heading_xf)
|
- |
|
| 1292 |
sheet.write(0, 15, "Lowest Seller Rating", heading_xf)
|
- |
|
| 1293 |
sheet.write(0, 16, "Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1294 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
- |
|
| 1295 |
sheet.write(0, 18, "Second Lowest Seller Rating", heading_xf)
|
- |
|
| 1296 |
sheet.write(0, 19, "Second Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1297 |
sheet.write(0, 20, "Third Lowest Seller SP", heading_xf)
|
- |
|
| 1298 |
sheet.write(0, 21, "Third Lowest Seller Rating", heading_xf)
|
- |
|
| 1299 |
sheet.write(0, 22, "Third Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1300 |
sheet.write(0, 23, "Other Cost", heading_xf)
|
- |
|
| 1301 |
sheet.write(0, 24, "WANLC", heading_xf)
|
- |
|
| 1302 |
sheet.write(0, 25, "Commission", heading_xf)
|
- |
|
| 1303 |
sheet.write(0, 26, "Competitor Commission", heading_xf)
|
- |
|
| 1304 |
sheet.write(0, 27, "Return Provision", heading_xf)
|
- |
|
| 1305 |
sheet.write(0, 28, "Vat Rate", heading_xf)
|
- |
|
| 1306 |
sheet.write(0, 29, "Margin", heading_xf)
|
- |
|
| 1307 |
sheet.write(0, 30, "Risky", heading_xf)
|
- |
|
| 1308 |
sheet.write(0, 31, "Proposed Sp", heading_xf)
|
- |
|
| 1309 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
- |
|
| 1310 |
sheet.write(0, 33, "Sales History", heading_xf)
|
- |
|
| 1311 |
'''
|
- |
|
| 1312 |
sheet.write(0, 36, "Decision", heading_xf)
|
1292 |
sheet.write(0, 36, "Decision", heading_xf)
|
| 1313 |
sheet.write(0, 37, "Reason", heading_xf)
|
1293 |
sheet.write(0, 37, "Reason", heading_xf)
|
| 1314 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
1294 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
| 1315 |
|
1295 |
|
| 1316 |
sheet_iterator = 1
|
1296 |
sheet_iterator = 1
|
| Line 1384... |
Line 1364... |
| 1384 |
|
1364 |
|
| 1385 |
excel_integer_format = '0'
|
1365 |
excel_integer_format = '0'
|
| 1386 |
integer_style = xlwt.XFStyle()
|
1366 |
integer_style = xlwt.XFStyle()
|
| 1387 |
integer_style.num_format_str = excel_integer_format
|
1367 |
integer_style.num_format_str = excel_integer_format
|
| 1388 |
writeheaders(sheet,heading_xf)
|
1368 |
writeheaders(sheet,heading_xf)
|
| 1389 |
'''
|
- |
|
| 1390 |
sheet.write(0, 0, "Item Id", heading_xf)
|
- |
|
| 1391 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
- |
|
| 1392 |
sheet.write(0, 2, "Asin", heading_xf)
|
- |
|
| 1393 |
sheet.write(0, 3, "Location", heading_xf)
|
- |
|
| 1394 |
sheet.write(0, 4, "Brand", heading_xf)
|
- |
|
| 1395 |
sheet.write(0, 5, "Product Name", heading_xf)
|
- |
|
| 1396 |
sheet.write(0, 6, "Weight", heading_xf)
|
- |
|
| 1397 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
- |
|
| 1398 |
sheet.write(0, 8, "Our SP", heading_xf)
|
- |
|
| 1399 |
sheet.write(0, 9, "Promo Price", heading_xf)
|
- |
|
| 1400 |
sheet.write(0, 10, "Is Promotion", heading_xf)
|
- |
|
| 1401 |
sheet.write(0, 11, "Lowest Possible SP", heading_xf)
|
- |
|
| 1402 |
sheet.write(0, 12, "Rank", heading_xf)
|
- |
|
| 1403 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
- |
|
| 1404 |
sheet.write(0, 14, "Lowest Seller SP", heading_xf)
|
- |
|
| 1405 |
sheet.write(0, 15, "Lowest Seller Rating", heading_xf)
|
- |
|
| 1406 |
sheet.write(0, 16, "Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1407 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
- |
|
| 1408 |
sheet.write(0, 18, "Second Lowest Seller Rating", heading_xf)
|
- |
|
| 1409 |
sheet.write(0, 19, "Second Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1410 |
sheet.write(0, 20, "Third Lowest Seller SP", heading_xf)
|
- |
|
| 1411 |
sheet.write(0, 21, "Third Lowest Seller Rating", heading_xf)
|
- |
|
| 1412 |
sheet.write(0, 22, "Third Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1413 |
sheet.write(0, 23, "Other Cost", heading_xf)
|
- |
|
| 1414 |
sheet.write(0, 24, "WANLC", heading_xf)
|
- |
|
| 1415 |
sheet.write(0, 25, "Commission", heading_xf)
|
- |
|
| 1416 |
sheet.write(0, 26, "Competitor Commission", heading_xf)
|
- |
|
| 1417 |
sheet.write(0, 27, "Return Provision", heading_xf)
|
- |
|
| 1418 |
sheet.write(0, 28, "Vat Rate", heading_xf)
|
- |
|
| 1419 |
sheet.write(0, 29, "Margin", heading_xf)
|
- |
|
| 1420 |
sheet.write(0, 30, "Risky", heading_xf)
|
- |
|
| 1421 |
sheet.write(0, 31, "Proposed Sp", heading_xf)
|
- |
|
| 1422 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
- |
|
| 1423 |
sheet.write(0, 33, "Sales History", heading_xf)
|
- |
|
| 1424 |
'''
|
- |
|
| 1425 |
sheet.write(0, 36, "Decision", heading_xf)
|
1369 |
sheet.write(0, 36, "Decision", heading_xf)
|
| 1426 |
sheet.write(0, 37, "Reason", heading_xf)
|
1370 |
sheet.write(0, 37, "Reason", heading_xf)
|
| 1427 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
1371 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
| 1428 |
sheet_iterator = 1
|
1372 |
sheet_iterator = 1
|
| 1429 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1373 |
almostCompetitiveItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.ALMOST_COMPETE).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| Line 1435... |
Line 1379... |
| 1435 |
sku = 'FBA'+str(amScraping.item_id)
|
1379 |
sku = 'FBA'+str(amScraping.item_id)
|
| 1436 |
loc = 'MUMBAI'
|
1380 |
loc = 'MUMBAI'
|
| 1437 |
else:
|
1381 |
else:
|
| 1438 |
sku = 'FBB'+str(amScraping.item_id)
|
1382 |
sku = 'FBB'+str(amScraping.item_id)
|
| 1439 |
loc = 'BANGLORE'
|
1383 |
loc = 'BANGLORE'
|
| 1440 |
'''
|
- |
|
| 1441 |
amScraping = competitiveItem[0]
|
- |
|
| 1442 |
item = competitiveItem[1]
|
- |
|
| 1443 |
if amScraping.warehouseLocation == 1:
|
- |
|
| 1444 |
sku = 'FBA'+str(amScraping.item_id)
|
- |
|
| 1445 |
loc = 'MUMBAI'
|
- |
|
| 1446 |
else:
|
- |
|
| 1447 |
sku = 'FBB'+str(amScraping.item_id)
|
- |
|
| 1448 |
loc = 'BANGLORE'
|
- |
|
| 1449 |
'''
|
- |
|
| 1450 |
sheet.write(sheet_iterator, 1, sku)
|
1384 |
sheet.write(sheet_iterator, 1, sku)
|
| 1451 |
sheet.write(sheet_iterator, 2, amScraping.asin)
|
1385 |
sheet.write(sheet_iterator, 2, amScraping.asin)
|
| 1452 |
sheet.write(sheet_iterator, 3, loc)
|
1386 |
sheet.write(sheet_iterator, 3, loc)
|
| 1453 |
sheet.write(sheet_iterator, 4, item.brand)
|
1387 |
sheet.write(sheet_iterator, 4, item.brand)
|
| 1454 |
sheet.write(sheet_iterator, 5, getCategory(item))
|
1388 |
sheet.write(sheet_iterator, 5, getCategory(item))
|
| Line 1506... |
Line 1440... |
| 1506 |
|
1440 |
|
| 1507 |
excel_integer_format = '0'
|
1441 |
excel_integer_format = '0'
|
| 1508 |
integer_style = xlwt.XFStyle()
|
1442 |
integer_style = xlwt.XFStyle()
|
| 1509 |
integer_style.num_format_str = excel_integer_format
|
1443 |
integer_style.num_format_str = excel_integer_format
|
| 1510 |
writeheaders(sheet,heading_xf)
|
1444 |
writeheaders(sheet,heading_xf)
|
| 1511 |
'''
|
- |
|
| 1512 |
sheet.write(0, 0, "Item Id", heading_xf)
|
- |
|
| 1513 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
- |
|
| 1514 |
sheet.write(0, 2, "Asin", heading_xf)
|
- |
|
| 1515 |
sheet.write(0, 3, "Location", heading_xf)
|
- |
|
| 1516 |
sheet.write(0, 4, "Brand", heading_xf)
|
- |
|
| 1517 |
sheet.write(0, 5, "Product Name", heading_xf)
|
- |
|
| 1518 |
sheet.write(0, 6, "Weight", heading_xf)
|
- |
|
| 1519 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
- |
|
| 1520 |
sheet.write(0, 8, "Our SP", heading_xf)
|
- |
|
| 1521 |
sheet.write(0, 9, "Promo Price", heading_xf)
|
- |
|
| 1522 |
sheet.write(0, 10, "Is Promotion", heading_xf)
|
- |
|
| 1523 |
sheet.write(0, 11, "Lowest Possible SP", heading_xf)
|
- |
|
| 1524 |
sheet.write(0, 12, "Rank", heading_xf)
|
- |
|
| 1525 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
- |
|
| 1526 |
sheet.write(0, 14, "Lowest Seller SP", heading_xf)
|
- |
|
| 1527 |
sheet.write(0, 15, "Lowest Seller Rating", heading_xf)
|
- |
|
| 1528 |
sheet.write(0, 16, "Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1529 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
- |
|
| 1530 |
sheet.write(0, 18, "Second Lowest Seller Rating", heading_xf)
|
- |
|
| 1531 |
sheet.write(0, 19, "Second Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1532 |
sheet.write(0, 20, "Third Lowest Seller SP", heading_xf)
|
- |
|
| 1533 |
sheet.write(0, 21, "Third Lowest Seller Rating", heading_xf)
|
- |
|
| 1534 |
sheet.write(0, 22, "Third Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1535 |
sheet.write(0, 23, "Other Cost", heading_xf)
|
- |
|
| 1536 |
sheet.write(0, 24, "WANLC", heading_xf)
|
- |
|
| 1537 |
sheet.write(0, 25, "Commission", heading_xf)
|
- |
|
| 1538 |
sheet.write(0, 26, "Competitor Commission", heading_xf)
|
- |
|
| 1539 |
sheet.write(0, 27, "Return Provision", heading_xf)
|
- |
|
| 1540 |
sheet.write(0, 28, "Vat Rate", heading_xf)
|
- |
|
| 1541 |
sheet.write(0, 29, "Margin", heading_xf)
|
- |
|
| 1542 |
sheet.write(0, 30, "Risky", heading_xf)
|
- |
|
| 1543 |
sheet.write(0, 31, "Proposed Sp", heading_xf)
|
- |
|
| 1544 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
- |
|
| 1545 |
sheet.write(0, 33, "Sales History", heading_xf)
|
- |
|
| 1546 |
'''
|
- |
|
| 1547 |
sheet.write(0, 36, "Decision", heading_xf)
|
1445 |
sheet.write(0, 36, "Decision", heading_xf)
|
| 1548 |
sheet.write(0, 37, "Reason", heading_xf)
|
1446 |
sheet.write(0, 37, "Reason", heading_xf)
|
| 1549 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
1447 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
| 1550 |
sheet_iterator = 1
|
1448 |
sheet_iterator = 1
|
| 1551 |
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()
|
1449 |
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()
|
| Line 1618... |
Line 1516... |
| 1618 |
|
1516 |
|
| 1619 |
excel_integer_format = '0'
|
1517 |
excel_integer_format = '0'
|
| 1620 |
integer_style = xlwt.XFStyle()
|
1518 |
integer_style = xlwt.XFStyle()
|
| 1621 |
integer_style.num_format_str = excel_integer_format
|
1519 |
integer_style.num_format_str = excel_integer_format
|
| 1622 |
writeheaders(sheet,heading_xf)
|
1520 |
writeheaders(sheet,heading_xf)
|
| 1623 |
'''
|
- |
|
| 1624 |
sheet.write(0, 0, "Item Id", heading_xf)
|
- |
|
| 1625 |
sheet.write(0, 1, "Amazon Sku", heading_xf)
|
- |
|
| 1626 |
sheet.write(0, 2, "Asin", heading_xf)
|
- |
|
| 1627 |
sheet.write(0, 3, "Location", heading_xf)
|
- |
|
| 1628 |
sheet.write(0, 4, "Brand", heading_xf)
|
- |
|
| 1629 |
sheet.write(0, 5, "Product Name", heading_xf)
|
- |
|
| 1630 |
sheet.write(0, 6, "Weight", heading_xf)
|
- |
|
| 1631 |
sheet.write(0, 7, "Courier Cost", heading_xf)
|
- |
|
| 1632 |
sheet.write(0, 8, "Our SP", heading_xf)
|
- |
|
| 1633 |
sheet.write(0, 9, "Promo Price", heading_xf)
|
- |
|
| 1634 |
sheet.write(0, 10, "Is Promotion", heading_xf)
|
- |
|
| 1635 |
sheet.write(0, 11, "Lowest Possible SP", heading_xf)
|
- |
|
| 1636 |
sheet.write(0, 12, "Rank", heading_xf)
|
- |
|
| 1637 |
sheet.write(0, 13, "Our Inventory", heading_xf)
|
- |
|
| 1638 |
sheet.write(0, 14, "Lowest Seller SP", heading_xf)
|
- |
|
| 1639 |
sheet.write(0, 15, "Lowest Seller Rating", heading_xf)
|
- |
|
| 1640 |
sheet.write(0, 16, "Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1641 |
sheet.write(0, 17, "Second Lowest Seller SP", heading_xf)
|
- |
|
| 1642 |
sheet.write(0, 18, "Second Lowest Seller Rating", heading_xf)
|
- |
|
| 1643 |
sheet.write(0, 19, "Second Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1644 |
sheet.write(0, 20, "Third Lowest Seller SP", heading_xf)
|
- |
|
| 1645 |
sheet.write(0, 21, "Third Lowest Seller Rating", heading_xf)
|
- |
|
| 1646 |
sheet.write(0, 22, "Third Lowest Seller Shipping Time", heading_xf)
|
- |
|
| 1647 |
sheet.write(0, 23, "Other Cost", heading_xf)
|
- |
|
| 1648 |
sheet.write(0, 24, "WANLC", heading_xf)
|
- |
|
| 1649 |
sheet.write(0, 25, "Commission", heading_xf)
|
- |
|
| 1650 |
sheet.write(0, 26, "Competitor Commission", heading_xf)
|
- |
|
| 1651 |
sheet.write(0, 27, "Return Provision", heading_xf)
|
- |
|
| 1652 |
sheet.write(0, 28, "Vat Rate", heading_xf)
|
- |
|
| 1653 |
sheet.write(0, 29, "Margin", heading_xf)
|
- |
|
| 1654 |
sheet.write(0, 30, "Risky", heading_xf)
|
- |
|
| 1655 |
sheet.write(0, 31, "Proposed Sp", heading_xf)
|
- |
|
| 1656 |
sheet.write(0, 32, "Avg Sale", heading_xf)
|
- |
|
| 1657 |
sheet.write(0, 33, "Sales History", heading_xf)
|
- |
|
| 1658 |
'''
|
- |
|
| 1659 |
sheet.write(0, 36, "Decision", heading_xf)
|
1521 |
sheet.write(0, 36, "Decision", heading_xf)
|
| 1660 |
sheet.write(0, 37, "Reason", heading_xf)
|
1522 |
sheet.write(0, 37, "Reason", heading_xf)
|
| 1661 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
1523 |
sheet.write(0, 38, "Updated Price", heading_xf)
|
| 1662 |
sheet_iterator = 1
|
1524 |
sheet_iterator = 1
|
| 1663 |
cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
1525 |
cheapestItems = session.query(AmazonScrapingHistory,Item).join((Item,AmazonScrapingHistory.item_id==Item.id)).filter(AmazonScrapingHistory.competitiveCategory==CompetitionCategory.BUY_BOX).filter(AmazonScrapingHistory.timestamp==timestamp).all()
|
| Line 1703... |
Line 1565... |
| 1703 |
sheet.write(sheet_iterator, 24, amScraping.otherCost)
|
1565 |
sheet.write(sheet_iterator, 24, amScraping.otherCost)
|
| 1704 |
sheet.write(sheet_iterator, 25, amScraping.wanlc)
|
1566 |
sheet.write(sheet_iterator, 25, amScraping.wanlc)
|
| 1705 |
sheet.write(sheet_iterator, 26, amScraping.subsidy)
|
1567 |
sheet.write(sheet_iterator, 26, amScraping.subsidy)
|
| 1706 |
sheet.write(sheet_iterator, 27, amScraping.commission)
|
1568 |
sheet.write(sheet_iterator, 27, amScraping.commission)
|
| 1707 |
sheet.write(sheet_iterator, 28, amScraping.competitorCommission)
|
1569 |
sheet.write(sheet_iterator, 28, amScraping.competitorCommission)
|
| 1708 |
sheet.write(sheet_iterator, 29, amScraping.vatRate)
|
1570 |
sheet.write(sheet_iterator, 29, amScraping.returnProvision)
|
| 1709 |
sheet.write(sheet_iterator, 30, amScraping.returnProvision)
|
1571 |
sheet.write(sheet_iterator, 30, amScraping.vatRate)
|
| 1710 |
sheet.write(sheet_iterator, 31, getMargin(amScraping))
|
1572 |
sheet.write(sheet_iterator, 31, getMargin(amScraping))
|
| 1711 |
sheet.write(sheet_iterator, 32, item.risky)
|
1573 |
sheet.write(sheet_iterator, 32, item.risky)
|
| 1712 |
sheet.write(sheet_iterator, 33, amScraping.proposedSp)
|
1574 |
sheet.write(sheet_iterator, 33, amScraping.proposedSp)
|
| 1713 |
sheet.write(sheet_iterator, 34, amScraping.avgSale)
|
1575 |
sheet.write(sheet_iterator, 34, amScraping.avgSale)
|
| 1714 |
sheet.write(sheet_iterator, 35, getOosString(saleMap.get(sku)))
|
1576 |
sheet.write(sheet_iterator, 35, getOosString(saleMap.get(sku)))
|
| Line 1895... |
Line 1757... |
| 1895 |
|
1757 |
|
| 1896 |
filename = "/tmp/amazon-report-"+runType+" " + str(timestamp) + ".xls"
|
1758 |
filename = "/tmp/amazon-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1897 |
wbk.save(filename)
|
1759 |
wbk.save(filename)
|
| 1898 |
try:
|
1760 |
try:
|
| 1899 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["anikendra.das@saholic.com"], " Amazon Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
1761 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["anikendra.das@saholic.com"], " Amazon Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
| 1900 |
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"], " Amazon Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","anikendra.das@saholic.com","vikram.raghav@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
|
1762 |
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"], " Amazon Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","anikendra.das@saholic.com","amit.gupta@saholic.com","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
|
| 1901 |
except Exception as e:
|
1763 |
except Exception as e:
|
| 1902 |
print e
|
1764 |
print e
|
| 1903 |
print "Unable to send report.Trying with local SMTP"
|
1765 |
print "Unable to send report.Trying with local SMTP"
|
| 1904 |
smtpServer = smtplib.SMTP('localhost')
|
1766 |
smtpServer = smtplib.SMTP('localhost')
|
| 1905 |
smtpServer.set_debuglevel(1)
|
1767 |
smtpServer.set_debuglevel(1)
|
| 1906 |
sender = 'build@shop2020.in'
|
1768 |
sender = 'build@shop2020.in'
|
| 1907 |
#recipients = ["anikendra.das@saholic.com"]
|
1769 |
#recipients = ["anikendra.das@saholic.com"]
|
| 1908 |
msg = MIMEMultipart()
|
1770 |
msg = MIMEMultipart()
|
| 1909 |
msg['Subject'] = "Amazon Auto Pricing" + ' '+runType+' - ' + str(datetime.now())
|
1771 |
msg['Subject'] = "Amazon Auto Pricing" + ' '+runType+' - ' + str(datetime.now())
|
| 1910 |
msg['From'] = sender
|
1772 |
msg['From'] = sender
|
| 1911 |
recipients = ['rajneesh.arora@saholic.com','anikendra.das@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']
|
1773 |
recipients = ['rajneesh.arora@saholic.com','anikendra.das@saholic.com','amit.gupta@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']
|
| 1912 |
msg['To'] = ",".join(recipients)
|
1774 |
msg['To'] = ",".join(recipients)
|
| 1913 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
1775 |
fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
|
| 1914 |
fileMsg.set_payload(file(filename).read())
|
1776 |
fileMsg.set_payload(file(filename).read())
|
| 1915 |
email.encoders.encode_base64(fileMsg)
|
1777 |
email.encoders.encode_base64(fileMsg)
|
| 1916 |
fileMsg.add_header('Content-Disposition','attachment;filename=amazon-auto-pricing.xls')
|
1778 |
fileMsg.add_header('Content-Disposition','attachment;filename=amazon-auto-pricing.xls')
|
| Line 1964... |
Line 1826... |
| 1964 |
</tr></thead>
|
1826 |
</tr></thead>
|
| 1965 |
<tbody>"""
|
1827 |
<tbody>"""
|
| 1966 |
for item in successfulAutoDecrease:
|
1828 |
for item in successfulAutoDecrease:
|
| 1967 |
it = Item.query.filter_by(id=item.item_id).one()
|
1829 |
it = Item.query.filter_by(id=item.item_id).one()
|
| 1968 |
vatRate = getNewVatRate(item.item_id,item.warehouseLocation,item.proposedSp)
|
1830 |
vatRate = getNewVatRate(item.item_id,item.warehouseLocation,item.proposedSp)
|
| 1969 |
oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
1831 |
#oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
| - |
|
1832 |
oldMargin = item.promoPrice - item.lowestPossibleSp
|
| 1970 |
newMargin = round(item.proposedSp - getNewLowestPossibleSp(item,12.36,vatRate))
|
1833 |
newMargin = round(item.proposedSp - getNewLowestPossibleSp(item,12.36,vatRate))
|
| 1971 |
sku = ''
|
1834 |
sku = ''
|
| 1972 |
if item.warehouseLocation==1:
|
1835 |
if item.warehouseLocation==1:
|
| 1973 |
sku='FBA'+str(item.item_id)
|
1836 |
sku='FBA'+str(item.item_id)
|
| 1974 |
else:
|
1837 |
else:
|
| Line 1981... |
Line 1844... |
| 1981 |
subsidy = 0
|
1844 |
subsidy = 0
|
| 1982 |
message+="""<tr>
|
1845 |
message+="""<tr>
|
| 1983 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
1846 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| 1984 |
<td style="text-align:center">"""+sku+"""</td>
|
1847 |
<td style="text-align:center">"""+sku+"""</td>
|
| 1985 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
1848 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| 1986 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
1849 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
| 1987 |
<td style="text-align:center">"""+str(math.ceil(item.proposedSp))+"""</td>
|
1850 |
<td style="text-align:center">"""+str(math.ceil(item.proposedSp))+"""</td>
|
| 1988 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
1851 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
| 1989 |
<td style="text-align:center">"""+str(round(oldMargin))+" ("+str(round((oldMargin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
1852 |
<td style="text-align:center">"""+str(round(oldMargin))+" ("+str(round((oldMargin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| 1990 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSp)*100,1))+"%)"+"""</td>
|
1853 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSp)*100,1))+"%)"+"""</td>
|
| 1991 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
1854 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
| Line 2012... |
Line 1875... |
| 2012 |
</tr></thead>
|
1875 |
</tr></thead>
|
| 2013 |
<tbody>"""
|
1876 |
<tbody>"""
|
| 2014 |
for item in successfulAutoIncrease:
|
1877 |
for item in successfulAutoIncrease:
|
| 2015 |
it = Item.query.filter_by(id=item.item_id).one()
|
1878 |
it = Item.query.filter_by(id=item.item_id).one()
|
| 2016 |
vatRate = getNewVatRate(item.item_id,item.warehouseLocation,math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
1879 |
vatRate = getNewVatRate(item.item_id,item.warehouseLocation,math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| 2017 |
oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
1880 |
#oldMargin = item.ourSellingPrice - item.lowestPossibleSp
|
| - |
|
1881 |
oldMargin = item.promoPrice - item.lowestPossibleSp
|
| 2018 |
newMargin = round(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)) - getNewLowestPossibleSp(item,12.36,vatRate))
|
1882 |
newMargin = round(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)) - getNewLowestPossibleSp(item,12.36,vatRate))
|
| 2019 |
sku = ''
|
1883 |
sku = ''
|
| 2020 |
if item.warehouseLocation==1:
|
1884 |
if item.warehouseLocation==1:
|
| 2021 |
sku='FBA'+str(item.item_id)
|
1885 |
sku='FBA'+str(item.item_id)
|
| 2022 |
else:
|
1886 |
else:
|
| Line 2029... |
Line 1893... |
| 2029 |
subsidy = 0
|
1893 |
subsidy = 0
|
| 2030 |
message+="""<tr>
|
1894 |
message+="""<tr>
|
| 2031 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
1895 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| 2032 |
<td style="text-align:center">"""+sku+"""</td>
|
1896 |
<td style="text-align:center">"""+sku+"""</td>
|
| 2033 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
1897 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| 2034 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
1898 |
<td style="text-align:center">"""+str(item.promoPrice)+"""</td>
|
| 2035 |
<td style="text-align:center">"""+str(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))+"""</td>
|
1899 |
<td style="text-align:center">"""+str(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))+"""</td>
|
| 2036 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
1900 |
<td style="text-align:center">"""+str(round(subsidy))+"""</td>
|
| 2037 |
<td style="text-align:center">"""+str(round((oldMargin),1))+" ("+str(round((oldMargin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
1901 |
<td style="text-align:center">"""+str(round((oldMargin),1))+" ("+str(round((oldMargin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| 2038 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))*100,1))+"%)"+"""</td>
|
1902 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))*100,1))+"%)"+"""</td>
|
| 2039 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|
1903 |
<td style="text-align:center">"""+str(item.commission)+" %"+"""</td>
|