Subversion Repositories SmartDukaan

Rev

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

Rev 6532 Rev 6759
Line 55... Line 55...
55
                      
55
                      
56
    private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0, 
56
    private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0, 
57
    				  TABLE_INDEX_PRICING_MOP = 1,
57
    				  TABLE_INDEX_PRICING_MOP = 1,
58
                      TABLE_INDEX_PRICING_DP = 2,
58
                      TABLE_INDEX_PRICING_DP = 2,
59
                      TABLE_INDEX_PRICING_TP = 3,
59
                      TABLE_INDEX_PRICING_TP = 3,
-
 
60
                      TABLE_INDEX_PRICING_NLC = 4,
60
                      TABLE_INDEX_PRICING_BUTTON = 4,
61
                      TABLE_INDEX_PRICING_BUTTON = 5,
61
                      TABLE_INDEX_PRICING_VENDORID = 5;
62
                      TABLE_INDEX_PRICING_VENDORID = 6;
62
 
63
 
63
    private final int TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC = 0, 
64
    private final int TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC = 0, 
64
    				  TABLE_INDEX_SOURCE_PRICING_MRP = 1,
65
    				  TABLE_INDEX_SOURCE_PRICING_MRP = 1,
65
    				  TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE = 2,
66
    				  TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE = 2,
66
    				  TABLE_INDEX_SOURCE_PRICING_BUTTON = 3,
67
    				  TABLE_INDEX_SOURCE_PRICING_BUTTON = 3,
Line 403... Line 404...
403
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
404
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
404
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
405
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
405
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
406
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
406
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
407
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
407
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
408
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
-
 
409
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_NLC, PRICE_WIDTH);
408
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
410
        headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
409
 
411
 
410
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
412
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
411
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
413
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
412
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
414
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
413
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
415
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
414
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
416
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
-
 
417
        headerVendorPrices.setText(0, TABLE_INDEX_PRICING_NLC, "NLC");
415
        
418
        
416
        headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
419
        headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
417
        
420
        
418
        Button addButton = new Button("Add");
421
        Button addButton = new Button("Add");
419
        headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
422
        headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
Line 422... Line 425...
422
            public void onClick(ClickEvent event) {
425
            public void onClick(ClickEvent event) {
423
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
426
                VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
424
                vendorPricesDialog.updateButton.setText("Add");
427
                vendorPricesDialog.updateButton.setText("Add");
425
                vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
428
                vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
426
                    @Override
429
                    @Override
427
                    public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
430
                    public boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId) {
428
                        if(!vendorExists(vendorId)) {
431
                        if(!vendorExists(vendorId)) {
429
                            Window.alert("Vendor already exists");
432
                            Window.alert("Vendor already exists");
430
                            return false;
433
                            return false;
431
                        }
434
                        }
432
                        /*if(!validateVendorPrices(mop, dp, tp)) {
435
                        /*if(!validateVendorPrices(mop, dp, tp)) {
Line 436... Line 439...
436
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
439
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
437
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
440
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
438
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
441
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
439
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
442
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
440
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
443
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
-
 
444
                        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_NLC, PRICE_WIDTH);
441
                        
445
                        
442
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
446
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
443
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
447
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
444
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
448
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
445
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
449
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
446
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
450
                        tableVendorPrices.setText(row, TABLE_INDEX_PRICING_NLC, nlc + "");
447
                        
451
                        
448
                        tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
452
                        tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
449
                        return true;
453
                        return true;
450
                    }
454
                    }
451
                });
455
                });
Line 762... Line 766...
762
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
766
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
763
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
767
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
764
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
768
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
765
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
769
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
766
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
770
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
-
 
771
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_NLC, PRICE_WIDTH);
767
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
772
        tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
768
 
773
 
769
 
774
 
770
        int i=0;
775
        int i=0;
771
        for(VendorPricings vendorDetail : vendorPricingMap.values()){
776
        for(VendorPricings vendorDetail : vendorPricingMap.values()){
772
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
777
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
773
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
778
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
774
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
779
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
775
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
780
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
776
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
781
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
-
 
782
            tableVendorPrices.setText(i, TABLE_INDEX_PRICING_NLC, vendorDetail.getNlc() + "");
777
            Button editButton = new Button("Edit");
783
            Button editButton = new Button("Edit");
778
            tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
784
            tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
779
            editButton.addClickHandler(new ClickHandler() {
785
            editButton.addClickHandler(new ClickHandler() {
780
                @Override
786
                @Override
781
                public void onClick(ClickEvent event) {
787
                public void onClick(ClickEvent event) {
Line 1304... Line 1310...
1304
        for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
1310
        for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
1305
            v = new VendorPricings();
1311
            v = new VendorPricings();
1306
            v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
1312
            v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
1307
            v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
1313
            v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
1308
            v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
1314
            v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
-
 
1315
            v.setNlc(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_NLC)));
1309
            v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
1316
            v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
1310
            vendorPrices.put(v.getVendorId(), v);
1317
            vendorPrices.put(v.getVendorId(), v);
1311
        }
1318
        }
1312
        newItem.setVendorPricesMap(vendorPrices);
1319
        newItem.setVendorPricesMap(vendorPrices);
1313
        newItem.setItemStatusDesc(statusDesc.getText().trim());
1320
        newItem.setItemStatusDesc(statusDesc.getText().trim());
Line 1359... Line 1366...
1359
     */
1366
     */
1360
    private void editVendorPrices(final long vendorId, final int row) {
1367
    private void editVendorPrices(final long vendorId, final int row) {
1361
        String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
1368
        String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
1362
        String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
1369
        String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
1363
        String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
1370
        String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
-
 
1371
        String nlc = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_NLC);
1364
        VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
1372
        VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp, nlc);
1365
        pricesDialog.updateButton.setText("Update");
1373
        pricesDialog.updateButton.setText("Update");
1366
        pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
1374
        pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
1367
            @Override
1375
            @Override
1368
            public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
1376
            public boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId) {
1369
                if(!validateVendorPrices(mop, dp, tp)) {
1377
                if(!validateVendorPrices(mop, dp, tp, nlc)) {
1370
                    return false;
1378
                    return false;
1371
                }
1379
                }
1372
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
1380
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
1373
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
1381
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
1374
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
1382
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
-
 
1383
                tableVendorPrices.setText(row, TABLE_INDEX_PRICING_NLC, nlc + "");
1375
                return true;
1384
                return true;
1376
            }
1385
            }
1377
        });
1386
        });
1378
        pricesDialog.show();
1387
        pricesDialog.show();
1379
    }
1388
    }
Line 1540... Line 1549...
1540
                sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
1549
                sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
1541
            }
1550
            }
1542
            if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
1551
            if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
1543
            	vendorPricingsChanged = true;
1552
            	vendorPricingsChanged = true;
1544
            }
1553
            }
-
 
1554
            if(vendorPricings.getNlc() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_NLC))) {
-
 
1555
            	vendorPricingsChanged = true;
-
 
1556
            }
1545
        }
1557
        }
1546
        if(vendorPricingsChanged){
1558
        if(vendorPricingsChanged){
1547
        	sb.append("\n-Vendor Pricing");
1559
        	sb.append("\n-Vendor Pricing");
1548
        	optionalChangedValMap.put(OPTIONAL_VENDOR_PRICING, newItem.getVendorPricesMap());
1560
        	optionalChangedValMap.put(OPTIONAL_VENDOR_PRICING, newItem.getVendorPricesMap());
1549
        }
1561
        }
Line 1606... Line 1618...
1606
            }
1618
            }
1607
        }
1619
        }
1608
        return true;
1620
        return true;
1609
    }
1621
    }
1610
    
1622
    
1611
    private boolean validateVendorPrices(double mop, double dp, double tp) {
1623
    private boolean validateVendorPrices(double mop, double dp, double tp, double nlc) {
1612
        if(item.getMrp() != null && item.getMrp() < mop) {
1624
        if(item.getMrp() != null && item.getMrp() < mop) {
1613
            Window.alert("MOP cannot be more than MRP.");
1625
            Window.alert("MOP cannot be more than MRP.");
1614
            return false;
1626
            return false;
1615
        }
1627
        }
1616
        if(tp > mop) {
1628
        if(tp > mop) {
1617
            Window.alert("Transfer Price cannot be more than MOP.");
1629
            Window.alert("Transfer Price cannot be more than MOP.");
1618
            return false;
1630
            return false;
1619
        }
1631
        }
-
 
1632
        if(tp < nlc) {
-
 
1633
            Window.alert("Transfer Price cannot be less than NLC.");
-
 
1634
            return false;
-
 
1635
        }
1620
        return true;
1636
        return true;
1621
    }
1637
    }
1622
 
1638
 
1623
    private boolean validateSourcePrices(double mrp, double sellingPrice) {
1639
    private boolean validateSourcePrices(double mrp, double sellingPrice) {
1624
        if(sellingPrice > mrp) {
1640
        if(sellingPrice > mrp) {