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.tasktop.c2c.server.internal.tasks.domain.conversion.TaskConverter.java
@SuppressWarnings("unchecked") @Override/*from ww w. ja v a 2 s . c o m*/ public void copy(Task target, Object internalObject, DomainConverter converter, DomainConversionContext context) { com.tasktop.c2c.server.internal.tasks.domain.Task source = (com.tasktop.c2c.server.internal.tasks.domain.Task) internalObject; DomainConversionContext subcontext = context.subcontext(); target.setId(source.getId()); target.setFoundInRelease( source.getVersion() == null ? null : source.getVersion().isEmpty() ? null : source.getVersion()); target.setCreationDate(source.getCreationTs()); target.setModificationDate(source.getDeltaTs()); target.setVersion(source.getDeltaTs() == null ? null : Long.toString(source.getDeltaTs().getTime())); target.setShortDescription(source.getShortDesc()); target.setEstimatedTime(source.getEstimatedTime()); target.setRemainingTime(source.getRemainingTime()); target.setDeadline(source.getDeadline()); target.setUrl(configuration.getWebUrlForTask(target.getId())); // Mandatory custom fields target.setTaskType(source.getTaskType()); List<ExternalTaskRelation> externalTaskRelations = new ArrayList<ExternalTaskRelation>(); if (source.getExternalTaskRelations() != null) { String[] strings = StringUtils.split(source.getExternalTaskRelations(), "\n"); Pattern p = Pattern.compile("(.*)\\.(.*): (.*)"); for (String string : strings) { Matcher matcher = p.matcher(string); if (matcher.matches()) { String type = matcher.group(1); String kind = matcher.group(2); String uri = matcher.group(3); externalTaskRelations.add(new ExternalTaskRelation(type, kind, uri)); } } } target.setExternalTaskRelations(externalTaskRelations); List<String> commits = new ArrayList<String>(); if (source.getCommits() != null) { for (String commit : StringUtils.split(source.getCommits(), ",")) { commits.add(commit); } } target.setCommits(commits); // These must be set from query join results target.setSeverity(context.getTaskSeverity(source.getSeverity())); target.setStatus(context.getTaskStatus(source.getStatus())); target.setResolution(context.getTaskResolution(source.getResolution())); target.setPriority(context.getPriority(source.getPriority())); target.setMilestone(context.getMilestone(source.getProduct(), source.getTargetMilestone())); target.setProduct((Product) converter.convert(source.getProduct(), subcontext)); target.setComponent((Component) converter.convert(source.getComponent(), subcontext)); target.setReporter((TaskUserProfile) converter.convert(source.getReporter(), subcontext)); target.setAssignee((TaskUserProfile) converter.convert(source.getAssignee(), subcontext)); target.setWatchers((List<TaskUserProfile>) converter.convert(source.getCcs(), subcontext)); List<Keyworddef> keyworddefs = new ArrayList<Keyworddef>(); for (com.tasktop.c2c.server.internal.tasks.domain.Keyword keyword : source.getKeywordses()) { keyworddefs.add(keyword.getKeyworddefs()); } target.setKeywords((List<Keyword>) converter.convert(keyworddefs, subcontext)); // Description (first comment), Comments, and Worklog items (comment with workTime) copyCommentsAndWorkLogs(target, source.getComments(), converter, context); BigDecimal sumOfSubtasksEstimate = BigDecimal.ZERO; BigDecimal sumOfSubtasksTimeSpent = BigDecimal.ZERO; Queue<Dependency> subTaskQueue = new LinkedList<Dependency>(source.getDependenciesesForBlocked()); while (!subTaskQueue.isEmpty()) { com.tasktop.c2c.server.internal.tasks.domain.Task subTask = subTaskQueue.poll().getBugsByDependson(); subTaskQueue.addAll(subTask.getDependenciesesForBlocked()); if (subTask.getEstimatedTime() != null) { sumOfSubtasksEstimate = sumOfSubtasksEstimate.add(subTask.getEstimatedTime()); } for (com.tasktop.c2c.server.internal.tasks.domain.Comment c : subTask.getComments()) { if (c.getWorkTime() != null && c.getWorkTime().signum() > 0) { sumOfSubtasksTimeSpent = sumOfSubtasksTimeSpent.add(c.getWorkTime()); } } } target.setSumOfSubtasksEstimatedTime(sumOfSubtasksEstimate); target.setSumOfSubtasksTimeSpent(sumOfSubtasksTimeSpent); if (!context.isThin()) { target.setBlocksTasks(new ArrayList<Task>(source.getDependenciesesForDependson().size())); for (Dependency dep : source.getDependenciesesForDependson()) { target.getBlocksTasks().add(shallowCopyAssociate(dep.getBugsByBlocked(), subcontext)); } target.setSubTasks(new ArrayList<Task>(source.getDependenciesesForBlocked().size())); for (Dependency dep : source.getDependenciesesForBlocked()) { target.getSubTasks().add(shallowCopyAssociate(dep.getBugsByDependson(), subcontext)); } if (source.getDuplicatesByBugId() != null) { target.setDuplicateOf( shallowCopyAssociate(source.getDuplicatesByBugId().getBugsByDupeOf(), subcontext)); } target.setDuplicates(new ArrayList<Task>()); for (Duplicate duplicate : source.getDuplicatesesForDupeOf()) { target.getDuplicates().add(shallowCopyAssociate(duplicate.getBugsByBugId(), subcontext)); } if (source.getStatusWhiteboard() != null && !source.getStatusWhiteboard().isEmpty()) { // A non-empty statusWhiteboard means we store description there for backward compatibility. (See // discussion in Task 422) target.setDescription(source.getStatusWhiteboard()); // REVIEW do we really need this for subtasks? target.setWikiRenderedDescription( renderer.render(source.getStatusWhiteboard(), context.getWikiMarkup())); } target.setAttachments((List<Attachment>) converter.convert(source.getAttachments(), subcontext)); } else { // THIN tasks still get their parent populated if (!source.getDependenciesesForDependson().isEmpty()) { target.setParentTask(shallowCopyAssociate( source.getDependenciesesForDependson().get(0).getBugsByBlocked(), subcontext)); } } }
From source file:dk.clanie.money.Money.java
public boolean isZero() { return (amount.compareTo(BigDecimal.ZERO) == 0); }
From source file:com.premiumminds.billy.core.services.builders.impl.TaxBuilderImpl.java
@Override protected void validateInstance() throws javax.validation.ValidationException { Tax t = this.getTypeInstance(); /*BillyValidator.mandatory(t.getDescription(), TaxBuilderImpl.LOCALIZER.getString("field.tax_description")); BillyValidator.mandatory(t.getCode(), TaxBuilderImpl.LOCALIZER.getString("field.tax_code")); BillyValidator.mandatory(t.getTaxRateType(), TaxBuilderImpl.LOCALIZER.getString("field.tax_rate_type"));*/ BillyValidator.mandatory(t.getCurrency(), TaxBuilderImpl.LOCALIZER.getString("field.tax_currency")); switch (t.getTaxRateType()) { case FLAT:/* w ww . ja va 2 s .c om*/ BillyValidator.mandatory(t.getFlatRateAmount(), TaxBuilderImpl.LOCALIZER.getString("field.tax_rate_flat_amount")); break; case PERCENTAGE: Validate.inclusiveBetween(BigDecimal.ZERO, new BigDecimal("100"), t.getPercentageRateValue()); break; case NONE: break; default: throw new RuntimeException("The tax rate type is unknown"); } }
From source file:dk.clanie.money.Money.java
public boolean isNegative() { return (amount.compareTo(BigDecimal.ZERO) < 0); }
From source file:net.shopxx.controller.shop.OrderController.java
@RequestMapping(value = "/check_pending_payment", method = RequestMethod.GET) public @ResponseBody boolean checkPendingPayment(String sn) { Order order = orderService.findBySn(sn); Member member = memberService.getCurrent(); return order != null && member.equals(order.getMember()) && order.getPaymentMethod() != null && PaymentMethod.Method.online.equals(order.getPaymentMethod().getMethod()) && order.getAmountPayable().compareTo(BigDecimal.ZERO) > 0; }
From source file:com.ar.dev.tierra.api.controller.FacturaController.java
@PreAuthorize("hasAnyAuthority('ROLE_ADMIN, ROLE_ENCARGADO/VENDEDOR')") @RequestMapping(value = "/delete", method = RequestMethod.POST) public ResponseEntity<?> delete(OAuth2Authentication authentication, @RequestParam("idFactura") int idFactura) { Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName()); List<DetalleFactura> detalles = facadeService.getDetalleFacturaDAO().facturaDetalle(idFactura); List<MetodoPagoFactura> metodos = facadeService.getMetodoPagoFacturaDAO().getFacturaMetodo(idFactura); if (metodos.isEmpty()) { if (!detalles.isEmpty()) { for (DetalleFactura detalleFactura : detalles) { detalleFactura.setEstadoDetalle(false); detalleFactura.setUsuarioModificacion(user.getIdUsuario()); detalleFactura.setFechaModificacion(new Date()); facadeService.getDetalleFacturaDAO().update(detalleFactura); @SuppressWarnings("UnusedAssignment") int cantidadActual = 0; WrapperStock stock = facadeService.getStockDAO().searchStockById(detalleFactura.getIdStock(), user.getUsuarioSucursal().getIdSucursal()); if (stock.getStockTierra() != null) { cantidadActual = stock.getStockTierra().getCantidad(); stock.getStockTierra().setCantidad(cantidadActual + detalleFactura.getCantidadDetalle()); } else if (stock.getStockBebelandia() != null) { cantidadActual = stock.getStockBebelandia().getCantidad(); stock.getStockBebelandia() .setCantidad(cantidadActual + detalleFactura.getCantidadDetalle()); } else { cantidadActual = stock.getStockLibertador().getCantidad(); stock.getStockLibertador() .setCantidad(cantidadActual + detalleFactura.getCantidadDetalle()); }/* w w w . ja va 2s . c o m*/ facadeService.getStockDAO().update(stock); Producto prodRest = facadeService.getProductoDAO() .findById(detalleFactura.getProducto().getIdProducto()); int cantProd = prodRest.getCantidadTotal(); prodRest.setCantidadTotal(cantProd + detalleFactura.getCantidadDetalle()); facadeService.getProductoDAO().update(prodRest); } } Factura factura = facadeService.getFacturaDAO().searchById(idFactura); factura.setEstado("CANCELADO"); factura.setFechaModificacion(new Date()); factura.setTotal(BigDecimal.ZERO); factura.setUsuarioModificacion(user.getIdUsuario()); facadeService.getFacturaDAO().update(factura); JsonResponse msg = new JsonResponse("Success", "Factura cancelada con exito."); return new ResponseEntity<>(msg, HttpStatus.OK); } else { JsonResponse msg = new JsonResponse("Error", "No puedes eliminar una factura con pagos realizados"); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } }
From source file:com.khartec.waltz.data.server_information.ServerInformationDao.java
private Tuple2<Integer, Integer> calculateVirtualAndPhysicalCounts(Condition condition) { Field<BigDecimal> virtualCount = DSL .coalesce(DSL.sum(DSL.choose(SERVER_INFORMATION.IS_VIRTUAL).when(Boolean.TRUE, 1).otherwise(0)), BigDecimal.ZERO) .as("virtual_count"); Field<BigDecimal> physicalCount = DSL .coalesce(DSL.sum(DSL.choose(SERVER_INFORMATION.IS_VIRTUAL).when(Boolean.TRUE, 0).otherwise(1)), BigDecimal.ZERO) .as("physical_count"); SelectConditionStep<Record2<BigDecimal, BigDecimal>> typeQuery = dsl.select(virtualCount, physicalCount) .from(SERVER_INFORMATION).where(dsl.renderInlined(condition)); return typeQuery.fetchOne(r -> Tuple.tuple(r.value1().intValue(), r.value2().intValue())); }
From source file:org.openvpms.archetype.rules.finance.till.TillRulesTestCase.java
/** * Tests the {@link TillRules#transfer)} method. *//*w w w . j ava 2 s .c om*/ @Test public void testTransfer() { List<FinancialAct> payment = createPayment(till); payment.get(0).setStatus(POSTED); FinancialAct balance = checkAddToTillBalance(till, payment, false, BigDecimal.ONE); // make sure using the latest version of the act (i.e, with relationship // to balance) Act act = get(payment.get(0)); Party newTill = createTill(); save(newTill); rules.transfer(balance, act, newTill); // reload the balance and make sure the payment has been removed balance = (FinancialAct) get(balance.getObjectReference()); assertEquals(0, countRelationships(balance, payment.get(0))); // balance should now be zero. assertTrue(BigDecimal.ZERO.compareTo(balance.getTotal()) == 0); // make sure the payment has been added to a new balance FinancialAct newBalance = TillHelper.getUnclearedTillBalance(newTill, getArchetypeService()); assertNotNull(newBalance); assertEquals(1, countRelationships(newBalance, payment.get(0))); assertEquals(TillBalanceStatus.UNCLEARED, newBalance.getStatus()); assertTrue(BigDecimal.ONE.compareTo(newBalance.getTotal()) == 0); }
From source file:pe.gob.mef.gescon.service.impl.ConsultaServiceImpl.java
@Override public List<HashMap<String, Object>> listarReporte(HashMap filters) { List<HashMap<String, Object>> lista = new ArrayList<HashMap<String, Object>>(); try {/*from w ww .j a va 2s . c om*/ ConsultaDao consultaDao = (ConsultaDao) ServiceFinder.findBean("ConsultaDao"); List<HashMap<String, Object>> consulta = consultaDao.listarReporte(filters); if (!CollectionUtils.isEmpty(consulta)) { for (HashMap<String, Object> r : consulta) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ID", r.get("ID")); map.put("NOMBRE", r.get("NOMBRE")); map.put("SUMILLA", r.get("SUMILLA")); map.put("FECHA", r.get("FECHA")); map.put("IDCATEGORIA", r.get("IDCATEGORIA")); map.put("CATEGORIA", r.get("CATEGORIA")); map.put("IDTIPOCONOCIMIENTO", r.get("IDTIPOCONOCIMIENTO")); map.put("TIPOCONOCIMIENTO", r.get("TIPOCONOCIMIENTO")); map.put("IDESTADO", r.get("IDESTADO")); map.put("ESTADO", r.get("ESTADO")); map.put("PROMEDIO", r.get("PROMEDIO")); map.put("USUARIOCREA", r.get("USUARIOCREA")); map.put("FECHACREA", r.get("FECHACREA")); BigDecimal contador = (BigDecimal) r.get("CONTADOR"); BigDecimal suma = (BigDecimal) r.get("SUMA"); if (BigDecimal.ZERO.equals(contador)) { map.put("CONTADOR", 0); } else { int calificacion = Math .round(Float.parseFloat(suma.toString()) / Integer.parseInt(contador.toString())); map.put("CONTADOR", calificacion); } lista.add(map); } } } catch (Exception e) { e.getMessage(); e.printStackTrace(); } return lista; }
From source file:dk.clanie.money.Money.java
public boolean isPositive() { return (amount.compareTo(BigDecimal.ZERO) > 0); }