@Override
 public HashMap<String, Object> saveView() {
   HashMap<String, Object> map = new HashMap<String, Object>();
   map.put("activeInActive", activeInActiveSelect.getSelectedValue());
   map.put("currentView", trasactionViewSelect.getSelectedValue());
   map.put("transactionType", trasactionViewTypeSelect.getSelectedValue());
   map.put("dateRange", dateRangeSelector.getSelectedValue());
   map.put("selectedItem", selectedItem == null ? "" : selectedItem.getName());
   map.put("itemSelection", itemsListGrid.getSelection());
   return map;
 }
 @Override
 public HashMap<String, Object> saveView() {
   HashMap<String, Object> map = new HashMap<String, Object>();
   map.put("activeInActive", activeInActiveSelect.getSelectedValue());
   map.put("currentView", trasactionViewSelect.getSelectedValue());
   map.put("transactionType", trasactionViewTypeSelect.getSelectedValue());
   map.put("dateRange", dateRangeSelector.getSelectedValue());
   map.put("selectedCustomer", selectedCustomer == null ? "" : selectedCustomer.getName());
   PayeeList selection = custGrid.getSelection();
   map.put("payeeSelection", selection);
   return map;
 }
 private int getTransactionStatusType() {
   if (trasactionViewTypeSelect.getSelectedValue() != null) {
     Set<Integer> keySet = transactiontypebyStatusMap.keySet();
     for (Integer integerKey : keySet) {
       String entrystring = transactiontypebyStatusMap.get(integerKey);
       if (trasactionViewTypeSelect.getSelectedValue().equals(entrystring)) {
         return integerKey;
       }
     }
   }
   return TransactionHistory.ALL_INVOICES;
 }
 private int getTransactionType() {
   String selectedValue = trasactionViewSelect.getSelectedValue();
   if (selectedValue.equalsIgnoreCase(messages.invoices())) {
     return ClientTransaction.TYPE_INVOICE;
   } else if (selectedValue.equalsIgnoreCase(messages.cashSales())) {
     return ClientTransaction.TYPE_CASH_SALES;
   } else if (selectedValue.equalsIgnoreCase(messages.payeeCreditNotes(Global.get().Customer()))) {
     return ClientTransaction.TYPE_CUSTOMER_CREDIT_MEMO;
   } else if (selectedValue.equalsIgnoreCase(messages.quotes())
       || selectedValue.equalsIgnoreCase(messages.credits())
       || selectedValue.equalsIgnoreCase(messages.Charges())) {
     return ClientTransaction.TYPE_ESTIMATE;
   } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.cashPurchases())) {
     return ClientTransaction.TYPE_CASH_PURCHASE;
   } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.bills())) {
     return ClientTransaction.TYPE_ENTER_BILL;
   } else if (trasactionViewSelect
       .getSelectedValue()
       .equalsIgnoreCase(messages.payeeCreditNotes(Global.get().Vendor()))) {
     return ClientTransaction.TYPE_VENDOR_CREDIT_MEMO;
   } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.expenses())) {
     return ClientTransaction.TYPE_EXPENSE;
   } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.salesOrders())) {
     return TransactionHistory.TYPE_SALES_ORDER;
   } else if (trasactionViewSelect
       .getSelectedValue()
       .equalsIgnoreCase(messages.purchaseOrders())) {
     return TransactionHistory.TYPE_PURCHASE_ORDER;
   }
   return 0;
 }
  private int getTransactionType() {
    String selectedValue = trasactionViewSelect.getSelectedValue();
    if (selectedValue.equalsIgnoreCase(messages.invoices())) {

      return TYPE_INVOICE;
    } else if (selectedValue.equalsIgnoreCase(messages.cashSales())) {
      return TYPE_CAHSSALE;
    } else if (selectedValue.equalsIgnoreCase(messages.receivedPayments())) {
      return TYPE_RECEIVE_PAYMENT;
    } else if (selectedValue.equalsIgnoreCase(messages.CustomerCreditNotes())) {
      return TYPE_CREDITNOTE;
    } else if (selectedValue.equalsIgnoreCase(messages.quotes())
        || selectedValue.equalsIgnoreCase(messages.credits())
        || selectedValue.equalsIgnoreCase(messages.Charges())) {
      return TYPE_ESTIMATE;
    } else if (selectedValue.equalsIgnoreCase(messages.customerRefunds(Global.get().Customer()))) {
      return TYPE_CUSTOMER_REFUND;
    } else if (selectedValue.equalsIgnoreCase(messages.cheques())) {
      return TYPE_WRITE_CHECK;
    } else if (selectedValue.equalsIgnoreCase(messages.salesOrders())) {
      return TYPE_SALES_ORDER;
    }
    return TYPE_ALL_TRANSACTION;
  }
  private void getMessagesList() {
    transactiontypebyStatusMap = new HashMap<Integer, String>();
    String selectedValue = trasactionViewSelect.getSelectedValue();
    if (selectedValue.equalsIgnoreCase(messages.allTransactions())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_TRANSACTIONS, messages.allTransactions());
    } else if (selectedValue.equalsIgnoreCase(messages.invoices())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_INVOICES, messages.getallInvoices());
      transactiontypebyStatusMap.put(
          TransactionHistory.OPENED_INVOICES, messages.getOpendInvoices());
      transactiontypebyStatusMap.put(
          TransactionHistory.OVER_DUE_INVOICES, messages.overDueInvoices());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_INVOICES, messages.draftTransaction(messages.invoices()));
      }
    } else if (selectedValue.equalsIgnoreCase(messages.cashSales())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_CASHSALES, messages.all() + " " + messages.cashSales());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CASHSALES, messages.draftTransaction(messages.cashSales()));
      }

    } else if (selectedValue.equalsIgnoreCase(messages.quotes())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_QUOTES, messages.allQuotes());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_QUOTES, messages.draftTransaction(messages.quotes()));
      }
    } else if (selectedValue.equalsIgnoreCase(messages.credits())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_CREDITS, messages.allCredits());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CREDITS, messages.draftTransaction(messages.credits()));
      }

    } else if (selectedValue.equalsIgnoreCase(messages.Charges())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_CHARGES, messages.allCahrges());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CHARGES, messages.draftTransaction(messages.Charges()));
      }

    } else if (selectedValue.equalsIgnoreCase(messages.receivedPayments())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_RECEIVEDPAYMENTS,
          messages.all() + " " + messages.receivedPayments());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_CASH, messages.receivedPaymentsbyCash());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_CHEQUE, messages.receivedPaymentsbyCheque());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_CREDITCARD, messages.receivedPaymentsbyCreditCard());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_DIRECT_DEBIT, messages.receivedPaymentsbyDirectDebit());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_MASTERCARD, messages.receivedPaymentsbyMastercard());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_ONLINE, messages.receivedPaymentsbyOnlineBanking());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_STANDING_ORDER,
          messages.receivedPaymentsbyStandingOrder());
      transactiontypebyStatusMap.put(
          TransactionHistory.RECEV_PAY_BY_MAESTRO, messages.receivedPaymentsbySwitchMaestro());

    } else if (selectedValue.equalsIgnoreCase(messages.CustomerCreditNotes())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_CREDITMEMOS, messages.allCreditMemos());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CREDITMEMOS, messages.draftTransaction(messages.creditNote()));
      }
      // transactiontypebyStatusMap.put(
      // TransactionHistory.OPEND_CREDITMEMOS,
      // messages.openCreditMemos());

    } else if (selectedValue.equalsIgnoreCase(messages.customerRefunds(Global.get().Customer()))) {
      transactiontypebyStatusMap.put(
          TransactionHistory.REFUNDS_BY_CREDITCARD, messages.refundsByCreditCard());
      transactiontypebyStatusMap.put(TransactionHistory.REFUNDS_BYCASH, messages.refundsByCash());
      transactiontypebyStatusMap.put(
          TransactionHistory.REFUNDS_BYCHEQUE, messages.refundsByCheck());

      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_CUSTOMER_REFUNDS, messages.allCustomerRefunds());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CUSTOMER_REFUNDS,
            messages.draftTransaction(messages.customerRefunds(Global.get().Customer())));
      }
    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.cheques())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_CHEQUES, messages.allcheques());
      if (Accounter.hasPermission(Features.DRAFTS)) {
        transactiontypebyStatusMap.put(
            TransactionHistory.DRAFT_CHEQUES, messages.draftTransaction(messages.cheques()));
      }
    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.salesOrders())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_SALES_ORDERS, messages.all());
      transactiontypebyStatusMap.put(
          TransactionHistory.COMPLETED_SALES_ORDERS, messages.completed());
      transactiontypebyStatusMap.put(TransactionHistory.OPEN_SALES_ORDERS, messages.open());
    }
    List<String> typeList = new ArrayList<String>(transactiontypebyStatusMap.values());
    Collections.sort(
        typeList,
        new Comparator<String>() {

          @Override
          public int compare(String entry1, String entry2) {
            return entry1.compareTo(entry2);
          }
        });
    trasactionViewTypeSelect.initCombo(typeList);
    trasactionViewTypeSelect.setComboItem(typeList.get(0));
  }
  private void getMessagesList() {
    String selectedValue = trasactionViewSelect.getSelectedValue();
    transactiontypebyStatusMap = new HashMap<Integer, String>();
    if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.allTransactions())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_TRANSACTIONS, messages.allTransactions());
    } else if (selectedValue.equalsIgnoreCase(messages.quotes())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_QUOTES, messages.allQuotes());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_QUOTES, messages.draftTransaction(messages.quotes()));

    } else if (selectedValue.equalsIgnoreCase(messages.Charges())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_CHARGES, messages.allCahrges());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CHARGES, messages.draftTransaction(messages.Charges()));

    } else if (selectedValue.equalsIgnoreCase(messages.credits())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_CREDITS, messages.allCredits());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CREDITS, messages.draftTransaction(messages.credits()));

    } else if (selectedValue.equalsIgnoreCase(messages.invoices())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_INVOICES, messages.getallInvoices());
      transactiontypebyStatusMap.put(
          TransactionHistory.OPENED_INVOICES, messages.getOpendInvoices());
      transactiontypebyStatusMap.put(
          TransactionHistory.OVER_DUE_INVOICES, messages.overDueInvoices());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_INVOICES, messages.draftTransaction(messages.invoices()));
    } else if (selectedValue.equalsIgnoreCase(messages.cashSales())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_CASHSALES, messages.all() + " " + messages.cashSales());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CASHSALES, messages.draftTransaction(messages.cashSales()));

    } else if (selectedValue.equalsIgnoreCase(messages.payeeCreditNotes(Global.get().Customer()))) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_CREDITMEMOS, messages.allCreditMemos());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CREDITMEMOS, messages.draftTransaction(messages.creditNote()));
      // transactiontypebyStatusMap.put(
      // TransactionHistory.OPEND_CREDITMEMOS,
      // messages.openCreditMemos());

    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.cashPurchases())) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_CASH_PURCHASES, messages.allCashPurchases());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CASH_PURCHASES,
          messages.draftTransaction(messages.cashPurchases()));

    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.bills())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_BILLS, messages.allBills());
      transactiontypebyStatusMap.put(
          TransactionHistory.OPEND_BILLS, messages.all() + " " + messages.openedBills());
      transactiontypebyStatusMap.put(
          TransactionHistory.OVERDUE_BILLS, messages.all() + " " + messages.overDueBills());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_BILLS, messages.draftTransaction(messages.bills()));

    } else if (trasactionViewSelect
        .getSelectedValue()
        .equalsIgnoreCase(messages.payeeCreditNotes(Global.get().Vendor()))) {
      transactiontypebyStatusMap.put(
          TransactionHistory.ALL_VENDOR_CREDITNOTES,
          messages.all() + " " + messages.payeeCreditNotes(Global.get().Vendor()));
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_VENDOR_CREDITNOTES,
          messages.draftTransaction(messages.payeeCreditNotes(Global.get().Vendor())));

    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.expenses())) {
      transactiontypebyStatusMap.put(TransactionHistory.ALL_EXPENSES, messages.allExpenses());
      transactiontypebyStatusMap.put(
          TransactionHistory.CREDIT_CARD_EXPENSES, messages.creditCardExpenses());
      transactiontypebyStatusMap.put(TransactionHistory.CASH_EXPENSES, messages.cashExpenses());
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CREDIT_CARD_EXPENSES,
          messages.draftTransaction(messages.creditCardExpenses()));
      transactiontypebyStatusMap.put(
          TransactionHistory.DRAFT_CASH_EXPENSES,
          messages.draftTransaction(messages.cashExpenses()));

    } else if (trasactionViewSelect.getSelectedValue().equalsIgnoreCase(messages.salesOrders())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_SALES_ORDERS, messages.all());
      transactiontypebyStatusMap.put(TransactionHistory.DRAFT_SALES_ORDERS, messages.drafts());

    } else if (trasactionViewSelect
        .getSelectedValue()
        .equalsIgnoreCase(messages.purchaseOrders())) {

      transactiontypebyStatusMap.put(TransactionHistory.ALL_PURCHASE_ORDERS, messages.all());
      transactiontypebyStatusMap.put(TransactionHistory.DRAFT_PURCHASE_ORDERS, messages.drafts());
    }
    List<String> typeList = new ArrayList<String>(transactiontypebyStatusMap.values());
    Collections.sort(
        typeList,
        new Comparator<String>() {

          @Override
          public int compare(String entry1, String entry2) {
            return entry1.compareTo(entry2);
          }
        });
    trasactionViewTypeSelect.initCombo(typeList);
    trasactionViewTypeSelect.setComboItem(typeList.get(0));
  }