Subversion Repositories SmartDukaan

Rev

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