private void viewReport() throws Exception {
    Date fromDate = fromDatePicker.getDate();
    Date toDate = toDatePicker.getDate();

    if (fromDate.after(toDate)) {
      POSMessageDialog.showError(
          com.floreantpos.util.POSUtil.getFocusedWindow(),
          com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_);
      return;
    }

    fromDate = DateUtil.startOfDay(fromDate);
    toDate = DateUtil.endOfDay(toDate);

    ReportService reportService = new ReportService();
    JournalReportModel report = reportService.getJournalReport(fromDate, toDate);

    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("reportTitle", "========= JOURNAL REPORT ==========");
    map.put("fromDate", ReportService.formatShortDate(fromDate));
    map.put("toDate", ReportService.formatShortDate(toDate));
    map.put("reportTime", ReportService.formatFullDate(new Date()));

    JasperReport jasperReport = ReportUtil.getReport("journal_report");
    JasperPrint jasperPrint =
        JasperFillManager.fillReport(
            jasperReport, map, new JRTableModelDataSource(report.getTableModel()));
    JRViewer viewer = new JRViewer(jasperPrint);
    reportContainer.removeAll();
    reportContainer.add(viewer);
    reportContainer.revalidate();
  }
  private void doRefreshReport(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_doRefreshReport
    Date fromDate = dpStartDate.getDate();
    Date toDate = dpEndDate.getDate();

    if (fromDate.after(toDate)) {
      POSMessageDialog.showError(
          com.floreantpos.util.POSUtil.getFocusedWindow(),
          com.floreantpos.POSConstants.FROM_DATE_CANNOT_BE_GREATER_THAN_TO_DATE_);
      return;
    }

    try {
      reportPanel.removeAll();
      reportPanel.revalidate();

      if (report != null) {
        int reportType = cbReportType.getSelectedIndex();

        report.setReportType(reportType);
        report.setStartDate(fromDate);
        report.setEndDate(toDate);

        report.refresh();

        if (report != null && report.getViewer() != null) {
          reportPanel.add(report.getViewer());
          reportPanel.revalidate();
        }
      }

    } catch (Exception e) {
      MessageDialog.showError(com.floreantpos.POSConstants.ERROR_MESSAGE, e);
    }
  } // GEN-LAST:event_doRefreshReport
  @Override
  protected boolean updateModel() {
    Tax tax = (Tax) getBean();

    String name = tfName.getText();
    if (POSUtil.isBlankOrNull(name)) {
      MessageDialog.showError(com.floreantpos.POSConstants.NAME_REQUIRED);
      return false;
    }

    tax.setName(name);
    tax.setRate(new Double(tfRate.getValue().toString()).doubleValue());

    return true;
  }
  public static InventoryItem fromCSV(String csvLine) {
    if (StringUtils.isEmpty(csvLine)) {
      return null;
    }

    String[] strings = csvLine.split(",");

    InventoryItem inventoryItem = new InventoryItem();

    int index = 0;

    try {

      //			"NAME", "UNIT_PER_PACKAGE", "TOTAL_PACKAGES", "AVERAGE_PACKAGE_PRICE",
      // "TOTAL_RECEPIE_UNITS",
      //			"UNIT_PURCHASE_PRICE", "PACKAGE_BARCODE", "UNIT_BARCODE", "PACKAGE_DESC", "SORT_ORDER",
      // "PACKAGE_REORDER_LEVEL",
      //			"PACKAGE_REPLENISH_LEVEL","DESCRIPTION","UNIT_SELLING_PRICE"

      inventoryItem.setName(strings[index++]);
      inventoryItem.setUnitPerPackage((float) POSUtil.parseDouble(strings[index++]));
      inventoryItem.setTotalPackages(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setAveragePackagePrice(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setTotalRecepieUnits(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setUnitPurchasePrice(POSUtil.parseDouble(strings[index++]));
      inventoryItem.setPackageBarcode(strings[index++]);
      inventoryItem.setUnitBarcode(strings[index++]);
      inventoryItem.setPackageDescription(strings[index++]);
      inventoryItem.setSortOrder(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setPackageReorderLevel(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setPackageReplenishLevel(POSUtil.parseInteger(strings[index++]));
      inventoryItem.setDescription(strings[index++]);
      inventoryItem.setUnitSellingPrice(POSUtil.parseDouble(strings[index++]));

    } catch (Exception e) {
      // e.printStackTrace();
    }

    return inventoryItem;
  }
  @Override
  public void doOk() {
    updateView();

    if (!isValidAmount()) {
      POSMessageDialog.showMessage(POSUtil.getFocusedWindow(), "Invalid Amount"); // $NON-NLS-1$
      return;
    }

    Terminal terminal = Application.getInstance().getTerminal();

    cashDrawer = CashDrawerDAO.getInstance().findByTerminal(terminal);
    if (cashDrawer == null) {
      cashDrawer = new CashDrawer();
      cashDrawer.setTerminal(terminal);

      if (cashDrawer.getCurrencyBalanceList() == null) {
        cashDrawer.setCurrencyBalanceList(new HashSet());
      }
    }

    for (CurrencyRow rowItem : currencyRows) {
      CurrencyBalance item = cashDrawer.getCurrencyBalance(rowItem.currency);
      if (item == null) {
        item = new CurrencyBalance();
        item.setCurrency(rowItem.currency);
        item.setCashDrawer(cashDrawer);
        cashDrawer.addTocurrencyBalanceList(item);
      }
      double tenderAmount = rowItem.getTenderAmount();
      double cashBackAmount = rowItem.getCashBackAmount();

      if (tenderAmount > 0) {
        ticket.addProperty(rowItem.currency.getName(), String.valueOf(tenderAmount));
      }
      if (cashBackAmount > 0) {
        ticket.addProperty(
            rowItem.currency.getName() + "_CASH_BACK", String.valueOf(cashBackAmount));
      }
      item.setBalance(
          NumberUtil.roundToThreeDigit(item.getBalance() + tenderAmount - cashBackAmount));
    }

    setCanceled(false);
    dispose();
  }