Subversion Repositories SmartDukaan

Rev

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