private boolean isTolerable() {
   double tolerance = CurrencyUtil.getMainCurrency().getTolerance();
   double diff = dueAmount - (totalTenderedAmount - totalCashBackAmount);
   if (diff <= tolerance) {
     if (diff > 0) {
       doAddToleranceToTicketDiscount(diff);
     }
     return true;
   }
   return false;
 }
  private boolean isValidAmount() {
    double remainingBalance = dueAmount - (totalTenderedAmount - totalCashBackAmount);
    if (totalTenderedAmount <= 0 || remainingBalance < 0) {
      return false;
    }

    double toleranceAmount = CurrencyUtil.getMainCurrency().getTolerance();
    if (remainingBalance > toleranceAmount) {
      return true;
    }

    if (!isTolerable()) {
      return false;
    }

    return true;
  }
  private void init() {
    JPanel contentPane = getContentPanel();
    setOkButtonText(POSConstants.SAVE_BUTTON_TEXT);
    setTitle("Enter tender amount");
    setTitlePaneText("Due amount: " + CurrencyUtil.getCurrencySymbol() + dueAmount);
    setResizable(true);

    MigLayout layout =
        new MigLayout(
            "inset 0", "[grow,fill]", "[grow,fill]"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    contentPane.setLayout(layout);

    JPanel inputPanel =
        new JPanel(
            new MigLayout(
                "fill,ins 0",
                "[fill][right]30px[120px,grow,fill,right][120px,grow,fill,right][][]",
                ""));

    inputPanel.add(getJLabel("Currency", Font.BOLD, 16, JLabel.LEADING));
    inputPanel.add(getJLabel("Remaining", Font.BOLD, 16, JLabel.CENTER), "gapleft 20");
    inputPanel.add(getJLabel("Tender", Font.BOLD, 16, JLabel.TRAILING), "center");
    inputPanel.add(getJLabel("Cash Back", Font.BOLD, 16, JLabel.TRAILING), "center");

    for (Currency currency : currencyList) {
      CurrencyRow item = new CurrencyRow(currency, dueAmount);
      inputPanel.add(item.currencyName, "newline");
      inputPanel.add(item.lblRemainingBalance);
      inputPanel.add(item.tfTenderdAmount, "grow");
      inputPanel.add(item.tfCashBackAmount, "grow");
      // inputPanel.add(item.btnExact, "h " + PosUIManager.getSize(30));
      // inputPanel.add(item.btnRound, "h " + PosUIManager.getSize(30));

      currencyRows.add(item);
    }
    contentPane.add(inputPanel, "cell 0 2,alignx left,aligny top"); // $NON-NLS-1$

    NumericKeypad numericKeypad = new NumericKeypad();
    contentPane.add(new JSeparator(), "newline, gapbottom 5,gaptop 10"); // $NON-NLS-1$
    contentPane.add(numericKeypad, "newline"); // $NON-NLS-1$
  }