| Line 59... |
Line 59... |
| 59 |
import org.slf4j.Logger;
|
59 |
import org.slf4j.Logger;
|
| 60 |
import org.slf4j.LoggerFactory;
|
60 |
import org.slf4j.LoggerFactory;
|
| 61 |
|
61 |
|
| 62 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
62 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
| 63 |
|
63 |
|
| 64 |
@SuppressWarnings("unused")
|
64 |
@SuppressWarnings({"unused","deprecation"})
|
| 65 |
|
65 |
|
| 66 |
@InterceptorRefs({
|
66 |
@InterceptorRefs({
|
| 67 |
@InterceptorRef("defaultStack"),
|
67 |
@InterceptorRef("defaultStack"),
|
| 68 |
@InterceptorRef("login")
|
68 |
@InterceptorRef("login")
|
| 69 |
})
|
69 |
})
|
| Line 316... |
Line 316... |
| 316 |
return "snapdeal-bulk-upload";
|
316 |
return "snapdeal-bulk-upload";
|
| 317 |
}
|
317 |
}
|
| 318 |
|
318 |
|
| 319 |
public String update() throws NumberFormatException, TException, InventoryServiceException, CatalogServiceException, JSONException{
|
319 |
public String update() throws NumberFormatException, TException, InventoryServiceException, CatalogServiceException, JSONException{
|
| 320 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
320 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
321 |
//Client catalogClientProd = new CatalogClient().getClient();
|
| 321 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
322 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
| - |
|
323 |
Item item = catalogClient.getItem(Long.valueOf(itemId));
|
| 322 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
324 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
| 323 |
if (mpCosting.getSource()==0){
|
325 |
if (mpCosting.getSource()==0){
|
| 324 |
throw new CatalogServiceException();
|
326 |
throw new CatalogServiceException();
|
| 325 |
}
|
327 |
}
|
| 326 |
MarketplaceItems mpItem = catalogClient.getMarketplacedetailsForItem(Long.valueOf(itemId),7);
|
328 |
MarketplaceItems mpItem = catalogClient.getMarketplacedetailsForItem(Long.valueOf(itemId),7);
|
| Line 329... |
Line 331... |
| 329 |
mpItem.setClosingFee(mpCosting.getClosingFee());
|
331 |
mpItem.setClosingFee(mpCosting.getClosingFee());
|
| 330 |
mpItem.setServiceTax(mpCosting.getServiceTax());
|
332 |
mpItem.setServiceTax(mpCosting.getServiceTax());
|
| 331 |
mpItem.setCommission(mpCosting.getCommission());
|
333 |
mpItem.setCommission(mpCosting.getCommission());
|
| 332 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
334 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 333 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
335 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 334 |
/*Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
336 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
| 335 |
if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
337 |
/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
| 336 |
throw new InventoryServiceException();
|
338 |
throw new InventoryServiceException();
|
| 337 |
}*/
|
339 |
}*/
|
| 338 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
340 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
| 339 |
snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
|
341 |
snapdealItem.setIsListedOnSnapdeal(Boolean.valueOf(isListedOnSnapdeal));
|
| 340 |
snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
|
342 |
snapdealItem.setSuppressInventoryFeed(Boolean.valueOf(isSuppressInventoryFeed));
|
| Line 347... |
Line 349... |
| 347 |
snapdealItem.setServiceTax(Double.valueOf(serviceTax));
|
349 |
snapdealItem.setServiceTax(Double.valueOf(serviceTax));
|
| 348 |
snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
|
350 |
snapdealItem.setMaxNlc(Double.valueOf(maxNlc));
|
| 349 |
snapdealItem.setSkuAtSnapdeal(sdItemCode);
|
351 |
snapdealItem.setSkuAtSnapdeal(sdItemCode);
|
| 350 |
snapdealItem.setSupc(supc);
|
352 |
snapdealItem.setSupc(supc);
|
| 351 |
MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
|
353 |
MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
|
| - |
|
354 |
//double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
|
| - |
|
355 |
//t_mpItem.setVat(vat);
|
| 352 |
snapdealItem.setUpdatedBy(getUserName());
|
356 |
snapdealItem.setUpdatedBy(getUserName());
|
| 353 |
snapdealItem.setMarketplaceItems(t_mpItem);
|
357 |
snapdealItem.setMarketplaceItems(t_mpItem);
|
| 354 |
|
358 |
|
| 355 |
if(!compareParameters(t_mpItem,snapdealItem)){
|
359 |
if(!compareParameters(t_mpItem,snapdealItem,warehouse,item.getWeight())){
|
| 356 |
setComparsionResult("0");
|
360 |
setComparsionResult("0");
|
| 357 |
return "snapdeal-update-result";
|
361 |
return "snapdeal-update-result";
|
| 358 |
}
|
362 |
}
|
| 359 |
else{
|
363 |
else{
|
| 360 |
setComparsionResult("1");
|
364 |
setComparsionResult("1");
|
| Line 367... |
Line 371... |
| 367 |
if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
|
371 |
if (t_mpItem.getCurrentSp()< t_mpItem.getMinimumPossibleSp()){
|
| 368 |
sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
|
372 |
sendAlert(t_mpItem.getItemId(),t_mpItem.getCurrentSp(),t_mpItem.getMinimumPossibleSp());
|
| 369 |
}
|
373 |
}
|
| 370 |
return "snapdeal-update-result";
|
374 |
return "snapdeal-update-result";
|
| 371 |
}
|
375 |
}
|
| - |
|
376 |
|
| 372 |
|
377 |
|
| 373 |
|
- |
|
| 374 |
public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem) throws TException, JSONException{
|
378 |
public boolean compareParameters(MarketplaceItems mpItem, SnapdealItem snapdealItem, Warehouse warehouse,double weight) throws TException, JSONException, CatalogServiceException{
|
| 375 |
double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
|
379 |
double nlc =getNlcForWarehouse(snapdealItem.getWarehouseId(),snapdealItem.getItem_id());
|
| 376 |
double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
|
380 |
double vat = (snapdealItem.getSellingPrice()/(1+(mpItem.getVat()/100))-(nlc/(1+(mpItem.getVat()/100))))*(mpItem.getVat()/100);
|
| 377 |
double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
|
381 |
double inHouseCost = 15+vat+(mpItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+mpItem.getOtherCost();
|
| 378 |
double lowest_possible_tp = nlc+inHouseCost;
|
382 |
double lowest_possible_tp = nlc+inHouseCost;
|
| 379 |
double our_tp = snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100));
|
383 |
double our_tp = snapdealItem.getSellingPrice()- snapdealItem.getSellingPrice()*(mpItem.getCommission()/100+mpItem.getEmiFee()/100)*(1+(mpItem.getServiceTax()/100))-(snapdealItem.getCourierCost()+mpItem.getClosingFee())*(1+(mpItem.getServiceTax()/100));
|
| Line 388... |
Line 392... |
| 388 |
x.put("COMMISSION", commission);
|
392 |
x.put("COMMISSION", commission);
|
| 389 |
x.put("SERVICE TAX", service_tax);
|
393 |
x.put("SERVICE TAX", service_tax);
|
| 390 |
x.put("LOWEST POS SP", lowest_possible_sp);
|
394 |
x.put("LOWEST POS SP", lowest_possible_sp);
|
| 391 |
logger.info("Snapdeal Backend validation "+x.toString());
|
395 |
logger.info("Snapdeal Backend validation "+x.toString());
|
| 392 |
boolean compare_result=true;
|
396 |
boolean compare_result=true;
|
| - |
|
397 |
|
| - |
|
398 |
if(!(getCourierCost(weight)==snapdealItem.getCourierCost())){
|
| - |
|
399 |
compare_result=false;
|
| - |
|
400 |
}
|
| - |
|
401 |
|
| - |
|
402 |
if(!(getVatRateForItem(warehouse,snapdealItem.getSellingPrice(),snapdealItem.getItem_id())==mpItem.getVat())){
|
| - |
|
403 |
compare_result=false;
|
| - |
|
404 |
}
|
| - |
|
405 |
|
| 393 |
if(!(nlc==snapdealItem.getMaxNlc())){
|
406 |
if(!(nlc==snapdealItem.getMaxNlc())){
|
| 394 |
compare_result=false;
|
407 |
compare_result=false;
|
| 395 |
}
|
408 |
}
|
| 396 |
if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
|
409 |
if(!(lowest_possible_tp-mpItem.getMinimumPossibleTp()>-1 && lowest_possible_tp-mpItem.getMinimumPossibleTp()<1)){
|
| 397 |
compare_result=false;
|
410 |
compare_result=false;
|
| Line 409... |
Line 422... |
| 409 |
compare_result=false;
|
422 |
compare_result=false;
|
| 410 |
}
|
423 |
}
|
| 411 |
return compare_result;
|
424 |
return compare_result;
|
| 412 |
|
425 |
|
| 413 |
}
|
426 |
}
|
| - |
|
427 |
|
| - |
|
428 |
public double getVatRateForItem(Warehouse warehouse, double sellingPrice,long itemId) throws CatalogServiceException, TException{
|
| - |
|
429 |
Client catalogClientProd = new CatalogClient().getClient();
|
| - |
|
430 |
return catalogClientProd.getVatPercentageForItem(itemId, warehouse.getStateId(), sellingPrice);
|
| - |
|
431 |
}
|
| 414 |
|
432 |
|
| 415 |
public double getNlcForWarehouse(long warehouseId,long item_id) throws TException{
|
433 |
public double getNlcForWarehouse(long warehouseId,long item_id) throws TException{
|
| 416 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
434 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 417 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
435 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 418 |
return inventoryClient.getNlcForWarehouse(warehouseId, item_id);
|
436 |
return inventoryClient.getNlcForWarehouse(warehouseId, item_id);
|
| 419 |
}
|
437 |
}
|
| 420 |
|
438 |
|
| 421 |
public double getCourierCost(double weight){
|
439 |
public double getCourierCost(double weight){
|
| 422 |
double cCost = 45;
|
440 |
double cCost = 45.0;
|
| 423 |
int slabs = (int) ((weight - .001)/(.5));
|
441 |
int slabs = (int) ((weight+.05 - .001)/(.5));
|
| 424 |
for(int i=0;i<slabs;i++){
|
442 |
for(int i=0;i<slabs;i++){
|
| 425 |
cCost = cCost + 35;
|
443 |
cCost = cCost + 35;
|
| 426 |
}
|
444 |
}
|
| 427 |
return cCost;
|
445 |
return cCost;
|
| 428 |
}
|
446 |
}
|
| Line 471... |
Line 489... |
| 471 |
|
489 |
|
| 472 |
public String addNewItem() throws TException, NumberFormatException, InventoryServiceException, CatalogServiceException, JSONException{
|
490 |
public String addNewItem() throws TException, NumberFormatException, InventoryServiceException, CatalogServiceException, JSONException{
|
| 473 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
491 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 474 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
492 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 475 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
493 |
Client catalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| - |
|
494 |
Item item = catalogClient.getItem(Long.valueOf(itemId));
|
| - |
|
495 |
//Client catalogClientProd = new CatalogClient().getClient();
|
| 476 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
496 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
| - |
|
497 |
|
| 477 |
if (mpCosting.getSource()==0){
|
498 |
if (mpCosting.getSource()==0){
|
| 478 |
throw new CatalogServiceException();
|
499 |
throw new CatalogServiceException();
|
| 479 |
}
|
500 |
}
|
| 480 |
/*Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
501 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
| 481 |
if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
502 |
/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
| 482 |
throw new InventoryServiceException();
|
503 |
throw new InventoryServiceException();
|
| 483 |
}*/
|
504 |
}*/
|
| 484 |
SnapdealItem snapdealItem = new SnapdealItem();
|
505 |
SnapdealItem snapdealItem = new SnapdealItem();
|
| 485 |
snapdealItem.setItem_id(Long.valueOf(itemId));
|
506 |
snapdealItem.setItem_id(Long.valueOf(itemId));
|
| 486 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
507 |
snapdealItem.setWarehouseId(Long.valueOf(warehouseId));
|
| Line 498... |
Line 519... |
| 498 |
snapdealItem.setSupc(supc);
|
519 |
snapdealItem.setSupc(supc);
|
| 499 |
snapdealItem.setUpdatedBy(getUserName());
|
520 |
snapdealItem.setUpdatedBy(getUserName());
|
| 500 |
|
521 |
|
| 501 |
MarketplaceItems mpItem = new MarketplaceItems();
|
522 |
MarketplaceItems mpItem = new MarketplaceItems();
|
| 502 |
MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
|
523 |
MarketplaceItems t_mpItem = updateMarketplaceItemDetails(mpItem);
|
| - |
|
524 |
/*double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
|
| - |
|
525 |
t_mpItem.setVat(vat);*/
|
| 503 |
t_mpItem.setCommission(mpCosting.getCommission());
|
526 |
t_mpItem.setCommission(mpCosting.getCommission());
|
| 504 |
t_mpItem.setServiceTax(mpCosting.getServiceTax());
|
527 |
t_mpItem.setServiceTax(mpCosting.getServiceTax());
|
| 505 |
t_mpItem.setReturnProvision(mpCosting.getReturnProvision());
|
528 |
t_mpItem.setReturnProvision(mpCosting.getReturnProvision());
|
| 506 |
t_mpItem.setEmiFee(mpCosting.getEmiFee());
|
529 |
t_mpItem.setEmiFee(mpCosting.getEmiFee());
|
| 507 |
t_mpItem.setClosingFee(mpCosting.getClosingFee());
|
530 |
t_mpItem.setClosingFee(mpCosting.getClosingFee());
|
| 508 |
if(!compareParameters(t_mpItem,snapdealItem)){
|
531 |
if(!compareParameters(t_mpItem,snapdealItem,warehouse,item.getWeight())){
|
| 509 |
setComparsionResult("0");
|
532 |
setComparsionResult("0");
|
| 510 |
return "snapdeal-update-result";
|
533 |
return "snapdeal-update-result";
|
| 511 |
}
|
534 |
}
|
| 512 |
else{
|
535 |
else{
|
| 513 |
setComparsionResult("1");
|
536 |
setComparsionResult("1");
|
| Line 527... |
Line 550... |
| 527 |
public String getAddNewItemForm(){
|
550 |
public String getAddNewItemForm(){
|
| 528 |
return "snapdeal-add-item";
|
551 |
return "snapdeal-add-item";
|
| 529 |
}
|
552 |
}
|
| 530 |
|
553 |
|
| 531 |
public String getItemDetailsInJson() throws NumberFormatException, CatalogServiceException, TException, JSONException, InventoryServiceException{
|
554 |
public String getItemDetailsInJson() throws NumberFormatException, CatalogServiceException, TException, JSONException, InventoryServiceException{
|
| - |
|
555 |
Client catalogClientProd = new CatalogClient().getClient();
|
| 532 |
Client catalogClient =new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
556 |
Client catalogClient =new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
|
| 533 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
557 |
SnapdealItem snapdealItem = catalogClient.getSnapdealItem(Long.valueOf(itemId));
|
| 534 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
558 |
MarketplacePercentage mpCosting = catalogClient.getCostingForMarketplace(7, Long.valueOf(itemId));
|
| 535 |
if (snapdealItem.getItem_id()!=0){
|
559 |
if (snapdealItem.getItem_id()!=0){
|
| 536 |
throw new CatalogServiceException();
|
560 |
throw new CatalogServiceException();
|
| Line 539... |
Line 563... |
| 539 |
if (item.getId()==0){
|
563 |
if (item.getId()==0){
|
| 540 |
throw new CatalogServiceException();
|
564 |
throw new CatalogServiceException();
|
| 541 |
}
|
565 |
}
|
| 542 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
566 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 543 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
567 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 544 |
/*Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
568 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
| 545 |
if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
569 |
/*if (!(warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD)){
|
| 546 |
throw new InventoryServiceException();
|
570 |
throw new InventoryServiceException();
|
| 547 |
}*/
|
571 |
}*/
|
| 548 |
double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
|
572 |
double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
|
| - |
|
573 |
double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
|
| 549 |
if (maxNLC==0){
|
574 |
if (maxNLC==0){
|
| 550 |
throw new InventoryServiceException();
|
575 |
throw new InventoryServiceException();
|
| 551 |
}
|
576 |
}
|
| 552 |
itemObj = new JSONObject();
|
577 |
itemObj = new JSONObject();
|
| 553 |
itemObj.put("ItemId", item.getId());
|
578 |
itemObj.put("ItemId", item.getId());
|
| Line 559... |
Line 584... |
| 559 |
itemObj.put("Risky", item.isRisky());
|
584 |
itemObj.put("Risky", item.isRisky());
|
| 560 |
itemObj.put("Status", item.getItemStatus());
|
585 |
itemObj.put("Status", item.getItemStatus());
|
| 561 |
itemObj.put("MRP", item.getMrp());
|
586 |
itemObj.put("MRP", item.getMrp());
|
| 562 |
itemObj.put("SellingPrice", item.getSellingPrice());
|
587 |
itemObj.put("SellingPrice", item.getSellingPrice());
|
| 563 |
itemObj.put("MaxNlc", maxNLC);
|
588 |
itemObj.put("MaxNlc", maxNLC);
|
| - |
|
589 |
itemObj.put("VatRate", vat);
|
| 564 |
itemObj.put("CommissionRate", mpCosting.getCommission());
|
590 |
itemObj.put("CommissionRate", mpCosting.getCommission());
|
| 565 |
itemObj.put("ServiceTaxRate", mpCosting.getServiceTax());
|
591 |
itemObj.put("ServiceTaxRate", mpCosting.getServiceTax());
|
| 566 |
itemObj.put("ReturnProvision", mpCosting.getReturnProvision());
|
592 |
itemObj.put("ReturnProvision", mpCosting.getReturnProvision());
|
| 567 |
itemObj.put("EmiFee", mpCosting.getEmiFee());
|
593 |
itemObj.put("EmiFee", mpCosting.getEmiFee());
|
| 568 |
itemObj.put("ClosingFee", mpCosting.getClosingFee());
|
594 |
itemObj.put("ClosingFee", mpCosting.getClosingFee());
|
| 569 |
return "item-details-json";
|
595 |
return "item-details-json";
|
| 570 |
}
|
596 |
}
|
| 571 |
|
597 |
|
| 572 |
public String ke$ha() throws NumberFormatException, TException, JSONException, InventoryServiceException{
|
598 |
public String ke$ha() throws NumberFormatException, TException, JSONException, InventoryServiceException, CatalogServiceException{
|
| - |
|
599 |
Client catalogClientProd = new CatalogClient().getClient();
|
| 573 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
600 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 574 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
601 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 575 |
//Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
602 |
Warehouse warehouse = inventoryClient.getWarehouse(Long.valueOf(warehouseId));
|
| 576 |
//if (warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD){
|
603 |
//if (warehouse.getWarehouseType()==WarehouseType.OURS && warehouse.getInventoryType() == InventoryType.GOOD){
|
| 577 |
double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
|
604 |
double maxNLC = inventoryClient.getNlcForWarehouse(Long.valueOf(warehouseId), Long.valueOf(itemId));
|
| - |
|
605 |
double vat = catalogClientProd.getVatPercentageForItem(Long.valueOf(itemId), warehouse.getStateId(), Double.valueOf(sellingPrice));
|
| 578 |
itemObj = new JSONObject();
|
606 |
itemObj = new JSONObject();
|
| 579 |
itemObj.put("ItemId", itemId);
|
607 |
itemObj.put("ItemId", itemId);
|
| 580 |
itemObj.put("WarehouseId", warehouseId);
|
608 |
itemObj.put("WarehouseId", warehouseId);
|
| 581 |
itemObj.put("MaxNlc", maxNLC);
|
609 |
itemObj.put("MaxNlc", maxNLC);
|
| - |
|
610 |
itemObj.put("VatRate", vat);
|
| 582 |
/*}
|
611 |
/*}
|
| 583 |
else{
|
612 |
else{
|
| 584 |
itemObj = new JSONObject();
|
613 |
itemObj = new JSONObject();
|
| 585 |
throw new InventoryServiceException();
|
614 |
throw new InventoryServiceException();
|
| 586 |
}*/
|
615 |
}*/
|
| Line 777... |
Line 806... |
| 777 |
}
|
806 |
}
|
| 778 |
|
807 |
|
| 779 |
|
808 |
|
| 780 |
}
|
809 |
}
|
| 781 |
|
810 |
|
| - |
|
811 |
|
| 782 |
public void uploadsnapdealBulkSheet() throws IOException, TException, NumberFormatException, InventoryServiceException, CatalogServiceException{
|
812 |
public void uploadsnapdealBulkSheet() throws IOException, TException, NumberFormatException, InventoryServiceException, CatalogServiceException{
|
| 783 |
File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
|
813 |
File fileToCreate = new File("/tmp/", "Snapdeal-bulk-upload.xls");
|
| 784 |
FileUtils.copyFile(this.file, fileToCreate);
|
814 |
FileUtils.copyFile(this.file, fileToCreate);
|
| 785 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
815 |
FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
|
| 786 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
816 |
HSSFWorkbook workbook = new HSSFWorkbook(iFile);
|
| Line 795... |
Line 825... |
| 795 |
} catch (TTransportException e) {
|
825 |
} catch (TTransportException e) {
|
| 796 |
e.printStackTrace();
|
826 |
e.printStackTrace();
|
| 797 |
}
|
827 |
}
|
| 798 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
828 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
| 799 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
829 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 800 |
|
830 |
|
| 801 |
for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
|
831 |
for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
|
| 802 |
if (sheet.getLastRowNum()-1>100){
|
832 |
if (sheet.getLastRowNum()-1>100){
|
| 803 |
sb.append("Number of items to update can't be greater than 100");
|
833 |
sb.append("Number of items to update can't be greater than 100");
|
| 804 |
break;
|
834 |
break;
|
| 805 |
}
|
835 |
}
|
| 806 |
SnapdealItem snapdealItem = null;
|
836 |
SnapdealItem snapdealItem = null;
|
| 807 |
MarketplaceItems marketplaceItem = null;
|
837 |
MarketplaceItems marketplaceItem = null;
|
| 808 |
MarketplacePercentage mpCosting = null;
|
838 |
MarketplacePercentage mpCosting = null;
|
| - |
|
839 |
Warehouse warehouse = null;
|
| 809 |
Item item = null;
|
840 |
Item item = null;
|
| 810 |
Long sku;
|
841 |
Long sku;
|
| 811 |
boolean new_item = false;
|
842 |
boolean new_item = false;
|
| 812 |
if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
|
843 |
if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
|
| 813 |
continue;
|
844 |
continue;
|
| Line 822... |
Line 853... |
| 822 |
marketplaceItem.setCommission(mpCosting.getCommission());
|
853 |
marketplaceItem.setCommission(mpCosting.getCommission());
|
| 823 |
marketplaceItem.setServiceTax(mpCosting.getServiceTax());
|
854 |
marketplaceItem.setServiceTax(mpCosting.getServiceTax());
|
| 824 |
marketplaceItem.setReturnProvision(mpCosting.getReturnProvision());
|
855 |
marketplaceItem.setReturnProvision(mpCosting.getReturnProvision());
|
| 825 |
marketplaceItem.setEmiFee(mpCosting.getEmiFee());
|
856 |
marketplaceItem.setEmiFee(mpCosting.getEmiFee());
|
| 826 |
marketplaceItem.setClosingFee(mpCosting.getClosingFee());
|
857 |
marketplaceItem.setClosingFee(mpCosting.getClosingFee());
|
| 827 |
|
858 |
|
| 828 |
try {
|
859 |
try {
|
| 829 |
item = catalogClient.getItem(sku);
|
860 |
item = catalogClient.getItem(sku);
|
| 830 |
if (item.getId()==0){
|
861 |
if (item.getId()==0){
|
| 831 |
sb.append(sku + " Item not valid"+"\n");
|
862 |
sb.append(sku + " Item not valid"+"\n");
|
| 832 |
continue;
|
863 |
continue;
|
| Line 857... |
Line 888... |
| 857 |
double maxNLC = inventoryClient.getNlcForWarehouse(warehouseId, item.getId());
|
888 |
double maxNLC = inventoryClient.getNlcForWarehouse(warehouseId, item.getId());
|
| 858 |
if (maxNLC==0){
|
889 |
if (maxNLC==0){
|
| 859 |
sb.append(sku + "Max Nlc can't be 0"+"\n");
|
890 |
sb.append(sku + "Max Nlc can't be 0"+"\n");
|
| 860 |
continue;
|
891 |
continue;
|
| 861 |
}
|
892 |
}
|
| - |
|
893 |
warehouse = inventoryClient.getWarehouse(warehouseId);
|
| - |
|
894 |
|
| 862 |
snapdealItem.setWarehouseId(warehouseId);
|
895 |
snapdealItem.setWarehouseId(warehouseId);
|
| 863 |
snapdealItem.setMaxNlc(maxNLC);
|
896 |
snapdealItem.setMaxNlc(maxNLC);
|
| 864 |
}
|
897 |
}
|
| 865 |
|
898 |
|
| 866 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
|
899 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
|
| Line 874... |
Line 907... |
| 874 |
}
|
907 |
}
|
| 875 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
|
908 |
if ((long)sheet.getRow(iterator).getCell(3).getNumericCellValue()==0){
|
| 876 |
snapdealItem.setIsListedOnSnapdeal(false);
|
909 |
snapdealItem.setIsListedOnSnapdeal(false);
|
| 877 |
}
|
910 |
}
|
| 878 |
}
|
911 |
}
|
| 879 |
|
912 |
|
| 880 |
double transferPrice = 0,sellingPrice,commission,courierCost =45,serviceTax,otherCost;
|
913 |
double transferPrice = 0,sellingPrice,commission,courierCost =45,serviceTax,otherCost;
|
| 881 |
if (checkEmptyString(sheet.getRow(iterator).getCell(4))&& new_item){
|
914 |
if (checkEmptyString(sheet.getRow(iterator).getCell(4))&& new_item){
|
| 882 |
sb.append(sku + "New Item - Selling Price cannot be empty"+"\n");
|
915 |
sb.append(sku + "New Item - Selling Price cannot be empty"+"\n");
|
| 883 |
continue;
|
916 |
continue;
|
| 884 |
}
|
917 |
}
|
| Line 889... |
Line 922... |
| 889 |
continue;
|
922 |
continue;
|
| 890 |
}
|
923 |
}
|
| 891 |
snapdealItem.setSellingPrice(sellingPrice);
|
924 |
snapdealItem.setSellingPrice(sellingPrice);
|
| 892 |
marketplaceItem.setCurrentSp(sellingPrice);
|
925 |
marketplaceItem.setCurrentSp(sellingPrice);
|
| 893 |
}
|
926 |
}
|
| 894 |
|
927 |
|
| 895 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
|
928 |
if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
|
| 896 |
otherCost = sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
929 |
otherCost = sheet.getRow(iterator).getCell(5).getNumericCellValue();
|
| 897 |
marketplaceItem.setOtherCost(otherCost);
|
930 |
marketplaceItem.setOtherCost(otherCost);
|
| 898 |
}
|
931 |
}
|
| 899 |
|
932 |
|
| Line 928... |
Line 961... |
| 928 |
sb.append(sku + " New Item - SKU@Snapdeal cannot be empty"+"\n");
|
961 |
sb.append(sku + " New Item - SKU@Snapdeal cannot be empty"+"\n");
|
| 929 |
continue;
|
962 |
continue;
|
| 930 |
}
|
963 |
}
|
| 931 |
snapdealItem.setSkuAtSnapdeal(snapdealItemCode);
|
964 |
snapdealItem.setSkuAtSnapdeal(snapdealItemCode);
|
| 932 |
}
|
965 |
}
|
| 933 |
|
966 |
|
| 934 |
if (checkEmptyString(sheet.getRow(iterator).getCell(9)) && new_item){
|
967 |
if (checkEmptyString(sheet.getRow(iterator).getCell(9)) && new_item){
|
| 935 |
sb.append(sku + " New Item - SUPC code cannot be empty"+"\n");
|
968 |
sb.append(sku + " New Item - SUPC code cannot be empty"+"\n");
|
| 936 |
continue;
|
969 |
continue;
|
| 937 |
}
|
970 |
}
|
| 938 |
|
971 |
|
| Line 945... |
Line 978... |
| 945 |
}
|
978 |
}
|
| 946 |
snapdealItem.setSupc(supc);
|
979 |
snapdealItem.setSupc(supc);
|
| 947 |
}
|
980 |
}
|
| 948 |
double weight = item.getWeight();
|
981 |
double weight = item.getWeight();
|
| 949 |
|
982 |
|
| 950 |
|
983 |
|
| 951 |
if(weight==0){
|
984 |
if(weight==0){
|
| 952 |
sb.append(sku + " Please add weight"+"\n");
|
985 |
sb.append(sku + " Please add weight"+"\n");
|
| 953 |
continue;
|
986 |
continue;
|
| 954 |
}
|
987 |
}
|
| 955 |
if (weight!=0){
|
988 |
if (weight!=0){
|
| Line 968... |
Line 1001... |
| 968 |
marketplaceItem.setCurrentTp(transferPrice);
|
1001 |
marketplaceItem.setCurrentTp(transferPrice);
|
| 969 |
commission = roundTwoDecimals(((marketplaceItem.getCommission()/100)*snapdealItem.getSellingPrice()));
|
1002 |
commission = roundTwoDecimals(((marketplaceItem.getCommission()/100)*snapdealItem.getSellingPrice()));
|
| 970 |
snapdealItem.setCommission(commission);
|
1003 |
snapdealItem.setCommission(commission);
|
| 971 |
serviceTax = roundTwoDecimals((marketplaceItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost()));
|
1004 |
serviceTax = roundTwoDecimals((marketplaceItem.getServiceTax()/100)*(snapdealItem.getCommission()+snapdealItem.getCourierCost()));
|
| 972 |
snapdealItem.setServiceTax(serviceTax);
|
1005 |
snapdealItem.setServiceTax(serviceTax);
|
| 973 |
double vatRate = catalogClientProd.getVatPercentageForItem(snapdealItem.getItem_id(),0,snapdealItem.getSellingPrice());
|
1006 |
double vatRate = catalogClientProd.getVatPercentageForItem(snapdealItem.getItem_id(),warehouse.getStateId(),snapdealItem.getSellingPrice());
|
| 974 |
marketplaceItem.setVat(vatRate);
|
1007 |
marketplaceItem.setVat(vatRate);
|
| 975 |
double vat = roundTwoDecimals((snapdealItem.getSellingPrice()/(1+(marketplaceItem.getVat()/100))-(snapdealItem.getMaxNlc()/(1+(marketplaceItem.getVat()/100))))*(marketplaceItem.getVat()/100));
|
1008 |
double vat = roundTwoDecimals((snapdealItem.getSellingPrice()/(1+(marketplaceItem.getVat()/100))-(snapdealItem.getMaxNlc()/(1+(marketplaceItem.getVat()/100))))*(marketplaceItem.getVat()/100));
|
| 976 |
double inHouseCost = roundTwoDecimals(15+vat+(marketplaceItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+marketplaceItem.getOtherCost());
|
1009 |
double inHouseCost = roundTwoDecimals(15+vat+(marketplaceItem.getReturnProvision()/100)*snapdealItem.getSellingPrice()+marketplaceItem.getOtherCost());
|
| 977 |
double lowest_possible_tp = roundTwoDecimals(snapdealItem.getMaxNlc()+inHouseCost);
|
1010 |
double lowest_possible_tp = roundTwoDecimals(snapdealItem.getMaxNlc()+inHouseCost);
|
| 978 |
marketplaceItem.setMinimumPossibleTp(lowest_possible_tp);
|
1011 |
marketplaceItem.setMinimumPossibleTp(lowest_possible_tp);
|
| 979 |
double lowest_possible_sp = roundTwoDecimals((snapdealItem.getMaxNlc()+(snapdealItem.getCourierCost()+marketplaceItem.getClosingFee())*(1+marketplaceItem.getServiceTax()/100)*(1+(marketplaceItem.getVat()/100))+(15+marketplaceItem.getOtherCost())*(1+(marketplaceItem.getVat())/100))/(1-(marketplaceItem.getCommission()/100+marketplaceItem.getEmiFee()/100)*(1+(marketplaceItem.getServiceTax()/100))*(1+(marketplaceItem.getVat())/100)-(marketplaceItem.getReturnProvision()/100)*(1+(marketplaceItem.getVat())/100)));
|
1012 |
double lowest_possible_sp = roundTwoDecimals((snapdealItem.getMaxNlc()+(snapdealItem.getCourierCost()+marketplaceItem.getClosingFee())*(1+marketplaceItem.getServiceTax()/100)*(1+(marketplaceItem.getVat()/100))+(15+marketplaceItem.getOtherCost())*(1+(marketplaceItem.getVat())/100))/(1-(marketplaceItem.getCommission()/100+marketplaceItem.getEmiFee()/100)*(1+(marketplaceItem.getServiceTax()/100))*(1+(marketplaceItem.getVat())/100)-(marketplaceItem.getReturnProvision()/100)*(1+(marketplaceItem.getVat())/100)));
|
| 980 |
marketplaceItem.setMinimumPossibleSp(lowest_possible_sp);
|
1013 |
marketplaceItem.setMinimumPossibleSp(lowest_possible_sp);
|
| 981 |
snapdealItem.setUpdatedBy(updatedBy);
|
1014 |
snapdealItem.setUpdatedBy(updatedBy);
|
| 982 |
snapdealItem.setMarketplaceItems(marketplaceItem);
|
1015 |
snapdealItem.setMarketplaceItems(marketplaceItem);
|
| - |
|
1016 |
//logger.info(snapdealItem.toString());
|
| 983 |
if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
|
1017 |
if(!catalogClient.addOrUpdateSnapdealItem(snapdealItem)){
|
| 984 |
sb.append(sku + " Service Error\n");
|
1018 |
sb.append(sku + " Service Error\n");
|
| 985 |
}
|
1019 |
}
|
| 986 |
}
|
1020 |
}
|
| 987 |
File file = new File("/tmp/snapdealbulk");
|
1021 |
File file = new File("/tmp/snapdealbulk");
|
| Line 1028... |
Line 1062... |
| 1028 |
double roundTwoDecimals(double d) {
|
1062 |
double roundTwoDecimals(double d) {
|
| 1029 |
DecimalFormat twoPlaces = new DecimalFormat("#.##");
|
1063 |
DecimalFormat twoPlaces = new DecimalFormat("#.##");
|
| 1030 |
return Double.valueOf(twoPlaces.format(d));
|
1064 |
return Double.valueOf(twoPlaces.format(d));
|
| 1031 |
}
|
1065 |
}
|
| 1032 |
|
1066 |
|
| - |
|
1067 |
/*String getLocation(String location){
|
| - |
|
1068 |
logger.info("Inside trim"+location);
|
| - |
|
1069 |
int loc = location.lastIndexOf(',');
|
| - |
|
1070 |
logger.info("end result "+location.substring(loc+1));
|
| - |
|
1071 |
return location.substring(loc+1);
|
| - |
|
1072 |
}*/
|
| - |
|
1073 |
|
| 1033 |
|
1074 |
|
| 1034 |
public String show() {
|
1075 |
public String show() {
|
| 1035 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
1076 |
if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
|
| 1036 |
return "authfail";
|
1077 |
return "authfail";
|
| 1037 |
}
|
1078 |
}
|