List of usage examples for java.math BigDecimal ZERO
BigDecimal ZERO
To view the source code for java.math BigDecimal ZERO.
Click Source Link
From source file:com.premiumminds.billy.core.services.builders.impl.GenericInvoiceEntryBuilderImpl.java
@Override @NotOnUpdate//from w ww.j a v 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:com.axelor.apps.base.service.MapService.java
public HashMap<String, Object> getMapGoogle(String qString, BigDecimal latitude, BigDecimal longitude) { HashMap<String, Object> result = new HashMap<String, Object>(); try {// ww w . ja va 2 s . c o m if (BigDecimal.ZERO.compareTo(latitude) == 0 || BigDecimal.ZERO.compareTo(longitude) == 0) { JSONObject googleResponse = geocodeGoogle(qString); if (googleResponse != null) { latitude = new BigDecimal(googleResponse.get("lat").toString()); longitude = new BigDecimal(googleResponse.get("lng").toString()); } } if (BigDecimal.ZERO.compareTo(latitude) != 0 && BigDecimal.ZERO.compareTo(longitude) != 0) { LOG.debug("URL:" + "map/gmaps.html?x=" + latitude + "&y=" + longitude + "&z=18"); result.put("url", "map/gmaps.html?x=" + latitude + "&y=" + longitude + "&z=18"); result.put("latitude", latitude); result.put("longitude", longitude); return result; } } catch (Exception e) { TraceBackService.trace(e); } return null; }
From source file:org.fineract.module.stellar.TestPaymentInSimpleNetwork.java
@Test public void paymentAboveCreditLimit() throws Exception { logger.info("paymentAboveCreditLimit test begin"); final AccountListener accountListener = new AccountListener(serverAddress, secondTenantId, firstTenantId); BigDecimal transferAmount = TRUST_LIMIT.add(BigDecimal.ONE); makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount); accountListener.waitForCredits(PAY_WAIT, creditMatcher(secondTenantId, transferAmount, ASSET_CODE, firstTenantId)); checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), BigDecimal.ZERO); }
From source file:pe.gob.mef.gescon.web.ui.RangoMB.java
public void cleanAttributes() { this.setId(BigDecimal.ZERO); this.setDescripcion(StringUtils.EMPTY); this.setNombre(StringUtils.EMPTY); this.setActivo(BigDecimal.ONE); this.setSelectedRango(null); Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(); if (iter.hasNext() == true) { iter.remove();//from ww w . ja v a 2s . c o m FacesContext.getCurrentInstance().renderResponse(); } }
From source file:com.gst.portfolio.shareaccounts.domain.ShareAccountCharge.java
private void populateDerivedFields(final BigDecimal transactionAmount, final BigDecimal chargeAmount) { this.amountOrPercentage = chargeAmount; if (this.chargeCalculation.equals(ChargeCalculationType.FLAT.getValue())) { this.percentage = null; this.amount = BigDecimal.ZERO; this.amountPercentageAppliedTo = null; this.amountPaid = null; this.amountOutstanding = BigDecimal.ZERO; this.amountWaived = null; this.amountWrittenOff = null; } else if (this.chargeCalculation.equals(ChargeCalculationType.PERCENT_OF_AMOUNT.getValue())) { this.percentage = chargeAmount; this.amountPercentageAppliedTo = transactionAmount; this.amount = percentageOf(this.amountPercentageAppliedTo, this.percentage); this.amountPaid = null; this.amountOutstanding = calculateOutstanding(); this.amountWaived = null; this.amountWrittenOff = null; }//from w w w. java2s . co m }
From source file:pe.gob.mef.gescon.web.ui.PerfilMB.java
public void cleanAttributes() { this.setId(BigDecimal.ZERO); this.setDescripcion(StringUtils.EMPTY); this.setNombre(StringUtils.EMPTY); this.setActivo(BigDecimal.ONE); this.setSelectedPerfil(null); Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(); if (iter.hasNext() == true) { iter.remove();/*from w w w.j ava 2 s. c o m*/ FacesContext.getCurrentInstance().renderResponse(); } }
From source file:com.ar.dev.tierra.api.controller.DetalleFacturaController.java
@RequestMapping(value = "/add", method = RequestMethod.POST) public ResponseEntity<?> add(OAuth2Authentication authentication, @RequestParam("idFactura") int idFactura, @RequestParam("idProducto") int idProducto, @RequestParam("idItem") int idItem, @RequestParam("cantidadItem") int cantidadItem) { /*Instancia de nuevo detalle*/ DetalleFactura detalleFactura = new DetalleFactura(); /*Traemos los objectos necesarios para aadir el detalle*/ Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName()); Producto prod = facadeService.getProductoDAO().findById(idProducto); WrapperStock stock = facadeService.getStockDAO().searchStockById(idItem, user.getUsuarioSucursal().getIdSucursal()); Factura factura = facadeService.getFacturaDAO().searchById(idFactura); /*Bandera de control*/ boolean control = false; /*Variable de calculo de cantidad*/ @SuppressWarnings("UnusedAssignment") int cantidadStock = 0; detalleFactura.setUsuarioCreacion(user.getIdUsuario()); detalleFactura.setFechaCreacion(new Date()); detalleFactura.setEstadoDetalle(true); if (prod.getCantidadTotal() >= cantidadItem) { if (stock.getStockTierra() != null) { if (stock.getStockTierra().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockTierra().getCantidad() - cantidadItem; stock.getStockTierra().setCantidad(cantidadStock); control = true;//www . j ava 2 s . c o m } } if (stock.getStockBebelandia() != null) { if (stock.getStockBebelandia().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockBebelandia().getCantidad() - cantidadItem; stock.getStockBebelandia().setCantidad(cantidadStock); control = true; } } if (stock.getStockLibertador() != null) { if (stock.getStockLibertador().getCantidad() >= cantidadItem) { cantidadStock = stock.getStockLibertador().getCantidad() - cantidadItem; stock.getStockLibertador().setCantidad(cantidadStock); control = true; } } if (control) { int cantidadTotal = prod.getCantidadTotal(); /*seteamos cantidad nueva de productos*/ prod.setCantidadTotal(cantidadTotal - cantidadItem); /*seteamos producto en el detalle*/ detalleFactura.setProducto(prod); /*Calculamos el total del detalle*/ BigDecimal monto = detalleFactura.getProducto().getPrecioVenta() .multiply(BigDecimal.valueOf(cantidadItem)); /*seteamos el total del detalle*/ detalleFactura.setTotalDetalle(monto); /*seteamos la factura del detalle*/ detalleFactura.setFactura(factura); /*seteamos descuento en cero*/ detalleFactura.setDescuentoDetalle(BigDecimal.ZERO); /*seteamos la cantidad de items en el detalle*/ detalleFactura.setCantidadDetalle(cantidadItem); /*Indicamos el idStock del detalle*/ detalleFactura.setIdStock(idItem); /*Actualizamos producto*/ facadeService.getProductoDAO().update(prod); /*Actualizamos el stock*/ facadeService.getStockDAO().update(stock); /*Insertamos el nuevo detalle*/ facadeService.getDetalleFacturaDAO().add(detalleFactura); /*Traemos lista de detalles, calculamos su nuevo total y actualizamos*/ List<DetalleFactura> detallesFactura = facadeService.getDetalleFacturaDAO() .facturaDetalle(idFactura); BigDecimal sumMonto = new BigDecimal(BigInteger.ZERO); for (DetalleFactura detailList : detallesFactura) { sumMonto = sumMonto.add(detailList.getTotalDetalle()); } factura.setTotal(sumMonto); factura.setFechaModificacion(new Date()); factura.setUsuarioModificacion(user.getIdUsuario()); facadeService.getFacturaDAO().update(factura); JsonResponse msg = new JsonResponse("Success", "Detalle agregado con exito"); return new ResponseEntity<>(msg, HttpStatus.OK); } else { JsonResponse msg = new JsonResponse("Error", "Stock insuficiente."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } } else { JsonResponse msg = new JsonResponse("Error", "Stock insuficiente."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } }
From source file:com.opensky.osis.BraintreeConnector.java
/** * Custom processor//from ww w . j av a2s . co m * * {@sample.xml ../../../doc/braintree-connector.xml.sample braintree:settle} * * @param id The transaction id * @param amount the amount of the transaction * @return The transaction */ @Processor public Result settle(String id, BigDecimal amount) { log.info("Settling transaction {} amount {}", id, amount); Validate.notNull(id, "token should not be null"); Validate.notNull(amount, "amount should not be null"); Validate.isTrue(amount.compareTo(BigDecimal.ZERO) >= 0, "amount must be >= 0"); try { Result<Transaction> res = getGateway().transaction().submitForSettlement(id, amount); return res; } catch (BraintreeException e) { return new ExceptionResult(e.getClass().getCanonicalName()); } }
From source file:org.openvpms.archetype.rules.stock.ChargeStockUpdaterTestCase.java
/** * Verifies that stock is updated correctly if a charge is saved multiple times in a transaction. */// ww w. j a v a2s .c o m @Test public void testMultipleSaveInTxn() { final List<FinancialAct> acts = createInvoice(); FinancialAct item = acts.get(1); BigDecimal initialQuantity = BigDecimal.ZERO; BigDecimal quantity = BigDecimal.valueOf(5); item.setQuantity(quantity); checkEquals(initialQuantity, getStock(stockLocation, product)); BigDecimal expected = getQuantity(initialQuantity, quantity, false); TransactionTemplate template = new TransactionTemplate(txnManager); template.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { save(acts); save(acts); } }); checkEquals(expected, getStock(stockLocation, product)); save(acts); // stock shouldn't change if resaved checkEquals(expected, getStock(stockLocation, product)); }