| Line 1... |
Line 1... |
| 1 |
from elixir import *
|
1 |
from elixir import *
|
| 2 |
from sqlalchemy.sql import or_ ,func
|
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
|
6 |
Category, SourcePercentageMaster, MarketPlaceHistory, SnapdealItemUpdateHistory, MarketPlaceItemPrice
|
| 7 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
7 |
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
|
| 8 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
8 |
from shop2020.thriftpy.model.v1.catalog.ttypes import CompetitionCategory, CompetitionBasis, SalesPotential,\
|
| 9 |
Decision, RunType
|
9 |
Decision, RunType
|
| 10 |
from shop2020.clients.CatalogClient import CatalogClient
|
10 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 11 |
from shop2020.clients.InventoryClient import InventoryClient
|
11 |
from shop2020.clients.InventoryClient import InventoryClient
|
| Line 191... |
Line 191... |
| 191 |
markReasonForMpItem(autoIncrementItem,'Proposed SP is greater than 10,000 and current sp is less than 10,000',Decision.AUTO_INCREMENT_FAILED)
|
191 |
markReasonForMpItem(autoIncrementItem,'Proposed SP is greater than 10,000 and current sp is less than 10,000',Decision.AUTO_INCREMENT_FAILED)
|
| 192 |
continue
|
192 |
continue
|
| 193 |
if getLastDaySale(autoIncrementItem.item_id)<=2:
|
193 |
if getLastDaySale(autoIncrementItem.item_id)<=2:
|
| 194 |
markReasonForMpItem(autoIncrementItem,'Last day sale is less than 3',Decision.AUTO_INCREMENT_FAILED)
|
194 |
markReasonForMpItem(autoIncrementItem,'Last day sale is less than 3',Decision.AUTO_INCREMENT_FAILED)
|
| 195 |
continue
|
195 |
continue
|
| 196 |
|
196 |
antecedentPrice = session.query(MarketPlaceHistory.ourSellingPrice).filter(MarketPlaceHistory.item_id==autoIncrementItem.item_id).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.timestamp>time-timedelta(days=1)).order_by(asc(MarketPlaceHistory.timestamp)).first()
|
| - |
|
197 |
if antecedentPrice is not None:
|
| - |
|
198 |
if float(math.ceil(autoIncrementItem.ourSellingPrice+max(10,.01*autoIncrementItem.ourSellingPrice))-math.ceil(antecedentPrice[0]+max(10,.01*antecedentPrice[0])))/math.ceil(antecedentPrice[0]+max(10,.01*antecedentPrice[0]))>.02:
|
| - |
|
199 |
markReasonForMpItem(autoIncrementItem,'Maximum price increase in last 24 hours should be 2%',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
200 |
continue
|
| - |
|
201 |
mpItem = MarketplaceItems.get_by(itemId=autoIncrementItem.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
202 |
if mpItem.maximumSellingPrice is not None and mpItem.maximumSellingPrice > 0:
|
| - |
|
203 |
if autoIncrementItem.ourSellingPrice+max(10,.01*autoIncrementItem.ourSellingPrice) > mpItem.maximumSellingPrice:
|
| - |
|
204 |
markReasonForMpItem(autoIncrementItem,'Price cannot exceed Maximum Selling Price',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
205 |
continue
|
| 197 |
#oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.item_id,0,3)
|
206 |
#oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.item_id,0,3)
|
| 198 |
#count,sale,daysOfStock = 0,0,0
|
207 |
#count,sale,daysOfStock = 0,0,0
|
| 199 |
#for obj in oosStatus:
|
208 |
#for obj in oosStatus:
|
| 200 |
# if not obj.is_oos:
|
209 |
# if not obj.is_oos:
|
| 201 |
# count+=1
|
210 |
# count+=1
|
| Line 1088... |
Line 1097... |
| 1088 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
1097 |
sheet.write(sheet_iterator, 6, math.ceil(mpHistory.ourSellingPrice+max(10,.01*mpHistory.ourSellingPrice)))
|
| 1089 |
sheet_iterator+=1
|
1098 |
sheet_iterator+=1
|
| 1090 |
|
1099 |
|
| 1091 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
1100 |
filename = "/tmp/snapdeal-report-"+runType+" " + str(timestamp) + ".xls"
|
| 1092 |
wbk.save(filename)
|
1101 |
wbk.save(filename)
|
| - |
|
1102 |
#EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
| 1093 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["rajneesh.arora@saholic.com","rajveer.singh@saholic.com","kshitij.sood@saholic.com"], " Snapdeal Auto Pricing "+runType+" " + str(timestamp), "", [get_attachment_part(filename)], [""], [])
|
1103 |
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","kshitij.sood@saholic.com","chaitnaya.vats@saholic.com","khushal.bhatia@saholic.com"], [])
|
| 1094 |
|
1104 |
|
| 1095 |
|
1105 |
|
| 1096 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
|
- |
|
| 1097 |
xstr = lambda s: s or ""
|
- |
|
| 1098 |
catalog_client = CatalogClient().get_client()
|
- |
|
| 1099 |
inventory_client = InventoryClient().get_client()
|
- |
|
| 1100 |
message="""<html>
|
- |
|
| 1101 |
<body>
|
- |
|
| 1102 |
<h3>Auto Decrease Items</h3>
|
- |
|
| 1103 |
<table border="1" style="width:100%;">
|
- |
|
| 1104 |
<thead>
|
- |
|
| 1105 |
<tr><th>Item Id</th>
|
- |
|
| 1106 |
<th>Product Name</th>
|
- |
|
| 1107 |
<th>Old Price</th>
|
- |
|
| 1108 |
<th>New Price</th>
|
- |
|
| 1109 |
<th>Old Margin %</th>
|
- |
|
| 1110 |
<th>New Margin %</th>
|
- |
|
| 1111 |
<th>Snapdeal Inventory</th>
|
- |
|
| 1112 |
</tr></thead>
|
- |
|
| 1113 |
<tbody>"""
|
- |
|
| 1114 |
for item in successfulAutoDecrease:
|
- |
|
| 1115 |
it = Item.query.filter_by(id=item.item_id).one()
|
- |
|
| 1116 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
- |
|
| 1117 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
- |
|
| 1118 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
- |
|
| 1119 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
|
- |
|
| 1120 |
newMargin = round((getNewOurTp(mpItem,item.proposedSellingPrice) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.proposedSellingPrice)),1)
|
- |
|
| 1121 |
message+="""<tr>
|
- |
|
| 1122 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
- |
|
| 1123 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
- |
|
| 1124 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
- |
|
| 1125 |
<td style="text-align:center">"""+str(math.ceil(item.proposedSellingPrice))+"""</td>
|
- |
|
| 1126 |
<td style="text-align:center">"""+str(round(item.margin/item.ourSellingPrice,2))+"""</td>
|
- |
|
| 1127 |
<td style="text-align:center">"""+str(round(newMargin/item.proposedSellingPrice,2))+"""</td>
|
- |
|
| 1128 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
- |
|
| 1129 |
</tr>"""
|
- |
|
| 1130 |
message+="""</tbody></table><h3>Auto Increase Items</h3><table border="1" style="width:100%;">
|
- |
|
| 1131 |
<thead>
|
- |
|
| 1132 |
<tr><th>Item Id</th>
|
- |
|
| 1133 |
<th>Product Name</th>
|
- |
|
| 1134 |
<th>Old Price</th>
|
- |
|
| 1135 |
<th>New Price</th>
|
- |
|
| 1136 |
<th>Old Margin %</th>
|
- |
|
| 1137 |
<th>New Margin %</th>
|
- |
|
| 1138 |
<th>Snapdeal Inventory</th>
|
- |
|
| 1139 |
</tr></thead>
|
- |
|
| 1140 |
<tbody>"""
|
- |
|
| 1141 |
for item in successfulAutoIncrease:
|
- |
|
| 1142 |
it = Item.query.filter_by(id=item.item_id).one()
|
- |
|
| 1143 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
- |
|
| 1144 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
- |
|
| 1145 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
- |
|
| 1146 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
|
- |
|
| 1147 |
newMargin = round((getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice)) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.ourSellingPrice+max(10,.01*item.ourSellingPrice))),1)
|
- |
|
| 1148 |
message+="""<tr>
|
- |
|
| 1149 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
- |
|
| 1150 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
- |
|
| 1151 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
- |
|
| 1152 |
<td style="text-align:center">"""+str(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))+"""</td>
|
- |
|
| 1153 |
<td style="text-align:center">"""+str(round(item.margin/item.ourSellingPrice,2))+"""</td>
|
- |
|
| 1154 |
<td style="text-align:center">"""+str(round(newMargin/(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)),2))+"""</td>
|
- |
|
| 1155 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
- |
|
| 1156 |
</tr>"""
|
- |
|
| 1157 |
message+="""</tbody></table></body></html>"""
|
- |
|
| 1158 |
print message
|
- |
|
| 1159 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
- |
|
| 1160 |
mailServer.ehlo()
|
- |
|
| 1161 |
mailServer.starttls()
|
- |
|
| 1162 |
mailServer.ehlo()
|
- |
|
| 1163 |
|
1106 |
|
| 1164 |
# Create the container (outer) email message.
|
- |
|
| 1165 |
msg = MIMEMultipart()
|
- |
|
| 1166 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
- |
|
| 1167 |
msg['From'] = ""
|
- |
|
| 1168 |
msg['To'] = 'sku-recipients@saholic.com'
|
- |
|
| 1169 |
msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
- |
|
| 1170 |
html_msg = MIMEText(message, 'html')
|
- |
|
| 1171 |
msg.attach(html_msg)
|
- |
|
| 1172 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
- |
|
| 1173 |
mailServer.sendmail("cafe@nes", ['rajneesh.arora@saholic.com','rajveer.singh@saholic.com','kshitij.sood@saholic.com'], msg.as_string())
|
- |
|
| 1174 |
|
1107 |
|
| 1175 |
def commitExceptionList(exceptionList,timestamp):
|
1108 |
def commitExceptionList(exceptionList,timestamp):
|
| 1176 |
exceptionItems=[]
|
1109 |
exceptionItems=[]
|
| 1177 |
for item in exceptionList:
|
1110 |
for item in exceptionList:
|
| 1178 |
mpHistory = MarketPlaceHistory()
|
1111 |
mpHistory = MarketPlaceHistory()
|
| Line 1411... |
Line 1344... |
| 1411 |
mpHistory.timestamp = timestamp
|
1344 |
mpHistory.timestamp = timestamp
|
| 1412 |
mpHistory.run = RunType._NAMES_TO_VALUES.get(snapdealItemInfo.runType)
|
1345 |
mpHistory.run = RunType._NAMES_TO_VALUES.get(snapdealItemInfo.runType)
|
| 1413 |
buyBoxList.append(mpHistory)
|
1346 |
buyBoxList.append(mpHistory)
|
| 1414 |
session.commit()
|
1347 |
session.commit()
|
| 1415 |
return buyBoxList
|
1348 |
return buyBoxList
|
| - |
|
1349 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
|
| - |
|
1350 |
xstr = lambda s: s or ""
|
| - |
|
1351 |
catalog_client = CatalogClient().get_client()
|
| - |
|
1352 |
inventory_client = InventoryClient().get_client()
|
| - |
|
1353 |
message="""<html>
|
| - |
|
1354 |
<body>
|
| - |
|
1355 |
<h3>Auto Decrease Items</h3>
|
| - |
|
1356 |
<table border="1" style="width:100%;">
|
| - |
|
1357 |
<thead>
|
| - |
|
1358 |
<tr><th>Item Id</th>
|
| - |
|
1359 |
<th>Product Name</th>
|
| - |
|
1360 |
<th>Old Price</th>
|
| - |
|
1361 |
<th>New Price</th>
|
| - |
|
1362 |
<th>Old Margin</th>
|
| - |
|
1363 |
<th>New Margin</th>
|
| - |
|
1364 |
<th>Snapdeal Inventory</th>
|
| - |
|
1365 |
</tr></thead>
|
| - |
|
1366 |
<tbody>"""
|
| - |
|
1367 |
for item in successfulAutoDecrease:
|
| - |
|
1368 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1369 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
1370 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
| - |
|
1371 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
| - |
|
1372 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
|
| - |
|
1373 |
newMargin = round(getNewOurTp(mpItem,item.proposedSellingPrice) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.proposedSellingPrice))
|
| - |
|
1374 |
message+="""<tr>
|
| - |
|
1375 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
1376 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
1377 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
1378 |
<td style="text-align:center">"""+str(math.ceil(item.proposedSellingPrice))+"""</td>
|
| - |
|
1379 |
<td style="text-align:center">"""+str(round(item.margin))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
1380 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
1381 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
1382 |
</tr>"""
|
| - |
|
1383 |
message+="""</tbody></table><h3>Auto Increase Items</h3><table border="1" style="width:100%;">
|
| - |
|
1384 |
<thead>
|
| - |
|
1385 |
<tr><th>Item Id</th>
|
| - |
|
1386 |
<th>Product Name</th>
|
| - |
|
1387 |
<th>Old Price</th>
|
| - |
|
1388 |
<th>New Price</th>
|
| - |
|
1389 |
<th>Old Margin</th>
|
| - |
|
1390 |
<th>New Margin</th>
|
| - |
|
1391 |
<th>Snapdeal Inventory</th>
|
| - |
|
1392 |
</tr></thead>
|
| - |
|
1393 |
<tbody>"""
|
| - |
|
1394 |
for item in successfulAutoIncrease:
|
| - |
|
1395 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1396 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
1397 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
| - |
|
1398 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
| - |
|
1399 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| - |
|
1400 |
newMargin = round(getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice)) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| - |
|
1401 |
message+="""<tr>
|
| - |
|
1402 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
1403 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
1404 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
1405 |
<td style="text-align:center">"""+str(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))+"""</td>
|
| - |
|
1406 |
<td style="text-align:center">"""+str(round((item.margin),1))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
1407 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))*100,1))+"%)"+"""</td>
|
| - |
|
1408 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
1409 |
</tr>"""
|
| - |
|
1410 |
message+="""</tbody></table></body></html>"""
|
| - |
|
1411 |
print message
|
| - |
|
1412 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
1413 |
mailServer.ehlo()
|
| - |
|
1414 |
mailServer.starttls()
|
| - |
|
1415 |
mailServer.ehlo()
|
| - |
|
1416 |
|
| - |
|
1417 |
# Create the container (outer) email message.
|
| - |
|
1418 |
msg = MIMEMultipart()
|
| - |
|
1419 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
1420 |
msg['From'] = ""
|
| - |
|
1421 |
msg['To'] = 'sku-recipients@saholic.com'
|
| - |
|
1422 |
msg.preamble = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
1423 |
html_msg = MIMEText(message, 'html')
|
| - |
|
1424 |
msg.attach(html_msg)
|
| - |
|
1425 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
1426 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
1427 |
mailServer.sendmail("cafe@nes", ['rajneesh.arora@saholic.com','rajveer.singh@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'], msg.as_string())
|
| - |
|
1428 |
|
| - |
|
1429 |
def commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp):
|
| - |
|
1430 |
catalog_client = CatalogClient().get_client()
|
| - |
|
1431 |
inventory_client = InventoryClient().get_client()
|
| - |
|
1432 |
for item in successfulAutoDecrease:
|
| - |
|
1433 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1434 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
1435 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
| - |
|
1436 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
| - |
|
1437 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
|
| - |
|
1438 |
addHistory(sdItem)
|
| - |
|
1439 |
sdItem.transferPrice = getNewOurTp(mpItem,item.proposedSellingPrice)
|
| - |
|
1440 |
sdItem.sellingPrice = math.ceil(item.proposedSellingPrice)
|
| - |
|
1441 |
sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)
|
| - |
|
1442 |
sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
|
| - |
|
1443 |
sdItem.updatedOn = timestamp
|
| - |
|
1444 |
sdItem.priceUpdatedBy = 'SYSTEM'
|
| - |
|
1445 |
mpItem.currentSp = sdItem.sellingPrice
|
| - |
|
1446 |
mpItem.currentTp = sdItem.transferPrice
|
| - |
|
1447 |
mpItem.minimumPossibleTp = getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.proposedSellingPrice)
|
| - |
|
1448 |
mpItem.minimumPossibleSp = getNewLowestPossibleSp(mpItem,item.ourNlc,vatRate)
|
| - |
|
1449 |
markStatusForMarketplaceItems(sdItem,mpItem)
|
| - |
|
1450 |
session.commit()
|
| - |
|
1451 |
for item in successfulAutoIncrease:
|
| - |
|
1452 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1453 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
1454 |
sdItem = SnapdealItem.get_by(item_id=item.item_id)
|
| - |
|
1455 |
warehouse = inventory_client.getWarehouse(sdItem.warehouseId)
|
| - |
|
1456 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| - |
|
1457 |
addHistory(sdItem)
|
| - |
|
1458 |
sdItem.transferPrice = getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
|
| - |
|
1459 |
sdItem.sellingPrice = math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice))
|
| - |
|
1460 |
sdItem.commission = round((mpItem.commission/100)*(sdItem.sellingPrice),2)
|
| - |
|
1461 |
sdItem.serviceTax = round((mpItem.serviceTax/100)*(sdItem.commission+sdItem.courierCost),2)
|
| - |
|
1462 |
sdItem.updatedOn = timestamp
|
| - |
|
1463 |
sdItem.priceUpdatedBy = 'SYSTEM'
|
| - |
|
1464 |
mpItem.currentSp = sdItem.sellingPrice
|
| - |
|
1465 |
mpItem.currentTp = sdItem.transferPrice
|
| - |
|
1466 |
mpItem.minimumPossibleTp = getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,sdItem.sellingPrice)
|
| - |
|
1467 |
mpItem.minimumPossibleSp = getNewLowestPossibleSp(mpItem,item.ourNlc,vatRate)
|
| - |
|
1468 |
markStatusForMarketplaceItems(sdItem,mpItem)
|
| - |
|
1469 |
session.commit()
|
| - |
|
1470 |
|
| - |
|
1471 |
def addHistory(item):
|
| - |
|
1472 |
itemHistory = SnapdealItemUpdateHistory()
|
| - |
|
1473 |
itemHistory.item_id = item.item_id
|
| - |
|
1474 |
itemHistory.exceptionPrice = item.exceptionPrice
|
| - |
|
1475 |
itemHistory.warehouseId = item.warehouseId
|
| - |
|
1476 |
itemHistory.isListedOnSnapdeal = item.isListedOnSnapdeal
|
| - |
|
1477 |
itemHistory.transferPrice = item.transferPrice
|
| - |
|
1478 |
itemHistory.sellingPrice = item.sellingPrice
|
| - |
|
1479 |
itemHistory.courierCost = item.courierCost
|
| - |
|
1480 |
itemHistory.commission = item.commission
|
| - |
|
1481 |
itemHistory.serviceTax = item.serviceTax
|
| - |
|
1482 |
itemHistory.suppressPriceFeed = item.suppressPriceFeed
|
| - |
|
1483 |
itemHistory.suppressInventoryFeed = item.suppressInventoryFeed
|
| - |
|
1484 |
itemHistory.updatedOn = item.updatedOn
|
| - |
|
1485 |
itemHistory.maxNlc = item.maxNlc
|
| - |
|
1486 |
itemHistory.skuAtSnapdeal = item.skuAtSnapdeal
|
| - |
|
1487 |
itemHistory.supc = item.supc
|
| - |
|
1488 |
itemHistory.priceUpdatedBy = item.priceUpdatedBy
|
| - |
|
1489 |
|
| - |
|
1490 |
def markStatusForMarketplaceItems(snapdealItem,marketplaceItem):
|
| - |
|
1491 |
markUpdatedItem = MarketPlaceItemPrice.query.filter(MarketPlaceItemPrice.item_id==snapdealItem.item_id).filter(MarketPlaceItemPrice.source==marketplaceItem.source).first()
|
| - |
|
1492 |
if markUpdatedItem is None:
|
| - |
|
1493 |
marketPlaceItemPrice = MarketPlaceItemPrice()
|
| - |
|
1494 |
marketPlaceItemPrice.item_id = snapdealItem.item_id
|
| - |
|
1495 |
marketPlaceItemPrice.source = marketplaceItem.source
|
| - |
|
1496 |
marketPlaceItemPrice.lastUpdatedOn = snapdealItem.updatedOn
|
| - |
|
1497 |
marketPlaceItemPrice.sellingPrice = snapdealItem.sellingPrice
|
| - |
|
1498 |
marketPlaceItemPrice.suppressPriceFeed = snapdealItem.suppressPriceFeed
|
| - |
|
1499 |
marketPlaceItemPrice.isListedOnSource = snapdealItem.isListedOnSnapdeal
|
| - |
|
1500 |
else:
|
| - |
|
1501 |
if (markUpdatedItem.sellingPrice!=snapdealItem.sellingPrice or markUpdatedItem.suppressPriceFeed!=snapdealItem.suppressPriceFeed or markUpdatedItem.isListedOnSource!=snapdealItem.isListedOnSnapdeal):
|
| - |
|
1502 |
markUpdatedItem.lastUpdatedOn = snapdealItem.updatedOn
|
| - |
|
1503 |
markUpdatedItem.sellingPrice = snapdealItem.sellingPrice
|
| - |
|
1504 |
markUpdatedItem.suppressPriceFeed = snapdealItem.suppressPriceFeed
|
| - |
|
1505 |
markUpdatedItem.isListedOnSource = snapdealItem.isListedOnSnapdeal
|
| - |
|
1506 |
|
| 1416 |
|
1507 |
|
| 1417 |
|
1508 |
|
| 1418 |
def getOtherTp(snapdealDetails,val,spm):
|
1509 |
def getOtherTp(snapdealDetails,val,spm):
|
| 1419 |
if val.parent_category==10011:
|
1510 |
if val.parent_category==10011:
|
| 1420 |
commissionPercentage = spm.competitorCommissionAccessory
|
1511 |
commissionPercentage = spm.competitorCommissionAccessory
|
| Line 1447... |
Line 1538... |
| 1447 |
return round(lowest_possible_tp,2)
|
1538 |
return round(lowest_possible_tp,2)
|
| 1448 |
|
1539 |
|
| 1449 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
1540 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
| 1450 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
1541 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100));
|
| 1451 |
return round(ourTp,2)
|
1542 |
return round(ourTp,2)
|
| - |
|
1543 |
|
| - |
|
1544 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
| - |
|
1545 |
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));
|
| - |
|
1546 |
return round(lowestPossibleSp,2)
|
| 1452 |
|
1547 |
|
| 1453 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
1548 |
def getLowestPossibleSp(snapdealDetails,val,spm,mpItem):
|
| 1454 |
if snapdealDetails.rank==0:
|
1549 |
if snapdealDetails.rank==0:
|
| 1455 |
return mpItem.minimumPossibleSp
|
1550 |
return mpItem.minimumPossibleSp
|
| 1456 |
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));
|
1551 |
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));
|
| Line 1497... |
Line 1592... |
| 1497 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
1592 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
| 1498 |
if options.runType=='FULL':
|
1593 |
if options.runType=='FULL':
|
| 1499 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
1594 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
| 1500 |
else:
|
1595 |
else:
|
| 1501 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
1596 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
| - |
|
1597 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
| 1502 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
1598 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| 1503 |
|
1599 |
|
| 1504 |
if __name__ == '__main__':
|
1600 |
if __name__ == '__main__':
|
| 1505 |
main()
|
1601 |
main()
|
| 1506 |
|
1602 |
|