Subversion Repositories SmartDukaan

Rev

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

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