| 9334 |
kshitij.so |
1 |
#!/usr/bin/python
|
|
|
2 |
# coding: ascii
|
|
|
3 |
from elixir import *
|
|
|
4 |
from shop2020.model.v1.catalog.impl import DataService
|
|
|
5 |
from shop2020.model.v1.catalog.impl.DataService import Item, Category,\
|
|
|
6 |
SnapdealItem
|
| 9359 |
kshitij.so |
7 |
from shop2020.thriftpy.model.v1.inventory import ttypes
|
|
|
8 |
from shop2020.thriftpy.model.v1.inventory.ttypes import WarehouseType, InventoryType
|
| 9334 |
kshitij.so |
9 |
import optparse
|
|
|
10 |
import xlrd
|
|
|
11 |
from shop2020.clients.InventoryClient import InventoryClient
|
|
|
12 |
import xlwt
|
|
|
13 |
import urllib2
|
|
|
14 |
import time
|
| 9492 |
kshitij.so |
15 |
from datetime import date
|
| 9334 |
kshitij.so |
16 |
import simplejson as json
|
| 9365 |
kshitij.so |
17 |
from shop2020.utils import EmailAttachmentSender
|
|
|
18 |
from shop2020.utils.EmailAttachmentSender import get_attachment_part
|
| 9334 |
kshitij.so |
19 |
|
|
|
20 |
|
| 9365 |
kshitij.so |
21 |
|
| 9334 |
kshitij.so |
22 |
if __name__ == '__main__' and __package__ is None:
|
|
|
23 |
import sys
|
|
|
24 |
import os
|
|
|
25 |
sys.path.insert(0, os.getcwd())
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
class _SnapdealItemInfo:
|
|
|
29 |
|
| 9426 |
kshitij.so |
30 |
def __init__(self, item_id, product_group, category_name, our_nlc, brand, model_name, model_number, color, weight, parent_category, risky, issue):
|
| 9334 |
kshitij.so |
31 |
self.item_id = item_id
|
|
|
32 |
self.product_group = product_group
|
|
|
33 |
self.category_name = category_name
|
|
|
34 |
self.our_nlc = our_nlc
|
|
|
35 |
self.brand = brand
|
|
|
36 |
self.model_name = model_name
|
|
|
37 |
self.model_number = model_number
|
|
|
38 |
self.color = color
|
|
|
39 |
self.weight = weight
|
|
|
40 |
self.parent_category = parent_category
|
| 9359 |
kshitij.so |
41 |
self.risky = risky
|
| 9426 |
kshitij.so |
42 |
self.issue = issue
|
| 9334 |
kshitij.so |
43 |
|
|
|
44 |
|
|
|
45 |
class SnapdealDetails:
|
| 9359 |
kshitij.so |
46 |
def __init__(self, supc, ourSp, offerPrice, ourInventory, otherInventory, rank, lowestSellerName,lowestSp,secondLowestSellerName,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice):
|
| 9334 |
kshitij.so |
47 |
self.supc = supc
|
|
|
48 |
self.ourSp = ourSp
|
|
|
49 |
self.offerPrice = offerPrice
|
|
|
50 |
self.ourInventory = ourInventory
|
|
|
51 |
self.otherInventory = otherInventory
|
|
|
52 |
self.rank = rank
|
|
|
53 |
self.lowestSellerName = lowestSellerName
|
|
|
54 |
self.lowestSp = lowestSp
|
|
|
55 |
self.secondLowestSellerName = secondLowestSellerName
|
|
|
56 |
self.secondLowestSellerSp = secondLowestSellerSp
|
|
|
57 |
self.secondLowestSellerInventory = secondLowestSellerInventory
|
| 9359 |
kshitij.so |
58 |
self.lowestOfferPrice = lowestOfferPrice
|
|
|
59 |
self.secondLowestSellerOfferPrice = secondLowestSellerOfferPrice
|
|
|
60 |
self.ourOfferPrice = ourOfferPrice
|
| 9334 |
kshitij.so |
61 |
|
|
|
62 |
|
|
|
63 |
def fetchDetails(supc_code):
|
|
|
64 |
url="http://www.snapdeal.com/json/gvbps?supc=%s&catId=91"%(supc_code)
|
|
|
65 |
print url
|
|
|
66 |
time.sleep(2)
|
|
|
67 |
req = urllib2.Request(url)
|
|
|
68 |
response = urllib2.urlopen(req)
|
|
|
69 |
json_input = response.read()
|
|
|
70 |
vendorInfo = json.loads(json_input)
|
|
|
71 |
rank ,otherInventory ,ourInventory, offerPrice, ourSp,iterator = 0, 0, 0, 0, 0, 0
|
| 9337 |
kshitij.so |
72 |
secondLowestSellerName=''
|
|
|
73 |
secondLowestSellerSp=0
|
|
|
74 |
secondLowestSellerInventory=0
|
| 9359 |
kshitij.so |
75 |
lowestOfferPrice = 0
|
|
|
76 |
secondLowestSellerOfferPrice = 0
|
|
|
77 |
ourOfferPrice = 0
|
| 9334 |
kshitij.so |
78 |
for vendor in vendorInfo:
|
|
|
79 |
if iterator == 0:
|
|
|
80 |
lowestSellerName = vendor['vendorDisplayName']
|
| 9362 |
kshitij.so |
81 |
try:
|
|
|
82 |
lowestSp = vendor['sellingPriceBefIntCashBack']
|
|
|
83 |
except:
|
|
|
84 |
lowestSp = vendor['sellingPrice']
|
| 9359 |
kshitij.so |
85 |
lowestOfferPrice = vendor['sellingPrice']
|
| 9334 |
kshitij.so |
86 |
|
|
|
87 |
if iterator ==1:
|
|
|
88 |
secondLowestSellerName = vendor['vendorDisplayName']
|
| 9362 |
kshitij.so |
89 |
try:
|
|
|
90 |
secondLowestSellerSp = vendor['sellingPriceBefIntCashBack']
|
|
|
91 |
except:
|
|
|
92 |
secondLowestSellerSp = vendor['sellingPrice']
|
| 9359 |
kshitij.so |
93 |
secondLowestSellerOfferPrice = vendor['sellingPrice']
|
| 9334 |
kshitij.so |
94 |
secondLowestSellerInventory = vendor['buyableInventory']
|
|
|
95 |
|
|
|
96 |
if vendor['vendorDisplayName'] == 'MobilesnMore':
|
|
|
97 |
ourInventory = vendor['buyableInventory']
|
| 9362 |
kshitij.so |
98 |
try:
|
|
|
99 |
ourSp = vendor['sellingPriceBefIntCashBack']
|
|
|
100 |
except:
|
|
|
101 |
ourSp = vendor['sellingPrice']
|
| 9359 |
kshitij.so |
102 |
ourOfferPrice = vendor['sellingPrice']
|
| 9334 |
kshitij.so |
103 |
rank = iterator +1
|
|
|
104 |
else:
|
|
|
105 |
if rank==0:
|
|
|
106 |
otherInventory = otherInventory +vendor['buyableInventory']
|
|
|
107 |
|
|
|
108 |
iterator+=1
|
| 9359 |
kshitij.so |
109 |
snapdealDetails = SnapdealDetails(supc_code,ourSp,offerPrice,ourInventory,otherInventory,rank,lowestSellerName,lowestSp,secondLowestSellerName,secondLowestSellerSp,secondLowestSellerInventory,lowestOfferPrice,secondLowestSellerOfferPrice,ourOfferPrice)
|
| 9334 |
kshitij.so |
110 |
return snapdealDetails
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
def read_data(filename):
|
|
|
114 |
all_lines = []
|
|
|
115 |
all_supc=[]
|
|
|
116 |
iclient = InventoryClient().get_client()
|
| 9337 |
kshitij.so |
117 |
DataService.initialize('catalog','192.168.166.135')
|
| 9334 |
kshitij.so |
118 |
workbook = xlrd.open_workbook(filename)
|
|
|
119 |
sheet = workbook.sheet_by_index(0)
|
|
|
120 |
num_rows = sheet.nrows
|
|
|
121 |
for rownum in range(1, num_rows):
|
|
|
122 |
print sheet.row_values(rownum)
|
| 9453 |
kshitij.so |
123 |
try:
|
| 9488 |
kshitij.so |
124 |
supc = sheet.row_values(rownum)[1]
|
| 9454 |
kshitij.so |
125 |
item_id = int(sheet.row_values(rownum)[0])
|
| 9453 |
kshitij.so |
126 |
item = Item.query.filter_by(id=item_id).one()
|
|
|
127 |
except Exception as e:
|
| 9483 |
kshitij.so |
128 |
print "No item found.Maybe due to snapdeal item code in place of our sku id.Lets try again."
|
| 9453 |
kshitij.so |
129 |
print e
|
| 9483 |
kshitij.so |
130 |
try:
|
|
|
131 |
item_id = sheet.row_values(rownum)[0]
|
|
|
132 |
snapdeal_item = SnapdealItem.query.filter_by(skuAtSnapdeal=item_id).one()
|
|
|
133 |
item = Item.query.filter_by(id=snapdeal_item.item_id).one()
|
|
|
134 |
except Exception as ex:
|
|
|
135 |
print ex
|
|
|
136 |
one_line = _SnapdealItemInfo(sheet.row_values(rownum)[0], '', '', 0, '', '','', '', 0, '', False,"item_related")
|
|
|
137 |
all_supc.append(supc)
|
|
|
138 |
all_lines.append(one_line)
|
|
|
139 |
continue
|
| 9453 |
kshitij.so |
140 |
|
| 9485 |
vikram.rag |
141 |
category = Category.query.filter_by(id=item.category).one()
|
| 9426 |
kshitij.so |
142 |
parent_category = Category.query.filter_by(parent_category_id=category.parent_category_id).first()
|
|
|
143 |
try:
|
| 9485 |
vikram.rag |
144 |
snapdeal_item = SnapdealItem.query.filter_by(item_id=item.id).one()
|
| 9426 |
kshitij.so |
145 |
warehouse = iclient.getWarehouse(snapdeal_item.warehouseId)
|
| 9484 |
kshitij.so |
146 |
item_pricing = iclient.getItemPricing(item.id, warehouse.vendor.id)
|
| 9426 |
kshitij.so |
147 |
one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"")
|
|
|
148 |
except Exception as e:
|
| 9484 |
kshitij.so |
149 |
print "Problem with item id ",item.id
|
| 9426 |
kshitij.so |
150 |
print e
|
|
|
151 |
one_line = _SnapdealItemInfo(item.id, item.product_group, parent_category.display_name, item_pricing.nlc, item.brand, item.model_name, item.model_number, item.color, item.weight, category.parent_category_id, item.risky,"our_side")
|
|
|
152 |
|
| 9359 |
kshitij.so |
153 |
#TO BE USED LATER
|
|
|
154 |
#inventory_snapshot = iclient.getInventorySnapshot(0)
|
|
|
155 |
#warehouses_ours = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("OURS"), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
|
|
|
156 |
#warehouses_third_party = iclient.getWarehouses(WarehouseType._NAMES_TO_VALUES.get("THIRD_PARTY "), InventoryType._NAMES_TO_VALUES.get("GOOD"), 0,0,0)
|
| 9334 |
kshitij.so |
157 |
all_supc.append(supc)
|
|
|
158 |
all_lines.append(one_line)
|
|
|
159 |
write_report("/tmp/snapdeal_running.xls", all_lines, all_supc)
|
|
|
160 |
|
| 9426 |
kshitij.so |
161 |
|
|
|
162 |
def exception_sheet(items,wbk):
|
|
|
163 |
sheet = wbk.add_sheet('Exception Item List')
|
|
|
164 |
|
|
|
165 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 9334 |
kshitij.so |
166 |
|
| 9426 |
kshitij.so |
167 |
excel_integer_format = '0'
|
|
|
168 |
integer_style = xlwt.XFStyle()
|
|
|
169 |
integer_style.num_format_str = excel_integer_format
|
|
|
170 |
|
|
|
171 |
sheet.write(0, 0, "Item ID", heading_xf)
|
| 9493 |
manish.sha |
172 |
sheet.write(0, 1, "Brand", heading_xf)
|
|
|
173 |
sheet.write(0, 2, "Model Name", heading_xf)
|
|
|
174 |
sheet.write(0, 3, "Model Number", heading_xf)
|
|
|
175 |
sheet.write(0, 4, "Color", heading_xf)
|
|
|
176 |
sheet.write(0, 5, "Problem Type", heading_xf)
|
| 9426 |
kshitij.so |
177 |
|
|
|
178 |
i=1
|
|
|
179 |
for item in items:
|
|
|
180 |
sheet.write(i, 0, item.item_id)
|
| 9493 |
manish.sha |
181 |
sheet.write(i, 1, item.brand)
|
|
|
182 |
sheet.write(i, 2, item.model_name)
|
|
|
183 |
sheet.write(i, 3, item.model_number)
|
|
|
184 |
sheet.write(i, 4, item.color)
|
| 9426 |
kshitij.so |
185 |
if len(item.issue)!=0:
|
| 9493 |
manish.sha |
186 |
sheet.write(i, 5, "Wrong item id or wrong warehouse Id")
|
| 9426 |
kshitij.so |
187 |
else:
|
| 9493 |
manish.sha |
188 |
sheet.write(i, 5, "Unable to fetch info from snapdeal server")
|
| 9426 |
kshitij.so |
189 |
i+=1
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
| 9334 |
kshitij.so |
193 |
|
| 9426 |
kshitij.so |
194 |
|
| 9334 |
kshitij.so |
195 |
def write_report(filename, all_lines, all_supc):
|
|
|
196 |
|
|
|
197 |
buyBoxItems = []
|
| 9387 |
kshitij.so |
198 |
competitive = []
|
| 9396 |
kshitij.so |
199 |
competitiveNoInventory = []
|
| 9426 |
kshitij.so |
200 |
exceptionItems = []
|
| 9451 |
kshitij.so |
201 |
negativeMargin = []
|
| 9334 |
kshitij.so |
202 |
|
|
|
203 |
wbk = xlwt.Workbook()
|
| 9396 |
kshitij.so |
204 |
sheet = wbk.add_sheet('Can\'t Compete')
|
| 9334 |
kshitij.so |
205 |
|
|
|
206 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
|
|
207 |
|
|
|
208 |
excel_integer_format = '0'
|
|
|
209 |
integer_style = xlwt.XFStyle()
|
|
|
210 |
integer_style.num_format_str = excel_integer_format
|
|
|
211 |
|
|
|
212 |
sheet.write(0, 0, "Item ID", heading_xf)
|
|
|
213 |
sheet.write(0, 1, "Category", heading_xf)
|
|
|
214 |
sheet.write(0, 2, "Product Group.", heading_xf)
|
|
|
215 |
sheet.write(0, 3, "SUPC", heading_xf)
|
|
|
216 |
sheet.write(0, 4, "Brand", heading_xf)
|
|
|
217 |
sheet.write(0, 5, "Model Name", heading_xf)
|
|
|
218 |
sheet.write(0, 6, "Model Number", heading_xf)
|
|
|
219 |
sheet.write(0, 7, "Color", heading_xf)
|
| 9359 |
kshitij.so |
220 |
sheet.write(0, 8, "Weight", heading_xf)
|
| 9400 |
kshitij.so |
221 |
sheet.write(0, 9, "Courier Cost", heading_xf)
|
| 9399 |
kshitij.so |
222 |
sheet.write(0, 10, "Risky", heading_xf)
|
|
|
223 |
sheet.write(0, 11, "Our SP", heading_xf)
|
| 9411 |
kshitij.so |
224 |
sheet.write(0, 13, "Our TP", heading_xf)
|
|
|
225 |
sheet.write(0, 12, "Our Offer Price", heading_xf)
|
| 9399 |
kshitij.so |
226 |
sheet.write(0, 14, "Our Rank", heading_xf)
|
|
|
227 |
sheet.write(0, 15, "Lowest Seller", heading_xf)
|
|
|
228 |
sheet.write(0, 16, "Lowest SP", heading_xf)
|
|
|
229 |
sheet.write(0, 17, "Lowest TP", heading_xf)
|
|
|
230 |
sheet.write(0, 18, "Lowest Offer Price", heading_xf)
|
|
|
231 |
sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
|
|
|
232 |
sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
|
|
|
233 |
sheet.write(0, 21, "Our NLC", heading_xf)
|
|
|
234 |
sheet.write(0, 22, "Lowest Possible TP", heading_xf)
|
|
|
235 |
sheet.write(0, 23, "Lowest Possible SP", heading_xf)
|
|
|
236 |
sheet.write(0, 24, "Competition Basis ", heading_xf)
|
|
|
237 |
sheet.write(0, 25, "Can Compete", heading_xf)
|
|
|
238 |
sheet.write(0, 26, "Target TP", heading_xf)
|
|
|
239 |
sheet.write(0, 27, "Target SP", heading_xf)
|
|
|
240 |
sheet.write(0, 28, "Target NLC", heading_xf)
|
|
|
241 |
sheet.write(0, 29, "Sales Potential", heading_xf)
|
| 9334 |
kshitij.so |
242 |
|
| 9337 |
kshitij.so |
243 |
i, sheet_iterator=1,1
|
| 9334 |
kshitij.so |
244 |
for one_line in all_lines:
|
| 9426 |
kshitij.so |
245 |
if len(one_line.issue)!=0:
|
|
|
246 |
exceptionItems.append(one_line)
|
|
|
247 |
i+=1
|
|
|
248 |
continue
|
| 9334 |
kshitij.so |
249 |
supc = all_supc[i-1]
|
| 9426 |
kshitij.so |
250 |
try:
|
|
|
251 |
supc_data = fetchDetails(supc)
|
|
|
252 |
except Exception as e:
|
|
|
253 |
print "Unable to get information about SUPC Code: ",supc
|
|
|
254 |
exceptionItems.append(one_line)
|
|
|
255 |
i+=1
|
|
|
256 |
continue
|
| 9334 |
kshitij.so |
257 |
|
|
|
258 |
courierCost = 45
|
|
|
259 |
|
|
|
260 |
if one_line.weight:
|
| 9381 |
kshitij.so |
261 |
slab = int(((one_line.weight+0.05) - .001)/.5)
|
| 9334 |
kshitij.so |
262 |
for x in range (0,slab):
|
|
|
263 |
courierCost = courierCost + 35
|
|
|
264 |
|
|
|
265 |
courierCost = courierCost * 1.1236
|
|
|
266 |
|
| 9451 |
kshitij.so |
267 |
if one_line.parent_category ==10011:
|
|
|
268 |
lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
|
|
|
269 |
else:
|
|
|
270 |
lowestTp = supc_data.lowestSp*0.9497-courierCost
|
|
|
271 |
|
|
|
272 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
|
|
273 |
|
| 9491 |
kshitij.so |
274 |
if (supc_data.ourSp*0.9597-courierCost < lowest_possible_tp and supc_data.ourSp > 0 and round((supc_data.ourSp*0.9597-courierCost) - lowest_possible_tp) < 0):
|
| 9451 |
kshitij.so |
275 |
temp=[]
|
|
|
276 |
temp.append(supc_data)
|
|
|
277 |
temp.append(one_line)
|
|
|
278 |
negativeMargin.append(temp)
|
|
|
279 |
i+=1
|
|
|
280 |
continue
|
|
|
281 |
|
| 9334 |
kshitij.so |
282 |
if supc_data.rank==1:
|
|
|
283 |
temp = []
|
|
|
284 |
temp.append(supc_data)
|
|
|
285 |
temp.append(one_line)
|
|
|
286 |
buyBoxItems.append(temp)
|
|
|
287 |
i+=1
|
|
|
288 |
continue
|
|
|
289 |
|
| 9387 |
kshitij.so |
290 |
|
| 9396 |
kshitij.so |
291 |
if (lowestTp > lowest_possible_tp and supc_data.ourInventory!=0):
|
| 9387 |
kshitij.so |
292 |
temp=[]
|
|
|
293 |
temp.append(supc_data)
|
|
|
294 |
temp.append(one_line)
|
|
|
295 |
competitive.append(temp)
|
|
|
296 |
i+=1
|
|
|
297 |
continue
|
|
|
298 |
|
| 9396 |
kshitij.so |
299 |
if (lowestTp > lowest_possible_tp and supc_data.ourInventory==0):
|
|
|
300 |
temp=[]
|
|
|
301 |
temp.append(supc_data)
|
|
|
302 |
temp.append(one_line)
|
|
|
303 |
competitiveNoInventory.append(temp)
|
|
|
304 |
i+=1
|
|
|
305 |
continue
|
| 9387 |
kshitij.so |
306 |
|
| 9451 |
kshitij.so |
307 |
|
| 9337 |
kshitij.so |
308 |
sheet.write(sheet_iterator, 0, one_line.item_id)
|
|
|
309 |
sheet.write(sheet_iterator, 1, one_line.category_name)
|
|
|
310 |
sheet.write(sheet_iterator, 2, one_line.product_group)
|
|
|
311 |
sheet.write(sheet_iterator, 3, supc)
|
|
|
312 |
sheet.write(sheet_iterator, 4, one_line.brand)
|
|
|
313 |
sheet.write(sheet_iterator, 5, one_line.model_name)
|
|
|
314 |
sheet.write(sheet_iterator, 6, one_line.model_number)
|
|
|
315 |
sheet.write(sheet_iterator, 7, one_line.color)
|
| 9359 |
kshitij.so |
316 |
sheet.write(sheet_iterator, 8, one_line.weight)
|
| 9400 |
kshitij.so |
317 |
sheet.write(sheet_iterator, 9, round(courierCost))
|
| 9399 |
kshitij.so |
318 |
sheet.write(sheet_iterator, 10, one_line.risky)
|
|
|
319 |
sheet.write(sheet_iterator, 11, supc_data.ourSp)
|
| 9411 |
kshitij.so |
320 |
sheet.write(sheet_iterator, 13, round(supc_data.ourSp*0.9597-courierCost))
|
|
|
321 |
sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
|
| 9399 |
kshitij.so |
322 |
sheet.write(sheet_iterator, 14, supc_data.rank)
|
|
|
323 |
sheet.write(sheet_iterator, 15, supc_data.lowestSellerName)
|
|
|
324 |
sheet.write(sheet_iterator, 16, supc_data.lowestSp)
|
| 9334 |
kshitij.so |
325 |
if one_line.parent_category ==10011:
|
|
|
326 |
lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
|
|
|
327 |
else:
|
|
|
328 |
lowestTp = supc_data.lowestSp*0.9497-courierCost
|
| 9399 |
kshitij.so |
329 |
sheet.write(sheet_iterator, 17, round(lowestTp))
|
|
|
330 |
sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
|
|
|
331 |
sheet.write(sheet_iterator, 19, supc_data.otherInventory)
|
|
|
332 |
sheet.write(sheet_iterator, 20, supc_data.ourInventory)
|
|
|
333 |
sheet.write(sheet_iterator, 21, one_line.our_nlc)
|
| 9334 |
kshitij.so |
334 |
if supc_data.rank==1:
|
|
|
335 |
i+=1
|
| 9337 |
kshitij.so |
336 |
sheet_iterator+=1
|
| 9334 |
kshitij.so |
337 |
continue
|
|
|
338 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
| 9366 |
kshitij.so |
339 |
lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
|
| 9399 |
kshitij.so |
340 |
sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
|
|
|
341 |
sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
|
| 9390 |
kshitij.so |
342 |
competitionBasis ='TP'
|
| 9411 |
kshitij.so |
343 |
if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice == supc_data.ourSp:
|
| 9390 |
kshitij.so |
344 |
competitionBasis ='SP'
|
| 9399 |
kshitij.so |
345 |
sheet.write(sheet_iterator, 24, 'SP')
|
| 9366 |
kshitij.so |
346 |
else:
|
| 9399 |
kshitij.so |
347 |
sheet.write(sheet_iterator, 24, 'TP')
|
| 9334 |
kshitij.so |
348 |
proposed_tp = 0
|
|
|
349 |
if lowestTp > lowest_possible_tp:
|
| 9399 |
kshitij.so |
350 |
sheet.write(sheet_iterator, 25, "Yes")
|
| 9334 |
kshitij.so |
351 |
else:
|
| 9399 |
kshitij.so |
352 |
sheet.write(sheet_iterator, 25, "No")
|
| 9396 |
kshitij.so |
353 |
if competitionBasis=='SP':
|
| 9411 |
kshitij.so |
354 |
proposed_sp = supc_data.lowestSp - max(10, supc_data.lowestSp*0.001)
|
| 9396 |
kshitij.so |
355 |
proposed_tp = proposed_sp*0.9597-courierCost
|
| 9399 |
kshitij.so |
356 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
357 |
sheet.write(sheet_iterator, 27, round(proposed_sp))
|
|
|
358 |
sheet.write(sheet_iterator, 28, round(proposed_tp*0.988-21))
|
| 9396 |
kshitij.so |
359 |
else:
|
| 9411 |
kshitij.so |
360 |
proposed_tp = lowestTp - max(10, lowestTp*0.001)
|
| 9399 |
kshitij.so |
361 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
362 |
sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
|
|
|
363 |
sheet.write(sheet_iterator, 28, round(proposed_tp*0.988-21))
|
| 9381 |
kshitij.so |
364 |
|
|
|
365 |
|
| 9366 |
kshitij.so |
366 |
if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
|
| 9399 |
kshitij.so |
367 |
sheet.write(sheet_iterator, 29, "HIGH")
|
| 9366 |
kshitij.so |
368 |
elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
|
| 9399 |
kshitij.so |
369 |
sheet.write(sheet_iterator, 29, "MEDIUM")
|
| 9366 |
kshitij.so |
370 |
else:
|
| 9399 |
kshitij.so |
371 |
sheet.write(sheet_iterator, 29, "LOW")
|
| 9334 |
kshitij.so |
372 |
i= i+1
|
| 9337 |
kshitij.so |
373 |
sheet_iterator+=1
|
|
|
374 |
|
| 9334 |
kshitij.so |
375 |
createSheetForBuyBoxItems(buyBoxItems,wbk)
|
| 9387 |
kshitij.so |
376 |
createSheetForCometitiveItems(competitive,wbk)
|
| 9396 |
kshitij.so |
377 |
createSheetForCometitiveItemsNoInventory(competitiveNoInventory,wbk)
|
| 9426 |
kshitij.so |
378 |
exception_sheet(exceptionItems,wbk)
|
| 9451 |
kshitij.so |
379 |
createSheetForNegativeMargin(negativeMargin,wbk)
|
| 9334 |
kshitij.so |
380 |
wbk.save(filename)
|
| 9492 |
kshitij.so |
381 |
today = date.today()
|
|
|
382 |
datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
|
|
|
383 |
EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["chandan.kumar@saholic.com","manoj.kumar@saholic.com","yukti.jain@saholic.com"], " Snapdeal Sheet " + datestr, "", [get_attachment_part(filename)], ["rajneesh.arora@saholic.com","kshitij.sood@saholic.com","khushal.bhatia@saholic.com"], [])
|
| 9334 |
kshitij.so |
384 |
|
| 9365 |
kshitij.so |
385 |
|
|
|
386 |
|
| 9334 |
kshitij.so |
387 |
def createSheetForBuyBoxItems(buyBoxItems,wbk):
|
| 9396 |
kshitij.so |
388 |
sheet = wbk.add_sheet('Lowest')
|
| 9334 |
kshitij.so |
389 |
|
|
|
390 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
|
|
391 |
|
|
|
392 |
excel_integer_format = '0'
|
|
|
393 |
integer_style = xlwt.XFStyle()
|
|
|
394 |
integer_style.num_format_str = excel_integer_format
|
|
|
395 |
|
|
|
396 |
sheet.write(0, 0, "Item ID", heading_xf)
|
|
|
397 |
sheet.write(0, 1, "Category", heading_xf)
|
|
|
398 |
sheet.write(0, 2, "Product Group.", heading_xf)
|
|
|
399 |
sheet.write(0, 3, "SUPC", heading_xf)
|
|
|
400 |
sheet.write(0, 4, "Brand", heading_xf)
|
|
|
401 |
sheet.write(0, 5, "Model Name", heading_xf)
|
|
|
402 |
sheet.write(0, 6, "Model Number", heading_xf)
|
|
|
403 |
sheet.write(0, 7, "Color", heading_xf)
|
| 9359 |
kshitij.so |
404 |
sheet.write(0, 8, "Weight", heading_xf)
|
| 9399 |
kshitij.so |
405 |
sheet.write(0, 9, "Courier Cost", heading_xf)
|
|
|
406 |
sheet.write(0, 10, "Risky", heading_xf)
|
|
|
407 |
sheet.write(0, 11, "Our SP", heading_xf)
|
| 9411 |
kshitij.so |
408 |
sheet.write(0, 13, "Our TP", heading_xf)
|
|
|
409 |
sheet.write(0, 12, "Our Offer Price", heading_xf)
|
| 9399 |
kshitij.so |
410 |
sheet.write(0, 14, "Our Rank", heading_xf)
|
|
|
411 |
sheet.write(0, 15, "Lowest Seller", heading_xf)
|
|
|
412 |
sheet.write(0, 16, "Second Lowest Seller", heading_xf)
|
|
|
413 |
sheet.write(0, 17, "Second Lowest Price", heading_xf)
|
|
|
414 |
sheet.write(0, 18, "Second Lowest Offer Price", heading_xf)
|
|
|
415 |
sheet.write(0, 19, "Second Lowest Seller TP", heading_xf)
|
| 9396 |
kshitij.so |
416 |
sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
|
|
|
417 |
sheet.write(0, 21, "Second Lowest Seller Inventory", heading_xf)
|
|
|
418 |
sheet.write(0, 22, "Our NLC", heading_xf)
|
|
|
419 |
sheet.write(0, 23, "Competition Basis", heading_xf)
|
|
|
420 |
sheet.write(0, 24, "Target TP", heading_xf)
|
|
|
421 |
sheet.write(0, 25, "Target SP", heading_xf)
|
| 9411 |
kshitij.so |
422 |
sheet.write(0, 26, "MARGIN INCREASED POTENTIAL", heading_xf)
|
| 9334 |
kshitij.so |
423 |
|
|
|
424 |
i=1
|
|
|
425 |
|
|
|
426 |
for data in buyBoxItems:
|
|
|
427 |
supc_data =data[0]
|
|
|
428 |
one_line = data[1]
|
|
|
429 |
|
|
|
430 |
courierCost = 45
|
|
|
431 |
|
|
|
432 |
if one_line.weight:
|
| 9381 |
kshitij.so |
433 |
slab = int(((one_line.weight+0.05) - .001)/.5)
|
| 9334 |
kshitij.so |
434 |
for x in range (0,slab):
|
|
|
435 |
courierCost = courierCost + 35
|
|
|
436 |
|
|
|
437 |
courierCost = courierCost * 1.1236
|
|
|
438 |
|
|
|
439 |
sheet.write(i, 0, one_line.item_id)
|
|
|
440 |
sheet.write(i, 1, one_line.category_name)
|
|
|
441 |
sheet.write(i, 2, one_line.product_group)
|
|
|
442 |
sheet.write(i, 3, supc_data.supc)
|
|
|
443 |
sheet.write(i, 4, one_line.brand)
|
|
|
444 |
sheet.write(i, 5, one_line.model_name)
|
|
|
445 |
sheet.write(i, 6, one_line.model_number)
|
|
|
446 |
sheet.write(i, 7, one_line.color)
|
| 9359 |
kshitij.so |
447 |
sheet.write(i, 8, one_line.weight)
|
| 9400 |
kshitij.so |
448 |
sheet.write(i, 9, round(courierCost))
|
| 9399 |
kshitij.so |
449 |
sheet.write(i, 10, one_line.risky)
|
|
|
450 |
sheet.write(i, 11, supc_data.ourSp)
|
| 9411 |
kshitij.so |
451 |
sheet.write(i, 13, round(supc_data.ourSp*0.9597-courierCost))
|
|
|
452 |
sheet.write(i, 12, supc_data.ourOfferPrice)
|
| 9399 |
kshitij.so |
453 |
sheet.write(i, 14, supc_data.rank)
|
|
|
454 |
sheet.write(i, 15, supc_data.lowestSellerName)
|
|
|
455 |
sheet.write(i, 16, supc_data.secondLowestSellerName)
|
|
|
456 |
sheet.write(i, 17, supc_data.secondLowestSellerSp)
|
|
|
457 |
sheet.write(i, 18, supc_data.secondLowestSellerOfferPrice)
|
| 9334 |
kshitij.so |
458 |
if one_line.parent_category ==10011:
|
| 9396 |
kshitij.so |
459 |
secondlowestTp = (supc_data.secondLowestSellerSp*(1-.0803))-courierCost
|
| 9334 |
kshitij.so |
460 |
else:
|
| 9396 |
kshitij.so |
461 |
secondlowestTp = supc_data.secondLowestSellerSp*0.9497-courierCost
|
| 9381 |
kshitij.so |
462 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
| 9396 |
kshitij.so |
463 |
lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
|
| 9401 |
kshitij.so |
464 |
sheet.write(i, 19, round(secondlowestTp))
|
| 9396 |
kshitij.so |
465 |
sheet.write(i, 20, supc_data.ourInventory)
|
|
|
466 |
sheet.write(i, 21, supc_data.secondLowestSellerInventory)
|
|
|
467 |
sheet.write(i, 22, one_line.our_nlc)
|
|
|
468 |
|
|
|
469 |
competitionBasis ='TP'
|
| 9411 |
kshitij.so |
470 |
if (supc_data.secondLowestSellerOfferPrice == supc_data.secondLowestSellerSp) and supc_data.ourOfferPrice==supc_data.ourSp:
|
| 9396 |
kshitij.so |
471 |
competitionBasis ='SP'
|
|
|
472 |
sheet.write(i, 23, 'SP')
|
|
|
473 |
else:
|
|
|
474 |
sheet.write(i, 23, 'TP')
|
|
|
475 |
|
|
|
476 |
if competitionBasis=='SP':
|
|
|
477 |
proposed_sp = max(supc_data.secondLowestSellerSp - max((20, supc_data.secondLowestSellerSp*0.002)), lowest_possible_sp)
|
|
|
478 |
proposed_tp = proposed_sp*0.9597-courierCost
|
|
|
479 |
sheet.write(i, 24, round(proposed_tp))
|
|
|
480 |
sheet.write(i, 25, round(proposed_sp))
|
|
|
481 |
else:
|
|
|
482 |
proposed_tp = max(secondlowestTp - max((20, secondlowestTp*0.002)), lowest_possible_tp)
|
|
|
483 |
sheet.write(i, 24, round(proposed_tp))
|
|
|
484 |
sheet.write(i, 25, round((proposed_tp+courierCost)/0.9597))
|
|
|
485 |
|
| 9411 |
kshitij.so |
486 |
sheet.write(i, 26, round(proposed_tp-(supc_data.ourSp*0.9597-courierCost)))
|
| 9334 |
kshitij.so |
487 |
i+=1
|
| 9387 |
kshitij.so |
488 |
|
|
|
489 |
|
|
|
490 |
def createSheetForCometitiveItems(competitiveItems,wbk):
|
| 9396 |
kshitij.so |
491 |
sheet = wbk.add_sheet('Can Compete-With Inventory')
|
| 9387 |
kshitij.so |
492 |
|
|
|
493 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 9334 |
kshitij.so |
494 |
|
| 9387 |
kshitij.so |
495 |
excel_integer_format = '0'
|
|
|
496 |
integer_style = xlwt.XFStyle()
|
|
|
497 |
integer_style.num_format_str = excel_integer_format
|
|
|
498 |
|
|
|
499 |
sheet.write(0, 0, "Item ID", heading_xf)
|
|
|
500 |
sheet.write(0, 1, "Category", heading_xf)
|
|
|
501 |
sheet.write(0, 2, "Product Group.", heading_xf)
|
|
|
502 |
sheet.write(0, 3, "SUPC", heading_xf)
|
|
|
503 |
sheet.write(0, 4, "Brand", heading_xf)
|
|
|
504 |
sheet.write(0, 5, "Model Name", heading_xf)
|
|
|
505 |
sheet.write(0, 6, "Model Number", heading_xf)
|
|
|
506 |
sheet.write(0, 7, "Color", heading_xf)
|
|
|
507 |
sheet.write(0, 8, "Weight", heading_xf)
|
| 9399 |
kshitij.so |
508 |
sheet.write(0, 9, "Courier Cost", heading_xf)
|
|
|
509 |
sheet.write(0, 10, "Risky", heading_xf)
|
|
|
510 |
sheet.write(0, 11, "Our SP", heading_xf)
|
| 9411 |
kshitij.so |
511 |
sheet.write(0, 13, "Our TP", heading_xf)
|
|
|
512 |
sheet.write(0, 12, "Our Offer Price", heading_xf)
|
| 9399 |
kshitij.so |
513 |
sheet.write(0, 14, "Our Rank", heading_xf)
|
|
|
514 |
sheet.write(0, 15, "Lowest Seller", heading_xf)
|
|
|
515 |
sheet.write(0, 16, "Lowest SP", heading_xf)
|
|
|
516 |
sheet.write(0, 17, "Lowest TP", heading_xf)
|
|
|
517 |
sheet.write(0, 18, "Lowest Offer Price", heading_xf)
|
|
|
518 |
sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
|
|
|
519 |
sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
|
|
|
520 |
sheet.write(0, 21, "Our NLC", heading_xf)
|
|
|
521 |
sheet.write(0, 22, "Lowest Possible TP", heading_xf)
|
|
|
522 |
sheet.write(0, 23, "Lowest Possible SP", heading_xf)
|
|
|
523 |
sheet.write(0, 24, "Competition Basis ", heading_xf)
|
|
|
524 |
sheet.write(0, 25, "Can Compete", heading_xf)
|
|
|
525 |
sheet.write(0, 26, "Target TP", heading_xf)
|
|
|
526 |
sheet.write(0, 27, "Target SP", heading_xf)
|
|
|
527 |
sheet.write(0, 28, "Sales Potential", heading_xf)
|
| 9387 |
kshitij.so |
528 |
|
|
|
529 |
i, sheet_iterator=1,1
|
|
|
530 |
for data in competitiveItems:
|
|
|
531 |
supc_data =data[0]
|
|
|
532 |
one_line = data[1]
|
|
|
533 |
|
|
|
534 |
courierCost = 45
|
|
|
535 |
|
|
|
536 |
if one_line.weight:
|
|
|
537 |
slab = int(((one_line.weight+0.05) - .001)/.5)
|
|
|
538 |
for x in range (0,slab):
|
|
|
539 |
courierCost = courierCost + 35
|
|
|
540 |
|
|
|
541 |
courierCost = courierCost * 1.1236
|
|
|
542 |
|
|
|
543 |
|
|
|
544 |
sheet.write(sheet_iterator, 0, one_line.item_id)
|
|
|
545 |
sheet.write(sheet_iterator, 1, one_line.category_name)
|
|
|
546 |
sheet.write(sheet_iterator, 2, one_line.product_group)
|
|
|
547 |
sheet.write(sheet_iterator, 3, supc_data.supc)
|
|
|
548 |
sheet.write(sheet_iterator, 4, one_line.brand)
|
|
|
549 |
sheet.write(sheet_iterator, 5, one_line.model_name)
|
|
|
550 |
sheet.write(sheet_iterator, 6, one_line.model_number)
|
|
|
551 |
sheet.write(sheet_iterator, 7, one_line.color)
|
|
|
552 |
sheet.write(sheet_iterator, 8, one_line.weight)
|
| 9400 |
kshitij.so |
553 |
sheet.write(sheet_iterator, 9, round(courierCost))
|
| 9399 |
kshitij.so |
554 |
sheet.write(sheet_iterator, 10, one_line.risky)
|
|
|
555 |
sheet.write(sheet_iterator, 11, supc_data.ourSp)
|
| 9411 |
kshitij.so |
556 |
sheet.write(sheet_iterator, 13, round(supc_data.ourSp*0.9597-courierCost))
|
|
|
557 |
sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
|
| 9399 |
kshitij.so |
558 |
sheet.write(sheet_iterator, 14, supc_data.rank)
|
|
|
559 |
sheet.write(sheet_iterator, 15, supc_data.lowestSellerName)
|
|
|
560 |
sheet.write(sheet_iterator, 16, supc_data.lowestSp)
|
| 9387 |
kshitij.so |
561 |
if one_line.parent_category ==10011:
|
|
|
562 |
lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
|
|
|
563 |
else:
|
|
|
564 |
lowestTp = supc_data.lowestSp*0.9497-courierCost
|
| 9399 |
kshitij.so |
565 |
sheet.write(sheet_iterator, 17, round(lowestTp))
|
|
|
566 |
sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
|
|
|
567 |
sheet.write(sheet_iterator, 19, supc_data.otherInventory)
|
|
|
568 |
sheet.write(sheet_iterator, 20, supc_data.ourInventory)
|
|
|
569 |
sheet.write(sheet_iterator, 21, one_line.our_nlc)
|
| 9387 |
kshitij.so |
570 |
if supc_data.rank==1:
|
|
|
571 |
i+=1
|
|
|
572 |
sheet_iterator+=1
|
|
|
573 |
continue
|
|
|
574 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
|
|
575 |
lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
|
| 9399 |
kshitij.so |
576 |
sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
|
|
|
577 |
sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
|
| 9390 |
kshitij.so |
578 |
competitionBasis ='TP'
|
| 9411 |
kshitij.so |
579 |
if (supc_data.lowestOfferPrice == supc_data.lowestSp) and supc_data.ourOfferPrice==supc_data.ourSp:
|
| 9390 |
kshitij.so |
580 |
competitionBasis ='SP'
|
| 9399 |
kshitij.so |
581 |
sheet.write(sheet_iterator, 24, 'SP')
|
| 9387 |
kshitij.so |
582 |
else:
|
| 9399 |
kshitij.so |
583 |
sheet.write(sheet_iterator, 24, 'TP')
|
| 9387 |
kshitij.so |
584 |
proposed_tp = 0
|
|
|
585 |
if lowestTp > lowest_possible_tp:
|
| 9399 |
kshitij.so |
586 |
sheet.write(sheet_iterator, 25, "Yes")
|
| 9390 |
kshitij.so |
587 |
if competitionBasis=='SP':
|
|
|
588 |
proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
|
| 9396 |
kshitij.so |
589 |
proposed_tp = proposed_sp*.9597-courierCost
|
| 9399 |
kshitij.so |
590 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
591 |
sheet.write(sheet_iterator, 27, round(proposed_sp))
|
| 9390 |
kshitij.so |
592 |
else:
|
|
|
593 |
proposed_tp = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
|
| 9399 |
kshitij.so |
594 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
595 |
sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
|
| 9387 |
kshitij.so |
596 |
else:
|
| 9399 |
kshitij.so |
597 |
sheet.write(sheet_iterator, 25, "No")
|
| 9387 |
kshitij.so |
598 |
|
|
|
599 |
if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
|
| 9399 |
kshitij.so |
600 |
sheet.write(sheet_iterator, 28, "HIGH")
|
| 9387 |
kshitij.so |
601 |
elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
|
| 9399 |
kshitij.so |
602 |
sheet.write(sheet_iterator, 28, "MEDIUM")
|
| 9387 |
kshitij.so |
603 |
else:
|
| 9399 |
kshitij.so |
604 |
sheet.write(sheet_iterator, 28, "LOW")
|
| 9387 |
kshitij.so |
605 |
i= i+1
|
|
|
606 |
sheet_iterator+=1
|
| 9334 |
kshitij.so |
607 |
|
| 9396 |
kshitij.so |
608 |
|
|
|
609 |
def createSheetForCometitiveItemsNoInventory(competitiveNoInventoryItems,wbk):
|
|
|
610 |
sheet = wbk.add_sheet('Can Compete-No Inventory')
|
|
|
611 |
|
|
|
612 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
|
|
613 |
|
|
|
614 |
excel_integer_format = '0'
|
|
|
615 |
integer_style = xlwt.XFStyle()
|
|
|
616 |
integer_style.num_format_str = excel_integer_format
|
|
|
617 |
|
|
|
618 |
sheet.write(0, 0, "Item ID", heading_xf)
|
|
|
619 |
sheet.write(0, 1, "Category", heading_xf)
|
|
|
620 |
sheet.write(0, 2, "Product Group.", heading_xf)
|
|
|
621 |
sheet.write(0, 3, "SUPC", heading_xf)
|
|
|
622 |
sheet.write(0, 4, "Brand", heading_xf)
|
|
|
623 |
sheet.write(0, 5, "Model Name", heading_xf)
|
|
|
624 |
sheet.write(0, 6, "Model Number", heading_xf)
|
|
|
625 |
sheet.write(0, 7, "Color", heading_xf)
|
|
|
626 |
sheet.write(0, 8, "Weight", heading_xf)
|
| 9399 |
kshitij.so |
627 |
sheet.write(0, 9, "Courier Cost", heading_xf)
|
|
|
628 |
sheet.write(0, 10, "Risky", heading_xf)
|
|
|
629 |
sheet.write(0, 11, "Our SP", heading_xf)
|
| 9411 |
kshitij.so |
630 |
sheet.write(0, 13, "Our TP", heading_xf)
|
|
|
631 |
sheet.write(0, 12, "Our Offer Price", heading_xf)
|
| 9399 |
kshitij.so |
632 |
sheet.write(0, 14, "Our Rank", heading_xf)
|
|
|
633 |
sheet.write(0, 15, "Lowest Seller", heading_xf)
|
|
|
634 |
sheet.write(0, 16, "Lowest SP", heading_xf)
|
|
|
635 |
sheet.write(0, 17, "Lowest TP", heading_xf)
|
|
|
636 |
sheet.write(0, 18, "Lowest Offer Price", heading_xf)
|
|
|
637 |
sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
|
|
|
638 |
sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
|
|
|
639 |
sheet.write(0, 21, "Our NLC", heading_xf)
|
|
|
640 |
sheet.write(0, 22, "Lowest Possible TP", heading_xf)
|
|
|
641 |
sheet.write(0, 23, "Lowest Possible SP", heading_xf)
|
|
|
642 |
sheet.write(0, 24, "Competition Basis ", heading_xf)
|
|
|
643 |
sheet.write(0, 25, "Can Compete", heading_xf)
|
|
|
644 |
sheet.write(0, 26, "Target TP", heading_xf)
|
|
|
645 |
sheet.write(0, 27, "Target SP", heading_xf)
|
|
|
646 |
sheet.write(0, 28, "Sales Potential", heading_xf)
|
| 9396 |
kshitij.so |
647 |
|
|
|
648 |
i, sheet_iterator=1,1
|
|
|
649 |
for data in competitiveNoInventoryItems:
|
|
|
650 |
supc_data =data[0]
|
|
|
651 |
one_line = data[1]
|
|
|
652 |
|
|
|
653 |
courierCost = 45
|
|
|
654 |
|
|
|
655 |
if one_line.weight:
|
|
|
656 |
slab = int(((one_line.weight+0.05) - .001)/.5)
|
|
|
657 |
for x in range (0,slab):
|
|
|
658 |
courierCost = courierCost + 35
|
|
|
659 |
|
|
|
660 |
courierCost = courierCost * 1.1236
|
|
|
661 |
|
|
|
662 |
|
|
|
663 |
sheet.write(sheet_iterator, 0, one_line.item_id)
|
|
|
664 |
sheet.write(sheet_iterator, 1, one_line.category_name)
|
|
|
665 |
sheet.write(sheet_iterator, 2, one_line.product_group)
|
|
|
666 |
sheet.write(sheet_iterator, 3, supc_data.supc)
|
|
|
667 |
sheet.write(sheet_iterator, 4, one_line.brand)
|
|
|
668 |
sheet.write(sheet_iterator, 5, one_line.model_name)
|
|
|
669 |
sheet.write(sheet_iterator, 6, one_line.model_number)
|
|
|
670 |
sheet.write(sheet_iterator, 7, one_line.color)
|
|
|
671 |
sheet.write(sheet_iterator, 8, one_line.weight)
|
| 9400 |
kshitij.so |
672 |
sheet.write(sheet_iterator, 9, round(courierCost))
|
| 9399 |
kshitij.so |
673 |
sheet.write(sheet_iterator, 10, one_line.risky)
|
|
|
674 |
sheet.write(sheet_iterator, 11, supc_data.ourSp)
|
| 9411 |
kshitij.so |
675 |
sheet.write(sheet_iterator, 13, '-')
|
|
|
676 |
sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
|
| 9399 |
kshitij.so |
677 |
sheet.write(sheet_iterator, 14, supc_data.rank)
|
|
|
678 |
sheet.write(sheet_iterator, 15, supc_data.lowestSellerName)
|
|
|
679 |
sheet.write(sheet_iterator, 16, supc_data.lowestSp)
|
| 9396 |
kshitij.so |
680 |
if one_line.parent_category ==10011:
|
|
|
681 |
lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
|
|
|
682 |
else:
|
|
|
683 |
lowestTp = supc_data.lowestSp*0.9497-courierCost
|
| 9399 |
kshitij.so |
684 |
sheet.write(sheet_iterator, 17, round(lowestTp))
|
|
|
685 |
sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
|
|
|
686 |
sheet.write(sheet_iterator, 19, supc_data.otherInventory)
|
|
|
687 |
sheet.write(sheet_iterator, 20, supc_data.ourInventory)
|
|
|
688 |
sheet.write(sheet_iterator, 21, one_line.our_nlc)
|
| 9396 |
kshitij.so |
689 |
if supc_data.rank==1:
|
|
|
690 |
i+=1
|
|
|
691 |
sheet_iterator+=1
|
|
|
692 |
continue
|
|
|
693 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
|
|
694 |
lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
|
| 9399 |
kshitij.so |
695 |
sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
|
|
|
696 |
sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
|
| 9396 |
kshitij.so |
697 |
competitionBasis ='TP'
|
|
|
698 |
if (supc_data.lowestOfferPrice == supc_data.lowestSp):
|
|
|
699 |
competitionBasis ='SP'
|
| 9399 |
kshitij.so |
700 |
sheet.write(sheet_iterator, 24, 'SP')
|
| 9396 |
kshitij.so |
701 |
else:
|
| 9399 |
kshitij.so |
702 |
sheet.write(sheet_iterator, 24, 'TP')
|
| 9396 |
kshitij.so |
703 |
proposed_tp = 0
|
|
|
704 |
if lowestTp > lowest_possible_tp:
|
| 9399 |
kshitij.so |
705 |
sheet.write(sheet_iterator, 25, "Yes")
|
| 9396 |
kshitij.so |
706 |
if competitionBasis=='SP':
|
|
|
707 |
proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
|
|
|
708 |
proposed_tp = proposed_sp*.9597-courierCost
|
| 9399 |
kshitij.so |
709 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
710 |
sheet.write(sheet_iterator, 27, round(proposed_sp))
|
| 9396 |
kshitij.so |
711 |
else:
|
|
|
712 |
proposed_tp = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
|
| 9399 |
kshitij.so |
713 |
sheet.write(sheet_iterator, 26, round(proposed_tp))
|
|
|
714 |
sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
|
| 9396 |
kshitij.so |
715 |
else:
|
| 9399 |
kshitij.so |
716 |
sheet.write(sheet_iterator, 25, "No")
|
| 9396 |
kshitij.so |
717 |
|
|
|
718 |
if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
|
| 9399 |
kshitij.so |
719 |
sheet.write(sheet_iterator, 28, "HIGH")
|
| 9396 |
kshitij.so |
720 |
elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
|
| 9399 |
kshitij.so |
721 |
sheet.write(sheet_iterator, 28, "MEDIUM")
|
| 9396 |
kshitij.so |
722 |
else:
|
| 9399 |
kshitij.so |
723 |
sheet.write(sheet_iterator, 28, "LOW")
|
| 9396 |
kshitij.so |
724 |
i= i+1
|
|
|
725 |
sheet_iterator+=1
|
|
|
726 |
|
| 9451 |
kshitij.so |
727 |
def createSheetForNegativeMargin(negativeMargin,wbk):
|
|
|
728 |
sheet = wbk.add_sheet('Negative Margin')
|
|
|
729 |
|
|
|
730 |
heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
|
| 9396 |
kshitij.so |
731 |
|
| 9451 |
kshitij.so |
732 |
excel_integer_format = '0'
|
|
|
733 |
integer_style = xlwt.XFStyle()
|
|
|
734 |
integer_style.num_format_str = excel_integer_format
|
|
|
735 |
|
|
|
736 |
sheet.write(0, 0, "Item ID", heading_xf)
|
|
|
737 |
sheet.write(0, 1, "Category", heading_xf)
|
|
|
738 |
sheet.write(0, 2, "Product Group.", heading_xf)
|
|
|
739 |
sheet.write(0, 3, "SUPC", heading_xf)
|
|
|
740 |
sheet.write(0, 4, "Brand", heading_xf)
|
|
|
741 |
sheet.write(0, 5, "Model Name", heading_xf)
|
|
|
742 |
sheet.write(0, 6, "Model Number", heading_xf)
|
|
|
743 |
sheet.write(0, 7, "Color", heading_xf)
|
|
|
744 |
sheet.write(0, 8, "Weight", heading_xf)
|
|
|
745 |
sheet.write(0, 9, "Courier Cost", heading_xf)
|
|
|
746 |
sheet.write(0, 10, "Risky", heading_xf)
|
|
|
747 |
sheet.write(0, 11, "Our SP", heading_xf)
|
|
|
748 |
sheet.write(0, 13, "Our TP", heading_xf)
|
|
|
749 |
sheet.write(0, 12, "Our Offer Price", heading_xf)
|
|
|
750 |
sheet.write(0, 14, "Our Rank", heading_xf)
|
| 9483 |
kshitij.so |
751 |
sheet.write(0, 15, "Our NLC", heading_xf)
|
|
|
752 |
sheet.write(0, 16, "Margin", heading_xf)
|
| 9451 |
kshitij.so |
753 |
|
|
|
754 |
i, sheet_iterator=1,1
|
|
|
755 |
for data in negativeMargin:
|
|
|
756 |
supc_data =data[0]
|
|
|
757 |
one_line = data[1]
|
|
|
758 |
|
|
|
759 |
courierCost = 45
|
|
|
760 |
|
|
|
761 |
if one_line.weight:
|
|
|
762 |
slab = int(((one_line.weight+0.05) - .001)/.5)
|
|
|
763 |
for x in range (0,slab):
|
|
|
764 |
courierCost = courierCost + 35
|
|
|
765 |
|
|
|
766 |
courierCost = courierCost * 1.1236
|
|
|
767 |
|
| 9483 |
kshitij.so |
768 |
'''if one_line.parent_category ==10011:
|
|
|
769 |
lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
|
|
|
770 |
else:
|
|
|
771 |
lowestTp = supc_data.lowestSp*0.9497-courierCost
|
|
|
772 |
'''
|
| 9451 |
kshitij.so |
773 |
|
| 9483 |
kshitij.so |
774 |
lowest_possible_tp = one_line.our_nlc/0.988+15+6
|
|
|
775 |
|
| 9451 |
kshitij.so |
776 |
sheet.write(sheet_iterator, 0, one_line.item_id)
|
|
|
777 |
sheet.write(sheet_iterator, 1, one_line.category_name)
|
|
|
778 |
sheet.write(sheet_iterator, 2, one_line.product_group)
|
|
|
779 |
sheet.write(sheet_iterator, 3, supc_data.supc)
|
|
|
780 |
sheet.write(sheet_iterator, 4, one_line.brand)
|
|
|
781 |
sheet.write(sheet_iterator, 5, one_line.model_name)
|
|
|
782 |
sheet.write(sheet_iterator, 6, one_line.model_number)
|
|
|
783 |
sheet.write(sheet_iterator, 7, one_line.color)
|
|
|
784 |
sheet.write(sheet_iterator, 8, one_line.weight)
|
|
|
785 |
sheet.write(sheet_iterator, 9, round(courierCost))
|
|
|
786 |
sheet.write(sheet_iterator, 10, one_line.risky)
|
|
|
787 |
sheet.write(sheet_iterator, 11, supc_data.ourSp)
|
| 9483 |
kshitij.so |
788 |
sheet.write(sheet_iterator, 13, round(supc_data.ourSp*0.9597-courierCost))
|
| 9451 |
kshitij.so |
789 |
sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
|
|
|
790 |
sheet.write(sheet_iterator, 14, supc_data.rank)
|
| 9483 |
kshitij.so |
791 |
sheet.write(sheet_iterator, 15, one_line.our_nlc)
|
|
|
792 |
sheet.write(sheet_iterator, 16, round((supc_data.ourSp*0.9597-courierCost) - lowest_possible_tp))
|
| 9451 |
kshitij.so |
793 |
i= i+1
|
|
|
794 |
sheet_iterator+=1
|
|
|
795 |
|
| 9396 |
kshitij.so |
796 |
|
| 9334 |
kshitij.so |
797 |
def main():
|
|
|
798 |
parser = optparse.OptionParser()
|
|
|
799 |
parser.add_option("-f", "--file", dest="filename",
|
|
|
800 |
default="ItemList.xls", type="string",
|
|
|
801 |
help="Read the item list from FILE",
|
|
|
802 |
metavar="FILE")
|
|
|
803 |
(options, args) = parser.parse_args()
|
|
|
804 |
if len(args) != 0:
|
|
|
805 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
|
|
806 |
filename = options.filename
|
|
|
807 |
read_data(filename)
|
|
|
808 |
|
|
|
809 |
if __name__ == '__main__':
|
|
|
810 |
main()
|
| 9451 |
kshitij.so |
811 |
|