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:pe.gob.mef.gescon.web.ui.PerfilMB.java
public void desactivar(ActionEvent event) { try {/*from w w w . ja v a 2s. co m*/ if (event != null) { if (this.getSelectedPerfil() != null) { LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User user = loginMB.getUser(); PerfilService service = (PerfilService) ServiceFinder.findBean("PerfilService"); this.getSelectedPerfil().setNactivo(BigDecimal.ZERO); this.getSelectedPerfil().setDfechamodificacion(new Date()); this.getSelectedPerfil().setVusuariomodificacion(user.getVlogin()); service.saveOrUpdate(this.getSelectedPerfil()); this.setListaPerfils(service.getPerfils()); } else { FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, Constante.SEVERETY_ALERTA, "Debe seleccionar el perfil a desactivar."); FacesContext.getCurrentInstance().addMessage(null, message); } } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:org.openvpms.archetype.rules.finance.account.CustomerBalanceGeneratorTestCase.java
/** * Verifies that an <em>participation.customerAccountBalance</tt> is * added for acts that don't have <tt>POSTED</tt> status. * * @param acts the act and associated child acts * @param status the act status/* w ww. j av a2s . c o m*/ */ private void checkAddParticipationForNonPostedAct(List<FinancialAct> acts, String status) { assertFalse(FinancialActStatus.POSTED.equals(status)); Party customer = getCustomer(); FinancialAct act = acts.get(0); act.setStatus(status); save(acts); checkEquals(BigDecimal.ZERO, generate(customer)); act = get(act); // verify the act hasn't affected the balance checkEquals(BigDecimal.ZERO, rules.getBalance(customer)); // verify a participation.customerAccountBalance has been added, // linked to the customer ActBean bean = new ActBean(act); assertEquals(customer, bean.getParticipant(BALANCE_PARTICIPATION)); // verify that there is no account allocation relationship assertNull(getAccountAllocationRelationship(act)); // verify the allocated amount is zero checkEquals(BigDecimal.ZERO, act.getAllocatedAmount()); }
From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java
public void markAsFullyPaid() { this.amountPaid = this.amount; this.amountOutstanding = BigDecimal.ZERO; this.paid = true; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398CoverPageSupplement_3_0V3_0Generator.java
private static IncomeBudgetPeriod[] getIncomeBudgetPeriod( final List<? extends BudgetProjectIncomeContract> projectIncomes) { //TreeMap Used to maintain the order of the Budget periods. Map<Integer, IncomeBudgetPeriod> incomeBudgetPeriodMap = new TreeMap<>(); BigDecimal anticipatedAmount; for (BudgetProjectIncomeContract projectIncome : projectIncomes) { Integer budgetPeriodNumber = projectIncome.getBudgetPeriodNumber(); IncomeBudgetPeriod incomeBudgPeriod = incomeBudgetPeriodMap.get(budgetPeriodNumber); if (incomeBudgPeriod == null) { incomeBudgPeriod = IncomeBudgetPeriod.Factory.newInstance(); incomeBudgPeriod.setBudgetPeriod(budgetPeriodNumber); anticipatedAmount = BigDecimal.ZERO; } else {//w ww. j av a2 s . c o m anticipatedAmount = incomeBudgPeriod.getAnticipatedAmount(); } anticipatedAmount = anticipatedAmount.add(projectIncome.getProjectIncome().bigDecimalValue()); incomeBudgPeriod.setAnticipatedAmount(anticipatedAmount); String description = getProjectIncomeDescription(projectIncome); if (description != null) { if (incomeBudgPeriod.getSource() != null) { incomeBudgPeriod.setSource(incomeBudgPeriod.getSource() + ";" + description); } else { incomeBudgPeriod.setSource(description); } } incomeBudgetPeriodMap.put(budgetPeriodNumber, incomeBudgPeriod); } return incomeBudgetPeriodMap.values().stream().toArray(IncomeBudgetPeriod[]::new); }
From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java
public void resetToOriginal(final MonetaryCurrency currency) { this.amountPaid = BigDecimal.ZERO; this.amountWaived = BigDecimal.ZERO; this.amountWrittenOff = BigDecimal.ZERO; this.amountOutstanding = calculateAmountOutstanding(currency); this.paid = false; this.waived = false; }
From source file:com.kcs.core.utilities.Utility.java
public static BigDecimal convertBigDecimalFromBatch(String data, int decimal, int line, String variable) throws Exception { String strBigDecimal = "0"; BigDecimal result = BigDecimal.ZERO; try {// w w w. ja v a2 s . co m if (StringUtil.isNotEmpty(data) && data.length() > decimal) { data = data.replace(".", ""); if (data.matches(".*-.*")) { data = data.substring(data.indexOf("-"), data.length()); } // else if(data.matches(".*+.*")) { // data = data.replace("+", ""); // } strBigDecimal = data.substring(0, data.length() - decimal) + "." + data.substring(data.length() - decimal, data.length()); if (checkNumbersOnly(strBigDecimal)) { result = new BigDecimal(strBigDecimal.trim()); } else { throw new Exception("Error occurred between process Read data file \"" + data + "\" is not BigDecimal Format.Variable >>> \"" + variable + "\" Line >>> \"" + line + "\""); } } else { return null; } } catch (Exception e) { e.printStackTrace(); throw e; } return result; }
From source file:org.openvpms.archetype.rules.finance.till.TillRules.java
/** * Adds an adjustment to a till, if required. * * @param balance the till balance act * @param cashFloat the new cash float// w ww . jav a2 s .c o m */ private void addAdjustment(FinancialAct balance, BigDecimal cashFloat, Till till) { BigDecimal lastCashFloat = till.getTillFloat(); BigDecimal diff = cashFloat.subtract(lastCashFloat); if (diff.compareTo(BigDecimal.ZERO) != 0) { // need to generate an adjustment, and associate it with the balance boolean credit = (lastCashFloat.compareTo(cashFloat) > 0); Act adjustment = createTillBalanceAdjustment(till.getEntity(), diff.abs(), credit); ActBean balanceBean = new ActBean(balance); balanceBean.addNodeRelationship("items", adjustment); service.save(adjustment); // NOTE that this will trigger TillBalanceRules.addToTill(), but will have no effect TillHelper.updateBalance(balanceBean, service); } }
From source file:com.ar.dev.tierra.api.controller.DetalleFacturaController.java
@RequestMapping(value = "/delete/discount", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> deleteDiscount(@RequestParam("dni") int dni, @RequestParam("password") String password, @RequestBody DetalleFactura detalleFactura) { Usuarios user = facadeService.getUsuariosDAO().findUsuarioByDNI(dni); boolean permiso = passwordEncoder.matches(password, user.getPassword()); if (permiso) { if (user.getRoles().getIdRol() == 1 || user.getRoles().getIdRol() == 6) { detalleFactura.setDescuentoDetalle(BigDecimal.ZERO); BigDecimal monto = detalleFactura.getProducto().getPrecioVenta() .multiply(BigDecimal.valueOf(detalleFactura.getCantidadDetalle())); detalleFactura.setTotalDetalle(monto); facadeService.getDetalleFacturaDAO().update(detalleFactura); List<DetalleFactura> detallesFactura = facadeService.getDetalleFacturaDAO() .facturaDetalle(detalleFactura.getFactura().getIdFactura()); BigDecimal sumMonto = new BigDecimal(BigInteger.ZERO); Factura factura = facadeService.getFacturaDAO() .searchById(detalleFactura.getFactura().getIdFactura()); for (DetalleFactura detailList : detallesFactura) { sumMonto = sumMonto.add(detailList.getTotalDetalle()); }/* w w w . j a va 2 s . c o m*/ factura.setTotal(sumMonto); factura.setFechaModificacion(new Date()); factura.setUsuarioModificacion(user.getIdUsuario()); facadeService.getFacturaDAO().update(factura); JsonResponse msg = new JsonResponse("Success", "Descuento eliminado con exito."); return new ResponseEntity<>(msg, HttpStatus.OK); } else { JsonResponse msg = new JsonResponse("Error", "No tienes los permisos necesarios para realizar esta operacion."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } } else { JsonResponse msg = new JsonResponse("Error", "No tienes los permisos necesarios para realizar esta operacion."); return new ResponseEntity<>(msg, HttpStatus.BAD_REQUEST); } }
From source file:com.gst.portfolio.shareaccounts.serialization.ShareAccountDataSerializer.java
private void createChargeTransaction(ShareAccount account) { BigDecimal totalChargeAmount = BigDecimal.ZERO; Set<ShareAccountCharge> charges = account.getCharges(); Date currentDate = DateUtils.getLocalDateOfTenant().toDate(); for (ShareAccountCharge charge : charges) { if (charge.isActive() && charge.isShareAccountActivation()) { charge.deriveChargeAmount(totalChargeAmount, account.getCurrency()); ShareAccountTransaction chargeTransaction = ShareAccountTransaction .createChargeTransaction(currentDate, charge); ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(chargeTransaction, charge, charge.percentageOrAmount()); chargeTransaction.addShareAccountChargePaidBy(paidBy); account.addChargeTransaction(chargeTransaction); }/* w w w . java2 s.c o m*/ } Set<ShareAccountTransaction> pendingApprovalTransaction = account .getPendingForApprovalSharePurchaseTransactions(); for (ShareAccountTransaction pending : pendingApprovalTransaction) { for (ShareAccountCharge charge : charges) { if (charge.isActive() && charge.isSharesPurchaseCharge()) { BigDecimal amount = charge.deriveChargeAmount(pending.amount(), account.getCurrency()); ShareAccountChargePaidBy paidBy = new ShareAccountChargePaidBy(pending, charge, amount); pending.addShareAccountChargePaidBy(paidBy); totalChargeAmount = totalChargeAmount.add(amount); } } pending.updateChargeAmount(totalChargeAmount); } }
From source file:org.fineract.module.stellar.service.BridgeService.java
public BigDecimal getVaultIssuedAssets(final String mifosTenantId, final String assetCode) { final StellarAccountId stellarAccountId = accountBridgeRepositoryDecorator .getStellarAccountId(mifosTenantId); final StellarAccountId stellarVaultAccountId = accountBridgeRepositoryDecorator .getStellarVaultAccountId(mifosTenantId); if (stellarVaultAccountId == null) return BigDecimal.ZERO; return horizonServerUtilities.currencyTrustSize(stellarAccountId, assetCode, stellarVaultAccountId); }