Subversion Repositories SmartDukaan

Rev

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