Subversion Repositories SmartDukaan

Rev

Rev 10278 | Rev 10307 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8739 vikram.rag 1
package in.shop2020.support.controllers;
2
 
10287 kshitij.so 3
import in.shop2020.config.ConfigException;
8739 vikram.rag 4
import in.shop2020.model.v1.catalog.CatalogService.Client;
9242 kshitij.so 5
import in.shop2020.model.v1.catalog.CatalogServiceException;
6
import in.shop2020.model.v1.catalog.Item;
9725 kshitij.so 7
import in.shop2020.model.v1.catalog.MarketplaceItems;
9780 kshitij.so 8
import in.shop2020.model.v1.catalog.MarketplacePercentage;
8739 vikram.rag 9
import in.shop2020.model.v1.catalog.SnapdealItem;
9242 kshitij.so 10
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
9725 kshitij.so 11
import in.shop2020.model.v1.inventory.InventoryServiceException;
12
import in.shop2020.model.v1.inventory.InventoryType;
13
import in.shop2020.model.v1.inventory.ItemInventory;
9923 kshitij.so 14
import in.shop2020.model.v1.inventory.OOSStatus;
9725 kshitij.so 15
import in.shop2020.model.v1.inventory.Warehouse;
16
import in.shop2020.model.v1.inventory.WarehouseType;
8886 vikram.rag 17
import in.shop2020.model.v1.order.SnapdealOrder;
8739 vikram.rag 18
import in.shop2020.support.utils.ReportsUtils;
10225 vikram.rag 19
import in.shop2020.support.utils.UpdateSDPricingUsingPanel;
8739 vikram.rag 20
import in.shop2020.thrift.clients.CatalogClient;
9478 kshitij.so 21
import in.shop2020.thrift.clients.InventoryClient;
8739 vikram.rag 22
import in.shop2020.thrift.clients.TransactionClient;
10287 kshitij.so 23
import in.shop2020.thrift.clients.config.ConfigClient;
9725 kshitij.so 24
import in.shop2020.utils.GmailUtils;
25
import javax.mail.MessagingException;
8739 vikram.rag 26
 
27
import java.io.BufferedInputStream;
28
import java.io.File;
29
import java.io.FileInputStream;
30
import java.io.FileNotFoundException;
31
import java.io.FileOutputStream;
32
import java.io.FileWriter;
33
import java.io.IOException;
34
import java.io.InputStream;
9242 kshitij.so 35
import java.text.DecimalFormat;
8739 vikram.rag 36
import java.util.ArrayList;
9242 kshitij.so 37
import java.util.Arrays;
8739 vikram.rag 38
import java.util.HashMap;
39
import java.util.List;
40
import java.util.Map;
41
 
42
import javax.servlet.ServletContext;
43
import javax.servlet.ServletOutputStream;
44
import javax.servlet.http.HttpServletRequest;
45
import javax.servlet.http.HttpServletResponse;
46
import javax.servlet.http.HttpSession;
47
 
48
import org.apache.commons.io.FileUtils;
49
import org.apache.commons.lang.xwork.StringUtils;
50
import org.apache.poi.hssf.usermodel.HSSFRow;
51
import org.apache.poi.hssf.usermodel.HSSFSheet;
52
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
53
import org.apache.poi.ss.usermodel.Cell;
54
import org.apache.struts2.convention.annotation.InterceptorRef;
55
import org.apache.struts2.convention.annotation.InterceptorRefs;
56
import org.apache.struts2.interceptor.ServletRequestAware;
57
import org.apache.struts2.interceptor.ServletResponseAware;
58
import org.apache.struts2.util.ServletContextAware;
59
import org.apache.thrift.TException;
60
import org.apache.thrift.transport.TTransportException;
9242 kshitij.so 61
import org.json.JSONException;
62
import org.json.JSONObject;
8739 vikram.rag 63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65
 
66
import com.opensymphony.xwork2.ValidationAwareSupport;
67
 
9825 kshitij.so 68
@SuppressWarnings({"unused","deprecation"})
9242 kshitij.so 69
 
70
@InterceptorRefs({
71
	@InterceptorRef("defaultStack"),
72
	@InterceptorRef("login")
73
})
74
 
8739 vikram.rag 75
public class SnapdealListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
9242 kshitij.so 76
	/**
77
	 * 
78
	 */
79
	private static final long serialVersionUID = 1L;
80
 
81
 
8739 vikram.rag 82
	private static Logger logger = LoggerFactory.getLogger(SnapdealListController.class);
83
 
84
 
85
	private HttpServletRequest request;
86
	private HttpServletResponse response;
87
	private HttpSession session;
88
	private ServletContext context;
89
	private String url;
90
	private String itemId;
91
	private String isSnapdealListed;
92
	private String exceptionPrice;
93
	private String warehouseId;
94
	private File file;
95
	private String errMsg;
96
	private String next;
97
	private String id;
9242 kshitij.so 98
	private String searchText;
99
	private List<SnapdealItemDetails> snapdealItems;
100
	private long searchCount;
101
	private long totalCount;
102
	private String sellingPrice;
103
	private String transferPrice;
104
	private String webisteMrp;
105
	private String webisteSellingPrice;
106
	private String isListedOnSnapdeal;
107
	private String commission;
108
	private String serviceTax;
109
	private String courierCost;
110
	private JSONObject itemObj;
111
	private String isSuppressInventoryFeed;
112
	private String isSuppressPriceFeed;
9478 kshitij.so 113
	private String maxNlc;
114
	private String sdItemCode;
9568 kshitij.so 115
	private String supc;
9725 kshitij.so 116
	private String held;
117
	private String lastUpdatedInventoryTimestamp;
118
	private String lastCheckedTimestamp;
119
	private String otherCost;
120
	private String isAutoIncrement;
121
	private String isAutoDecrement;
122
	private String isManualFavourite;
123
	private String isAutoFavourite;
124
	private String currentSp;
125
	private String currentTp;
126
	private String minPosSp;
127
	private String minPosTp;
128
	private String vat;
9734 kshitij.so 129
	private String comparsionResult;
9923 kshitij.so 130
	private String maxSp;
131
	private String nDaySale;
10287 kshitij.so 132
	private static String live;
9923 kshitij.so 133
 
134
	public String getnDaySale() {
135
		return nDaySale;
136
	}
137
 
138
	public void setnDaySale(String nDaySale) {
139
		this.nDaySale = nDaySale;
140
	}
141
 
142
	private String avgSale;
143
 
144
	public String getAvgSale() {
145
		return avgSale;
146
	}
147
 
148
	public void setAvgSale(String avgSale) {
149
		this.avgSale = avgSale;
150
	}
151
 
152
	public String getMaxSp() {
153
		return maxSp;
154
	}
155
 
156
	public void setMaxSp(String maxSp) {
157
		this.maxSp = maxSp;
158
	}
159
 
9734 kshitij.so 160
	public String getComparsionResult() {
161
		return comparsionResult;
162
	}
8739 vikram.rag 163
 
9734 kshitij.so 164
	public void setComparsionResult(String comparsionResult) {
165
		this.comparsionResult = comparsionResult;
166
	}
167
 
168
	private Map<Integer, Long> holdInventoryMap;
169
 
9725 kshitij.so 170
	public String getVat() {
171
		return vat;
172
	}
9242 kshitij.so 173
 
9725 kshitij.so 174
	public void setVat(String vat) {
175
		this.vat = vat;
176
	}
9242 kshitij.so 177
 
9725 kshitij.so 178
	public String getOtherCost() {
179
		return otherCost;
180
	}
181
 
182
	public void setOtherCost(String otherCost) {
183
		this.otherCost = otherCost;
184
	}
185
 
186
 
187
	public String getCurrentSp() {
188
		return currentSp;
189
	}
190
 
191
	public void setCurrentSp(String currentSp) {
192
		this.currentSp = currentSp;
193
	}
194
 
195
	public String getCurrentTp() {
196
		return currentTp;
197
	}
198
 
199
	public void setCurrentTp(String currentTp) {
200
		this.currentTp = currentTp;
201
	}
202
 
203
 
204
	public String getLastCheckedTimestamp() {
205
		return lastCheckedTimestamp;
206
	}
207
 
208
	public String getLastUpdatedInventoryTimestamp() {
209
		return lastUpdatedInventoryTimestamp;
210
	}
211
 
212
	public void setLastUpdatedInventoryTimestamp(
213
			String lastUpdatedInventoryTimestamp) {
214
		this.lastUpdatedInventoryTimestamp = lastUpdatedInventoryTimestamp;
215
	}
216
 
217
	public void setLastCheckedTimestamp(
218
			String lastCheckedTimestamp) {
219
		this.lastCheckedTimestamp = lastCheckedTimestamp;
220
	}
221
 
222
	public String getIsAutoIncrement() {
223
		return isAutoIncrement;
224
	}
225
 
226
	public void setIsAutoIncrement(String isAutoIncrement) {
227
		this.isAutoIncrement = isAutoIncrement;
228
	}
229
 
230
	public String getIsAutoDecrement() {
231
		return isAutoDecrement;
232
	}
233
 
234
	public void setIsAutoDecrement(String isAutoDecrement) {
235
		this.isAutoDecrement = isAutoDecrement;
236
	}
237
 
238
	public String getIsManualFavourite() {
239
		return isManualFavourite;
240
	}
241
 
242
	public void setIsManualFavourite(String isManualFavourite) {
243
		this.isManualFavourite = isManualFavourite;
244
	}
245
 
246
	public String getIsAutoFavourite() {
247
		return isAutoFavourite;
248
	}
249
 
250
	public void setIsAutoFavourite(String isAutoFavourite) {
251
		this.isAutoFavourite = isAutoFavourite;
252
	}
253
 
254
	public String getMinPosSp() {
255
		return minPosSp;
256
	}
257
 
258
	public void setMinPosSp(String minPosSp) {
259
		this.minPosSp = minPosSp;
260
	}
261
 
262
	public String getMinPosTp() {
263
		return minPosTp;
264
	}
265
 
266
	public void setMinPosTp(String minPosTp) {
267
		this.minPosTp = minPosTp;
268
	}
269
 
270
	public String getHeld() {
271
		return held;
272
	}
273
 
274
	public void setHeld(String held) {
275
		this.held = held;
276
	}
277
 
9568 kshitij.so 278
	public String getSupc() {
279
		return supc;
280
	}
281
 
282
	public void setSupc(String supc) {
283
		this.supc = supc;
284
	}
285
 
9478 kshitij.so 286
	public String getSdItemCode() {
287
		return sdItemCode;
288
	}
289
 
290
	public void setSdItemCode(String sdItemCode) {
291
		this.sdItemCode = sdItemCode;
292
	}
10287 kshitij.so 293
 
294
 
295
	static{
296
		try {
297
			live = ConfigClient.getClient().get("sync_price_on_marketplace");
298
			logger.info("Update_price_on_mp"+live);
299
		} catch (ConfigException e) {
300
		    logger.error("Unable to get parameter from the config service", e);
301
		    live = "false";
302
		}
303
	}
9478 kshitij.so 304
 
8739 vikram.rag 305
	public String index() {
306
		if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
307
			return "authfail";
308
		}
309
		return "index";
310
	}
311
 
9242 kshitij.so 312
	public String edit() {
313
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
314
			return "authfail";
315
		}
316
		return "edit";
317
	}
318
 
319
	public String fetchItems() throws TException {
320
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
321
		if (searchText.length() == 0) {
322
			snapdealItems = CatalogClient.getSnapdealItems(Long.valueOf(next), 10);
323
			totalCount = CatalogClient.getCountForSnapdealItems();
324
			setSearchCount(totalCount);
325
		} else {
326
			List<String> subString = Arrays.asList(searchText.split(" "));
327
			snapdealItems = CatalogClient.searchSnapdealItems(subString,Long.valueOf(next), 10);
328
			totalCount = CatalogClient.getCountForSnapdealItems();
329
			searchCount = CatalogClient.getSnapdealSearchResultCount(subString);
330
		}
331
		return "snapdeal-item-table";
332
	}
333
 
334
	public SnapdealItemDetails fetchItemDetail() throws NumberFormatException, TException {
335
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
9725 kshitij.so 336
		SnapdealItemDetails sdItemDetails = CatalogClient.getSnapdealItemDetails(Long.valueOf(id));
337
		lastUpdatedInventoryTimeStampForItem(sdItemDetails.getLastUpdatedInventoryTimestamp());
338
		return sdItemDetails;
9242 kshitij.so 339
	}
340
 
9725 kshitij.so 341
	public MarketplaceItems fetchMarketplaceDetail() throws NumberFormatException, TException {
342
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
343
		MarketplaceItems mpItemDetails = CatalogClient.getMarketplacedetailsForItem(Long.valueOf(id), 7);
344
		lastCheckedTimeStampForItem(mpItemDetails.getLastCheckedTimestamp());
345
		return mpItemDetails;
346
	}
347
 
348
	public void lastUpdatedInventoryTimeStampForItem(long timestamp){
349
		setLastUpdatedInventoryTimestamp(new java.util.Date(timestamp).toLocaleString());
350
	}
351
 
352
	public void lastCheckedTimeStampForItem(long timestamp){
353
		setLastCheckedTimestamp(new java.util.Date(timestamp).toLocaleString());
354
	}
355
 
8739 vikram.rag 356
	public String uploadBulkSheet(){
357
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
358
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
359
			return "authfail";
360
		}
361
		return "snapdeal-bulk-upload";
362
	}
9242 kshitij.so 363
 
9734 kshitij.so 364
	public String update() throws NumberFormatException, TException, InventoryServiceException, CatalogServiceException, JSONException{
9242 kshitij.so 365
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
9825 kshitij.so 366
		//Client catalogClientProd = new CatalogClient().getClient();
10225 vikram.rag 367
		Long timestamp = System.currentTimeMillis();
9242 kshitij.so 368
		SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
10228 vikram.rag 369
		Double oldPrice = snapdealItem.getSellingPrice(); 
9825 kshitij.so 370
		Item item = catalogClient.getItem(Long.valueOf(itemId));
9780 kshitij.so 371
		MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
372
		if (mpCosting.getSource()==0){
373
			throw new CatalogServiceException();
374
		}
9725 kshitij.so 375
		MarketplaceItems mpItem = catalogClient.getMarketplacedetailsForItem(Long.valueOf(itemId),7);
9780 kshitij.so 376
		mpItem.setEmiFee(mpCosting.getEmiFee());
377
		mpItem.setReturnProvision(mpCosting.getReturnProvision());
378
		mpItem.setClosingFee(mpCosting.getClosingFee());
379
		mpItem.setServiceTax(mpCosting.getServiceTax());
380
		mpItem.setCommission(mpCosting.getCommission());
10287 kshitij.so 381
		mpItem.setPgFee(mpCosting.getPgFee());
9725 kshitij.so 382
		InventoryClient inventoryServiceClient = new InventoryClient();
383
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9825 kshitij.so 384
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
385
		/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
9725 kshitij.so 386
			throw new InventoryServiceException();
9780 kshitij.so 387
		}*/
388
		snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
389
		snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
390
		snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
391
		snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
392
		snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
393
		snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
394
		snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
395
		snapdealItem.setCourierCost(Double.valueOf(courierCost));
396
		snapdealItem.setCommission(Double.valueOf(commission));
397
		snapdealItem.setServiceTax(Double.valueOf(serviceTax));
398
		snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
399
		snapdealItem.setSkuAtSnapdeal(sdItemCode);
400
		snapdealItem.setSupc(supc);
9734 kshitij.so 401
		MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
9825 kshitij.so 402
		//double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
403
		//t_mpItem.setVat(vat);
9780 kshitij.so 404
		snapdealItem.setUpdatedBy(getUserName());
405
		snapdealItem.setMarketplaceItems(t_mpItem);
406
 
9825 kshitij.so 407
		if(!compareParameters(t_mpItem,snapdealItem,warehouse,item.getWeight())){
9734 kshitij.so 408
			setComparsionResult("0");
409
			return "snapdeal-update-result";
410
		}
411
		else{
412
			setComparsionResult("1");
413
		}
9478 kshitij.so 414
 
9780 kshitij.so 415
		if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
9725 kshitij.so 416
			throw new CatalogServiceException();
417
		}
9780 kshitij.so 418
 
9725 kshitij.so 419
		if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
420
			sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
421
		}
10139 amar.kumar 422
		logger.info("\nUpdate Method Item Id "+itemId+"\nSelling Price "+sellingPrice+"\nWarehouse Id "+warehouseId+"\nMax Nlc "+maxNlc+"\nUpdated By: "+session.getAttribute(ReportsUtils.USER_NAME).toString());
10287 kshitij.so 423
		if(oldPrice!=Double.valueOf(sellingPrice) && Boolean.valueOf(live) && snapdealItem.isSuppressPriceFeed() && snapdealItem.isIsListedOnSnapdeal()){
10226 vikram.rag 424
			logger.info("Calling Method to update price at snapdeal");
10225 vikram.rag 425
			UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(Float.valueOf(sellingPrice),supc,item,timestamp);
10226 vikram.rag 426
			logger.info("Calling Thread to update price at snapdeal");
10225 vikram.rag 427
			updatePriceOnSnapdeal.start();	
428
		}
9734 kshitij.so 429
		return "snapdeal-update-result";
9242 kshitij.so 430
	}
10278 kshitij.so 431
 
432
 
433
	public void updateForAutoPricing() throws NumberFormatException, CatalogServiceException, TException{
434
		logger.info("Calling Method to update price at snapdeal for auto pricing");
435
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
436
		Item item = catalogClient.getItem(Long.valueOf(itemId));
437
		UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(Float.valueOf(sellingPrice),supc,item,System.currentTimeMillis());
438
		logger.info("Calling Thread to update price at snapdeal for auto pricing");
439
		updatePriceOnSnapdeal.start();	
440
	}
9242 kshitij.so 441
 
10287 kshitij.so 442
 
9825 kshitij.so 443
	public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem, Warehouse warehouse,double weight) throws TException, JSONException, CatalogServiceException{
9734 kshitij.so 444
		double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
445
		double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
446
		double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
9780 kshitij.so 447
		double lowest_possible_tp = nlc+inHouseCost;
10287 kshitij.so 448
		double our_tp =  snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*((mpItem.getCommission()/100)+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100))-(Math.max(20,(mpItem.getPgFee()/100)*snapdealItem.getSellingPrice())*(1+(mpItem.getServiceTax()/100)));
449
		double commission=0.0;
450
		if ((mpItem.getPgFee()/100)*snapdealItem.getSellingPrice()>=20){
451
			commission =  (((mpItem.getCommission()/100)+mpItem.getPgFee()/100)*snapdealItem.getSellingPrice());
452
		}
453
		else{
454
			commission =  ((mpItem.getCommission()/100)*snapdealItem.getSellingPrice()+20);
455
		}
9780 kshitij.so 456
		double service_tax = (mpItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost());
10287 kshitij.so 457
		double lowest_possible_sp = 0.0;
458
		if ((mpItem.getPgFee()/100)*snapdealItem.getSellingPrice()>=20){
459
			lowest_possible_sp = (nlc+(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat()/100))+(15+mpItem.getOtherCost())*(1+(mpItem.getVat())/100))/(1-((mpItem.getCommission()/100)+mpItem.getEmiFee()/100+mpItem.getPgFee()/100)*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat())/100)-(mpItem.getReturnProvision()/100)*(1+(mpItem.getVat())/100));
460
		}
461
		else{
462
			lowest_possible_sp = (nlc+(snapdealItem.getCourierCost()+mpItem.getClosingFee()+20)*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat()/100))+(15+mpItem.getOtherCost())*(1+(mpItem.getVat())/100))/(1-((mpItem.getCommission()/100)+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))*(1+(mpItem.getVat())/100)-(mpItem.getReturnProvision()/100)*(1+(mpItem.getVat())/100));
463
		}
9923 kshitij.so 464
		double vat_rate_prod = getVatRateForItem(warehouse,snapdealItem.getSellingPrice(),snapdealItem.getItem_id());
9780 kshitij.so 465
		JSONObject x = new JSONObject();
466
		x.put("NLC", nlc);
467
		x.put("VAT", vat);
9923 kshitij.so 468
		x.put("COURIER COST",getCourierCost(weight));
9780 kshitij.so 469
		x.put("LOWEST POS TP", lowest_possible_tp);
470
		x.put("TP", our_tp);
471
		x.put("COMMISSION", commission);
472
		x.put("SERVICE TAX", service_tax);
473
		x.put("LOWEST POS SP", lowest_possible_sp);
9923 kshitij.so 474
		x.put("VAT RATE",vat_rate_prod);
9780 kshitij.so 475
		logger.info("Snapdeal Backend validation "+x.toString());
476
		boolean compare_result=true;
9923 kshitij.so 477
 
9825 kshitij.so 478
		if(!(getCourierCost(weight)==snapdealItem.getCourierCost())){
479
			compare_result=false;
480
		}
9923 kshitij.so 481
 
482
		if(!(vat_rate_prod==mpItem.getVat())){
9825 kshitij.so 483
			compare_result=false;
484
		}
9923 kshitij.so 485
 
9780 kshitij.so 486
		if(!(nlc==snapdealItem.getMaxNlc())){
487
			compare_result=false;
488
		}
489
		if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
490
			compare_result=false;
491
		}
492
		if(!(our_tp-snapdealItem.getTransferPrice()>-1 && our_tp-snapdealItem.getTransferPrice()<1)){
493
			compare_result=false;
494
		}
495
		if(!(commission-snapdealItem.getCommission()>-1 && commission-snapdealItem.getCommission()<1)){
496
			compare_result=false;
497
		}
498
		if(!(service_tax-snapdealItem.getServiceTax()>-1 && service_tax-snapdealItem.getServiceTax()<1)){
499
			compare_result=false;
500
		}
501
		if(!(lowest_possible_sp-mpItem.getMinimumPossibleSp()>-1 && lowest_possible_sp-mpItem.getMinimumPossibleSp()<1)){
502
			compare_result=false;
503
		}
504
		return compare_result;
505
 
9734 kshitij.so 506
	}
9923 kshitij.so 507
 
9825 kshitij.so 508
	public double getVatRateForItem(Warehouse warehouse, double sellingPrice,long itemId) throws CatalogServiceException, TException{
509
		Client catalogClientProd = new CatalogClient().getClient();
510
		return catalogClientProd.getVatPercentageForItem(itemId, warehouse.getStateId(), sellingPrice);
511
	}
9780 kshitij.so 512
 
9734 kshitij.so 513
	public double getNlcForWarehouse(long warehouseId,long item_id) throws TException{
514
		InventoryClient inventoryServiceClient = new InventoryClient();
515
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
516
		return inventoryClient.getNlcForWarehouse(warehouseId, item_id);
517
	}
9780 kshitij.so 518
 
9734 kshitij.so 519
	public double getCourierCost(double weight){
9825 kshitij.so 520
		double cCost = 45.0;
521
		int slabs = (int) ((weight+.05 - .001)/(.5));
9734 kshitij.so 522
		for(int i=0;i<slabs;i++){
523
			cCost = cCost + 35;
524
		}
525
		return cCost;
526
	}
527
 
9923 kshitij.so 528
	public void getLastNDaySaleForItem(String itemId,String days) {
529
		try{
530
			InventoryClient inventoryServiceClient = new InventoryClient();
531
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
532
			List<OOSStatus> oosStatuses = inventoryClient.getOosStatusesForXDaysForItem(Long.valueOf(itemId), 7, Integer.valueOf(days));
533
			String lastNdaySale="";
534
			double avgSale = 0.0;
535
			long count = 0,sale = 0;
536
			for(OOSStatus oosStatus : oosStatuses){
537
				if(oosStatus.isIs_oos()){
538
					lastNdaySale += "X-";
539
				}else{
540
					lastNdaySale += oosStatus.getNum_orders() + "-";
541
					sale = sale + oosStatus.getNum_orders();
542
					count+=1;
543
				}
544
			}
545
			lastNdaySale = lastNdaySale.substring(0, lastNdaySale.length()-1);
546
			lastNdaySale += "\n";
547
			setnDaySale(lastNdaySale);
548
			if (count!=0){
9924 kshitij.so 549
				setAvgSale(String.valueOf(roundTwoDecimals(sale/(double)count)));
9923 kshitij.so 550
			}
551
			else{
552
				setAvgSale("0");
553
			}
554
		}
555
		catch (Exception e){
556
			setAvgSale("0");
557
			setnDaySale("Unable to fetch");
558
			logger.error("Unable to get last n day sale",e);
559
		}
9734 kshitij.so 560
 
9923 kshitij.so 561
	}
562
 
563
 
9725 kshitij.so 564
	private MarketplaceItems updateMarketplaceItemDetails(MarketplaceItems mpItem){
565
		mpItem.setItemId(Long.valueOf(itemId));
566
		mpItem.setSource(7);
567
		mpItem.setVat(Double.valueOf(vat));
568
		mpItem.setCourierCost(Double.valueOf(courierCost));
569
		mpItem.setOtherCost(Double.valueOf(otherCost));
570
		mpItem.setCurrentSp(Double.valueOf(sellingPrice));
571
		mpItem.setCurrentTp(Double.valueOf(transferPrice));
572
		mpItem.setAutoDecrement(Boolean.valueOf(isAutoDecrement));
573
		mpItem.setAutoIncrement(Boolean.valueOf(isAutoIncrement));
574
		mpItem.setManualFavourite(Boolean.valueOf(isManualFavourite));
575
		mpItem.setMinimumPossibleSp(Double.valueOf(minPosSp));
576
		mpItem.setMinimumPossibleTp(Double.valueOf(minPosTp));
9923 kshitij.so 577
		mpItem.setMaximumSellingPrice(Double.valueOf(maxSp));
9725 kshitij.so 578
		return mpItem;
579
	}
580
 
581
	private void sendAlert(long itemId,double sp,double minSp){
582
		Item item;
583
		try{
584
			Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
585
			item= catalogClient.getItem(itemId);
586
		}
587
		catch(Exception e){
588
			e.printStackTrace();
589
			return;
590
		}
591
		String emailSubjectTxt="Snapdeal SP is set below Min Possible SP";
9729 kshitij.so 592
		String[] sendTo=new String[]{ "kshitij.sood@saholic.com","rajneesh.arora@saholic.com","rajveer.singh@saholic.com","vikram.raghav@saholic.com"};
9780 kshitij.so 593
		String text = "Item Details-\nItem Id: "+itemId+"\nProduct Name: "+item.getBrand()+" "+item.getModelName()+" "+item.getModelNumber()+" "+item.getColor()+"\nSellingPrice: "+sp+"\nMinPossibleSp: "+minSp+"\nUpdated By: "+session.getAttribute(ReportsUtils.USER_NAME).toString();
9725 kshitij.so 594
		logger.info(text);
595
		String emailFromAddress = "build@shop2020.in";
596
		String password = "cafe@nes";
597
		GmailUtils mailer = new GmailUtils();
598
		try {
9780 kshitij.so 599
			mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
9725 kshitij.so 600
		}
601
		catch (Exception e) {
9729 kshitij.so 602
			logger.info(e.toString());
9725 kshitij.so 603
		}
604
	}
605
 
9780 kshitij.so 606
	public String addNewItem() throws TException, NumberFormatException, InventoryServiceException, CatalogServiceException, JSONException{
9725 kshitij.so 607
		InventoryClient inventoryServiceClient = new InventoryClient();
608
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9780 kshitij.so 609
		Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
9825 kshitij.so 610
		Item item = catalogClient.getItem(Long.valueOf(itemId));
611
		//Client catalogClientProd = new CatalogClient().getClient();
9780 kshitij.so 612
		MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
9923 kshitij.so 613
 
9780 kshitij.so 614
		if (mpCosting.getSource()==0){
615
			throw new CatalogServiceException();
616
		}
9825 kshitij.so 617
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
618
		/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
9725 kshitij.so 619
			throw new InventoryServiceException();
9780 kshitij.so 620
		}*/
9242 kshitij.so 621
		SnapdealItem snapdealItem = new SnapdealItem();
622
		snapdealItem.setItem_id(Long.valueOf(itemId));
623
		snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
624
		snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
625
		snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
626
		snapdealItem.setSuppressPriceFeed(Boolean.valueOf(isSuppressPriceFeed));
627
		snapdealItem.setTransferPrice(Double.valueOf(transferPrice));
628
		snapdealItem.setExceptionPrice(Double.valueOf(exceptionPrice));
629
		snapdealItem.setSellingPrice(Double.valueOf(sellingPrice));
630
		snapdealItem.setCourierCost(Double.valueOf(courierCost));
631
		snapdealItem.setCommission(Double.valueOf(commission));
632
		snapdealItem.setServiceTax(Double.valueOf(serviceTax));
9478 kshitij.so 633
		snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
634
		snapdealItem.setSkuAtSnapdeal(sdItemCode);
9568 kshitij.so 635
		snapdealItem.setSupc(supc);
9780 kshitij.so 636
		snapdealItem.setUpdatedBy(getUserName());
9734 kshitij.so 637
 
9725 kshitij.so 638
		MarketplaceItems mpItem = new MarketplaceItems();
639
		MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
9825 kshitij.so 640
		/*double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
641
		t_mpItem.setVat(vat);*/
9780 kshitij.so 642
		t_mpItem.setCommission(mpCosting.getCommission());
643
		t_mpItem.setServiceTax(mpCosting.getServiceTax());
644
		t_mpItem.setReturnProvision(mpCosting.getReturnProvision());
645
		t_mpItem.setEmiFee(mpCosting.getEmiFee());
646
		t_mpItem.setClosingFee(mpCosting.getClosingFee());
10287 kshitij.so 647
		t_mpItem.setPgFee(mpCosting.getPgFee());
9825 kshitij.so 648
		if(!compareParameters(t_mpItem,snapdealItem,warehouse,item.getWeight())){
9780 kshitij.so 649
			setComparsionResult("0");
650
			return "snapdeal-update-result";
651
		}
652
		else{
653
			setComparsionResult("1");
654
		}
655
		snapdealItem.setMarketplaceItems(t_mpItem);
10225 vikram.rag 656
		Long timestamp = System.currentTimeMillis();
9780 kshitij.so 657
		boolean result = catalogClient.addOrUpdateSnapdealItem(snapdealItem);
9725 kshitij.so 658
		if(!result){
659
			throw new CatalogServiceException();
660
		}
661
		if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
662
			sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
663
		}
10287 kshitij.so 664
		if (Boolean.valueOf(live) && snapdealItem.isSuppressPriceFeed() && snapdealItem.isIsListedOnSnapdeal()){
665
			logger.info("Calling Method to update new item price at snapdeal");
666
			UpdateSDPricingUsingPanel updatePriceOnSnapdeal = new UpdateSDPricingUsingPanel(Float.valueOf(sellingPrice),supc,item,timestamp);
667
			logger.info("Calling Thread to update new item price at snapdeal");
668
			updatePriceOnSnapdeal.start();
669
		}
9780 kshitij.so 670
		return "snapdeal-update-result";
9242 kshitij.so 671
	}
672
 
9780 kshitij.so 673
 
9242 kshitij.so 674
	public String getAddNewItemForm(){
675
		return "snapdeal-add-item";
676
	}
677
 
9725 kshitij.so 678
	public String getItemDetailsInJson() throws NumberFormatException, CatalogServiceException, TException, JSONException, InventoryServiceException{
9825 kshitij.so 679
		Client catalogClientProd = new CatalogClient().getClient();
9242 kshitij.so 680
		Client catalogClient =new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
681
		SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
9780 kshitij.so 682
		MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
9242 kshitij.so 683
		if (snapdealItem.getItem_id()!=0){
684
			throw new CatalogServiceException();
685
		}
686
		Item item = catalogClient.getItem(Long.valueOf(itemId));
687
		if (item.getId()==0){
688
			throw new CatalogServiceException();
689
		}
9478 kshitij.so 690
		InventoryClient inventoryServiceClient = new InventoryClient();
691
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9825 kshitij.so 692
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
693
		/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
9725 kshitij.so 694
			throw new InventoryServiceException();
9780 kshitij.so 695
		}*/
696
		double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
9825 kshitij.so 697
		double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
9780 kshitij.so 698
		if (maxNLC==0){
699
			throw new InventoryServiceException();
9725 kshitij.so 700
		}
9242 kshitij.so 701
		itemObj = new JSONObject();
702
		itemObj.put("ItemId", item.getId());
703
		itemObj.put("Brand", item.getBrand());
704
		itemObj.put("ModelName", item.getModelName());
705
		itemObj.put("ModelNumber", item.getModelNumber());
706
		itemObj.put("Color", item.getColor());
707
		itemObj.put("Weight", item.getWeight());
708
		itemObj.put("Risky", item.isRisky());
709
		itemObj.put("Status", item.getItemStatus());
710
		itemObj.put("MRP", item.getMrp());
711
		itemObj.put("SellingPrice", item.getSellingPrice());
9478 kshitij.so 712
		itemObj.put("MaxNlc", maxNLC);
9825 kshitij.so 713
		itemObj.put("VatRate", vat);
9780 kshitij.so 714
		itemObj.put("CommissionRate", mpCosting.getCommission());
715
		itemObj.put("ServiceTaxRate", mpCosting.getServiceTax());
716
		itemObj.put("ReturnProvision", mpCosting.getReturnProvision());
717
		itemObj.put("EmiFee", mpCosting.getEmiFee());
718
		itemObj.put("ClosingFee", mpCosting.getClosingFee());
10287 kshitij.so 719
		itemObj.put("PgFee", mpCosting.getPgFee());
9242 kshitij.so 720
		return "item-details-json";
721
	}
722
 
9825 kshitij.so 723
	public String ke$ha() throws NumberFormatException, TException, JSONException, InventoryServiceException, CatalogServiceException{
724
		Client catalogClientProd = new CatalogClient().getClient();
9478 kshitij.so 725
		InventoryClient inventoryServiceClient = new InventoryClient();
726
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9825 kshitij.so 727
		Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
9780 kshitij.so 728
		//if (warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD){
729
		double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
9825 kshitij.so 730
		double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
9780 kshitij.so 731
		itemObj = new JSONObject();
732
		itemObj.put("ItemId", itemId);
733
		itemObj.put("WarehouseId", warehouseId);
734
		itemObj.put("MaxNlc", maxNLC);
9825 kshitij.so 735
		itemObj.put("VatRate", vat);
9780 kshitij.so 736
		/*}
9725 kshitij.so 737
		else{
738
			itemObj = new JSONObject();
739
			throw new InventoryServiceException();
9780 kshitij.so 740
		}*/
9478 kshitij.so 741
		return "item-details-json";
742
	}
743
 
9725 kshitij.so 744
	public ItemInventory getItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
745
		try{
746
			InventoryClient inventoryServiceClient = new InventoryClient();
747
			in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
748
			in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
749
			return thriftItemInventory;
750
		}
751
		catch(Exception e){
752
			logger.error("Unable to get inventory info for item",e);
753
			return null;
754
		}
755
	}
756
 
9734 kshitij.so 757
 
758
 
759
	public Warehouse getWarehouse(String warehouseId,String itemId) throws NumberFormatException, TException, InventoryServiceException { 
9725 kshitij.so 760
		InventoryClient inventoryServiceClient = new InventoryClient();
9734 kshitij.so 761
		holdInventoryMap =inventoryServiceClient.getClient().getHeldInventoryMapForItem(Long.valueOf(itemId), Long.valueOf(warehouseId));
9725 kshitij.so 762
		return inventoryServiceClient.getClient().getWarehouse(Long.valueOf(warehouseId));
763
	}
764
 
9734 kshitij.so 765
	public Map<Integer, Long> getHoldInventoryMapForItem(){
766
		return holdInventoryMap;
767
	}
768
 
9725 kshitij.so 769
	public void changeHeldForSource() throws NumberFormatException, TException, InventoryServiceException{
770
		InventoryClient inventoryServiceClient = new InventoryClient();
771
		Warehouse warehouse = inventoryServiceClient.getClient().getWarehouse(Long.valueOf(warehouseId));
772
		if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
773
			throw new InventoryServiceException();
774
		}
775
		inventoryServiceClient.getClient().addUpdateHoldInventory(Long.valueOf(itemId),Long.valueOf(warehouseId),Long.valueOf(held),7);
776
	}
777
 
8739 vikram.rag 778
	public void downloadSnapdealListings() throws IOException, TException{
779
		File file = new File("/tmp/snapdeal-bulk-upload-template.xls");
780
		HSSFWorkbook hwb=new HSSFWorkbook();
781
		HSSFSheet sheet =  hwb.createSheet("Snapdeal-Listings");
782
		HSSFRow rowhead=   sheet.createRow((short)0);
783
		rowhead.createCell((short) 0).setCellValue("ITEM-ID");
9811 vikram.rag 784
		rowhead.createCell((short) 1).setCellValue("PRODUCT");
785
		rowhead.createCell((short) 2).setCellValue("WAREHOUSE-ID");
786
		rowhead.createCell((short) 3).setCellValue("EXCEPTIONAL-PRICE");
787
		rowhead.createCell((short) 4).setCellValue("SNAPDEAL-LISTED");
788
		rowhead.createCell((short) 5).setCellValue("TRANSFER-PRICE");
789
		rowhead.createCell((short) 6).setCellValue("SELLING-PRICE");
790
		rowhead.createCell((short) 7).setCellValue("LOWEST POSSIBLE SP");
791
		rowhead.createCell((short) 8).setCellValue("LOWEST POSSIBLE TP");
792
		rowhead.createCell((short) 9).setCellValue("OTHER COST");
793
		rowhead.createCell((short) 10).setCellValue("COURIER-COST");
794
		rowhead.createCell((short) 11).setCellValue("COMMISION");
795
		rowhead.createCell((short) 12).setCellValue("SERVICE-TAX");
796
		rowhead.createCell((short) 13).setCellValue("Suppress Inventory Feed");
797
		rowhead.createCell((short) 14).setCellValue("Suppress Price Feed");
798
		rowhead.createCell((short) 15).setCellValue("AUTO FAVOURITE");
799
		rowhead.createCell((short) 16).setCellValue("MANUAL FAVOURITE");
800
		rowhead.createCell((short) 17).setCellValue("AUTO INCREMENT");
801
		rowhead.createCell((short) 18).setCellValue("AUTO DECREMENT");
802
		rowhead.createCell((short) 19).setCellValue("Max NLC");
803
		rowhead.createCell((short) 20).setCellValue("SKU @ Snapdeal");
804
		rowhead.createCell((short) 21).setCellValue("SUPC");
9780 kshitij.so 805
		Client catalogClient = null;
9242 kshitij.so 806
		List<SnapdealItemDetails> snapdealItems = null;
8739 vikram.rag 807
		try {
9780 kshitij.so 808
			catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
8739 vikram.rag 809
			snapdealItems = catalogClient.getAllSnapdealItems();
810
		} catch (Exception e) {
811
			e.printStackTrace();
812
		}
813
		int iterator=1;
9811 vikram.rag 814
		Item item;
815
		MarketplaceItems marketplaceItem;
9242 kshitij.so 816
		for(SnapdealItemDetails snapdealItem:snapdealItems){
9811 vikram.rag 817
			marketplaceItem = catalogClient.getMarketplacedetailsForItem(snapdealItem.getItem_id(), 7);
818
			try {
819
				item = catalogClient.getItem(snapdealItem.getItem_id());
820
			} catch (CatalogServiceException e) {
821
				e.printStackTrace();
822
				continue;
823
			}
8739 vikram.rag 824
			HSSFRow row = sheet.createRow((short)iterator);
825
			row.createCell((short) 0).setCellValue(snapdealItem.getItem_id());
9812 vikram.rag 826
			row.createCell((short) 1).setCellValue(getVaildName(item.getBrand())+" "+getVaildName(item.getModelName())+" "+getVaildName(item.getModelNumber())+" "+getVaildName(item.getColor()));
9811 vikram.rag 827
			row.createCell((short) 2).setCellValue(snapdealItem.getWarehouseId());
828
			row.createCell((short) 3).setCellValue(roundTwoDecimals(snapdealItem.getExceptionPrice()));
8739 vikram.rag 829
			if(snapdealItem.isIsListedOnSnapdeal()){
9811 vikram.rag 830
				row.createCell((short) 4).setCellValue(1);
8739 vikram.rag 831
			}
832
			else{
9811 vikram.rag 833
				row.createCell((short) 4).setCellValue(0);
8739 vikram.rag 834
			}
9811 vikram.rag 835
			row.createCell((short) 5).setCellValue(roundTwoDecimals(snapdealItem.getTransferPrice()));
836
			row.createCell((short) 6).setCellValue(roundTwoDecimals(snapdealItem.getSellingPrice()));
837
			row.createCell((short) 7).setCellValue(roundTwoDecimals(marketplaceItem.getMinimumPossibleSp()));
838
			row.createCell((short) 8).setCellValue(roundTwoDecimals(marketplaceItem.getMinimumPossibleTp()));
839
			row.createCell((short) 9).setCellValue(roundTwoDecimals(marketplaceItem.getOtherCost()));
840
			row.createCell((short) 10).setCellValue(snapdealItem.getCourierCost());
841
			row.createCell((short) 11).setCellValue(roundTwoDecimals(snapdealItem.getCommission()));
842
			row.createCell((short) 12).setCellValue(roundTwoDecimals(snapdealItem.getServiceTax()));
9780 kshitij.so 843
			if(snapdealItem.isSuppressInventoryFeed()){
844
				row.createCell((short) 13).setCellValue(1);
845
			}
846
			else{
847
				row.createCell((short) 13).setCellValue(0);
848
			}
9811 vikram.rag 849
			if(snapdealItem.isSuppressPriceFeed()){
9780 kshitij.so 850
				row.createCell((short) 14).setCellValue(1);
851
			}
852
			else{
853
				row.createCell((short) 14).setCellValue(0);
854
			}
9811 vikram.rag 855
			if(marketplaceItem.isAutoFavourite()){
9780 kshitij.so 856
				row.createCell((short) 15).setCellValue(1);
857
			}
858
			else{
859
				row.createCell((short) 15).setCellValue(0);
860
			}
9811 vikram.rag 861
			if(marketplaceItem.isManualFavourite()){
9780 kshitij.so 862
				row.createCell((short) 16).setCellValue(1);
863
			}
864
			else{
865
				row.createCell((short) 16).setCellValue(0);
866
			}
9811 vikram.rag 867
			if(marketplaceItem.isAutoIncrement()){
9780 kshitij.so 868
				row.createCell((short) 17).setCellValue(1);
869
			}
870
			else{
871
				row.createCell((short) 17).setCellValue(0);
872
			}
9811 vikram.rag 873
			if(marketplaceItem.isAutoDecrement()){
874
				row.createCell((short) 18).setCellValue(1);
875
			}
876
			else{
877
				row.createCell((short) 18).setCellValue(0);
878
			}
879
			row.createCell((short) 19).setCellValue(snapdealItem.getMaxNlc());
880
			row.createCell((short) 20).setCellValue(snapdealItem.getSkuAtSnapdeal());
881
			row.createCell((short) 21).setCellValue(snapdealItem.getSupc());
8739 vikram.rag 882
			iterator++;
883
		}
9242 kshitij.so 884
 
8739 vikram.rag 885
		FileOutputStream fileOut = null;
886
		try {
887
			fileOut = new FileOutputStream(file);
888
		} catch (FileNotFoundException e) {
889
			// TODO Auto-generated catch block
890
			e.printStackTrace();
891
		}
892
		try {
893
			hwb.write(fileOut);
894
		} catch (IOException e) {
895
			// TODO Auto-generated catch block
896
			e.printStackTrace();
897
		}
898
		try {
899
			fileOut.close();
900
		} catch (IOException e) {
901
			// TODO Auto-generated catch block
902
			e.printStackTrace();
903
		}
904
		byte[] buffer = new byte[(int)file.length()];
905
		InputStream input = null;
906
		try {
907
			int totalBytesRead = 0;
908
			input = new BufferedInputStream(new FileInputStream(file));
909
			while(totalBytesRead < buffer.length){
910
				int bytesRemaining = buffer.length - totalBytesRead;
911
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
912
				if (bytesRead > 0){
913
					totalBytesRead = totalBytesRead + bytesRead;
914
				}
915
			}
916
		}
917
		finally {
918
			input.close();
919
			file.delete();
920
		}
921
 
922
		response.setHeader("Content-Disposition", "attachment; filename=\"Snapdeal-Bulk-Listings.xls\"");
923
		response.setContentType("application/octet-stream");
924
		ServletOutputStream sos;
925
		try {
926
			sos = response.getOutputStream();
927
			sos.write(buffer);
928
			sos.flush();
929
		} catch (IOException e) {
930
			System.out.println("Unable to stream the manifest file");
931
		}   
932
 
9242 kshitij.so 933
 
8739 vikram.rag 934
	}
935
 
9825 kshitij.so 936
 
9780 kshitij.so 937
	public void uploadsnapdealBulkSheet() throws IOException, TException, NumberFormatException, InventoryServiceException, CatalogServiceException{
8739 vikram.rag 938
		File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
939
		FileUtils.copyFile(this.file, fileToCreate);
940
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
941
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
942
		HSSFSheet sheet = workbook.getSheetAt(0);
9780 kshitij.so 943
		String updatedBy = getUserName();
8887 vikram.rag 944
		Client catalogClient=null;
9780 kshitij.so 945
		Client catalogClientProd=null;
8739 vikram.rag 946
		StringBuilder sb = new StringBuilder();
947
		try {
9242 kshitij.so 948
			catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
9780 kshitij.so 949
			catalogClientProd = new CatalogClient().getClient();
8739 vikram.rag 950
		} catch (TTransportException e) {
951
			e.printStackTrace();
952
		}
9478 kshitij.so 953
		InventoryClient inventoryServiceClient = new InventoryClient();
954
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
9825 kshitij.so 955
 
8739 vikram.rag 956
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
9780 kshitij.so 957
			if (sheet.getLastRowNum()-1>100){
958
				sb.append("Number of items to update can't be greater than 100");
959
				break;
960
			}
961
			SnapdealItem snapdealItem = null;
962
			MarketplaceItems marketplaceItem = null;
963
			MarketplacePercentage mpCosting = null;
9825 kshitij.so 964
			Warehouse warehouse = null;
9242 kshitij.so 965
			Item item = null;
8739 vikram.rag 966
			Long sku;
9595 kshitij.so 967
			boolean new_item = false;
8739 vikram.rag 968
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
969
				continue;
970
			}
971
			else {
8791 kshitij.so 972
				sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
8887 vikram.rag 973
				snapdealItem = catalogClient.getSnapdealItem(sku);
9780 kshitij.so 974
				mpCosting = catalogClient.getCostingForMarketplace(7, sku);
975
				marketplaceItem  = catalogClient.getMarketplacedetailsForItem(sku, 7);
976
				marketplaceItem.setItemId(sku);
977
				marketplaceItem.setSource(7);
978
				marketplaceItem.setCommission(mpCosting.getCommission());
979
				marketplaceItem.setServiceTax(mpCosting.getServiceTax());
980
				marketplaceItem.setReturnProvision(mpCosting.getReturnProvision());
981
				marketplaceItem.setEmiFee(mpCosting.getEmiFee());
982
				marketplaceItem.setClosingFee(mpCosting.getClosingFee());
10287 kshitij.so 983
				marketplaceItem.setPgFee(mpCosting.getPgFee());
9825 kshitij.so 984
 
9242 kshitij.so 985
				try {
986
					item = catalogClient.getItem(sku);
987
					if (item.getId()==0){
9780 kshitij.so 988
						sb.append(sku + " Item not valid"+"\n");
9242 kshitij.so 989
						continue;
990
					}
991
				} catch (CatalogServiceException e) {
9780 kshitij.so 992
					sb.append(sku + " Item not valid"+"\n");
9242 kshitij.so 993
					continue;
994
				}
8886 vikram.rag 995
				if(snapdealItem.getItem_id()==0){
9595 kshitij.so 996
					new_item = true;
8886 vikram.rag 997
					snapdealItem = new SnapdealItem();
998
					snapdealItem.setItem_id(sku); 
999
				}
8739 vikram.rag 1000
			}
9725 kshitij.so 1001
 
9595 kshitij.so 1002
			if (checkEmptyString(sheet.getRow(iterator).getCell(1)) && new_item){
1003
				sb.append(sku + " New Listing - Warehouse Id not Present"+"\n");
1004
				continue;
1005
			}
9725 kshitij.so 1006
 
8739 vikram.rag 1007
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
9780 kshitij.so 1008
				/*Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
9725 kshitij.so 1009
				if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
1010
					sb.append(sku + "Not acceptable warehouse"+"\n");
1011
					continue;
9780 kshitij.so 1012
				}*/
8739 vikram.rag 1013
				long warehouseId = (long) sheet.getRow(iterator).getCell(1).getNumericCellValue();
9478 kshitij.so 1014
				double maxNLC = inventoryClient.getNlcForWarehouse(warehouseId, item.getId());
9595 kshitij.so 1015
				if (maxNLC==0){
1016
					sb.append(sku + "Max Nlc can't be 0"+"\n");
1017
					continue;
1018
				}
8739 vikram.rag 1019
				snapdealItem.setWarehouseId(warehouseId);
9478 kshitij.so 1020
				snapdealItem.setMaxNlc(maxNLC);
8739 vikram.rag 1021
			}
1022
 
1023
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
1024
				double exceptionPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
1025
				snapdealItem.setExceptionPrice(exceptionPrice);
1026
			}
1027
 
1028
			if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
1029
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==1){
1030
					snapdealItem.setIsListedOnSnapdeal(true);
1031
				}
1032
				if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
1033
					snapdealItem.setIsListedOnSnapdeal(false);
1034
				}
1035
			}
9825 kshitij.so 1036
 
9780 kshitij.so 1037
			double transferPrice = 0,sellingPrice,commission,courierCost =45,serviceTax,otherCost;
1038
			if (checkEmptyString(sheet.getRow(iterator).getCell(4))&& new_item){
1039
				sb.append(sku + "New Item -  Selling Price cannot be empty"+"\n");
9242 kshitij.so 1040
				continue;
1041
			}
1042
			if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
9780 kshitij.so 1043
				sellingPrice = sheet.getRow(iterator).getCell(4).getNumericCellValue();
1044
				if(sellingPrice==0){
1045
					sb.append(sku + " Selling Price cannot be zero"+"\n");
9242 kshitij.so 1046
					continue;
1047
				}
9780 kshitij.so 1048
				snapdealItem.setSellingPrice(sellingPrice);
1049
				marketplaceItem.setCurrentSp(sellingPrice);
9242 kshitij.so 1050
			}
9825 kshitij.so 1051
 
9780 kshitij.so 1052
			if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
1053
				otherCost = sheet.getRow(iterator).getCell(5).getNumericCellValue();
1054
				marketplaceItem.setOtherCost(otherCost);
1055
			}
9242 kshitij.so 1056
 
9780 kshitij.so 1057
 
1058
			if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
1059
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
9242 kshitij.so 1060
					snapdealItem.setSuppressPriceFeed(true);
1061
				}
9780 kshitij.so 1062
				if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
9242 kshitij.so 1063
					snapdealItem.setSuppressPriceFeed(false);
1064
				}
1065
			}
1066
 
9780 kshitij.so 1067
			if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
1068
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
9242 kshitij.so 1069
					snapdealItem.setSuppressInventoryFeed(true);
1070
				}
9780 kshitij.so 1071
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
9242 kshitij.so 1072
					snapdealItem.setSuppressInventoryFeed(false);
1073
				}
1074
			}
9725 kshitij.so 1075
 
9780 kshitij.so 1076
			if (checkEmptyString(sheet.getRow(iterator).getCell(8)) && new_item){
1077
				sb.append(sku + " New Item -  SKU@Snapdeal cannot be empty"+"\n");
1078
				continue;
9478 kshitij.so 1079
			}
9725 kshitij.so 1080
 
9568 kshitij.so 1081
			if (!checkEmptyString(sheet.getRow(iterator).getCell(8))){
9597 kshitij.so 1082
				sheet.getRow(iterator).getCell(8).setCellType(Cell.CELL_TYPE_STRING);
9780 kshitij.so 1083
				String snapdealItemCode = sheet.getRow(iterator).getCell(8).getStringCellValue();
1084
				if (snapdealItemCode.length()==0 && new_item){
1085
					sb.append(sku + " New Item -  SKU@Snapdeal cannot be empty"+"\n");
1086
					continue;
1087
				}
1088
				snapdealItem.setSkuAtSnapdeal(snapdealItemCode);
1089
			}
9825 kshitij.so 1090
 
9780 kshitij.so 1091
			if (checkEmptyString(sheet.getRow(iterator).getCell(9)) && new_item){
1092
				sb.append(sku + " New Item -  SUPC code cannot be empty"+"\n");
1093
				continue;
1094
			}
1095
 
1096
			if (!checkEmptyString(sheet.getRow(iterator).getCell(9))){
1097
				sheet.getRow(iterator).getCell(9).setCellType(Cell.CELL_TYPE_STRING);
1098
				String supc = sheet.getRow(iterator).getCell(9).getStringCellValue();
1099
				if (supc.length()==0 && new_item){
1100
					sb.append(sku + "  New Item -  SUPC code cannot be empty"+"\n");
1101
					continue;
1102
				}
9568 kshitij.so 1103
				snapdealItem.setSupc(supc);
1104
			}
9242 kshitij.so 1105
			double weight = item.getWeight();
1106
 
9825 kshitij.so 1107
 
9780 kshitij.so 1108
			if(weight==0){
9242 kshitij.so 1109
				sb.append(sku + " Please add weight"+"\n");
1110
				continue;
9780 kshitij.so 1111
			}
9242 kshitij.so 1112
			if (weight!=0){
9780 kshitij.so 1113
				weight = weight+.05;
9242 kshitij.so 1114
				int slabs = (int) ((weight - .001)/(.5));
1115
 
1116
				for(int i=0;i<slabs;i++){
1117
					courierCost = courierCost + 35;
1118
				}
1119
			}
10225 vikram.rag 1120
 
10114 kshitij.so 1121
			warehouse = inventoryClient.getWarehouse(snapdealItem.getWarehouseId());
9242 kshitij.so 1122
			snapdealItem.setCourierCost(courierCost);
9780 kshitij.so 1123
			marketplaceItem.setCourierCost(courierCost);
10287 kshitij.so 1124
			transferPrice = roundTwoDecimals(snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*((marketplaceItem.getCommission()/100)+marketplaceItem.getEmiFee()/100)*(1+(marketplaceItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+marketplaceItem.getClosingFee())*(1+(marketplaceItem.getServiceTax()/100))-(Math.max(20,(marketplaceItem.getPgFee()/100)*snapdealItem.getSellingPrice())*(1+(marketplaceItem.getServiceTax()/100))));
9780 kshitij.so 1125
			snapdealItem.setTransferPrice(transferPrice);
1126
			marketplaceItem.setCurrentTp(transferPrice);
10287 kshitij.so 1127
			if ((marketplaceItem.getPgFee()/100)*snapdealItem.getSellingPrice()>=20){
1128
				commission =  (((marketplaceItem.getCommission()/100)+marketplaceItem.getPgFee()/100)*snapdealItem.getSellingPrice());
1129
			}
1130
			else{
1131
				commission =  ((marketplaceItem.getCommission()/100)*snapdealItem.getSellingPrice()+20);
1132
			}
1133
			commission = roundTwoDecimals(commission);
9242 kshitij.so 1134
			snapdealItem.setCommission(commission);
9780 kshitij.so 1135
			serviceTax = roundTwoDecimals((marketplaceItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost())); 
9242 kshitij.so 1136
			snapdealItem.setServiceTax(serviceTax);
9825 kshitij.so 1137
			double vatRate = catalogClientProd.getVatPercentageForItem(snapdealItem.getItem_id(),warehouse.getStateId(),snapdealItem.getSellingPrice());
9780 kshitij.so 1138
			marketplaceItem.setVat(vatRate);
1139
			double vat = roundTwoDecimals((snapdealItem.getSellingPrice()/(1+(marketplaceItem.getVat()/100))-(snapdealItem.getMaxNlc()/(1+(marketplaceItem.getVat()/100))))*(marketplaceItem.getVat()/100));
1140
			double inHouseCost = roundTwoDecimals(15+vat+(marketplaceItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+marketplaceItem.getOtherCost());
1141
			double lowest_possible_tp = roundTwoDecimals(snapdealItem.getMaxNlc()+inHouseCost);
1142
			marketplaceItem.setMinimumPossibleTp(lowest_possible_tp);
10287 kshitij.so 1143
			double lowest_possible_sp=0.0;
1144
			if ((marketplaceItem.getPgFee()/100)*snapdealItem.getSellingPrice()>=20){
1145
				lowest_possible_sp = roundTwoDecimals((snapdealItem.getMaxNlc()+(snapdealItem.getCourierCost()+marketplaceItem.getClosingFee())*(1+marketplaceItem.getServiceTax()/100)*(1+(marketplaceItem.getVat()/100))+(15+marketplaceItem.getOtherCost())*(1+(marketplaceItem.getVat())/100))/(1-((marketplaceItem.getCommission()/100)+marketplaceItem.getEmiFee()/100+marketplaceItem.getPgFee()/100)*(1+(marketplaceItem.getServiceTax()/100))*(1+(marketplaceItem.getVat())/100)-(marketplaceItem.getReturnProvision()/100)*(1+(marketplaceItem.getVat())/100)));
1146
			}
1147
			else{
1148
				lowest_possible_sp = roundTwoDecimals((snapdealItem.getMaxNlc()+(snapdealItem.getCourierCost()+marketplaceItem.getClosingFee()+20)*(1+marketplaceItem.getServiceTax()/100)*(1+(marketplaceItem.getVat()/100))+(15+marketplaceItem.getOtherCost())*(1+(marketplaceItem.getVat())/100))/(1-((marketplaceItem.getCommission()/100)+marketplaceItem.getEmiFee()/100)*(1+(marketplaceItem.getServiceTax()/100))*(1+(marketplaceItem.getVat())/100)-(marketplaceItem.getReturnProvision()/100)*(1+(marketplaceItem.getVat())/100)));
1149
			}
9780 kshitij.so 1150
			marketplaceItem.setMinimumPossibleSp(lowest_possible_sp);
1151
			snapdealItem.setUpdatedBy(updatedBy);
1152
			snapdealItem.setMarketplaceItems(marketplaceItem);
9825 kshitij.so 1153
			//logger.info(snapdealItem.toString());
8888 vikram.rag 1154
			if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
9780 kshitij.so 1155
				sb.append(sku + " Service Error\n");
8739 vikram.rag 1156
			}	
1157
		}
9780 kshitij.so 1158
		File file = new File("/tmp/snapdealbulk");
8739 vikram.rag 1159
		FileWriter writer = new FileWriter(file);
1160
		writer.append(sb.toString());
1161
		writer.close();
1162
		byte[] buffer = new byte[(int)file.length()];
1163
		InputStream input = null;
1164
		try {
1165
			int totalBytesRead = 0;
1166
			input = new BufferedInputStream(new FileInputStream(file));
1167
			while(totalBytesRead < buffer.length){
1168
				int bytesRemaining = buffer.length - totalBytesRead;
1169
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
1170
				if (bytesRead > 0){
1171
					totalBytesRead = totalBytesRead + bytesRead;
1172
				}
1173
			}
1174
		}
1175
		finally {
1176
			input.close();
1177
			file.delete();
1178
		}
1179
 
1180
		response.setHeader("Content-Type", "text/javascript");
1181
 
1182
		ServletOutputStream sos;
1183
		try {
1184
			sos = response.getOutputStream();
1185
			sos.write(buffer);
1186
			sos.flush();
1187
		} catch (IOException e) {
1188
			System.out.println("Unable to stream the manifest file");
1189
		}   
1190
	}
1191
 
1192
	public boolean checkEmptyString(Cell cell){
10114 kshitij.so 1193
		if (cell==null || cell.getCellType() == Cell.CELL_TYPE_BLANK){
8739 vikram.rag 1194
			return true;
1195
		}
1196
		return false;
1197
	}
1198
 
9242 kshitij.so 1199
	double roundTwoDecimals(double d) {
1200
		DecimalFormat twoPlaces = new DecimalFormat("#.##");
1201
		return Double.valueOf(twoPlaces.format(d));
1202
	}
1203
 
9825 kshitij.so 1204
	/*String getLocation(String location){
1205
		logger.info("Inside trim"+location);
1206
		int loc = location.lastIndexOf(',');
1207
		logger.info("end result "+location.substring(loc+1));
1208
		return location.substring(loc+1);
1209
	}*/
9242 kshitij.so 1210
 
9825 kshitij.so 1211
 
8739 vikram.rag 1212
	public String show() {
1213
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
1214
			return "authfail";
1215
		}
1216
 
1217
		if (StringUtils.equals(id, "snapdeal-options")){
1218
			return "snapdeal-options";
1219
		}
9242 kshitij.so 1220
		if (StringUtils.equals(id, "item-table")){
1221
			return "snapdeal-item-table";
1222
		}
8739 vikram.rag 1223
 
1224
		return "id";
1225
	}
1226
 
1227
	public void setId(String id) {
1228
		this.id = id;
1229
	}
1230
 
9780 kshitij.so 1231
	public String getUserName(){
1232
		return session.getAttribute(ReportsUtils.USER_NAME).toString();
1233
	}
1234
 
8739 vikram.rag 1235
	public HttpServletRequest getRequest() {
1236
		logger.info("set request"+request.toString());
1237
		return request;
1238
	}
1239
 
1240
	public void setRequest(HttpServletRequest request) {
1241
		this.request = request;
1242
	}
1243
 
1244
	public HttpServletResponse getResponse() {
1245
		return response;
1246
	}
1247
 
1248
	public void setResponse(HttpServletResponse response) {
1249
		this.response = response;
1250
	}
1251
 
1252
	public HttpSession getSession() {
1253
		return session;
1254
	}
1255
 
1256
	public void setSession(HttpSession session) {
1257
		this.session = session;
1258
	}
1259
 
1260
	public ServletContext getContext() {
1261
		return context;
1262
	}
1263
 
1264
	public void setContext(ServletContext context) {
1265
		this.context = context;
1266
	}
1267
 
1268
	public String getUrl() {
1269
		return url;
1270
	}
1271
 
1272
	public void setUrl(String url) {
1273
		this.url = url;
1274
	}
1275
 
1276
	public String getItemId() {
1277
		return itemId;
1278
	}
1279
 
1280
	public void setItemId(String itemId) {
1281
		this.itemId = itemId;
1282
	}
1283
 
1284
	public String getIsSnapdealListed() {
1285
		return isSnapdealListed;
1286
	}
1287
 
1288
	public void setIsSnapdealListed(String isSnapdealListed) {
1289
		this.isSnapdealListed = isSnapdealListed;
1290
	}
1291
 
1292
	public String getExceptionPrice() {
1293
		return exceptionPrice;
1294
	}
1295
 
1296
	public void setExceptionPrice(String exceptionPrice) {
1297
		this.exceptionPrice = exceptionPrice;
1298
	}
1299
 
1300
	public String getWarehouseId() {
1301
		return warehouseId;
1302
	}
1303
 
1304
	public void setWarehouseId(String warehouseId) {
1305
		this.warehouseId = warehouseId;
1306
	}
1307
 
1308
	public File getFile() {
1309
		return file;
1310
	}
1311
 
1312
	public void setFile(File file) {
1313
		this.file = file;
1314
	}
1315
 
1316
	public String getErrMsg() {
1317
		return errMsg;
1318
	}
1319
 
1320
	public void setErrMsg(String errMsg) {
1321
		this.errMsg = errMsg;
1322
	}
1323
 
1324
	public String getNext() {
1325
		return next;
1326
	}
1327
 
1328
	public void setNext(String next) {
1329
		this.next = next;
1330
	}
1331
 
1332
	public String getId() {
1333
		return id;
1334
	}
1335
 
1336
	public void setServletRequest(HttpServletRequest req) {
1337
		this.request = req;
1338
		this.session = req.getSession();        
1339
	}
1340
 
1341
	public void setServletContext(ServletContext arg0) {
1342
		// TODO Auto-generated method stub
1343
 
1344
	}
1345
 
1346
	public void setServletResponse(HttpServletResponse response) {
1347
		this.response = response;
1348
	}
1349
 
9242 kshitij.so 1350
	public void setSearchText(String searchText) {
1351
		this.searchText = searchText;
1352
	}
1353
 
1354
	public String getSearchText() {
1355
		return searchText;
1356
	}
1357
 
1358
	public long getSearchCount() {
1359
		return searchCount;
1360
	}
1361
 
1362
	public long getTotalCount() {
1363
		return totalCount;
1364
	}
1365
 
1366
	public void setSearchCount(long count) {
1367
		this.searchCount = count;
1368
	}
1369
 
1370
	public List<SnapdealItemDetails> getSnapdealItems(){
1371
		return snapdealItems;
1372
	}
1373
 
1374
	public void setSellingPrice(String sellingPrice) {
1375
		this.sellingPrice = sellingPrice;
1376
	}
1377
 
1378
	public String getSellingPrice() {
1379
		return sellingPrice;
1380
	}
1381
 
1382
	public void setTransferPrice(String transferPrice) {
1383
		this.transferPrice = transferPrice;
1384
	}
1385
 
1386
	public String getTransferPrice() {
1387
		return transferPrice;
1388
	}
1389
 
1390
	public void setWebisteMrp(String webisteMrp) {
1391
		this.webisteMrp = webisteMrp;
1392
	}
1393
 
1394
	public String getWebisteMrp() {
1395
		return webisteMrp;
1396
	}
1397
 
1398
	public void setWebisteSellingPrice(String webisteSellingPrice) {
1399
		this.webisteSellingPrice = webisteSellingPrice;
1400
	}
1401
 
1402
	public String getWebisteSellingPrice() {
1403
		return webisteSellingPrice;
1404
	}
1405
 
1406
	public void setIsListedOnSnapdeal(String isListedOnSnapdeal) {
1407
		this.isListedOnSnapdeal = isListedOnSnapdeal;
1408
	}
1409
 
1410
	public String getIsSuppressInventoryFeed() {
1411
		return isSuppressInventoryFeed;
1412
	}
1413
 
1414
	public void setIsSuppressInventoryFeed(String isSuppressInventoryFeed) {
1415
		this.isSuppressInventoryFeed = isSuppressInventoryFeed;
1416
	}
1417
 
1418
	public String getIsSuppressPriceFeed() {
1419
		return isSuppressPriceFeed;
1420
	}
1421
 
1422
	public void setIsSuppressPriceFeed(String isSuppressPriceFeed) {
1423
		this.isSuppressPriceFeed = isSuppressPriceFeed;
1424
	}
1425
 
1426
	public String getIsListedOnSnapdeal() {
1427
		return isListedOnSnapdeal;
1428
	}
1429
 
1430
	public void setCommission(String commission) {
1431
		this.commission = commission;
1432
	}
1433
 
1434
	public String getCommission() {
1435
		return commission;
1436
	}
1437
 
1438
	public void setServiceTax(String serviceTax) {
1439
		this.serviceTax = serviceTax;
1440
	}
1441
 
1442
	public String getServiceTax() {
1443
		return serviceTax;
1444
	}
1445
 
1446
	public void setCourierCost(String courierCost) {
1447
		this.courierCost = courierCost;
1448
	}
1449
 
1450
	public String getCourierCost() {
1451
		return courierCost;
1452
	}
1453
 
9478 kshitij.so 1454
	public void setMaxNlc(String maxNlc) {
1455
		this.maxNlc = maxNlc;
1456
	}
1457
 
1458
	public String getMaxNlc() {
1459
		return maxNlc;
1460
	}
1461
 
9242 kshitij.so 1462
	public String getItemDetails(){
1463
		return itemObj.toString();
1464
	}
1465
 
9725 kshitij.so 1466
	public double getRoundOfValue(String val){
1467
		return roundTwoDecimals(Double.valueOf(val));
1468
	}
9923 kshitij.so 1469
 
9812 vikram.rag 1470
	public String getVaildName(String name){
1471
		return name!=null?name:"";
1472
	}
9242 kshitij.so 1473
 
1474
 
9725 kshitij.so 1475
 
10287 kshitij.so 1476
}