public String getDisplayText() { Tax tax = (Tax) getBean(); if (tax.getId() == null) { return com.floreantpos.POSConstants.NEW_TAX_RATE; } return com.floreantpos.POSConstants.EDIT_TAX_RATE; }
@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; }
private void initData() { List<Tax> taxes = TaxDAO.getInstance().findAll(); cbTax.setModel(new ComboBoxModel(taxes)); int defaultTaxId = TerminalConfig.getMiscItemDefaultTaxId(); if (defaultTaxId != -1) { for (int i = 0; i < taxes.size(); i++) { Tax tax = taxes.get(i); if (tax.getId() == defaultTaxId) { cbTax.setSelectedIndex(i); break; } } } List<PrinterGroup> printerGroups = PrinterGroupDAO.getInstance().findAll(); cbPrinterGroup.setModel(new ComboBoxModel(printerGroups)); }
private void doFinish(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_doFinish double amount = tfItemPrice.getDouble(); String itemName = tfItemName.getText(); if (StringUtils.isEmpty(itemName)) { POSMessageDialog.showError(Application.getPosWindow(), "Please intsert item name"); return; } if (amount < 0 || Double.isNaN(amount)) { POSMessageDialog.showError(Application.getPosWindow(), "Please intsert valid item price"); return; } setCanceled(false); ticketItem = new TicketItem(); ticketItem.setItemCount(1); ticketItem.setUnitPrice(amount); ticketItem.setName(itemName); ticketItem.setCategoryName(com.floreantpos.POSConstants.MISC_BUTTON_TEXT); ticketItem.setGroupName(com.floreantpos.POSConstants.MISC_BUTTON_TEXT); ticketItem.setShouldPrintToKitchen(true); Tax tax = (Tax) cbTax.getSelectedItem(); if (tax != null) { ticketItem.setTaxRate(tax.getRate()); TerminalConfig.setMiscItemDefaultTaxId(tax.getId()); } PrinterGroup printerGroup = (PrinterGroup) cbPrinterGroup.getSelectedItem(); if (printerGroup != null) { ticketItem.setPrinterGroup(printerGroup); } dispose(); } // GEN-LAST:event_doFinish
@Override protected void updateView() { Tax tax = (Tax) getBean(); tfName.setText(tax.getName()); tfRate.setValue(Double.valueOf(tax.getRate())); }