Subversion Repositories SmartDukaan

Rev

Rev 2138 | Rev 2359 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2138 Rev 2252
Line 64... Line 64...
64
    @UiField TextBox bestDealsText, bestDealsValue; 
64
    @UiField TextBox bestDealsText, bestDealsValue; 
65
    @UiField FlexTable headerAvailability, availabilityTable;
65
    @UiField FlexTable headerAvailability, availabilityTable;
66
    @UiField FlexTable headerVendorM, vendorTableM;
66
    @UiField FlexTable headerVendorM, vendorTableM;
67
    @UiField FlexTable headerVendor, vendorTable;
67
    @UiField FlexTable headerVendor, vendorTable;
68
    @UiField TextBox bestSellingRank;
68
    @UiField TextBox bestSellingRank;
69
    @UiField CheckBox defaultForEntity;
69
    @UiField CheckBox defaultForEntity, risky;
70
    //@UiField Button submit;
70
    //@UiField Button submit;
71
    @UiField DateBox startDate;
71
    @UiField DateBox startDate;
72
 
72
 
73
    public ItemDetails(Item item){
73
    public ItemDetails(Item item){
74
        this();
74
        this();
Line 109... Line 109...
109
 
109
 
110
        bestDealsText.setText(item.getBestDealsText());
110
        bestDealsText.setText(item.getBestDealsText());
111
        bestDealsValue.setText(item.getBestDealsValue() != -1 ? item.getBestDealsValue()+"" : "");
111
        bestDealsValue.setText(item.getBestDealsValue() != -1 ? item.getBestDealsValue()+"" : "");
112
        bestSellingRank.setText(item.getBestSellingRank() != -1 ? item.getBestSellingRank()+"" : "");
112
        bestSellingRank.setText(item.getBestSellingRank() != -1 ? item.getBestSellingRank()+"" : "");
113
        defaultForEntity.setValue(item.isDefaultForEntity());
113
        defaultForEntity.setValue(item.isDefaultForEntity());
-
 
114
        risky.setValue(item.isRisky());
114
        
115
        
115
        itemStatus.setText(item.getItemStatus());
116
        itemStatus.setText(item.getItemStatus());
116
 
117
 
117
        updateAvailabilityTable(item.getAvailability());
118
        updateAvailabilityTable(item.getAvailability());
118
        updateMappingTable(item.getVendorMappingsMap());
119
        updateMappingTable(item.getVendorMappingsMap());
Line 318... Line 319...
318
        }
319
        }
319
        try {
320
        try {
320
            if(!createNewItem()) {
321
            if(!createNewItem()) {
321
                return;
322
                return;
322
            }
323
            }
-
 
324
            String paramsChanged = isItemChanged();
323
            if(!isItemChanged()) {
325
            if(paramsChanged.equals("")) {
324
                Window.alert("Nothing to update. Please change intended item parameters and try again.");
326
                Window.alert("Nothing to update. Please change intended item parameters and try again.");
325
                return;
327
                return;
-
 
328
            } else {
-
 
329
                paramsChanged = "You have changed following items.\n" + paramsChanged;
-
 
330
                Window.alert(paramsChanged);
326
            }
331
            }
327
        } catch(NumberFormatException ex) {
332
        } catch(NumberFormatException ex) {
328
            ex.printStackTrace();
333
            ex.printStackTrace();
329
            GWT.log("Number format exception");
334
            GWT.log("Number format exception");
330
        }
335
        }
Line 448... Line 453...
448
        } catch(NumberFormatException ex) {
453
        } catch(NumberFormatException ex) {
449
            Window.alert("Invalid best selling rank format");
454
            Window.alert("Invalid best selling rank format");
450
            return false;
455
            return false;
451
        }
456
        }
452
        newItem.setDefaultForEntity(defaultForEntity.getValue());
457
        newItem.setDefaultForEntity(defaultForEntity.getValue());
-
 
458
        newItem.setRisky(risky.getValue());
453
        
459
        
454
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
460
        /*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
455
          Add the instance to map and set the map to the item instance created above.*/
461
          Add the instance to map and set the map to the item instance created above.*/
456
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
462
        Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
457
        VendorPricings v;
463
        VendorPricings v;
Line 532... Line 538...
532
            }
538
            }
533
        });
539
        });
534
        mappingDialog.show();
540
        mappingDialog.show();
535
    }
541
    }
536
 
542
 
537
    private boolean isItemChanged() {
543
    private String isItemChanged() {
-
 
544
        StringBuilder sb = new StringBuilder("");
538
        if(!productGroup.getText().trim().equals(item.getProductGroup())) {
545
        if(!productGroup.getText().trim().equals(item.getProductGroup())) {
539
            return true;
546
            sb.append("\nProduct Group");
540
        }
547
        }
541
        if(!brand.getText().trim().equals(item.getBrand())) {
548
        if(!brand.getText().trim().equals(item.getBrand())) {
542
            return true;
549
            sb.append("\nBrand");
543
        }
550
        }
544
        if(!modelNumber.getText().trim().equals(item.getModelNumber())) {
551
        if(!modelNumber.getText().trim().equals(item.getModelNumber())) {
545
            return true;
552
            sb.append("\nModel Number");
546
        }
553
        }
547
        if(!modelName.getText().trim().equals(item.getModelName())) {
554
        if(!modelName.getText().trim().equals(item.getModelName())) {
548
            return true;
555
            sb.append("\nModel Name");
549
        }
556
        }
550
        if(!color.getText().trim().equals(item.getColor())) {
557
        if(!color.getText().trim().equals(item.getColor())) {
551
            return true;
558
            sb.append("\nColor");
552
        }
559
        }
553
        if(!comments.getText().trim().equals(item.getComments())) {
560
        if(!comments.getText().trim().equals(item.getComments())) {
554
            return true;
561
            sb.append("\nComments");
555
        }
562
        }
556
        if(newItem.getMrp() != item.getMrp()) {
563
        if(newItem.getMrp() != item.getMrp()) {
557
            return true;
564
            sb.append("\nMRP");
558
        }
565
        }
559
        if(newItem.getSellingPrice() != item.getSellingPrice()) {
566
        if(newItem.getSellingPrice() != item.getSellingPrice()) {
560
            return true;
567
            sb.append("\nSelling Price");
561
        }
568
        }
562
        if(newItem.getWeight() != item.getWeight()) {
569
        if(newItem.getWeight() != item.getWeight()) {
563
            return true;
570
            sb.append("\nWeight");
564
        }
571
        }
565
        if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
572
        if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
566
            return true;
573
            sb.append("\nBest Deal Text");
567
        }
574
        }
568
        if(newItem.getBestDealsValue() != item.getBestDealsValue()) {
575
        if(newItem.getBestDealsValue() != item.getBestDealsValue()) {
569
            return true;
576
            sb.append("\nBest Deal Value");
570
        }
577
        }
571
        if(newItem.getBestSellingRank() != item.getBestSellingRank()) {
578
        if(newItem.getBestSellingRank() != item.getBestSellingRank()) {
572
            return true;
579
            sb.append("\nBest Selling Rank");
573
        }
580
        }
574
        if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
581
        if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
-
 
582
            sb.append("\nDefault For Entity Flag");
-
 
583
        }
-
 
584
        if(item.isRisky() != risky.getValue()) {
575
            return true;
585
            sb.append("\nRisky Flag");
576
        }
586
        }
577
        if(newItem.getStartDate() != item.getStartDate()) {
587
        if(newItem.getStartDate() != item.getStartDate()) {
578
            return true;
588
            sb.append("\nStart Date");
579
        }
589
        }
580
        VendorPricings vendorPricings;
590
        VendorPricings vendorPricings;
581
        long vendorId;
591
        long vendorId;
582
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
592
        for(int row = 0; row < vendorTable.getRowCount(); row++) {
583
            vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
593
            vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
584
            vendorPricings = item.getVendorPricesMap().get(vendorId);
594
            vendorPricings = item.getVendorPricesMap().get(vendorId);
585
            if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
595
            if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
586
                return true;
596
                sb.append("\nMOP (Vendor:" + vendorId + ")");
587
            }
597
            }
588
            if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
598
            if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
589
                return true;
599
                sb.append("\nDealer Price (Vendor:" + vendorId + ")");
590
            }
600
            }
591
            if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP))) {
601
            if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP))) {
592
                return true;
602
                sb.append("\nTransfer Price (Vendor:" + vendorId + ")");
593
            }
603
            }
594
        }
604
        }
595
        return false;
605
        return sb.toString();
596
    }
606
    }
597
    
607
    
598
    private boolean validatePrices() {
608
    private boolean validatePrices() {
599
        if(newItem.getSellingPrice() > newItem.getMrp()) {
609
        if(newItem.getSellingPrice() > newItem.getMrp()) {
600
            Window.alert("Selling price cannot be more than MRP");
610
            Window.alert("Selling price cannot be more than MRP");