Subversion Repositories SmartDukaan

Rev

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