List of usage examples for java.math BigDecimal compareTo
@Override public int compareTo(BigDecimal val)
From source file:BlogRocksteady2.bean.EditPerfilBean.java
public String cargarPerfil() { BigDecimal user = (BigDecimal) FacesContext.getCurrentInstance().getExternalContext().getSessionMap() .get("user"); if (user.compareTo(BigDecimal.ZERO) >= 1) { usuario = usuarioFacade.findById(user); setEmail(usuario.getEmail());/*from w w w . ja va2 s .c o m*/ setFacebook(usuario.getFacebook()); setTwitter(usuario.getTwitter()); setWebsite(usuario.getWebsite()); setDescription(usuario.getDescription()); setLinkedin(usuario.getLinkedin()); setInstagram(usuario.getInstagram()); return "editProfile.xhtml"; } else { return "index.xhtml"; } }
From source file:BlogRocksteady2.bean.EditPerfilBean.java
public void editarPerfil(ActionEvent event) throws IOException { BigDecimal user = (BigDecimal) FacesContext.getCurrentInstance().getExternalContext().getSessionMap() .get("user"); if (user.compareTo(BigDecimal.ZERO) >= 1) { usuario = usuarioFacade.findById(user); usuario.setEmail(email);/*from w ww . j a v a2 s . c o m*/ usuario.setDescription(description); usuario.setWebsite(website); usuario.setFacebook(facebook); usuario.setTwitter(twitter); usuario.setLinkedin(linkedin); usuario.setInstagram(instagram); if (foto != null) { InputStream inputStream = foto.getInputStream(); byte[] imagen = IOUtils.toByteArray(inputStream); usuario.setImg(imagen); } usuarioFacade.edit(usuario); FacesMessage message = new FacesMessage("Perfil actualizado con xito"); FacesContext.getCurrentInstance().addMessage(null, message); } }
From source file:org.apache.ofbiz.accounting.thirdparty.verisign.PayflowPro.java
private static void addCartDetails(Map<String, String> parameterMap, ShoppingCart cart) throws GenericEntityException { parameterMap.put("CURRENCY", cart.getCurrency()); int line = 0; for (ShoppingCartItem item : cart.items()) { //paramMap.put("L_NUMBER" + line, item.getProductId()); parameterMap.put("L_NAME" + line, item.getName()); parameterMap.put("L_DESC" + line, item.getDescription()); parameterMap.put("L_AMT" + line, item.getBasePrice().setScale(2).toPlainString()); parameterMap.put("L_QTY" + line, item.getQuantity().toBigInteger().toString()); line++;/*from w ww .j a v a 2 s .c o m*/ BigDecimal otherAdjustments = item.getOtherAdjustments(); if (otherAdjustments.compareTo(BigDecimal.ZERO) != 0) { parameterMap.put("L_NAME" + line, item.getName() + " Adjustments"); parameterMap.put("L_DESC" + line, "Adjustments for item: " + item.getName()); parameterMap.put("L_AMT" + line, otherAdjustments.setScale(2).toPlainString()); parameterMap.put("L_QTY" + line, "1"); line++; } } BigDecimal otherAdjustments = cart.getOrderOtherAdjustmentTotal(); if (otherAdjustments.compareTo(BigDecimal.ZERO) != 0) { parameterMap.put("L_NAME" + line, "Order Adjustments"); parameterMap.put("L_AMT" + line, otherAdjustments.setScale(2).toPlainString()); parameterMap.put("L_QTY" + line, "1"); line++; } parameterMap.put("ITEMAMT", cart.getSubTotal().add(otherAdjustments).setScale(2).toPlainString()); parameterMap.put("TAXAMT", cart.getTotalSalesTax().setScale(2).toPlainString()); parameterMap.put("FREIGHTAMT", cart.getTotalShipping().setScale(2).toPlainString()); parameterMap.put("AMT", cart.getGrandTotal().setScale(2).toPlainString()); if (!cart.shippingApplies()) { parameterMap.put("NOSHIPPING", "1"); } else { GenericValue shippingAddress = cart.getShippingAddress(); parameterMap.put("ADDROVERRIDE", "1"); parameterMap.put("SHIPTOSTREET", StringUtils.left(shippingAddress.getString("address1"), 30)); parameterMap.put("SHIPTOSTREET2", StringUtils.left(shippingAddress.getString("address2"), 30)); parameterMap.put("SHIPTOCITY", StringUtils.left(shippingAddress.getString("city"), 40)); if (shippingAddress.getString("stateProvinceGeoId") != null && !"_NA_".equals(shippingAddress.getString("stateProvinceGeoId"))) { GenericValue stateProvinceGeo = shippingAddress.getRelatedOne("StateProvinceGeo", false); parameterMap.put("SHIPTOSTATE", StringUtils.left(stateProvinceGeo.getString("geoCode"), 40)); } parameterMap.put("SHIPTOZIP", StringUtils.left(shippingAddress.getString("postalCode"), 16)); GenericValue countryGeo = shippingAddress.getRelatedOne("CountryGeo", false); parameterMap.put("SHIPTOCOUNTRY", StringUtils.left(countryGeo.getString("geoCode"), 2)); } }
From source file:com.siapa.managedbean.RegistroMortalidadManagedBean.java
public Boolean updateStoc() { Boolean isOk;/* w w w .j a v a 2 s . c o m*/ Integer existencia = 0; Integer existenciaActual = jaula.getVentaJaula(); BigDecimal cantActual = new BigDecimal(existenciaActual); BigDecimal reduccion = registroMortalidad.getCantidadRegistroMortalidad(); int reducc = reduccion.intValue(); if (cantActual.compareTo(reduccion) == -1) { FacesContext context = FacesContext.getCurrentInstance(); context.addMessage(null, new FacesMessage("No contiene existencias del producto")); isOk = false; } else { Jaula newJaula = getJaula(); Jaula idJaula = registroMortalidad.getIdJaula(); Jaula cactual = jaulaService.findById(idJaula.getIdJaula()); existencia = cactual.getVentaJaula() - reducc; newJaula.setVentaJaula(existencia); jaulaService.merge(newJaula); isOk = true; } return isOk; }
From source file:nl.strohalm.cyclos.entities.accounts.loans.LoanParameters.java
/** * Calculates the grant fee to the given amount * @return 0 if no grant fee, the applied grant fee otherwise (ie: if grant fee = 3%, returns 30 for amount = 1000) *///from w ww .j a v a2 s .com public BigDecimal calculateGrantFee(final BigDecimal amount) { if (grantFee == null || grantFee.getValue() == null || amount.compareTo(BigDecimal.ZERO) != 1) { return BigDecimal.ZERO; } return grantFee.apply(amount); }
From source file:com.nkapps.billing.services.PaymentServiceImpl.java
@Override public AccountInfoBean getAccountInfo(String tin) throws Exception { AccountInfoBean aib = new AccountInfoBean(); BigDecimal overpaymentSum = paymentDao.getOverpaymentSumByTin(tin); if (overpaymentSum == null) { throw new Exception("Overpayment sum returned null value"); }/*w ww . j a v a 2 s .c o m*/ if (overpaymentSum.compareTo(BigDecimal.ZERO) == -1) { throw new Exception("Overpayment sum returned negative value"); } BigDecimal keyCost = getKeyCost(); aib.setTin(tin); aib.setOverpaymentSum(overpaymentSum); aib.setKeyCost(keyCost); return aib; }
From source file:net.groupbuy.controller.shop.member.DepositController.java
/** * //from ww w .ja v a 2s. c o m */ @RequestMapping(value = "/calculate_fee", method = RequestMethod.POST) public @ResponseBody Map<String, Object> calculateFee(String paymentPluginId, BigDecimal amount) { Map<String, Object> data = new HashMap<String, Object>(); PaymentPlugin paymentPlugin = pluginService.getPaymentPlugin(paymentPluginId); if (paymentPlugin == null || !paymentPlugin.getIsEnabled() || amount == null || amount.compareTo(new BigDecimal(0)) < 0) { data.put("message", ERROR_MESSAGE); return data; } data.put("message", SUCCESS_MESSAGE); data.put("fee", paymentPlugin.calculateFee(amount)); return data; }
From source file:com.rockagen.gnext.service.spring.AccountServImpl.java
/** * Balance enough?/*from w w w . j av a 2 s .c o m*/ * * @param account Account * @param amount amount * @return true if enough */ private boolean checkBalance(Account account, BigDecimal amount) { BigDecimal tmp = account.getAvailableBalance().subtract(amount.abs()); if ((tmp.compareTo(BigDecimal.ZERO)) < 0) { return false; } return true; }
From source file:com.premiumminds.billy.core.services.builders.impl.GenericInvoiceEntryBuilderImpl.java
@Override @NotOnUpdate// w w w. j av a2 s . c o m public TBuilder setQuantity(BigDecimal quantity) { Validate.isTrue(quantity.compareTo(BigDecimal.ZERO) > 0, "The quantity must be positive"); // TODO message this.getTypeInstance().setQuantity(quantity); return this.getBuilder(); }
From source file:nl.tudelft.stocktrader.mysql.MySQLMarketSummaryDAO.java
public void updateStockPriceVolume(double quantity, Quote quote) throws DAOException { BigDecimal priceChangeFactor = StockTraderUtility.getRandomPriceChangeFactor(quote.getPrice()); BigDecimal newPrice = quote.getPrice().multiply(priceChangeFactor); if (newPrice.compareTo(quote.getLow()) == -1) { quote.setLow(newPrice);//from www . j a v a 2s. c om } if (newPrice.compareTo(quote.getHigh()) == 1) { quote.setHigh(newPrice); } PreparedStatement updateStockPriceVolumeStat = null; try { updateStockPriceVolumeStat = sqlConnection.prepareStatement(SQL_UPDATE_STOCKPRICEVOLUME); updateStockPriceVolumeStat.setBigDecimal(1, newPrice); updateStockPriceVolumeStat.setBigDecimal(2, quote.getLow()); updateStockPriceVolumeStat.setBigDecimal(3, quote.getHigh()); updateStockPriceVolumeStat.setBigDecimal(4, newPrice); updateStockPriceVolumeStat.setFloat(5, (float) quantity); updateStockPriceVolumeStat.setString(6, quote.getSymbol()); updateStockPriceVolumeStat.executeUpdate(); } catch (SQLException e) { throw new DAOException("", e); } finally { try { if (updateStockPriceVolumeStat != null) { updateStockPriceVolumeStat.close(); } } catch (SQLException e) { logger.debug("", e); } } }