List of usage examples for java.math BigDecimal ONE
BigDecimal ONE
To view the source code for java.math BigDecimal ONE.
Click Source Link
From source file:org.kuali.ole.sys.service.impl.TaxServiceImpl.java
/** * This method returns a preTax amount//from ww w .ja v a2 s . c o m * * @param dateOfTransaction * @param postalCode * @param amountWithTax * @return */ @Override public KualiDecimal getPretaxAmount(Date dateOfTransaction, String postalCode, KualiDecimal amountWithTax) { BigDecimal totalTaxRate = BigDecimal.ZERO; // there is not tax amount if (StringUtils.isEmpty(postalCode)) return amountWithTax; // strip digits from the postal code before passing it to the sales tax regions // if the parameters indicate to do so. postalCode = truncatePostalCodeForSalesTaxRegionService(postalCode); List<TaxRegion> salesTaxRegions = taxRegionService.getSalesTaxRegions(postalCode); if (salesTaxRegions.size() == 0) return amountWithTax; for (TaxRegion taxRegion : salesTaxRegions) { if (ObjectUtils.isNotNull((taxRegion.getEffectiveTaxRegionRate(dateOfTransaction)))) totalTaxRate = totalTaxRate .add(taxRegion.getEffectiveTaxRegionRate(dateOfTransaction).getTaxRate()); } KualiDecimal divisor = new KualiDecimal(totalTaxRate.add(BigDecimal.ONE)); KualiDecimal pretaxAmount = amountWithTax.divide(divisor); return pretaxAmount; }
From source file:pe.gob.mef.gescon.web.ui.MaestroMB.java
public void cleanAttributes() { this.setId(BigDecimal.ZERO); this.setDescripcion(StringUtils.EMPTY); this.setNombre(StringUtils.EMPTY); this.setActivo(BigDecimal.ONE); // this.setSelectedMaestro(null); Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages(); if (iter.hasNext() == true) { iter.remove();/*w ww . j a v a 2s . c o m*/ FacesContext.getCurrentInstance().renderResponse(); } }
From source file:org.openvpms.archetype.rules.finance.till.TillRulesTestCase.java
/** * Tests the {@link TillRules#transfer)} method. *//*from w ww . ja va 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:alfio.manager.system.DataMigratorIntegrationTest.java
private Pair<Event, String> initEvent(List<TicketCategoryModification> categories, String displayName) { String organizationName = UUID.randomUUID().toString(); String username = UUID.randomUUID().toString(); String eventName = UUID.randomUUID().toString(); organizationRepository.create(organizationName, "org", "email@example.com"); Organization organization = organizationRepository.findByName(organizationName).get(); userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR, User.Type.INTERNAL); Map<String, String> desc = new HashMap<>(); desc.put("en", "muh description"); desc.put("it", "muh description"); desc.put("de", "muh description"); EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", null, null, eventName, displayName, organization.getId(), "muh location", "0.0", "0.0", ZoneId.systemDefault().getId(), desc, new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)), BigDecimal.TEN, "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, null, categories, false, new LocationDescriptor("", "", "", ""), 7, null, null); eventManager.createEvent(em);//from ww w.j a va 2 s.c om return Pair.of(eventManager.getSingleEvent(eventName, username), username); }
From source file:org.yes.cart.web.service.rest.ProductController.java
private ProductRO viewProductInternal(final String product, final boolean recordViewed) { final long productId = bookmarkMixin.resolveProductId(product); final Product productEntity = productServiceFacade.getProductById(productId); if (productEntity != null) { final ShoppingCart cart = cartMixin.getCurrentCart(); final Pair<String, Boolean> symbol = currencySymbolService.getCurrencySymbol(cart.getCurrencyCode()); final ProductRO prodRO = mappingMixin.map(productEntity, ProductRO.class, Product.class); final Pair<String, String> templates = resolveTemplate(prodRO); if (templates != null) { prodRO.setUitemplate(templates.getFirst()); prodRO.setUitemplateFallback(templates.getSecond()); }//from www. ja va 2 s . co m // Brand is lazy so need to retrieve name manually final Brand brand = brandService.findById(prodRO.getBrandId()); prodRO.setBrandName(brand.getName()); final ProductAvailabilityModel skuPam = productServiceFacade.getProductAvailability(productEntity, cart.getShoppingContext().getShopId()); final ProductAvailabilityModelRO amRo = mappingMixin.map(skuPam, ProductAvailabilityModelRO.class, ProductAvailabilityModel.class); prodRO.setProductAvailabilityModel(amRo); final SkuPrice price = productServiceFacade.getSkuPrice(productEntity.getProductId(), null, BigDecimal.ONE, cart.getCurrencyCode(), cart.getShoppingContext().getShopId()); final SkuPriceRO priceRo = mappingMixin.map(price, SkuPriceRO.class, SkuPrice.class); priceRo.setSymbol(symbol.getFirst()); priceRo.setSymbolPosition(symbol.getSecond() != null && symbol.getSecond() ? "after" : "before"); prodRO.setPrice(priceRo); final List<ProductSkuRO> skuRo = new ArrayList<ProductSkuRO>(); if (CollectionUtils.isNotEmpty(productEntity.getSku())) { for (final ProductSku sku : productEntity.getSku()) { final ProductSkuRO skuRoItem = viewSkuInternal(sku, cart.getShoppingContext().getShopId(), cart.getCurrencyCode(), symbol); if (skuRoItem != null) { skuRo.add(skuRoItem); } } } prodRO.setSkus(skuRo); if (recordViewed) { executeViewProductCommand(productEntity); } return prodRO; } return null; }
From source file:com.feilong.commons.core.lang.ObjectUtilTest.java
/** * Test method for {@link com.feilong.commons.core.lang.ObjectUtil#toT(java.lang.Object, java.lang.Class)}. *//* w ww.j av a 2s.co m*/ @Test public final void testToT() { log.info(ObjectUtil.toT(BigDecimal.ONE, Float.class) + ""); }
From source file:org.openbravo.common.actionhandler.SetNewBPCurrency.java
@Override protected JSONObject doExecute(Map<String, Object> parameters, String content) { JSONObject jsonRequest = null;/*from w w w . j a v a 2 s. c o m*/ OBContext.setAdminMode(true); try { jsonRequest = new JSONObject(content); JSONObject params = jsonRequest.getJSONObject("_params"); final String strOrgId = jsonRequest.getString("inpadOrgId"); final String strFromCurrencyId = jsonRequest.getString("inpbpCurrencyId"); final String strToCurrencyId = params.getString("C_Currency_ID"); final String strRate = params.getString("Rate"); final String strAmount = params.getString("Foreign_Amount"); final boolean strSetAmount = params.getBoolean("Amount"); final boolean strUseDefaultConversion = params.getBoolean("Default_Conversion_Rate"); final String strBpartnerId = jsonRequest.getString("C_BPartner_ID"); final String glItemId = params.getString("c_glitem_id"); BigDecimal creditUsed = BigDecimal.ZERO; BigDecimal rate = BigDecimal.ZERO; Double amount = new Double(0); if (strSetAmount && !"null".equals(strAmount)) { amount = Double.parseDouble(strAmount); } if (strUseDefaultConversion && !strSetAmount) { rate = getConversionRate(strOrgId, strFromCurrencyId, strToCurrencyId); if (rate == BigDecimal.ZERO && !strFromCurrencyId.equals(strToCurrencyId)) { try { jsonRequest = new JSONObject(); String message = OBMessageUtils.messageBD("NoCurrencyConversion"); JSONObject errorMessage = new JSONObject(); errorMessage.put("severity", "error"); errorMessage.put("text", message); jsonRequest.put("message", errorMessage); } catch (Exception e) { OBDal.getInstance().rollbackAndClose(); log.error(e.getMessage(), e); } return jsonRequest; } } else { rate = "null".equals(strRate) ? BigDecimal.ZERO : BigDecimal.valueOf(Double.parseDouble(strRate)); } BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, strBpartnerId); creditUsed = businessPartner.getCreditUsed(); ScrollableResults scroll = null; GLItem glItem = OBDal.getInstance().get(GLItem.class, glItemId); Currency currency = OBDal.getInstance().get(Currency.class, strToCurrencyId); BigDecimal creditAmount = BigDecimal.ZERO; BigDecimal creditRate = BigDecimal.ONE; // Convert available credit automatically if (!StringUtils.equals(strFromCurrencyId, strToCurrencyId) && !StringUtils.isEmpty(glItemId) && !StringUtils.equals(glItemId, "null")) { // Get the rate if (!strSetAmount) { creditRate = rate; } else if (creditUsed.compareTo(BigDecimal.ZERO) != 0) { creditRate = BigDecimal.valueOf(amount).divide(creditUsed, FIN_Utility.getConversionRatePrecision(RequestContext.get().getVariablesSecureApp()), RoundingMode.HALF_UP); } // Loop through all payment documents which generate credit scroll = FinancialUtils.getPaymentsWithCredit(businessPartner.getId(), strFromCurrencyId); int i = 0; try { while (scroll.next()) { final String paymentCreditId = (String) scroll.get()[0]; final FIN_Payment paymentCredit = OBDal.getInstance().get(FIN_Payment.class, paymentCreditId); creditAmount = paymentCredit.getGeneratedCredit().subtract(paymentCredit.getUsedCredit()); // Create a payment to consume the credit with a glitem FIN_Payment payment1 = (FIN_Payment) DalUtil.copy(paymentCredit, false); payment1.setPaymentDate(new Date()); payment1.setAmount(creditAmount); payment1.setDocumentNo(FIN_Utility.getDocumentNo(payment1.getOrganization(), payment1.getDocumentType().getDocumentCategory(), "DocumentNo_FIN_Payment")); payment1.setProcessed(false); payment1.setPosted("N"); payment1.setDescription(null); payment1.setGeneratedCredit(BigDecimal.ZERO); payment1.setUsedCredit(BigDecimal.ZERO); // Create a payment detail to consume the credit with a glitem FIN_PaymentDetail paymentDetail1 = OBProvider.getInstance().get(FIN_PaymentDetail.class); paymentDetail1.setClient(paymentCredit.getClient()); paymentDetail1.setOrganization(paymentCredit.getOrganization()); paymentDetail1.setFinPayment(payment1); paymentDetail1.setAmount(creditAmount); paymentDetail1.setRefund(false); paymentDetail1.setGLItem(glItem); paymentDetail1.setPrepayment(false); // Create a payment schedule detail to consume the credit with a glitem FIN_PaymentScheduleDetail paymentScheduleDetail1 = OBProvider.getInstance() .get(FIN_PaymentScheduleDetail.class); paymentScheduleDetail1.setClient(paymentCredit.getClient()); paymentScheduleDetail1.setOrganization(paymentCredit.getOrganization()); paymentScheduleDetail1.setPaymentDetails(paymentDetail1); paymentScheduleDetail1.setAmount(creditAmount); // Process the payment paymentDetail1.getFINPaymentScheduleDetailList().add(paymentScheduleDetail1); payment1.getFINPaymentDetailList().add(paymentDetail1); OBDal.getInstance().save(payment1); OBDal.getInstance().save(paymentDetail1); OBDal.getInstance().save(paymentScheduleDetail1); FIN_PaymentProcess.doProcessPayment(payment1, "D", false, null, null); // Modify description of original credit payment String paymentCreditDesc = paymentCredit.getDescription() + "\n" + String.format( OBMessageUtils.messageBD("APRM_CreditUsedPayment"), payment1.getDocumentNo()); paymentCredit.setDescription((paymentCreditDesc.length() > 255) ? paymentCreditDesc.substring(0, 251).concat("...").toString() : paymentCreditDesc.toString()); // Create a payment to refund the credit FIN_Payment payment2 = (FIN_Payment) DalUtil.copy(paymentCredit, false); payment2.setPaymentDate(new Date()); payment2.setAmount(creditAmount.negate()); payment2.setDocumentNo(FIN_Utility.getDocumentNo(payment2.getOrganization(), payment2.getDocumentType().getDocumentCategory(), "DocumentNo_FIN_Payment")); payment2.setProcessed(false); payment2.setPosted("N"); payment2.setDescription( OBMessageUtils.messageBD("APRM_RefundPayment") + ": " + payment1.getDocumentNo()); payment2.setGeneratedCredit(BigDecimal.ZERO); payment2.setUsedCredit(creditAmount); // Create a payment credit to refund the credit FIN_Payment_Credit paymentCredit2 = OBProvider.getInstance().get(FIN_Payment_Credit.class); paymentCredit2.setClient(paymentCredit.getClient()); paymentCredit2.setOrganization(paymentCredit.getOrganization()); paymentCredit2.setPayment(payment2); paymentCredit2.setCreditPaymentUsed(paymentCredit); paymentCredit2.setAmount(creditAmount); paymentCredit2.setCurrency(paymentCredit.getCurrency()); // Create a payment detail to refund the credit FIN_PaymentDetail paymentDetail2 = OBProvider.getInstance().get(FIN_PaymentDetail.class); paymentDetail2.setClient(paymentCredit.getClient()); paymentDetail2.setOrganization(paymentCredit.getOrganization()); paymentDetail2.setFinPayment(payment2); paymentDetail2.setAmount(creditAmount.negate()); paymentDetail2.setRefund(true); paymentDetail2.setPrepayment(true); // Create a payment schedule detail to refund the credit FIN_PaymentScheduleDetail paymentScheduleDetail2 = OBProvider.getInstance() .get(FIN_PaymentScheduleDetail.class); paymentScheduleDetail2.setClient(paymentCredit.getClient()); paymentScheduleDetail2.setOrganization(paymentCredit.getOrganization()); paymentScheduleDetail2.setPaymentDetails(paymentDetail2); paymentScheduleDetail2.setAmount(creditAmount.negate()); // Process the payment paymentDetail2.getFINPaymentScheduleDetailList().add(paymentScheduleDetail2); payment2.getFINPaymentDetailList().add(paymentDetail2); payment2.getFINPaymentCreditList().add(paymentCredit2); paymentCredit.setUsedCredit(creditAmount); OBDal.getInstance().save(paymentCredit); OBDal.getInstance().save(payment2); OBDal.getInstance().save(paymentCredit2); OBDal.getInstance().save(paymentDetail2); OBDal.getInstance().save(paymentScheduleDetail2); FIN_PaymentProcess.doProcessPayment(payment2, "D", false, null, null); i++; if (i % 100 == 0) { OBDal.getInstance().flush(); OBDal.getInstance().getSession().clear(); } } // Set the new currency businessPartner.setCurrency(currency); // Loop through all payment documents which generate credit scroll.beforeFirst(); i = 0; while (scroll.next()) { final String paymentCreditId = (String) scroll.get()[0]; final FIN_Payment paymentCredit = OBDal.getInstance().get(FIN_Payment.class, paymentCreditId); // Create a payment to create the credit with a glitem FIN_Payment payment3 = (FIN_Payment) DalUtil.copy(paymentCredit, false); payment3.setPaymentDate(new Date()); payment3.setCurrency(currency); payment3.setAmount(BigDecimal.ZERO); payment3.setDocumentNo(FIN_Utility.getDocumentNo(payment3.getOrganization(), payment3.getDocumentType().getDocumentCategory(), "DocumentNo_FIN_Payment")); payment3.setProcessed(false); payment3.setPosted("N"); payment3.setDescription(null); final BigDecimal generatedCredit = creditAmount.multiply(creditRate) .setScale(currency.getStandardPrecision().intValue(), RoundingMode.HALF_UP); payment3.setGeneratedCredit(generatedCredit); payment3.setUsedCredit(BigDecimal.ZERO); // Create a payment detail to create the credit with a glitem FIN_PaymentDetail paymentDetail3 = OBProvider.getInstance().get(FIN_PaymentDetail.class); paymentDetail3.setClient(paymentCredit.getClient()); paymentDetail3.setOrganization(paymentCredit.getOrganization()); paymentDetail3.setFinPayment(payment3); paymentDetail3.setAmount(generatedCredit); paymentDetail3.setRefund(false); paymentDetail3.setPrepayment(true); // Create a payment detail to create the credit with a glitem FIN_PaymentDetail paymentDetail4 = OBProvider.getInstance().get(FIN_PaymentDetail.class); paymentDetail4.setClient(paymentCredit.getClient()); paymentDetail4.setOrganization(paymentCredit.getOrganization()); paymentDetail4.setFinPayment(payment3); paymentDetail4.setAmount(generatedCredit.negate()); paymentDetail4.setGLItem(glItem); paymentDetail4.setRefund(false); paymentDetail4.setPrepayment(false); // Create a payment schedule detail to create the credit with a glitem FIN_PaymentScheduleDetail paymentScheduleDetail3 = OBProvider.getInstance() .get(FIN_PaymentScheduleDetail.class); paymentScheduleDetail3.setClient(paymentCredit.getClient()); paymentScheduleDetail3.setOrganization(paymentCredit.getOrganization()); paymentScheduleDetail3.setPaymentDetails(paymentDetail3); paymentScheduleDetail3.setAmount(generatedCredit); // Create a payment schedule detail to create the credit with a glitem FIN_PaymentScheduleDetail paymentScheduleDetail4 = OBProvider.getInstance() .get(FIN_PaymentScheduleDetail.class); paymentScheduleDetail4.setClient(paymentCredit.getClient()); paymentScheduleDetail4.setOrganization(paymentCredit.getOrganization()); paymentScheduleDetail4.setPaymentDetails(paymentDetail4); paymentScheduleDetail4.setAmount(generatedCredit.negate()); // Process the payment paymentDetail3.getFINPaymentScheduleDetailList().add(paymentScheduleDetail3); paymentDetail4.getFINPaymentScheduleDetailList().add(paymentScheduleDetail4); payment3.getFINPaymentDetailList().add(paymentDetail3); payment3.getFINPaymentDetailList().add(paymentDetail4); OBDal.getInstance().save(payment3); OBDal.getInstance().save(paymentDetail3); OBDal.getInstance().save(paymentDetail4); OBDal.getInstance().save(paymentScheduleDetail3); OBDal.getInstance().save(paymentScheduleDetail4); OBDal.getInstance().save(paymentCredit); FIN_PaymentProcess.doProcessPayment(payment3, "D", false, null, null); i++; if (i % 100 == 0) { OBDal.getInstance().flush(); OBDal.getInstance().getSession().clear(); } } } finally { scroll.close(); } } if (strSetAmount && creditUsed.compareTo(BigDecimal.valueOf(amount)) != 0) { businessPartner.setCreditUsed(BigDecimal.valueOf(amount)); } if (!strToCurrencyId.equals(strFromCurrencyId) && strToCurrencyId != null && !"null".equals(strToCurrencyId)) { businessPartner.setCurrency(OBDal.getInstance().get(Currency.class, strToCurrencyId)); if (rate.compareTo(BigDecimal.ZERO) != 0 && creditUsed.compareTo(BigDecimal.ZERO) != 0 && !strSetAmount) { businessPartner.setCreditUsed(creditUsed.multiply(rate)); } } String messageText = OBMessageUtils.messageBD("CurrencyUpdated"); JSONObject msg = new JSONObject(); msg.put("severity", "success"); msg.put("text", OBMessageUtils.parseTranslation(messageText)); jsonRequest.put("message", msg); } catch (Exception e) { OBDal.getInstance().rollbackAndClose(); log.error("Error in set new currency Action Handler", e); try { jsonRequest = new JSONObject(); Throwable ex = DbUtility.getUnderlyingSQLException(e); String message = OBMessageUtils.translateError(ex.getMessage()).getMessage(); JSONObject errorMessage = new JSONObject(); errorMessage.put("severity", "error"); errorMessage.put("text", message); jsonRequest.put("message", errorMessage); } catch (Exception e2) { log.error(e.getMessage(), e2); // do nothing, give up } } finally { OBContext.restorePreviousMode(); } return jsonRequest; }
From source file:org.kuali.kfs.sys.service.impl.TaxServiceImpl.java
/** * This method returns a preTax amount//from ww w .ja va2 s. c o m * * @param dateOfTransaction * @param postalCode * @param amountWithTax * @return */ @Override public KualiDecimal getPretaxAmount(Date dateOfTransaction, String postalCode, KualiDecimal amountWithTax) { BigDecimal totalTaxRate = BigDecimal.ZERO; // there is not tax amount if (StringUtils.isEmpty(postalCode)) return amountWithTax; // strip digits from the postal code before passing it to the sales tax regions // if the parameters indicate to do so. postalCode = truncatePostalCodeForSalesTaxRegionService(postalCode); List<TaxRegion> salesTaxRegions = taxRegionService.getSalesTaxRegions(postalCode); if (salesTaxRegions.size() == 0) return amountWithTax; for (TaxRegion taxRegion : salesTaxRegions) { if (ObjectUtils.isNotNull((taxRegion.getEffectiveTaxRegionRate(dateOfTransaction)))) totalTaxRate = totalTaxRate .add(taxRegion.getEffectiveTaxRegionRate(dateOfTransaction).getTaxRate()); } KualiDecimal divisor = new KualiDecimal(totalTaxRate.add(BigDecimal.ONE)); KualiDecimal pretaxAmount = amountWithTax.divide(divisor); return pretaxAmount; }
From source file:org.impotch.calcul.impot.cantonal.fr.pp.ProducteurImpotRevenu2007Test.java
private FournisseurAssiettePeriodique creerAssiettes(final int annee, final int montantImposable, final int montantDeterminant, final ICommuneSuisse commune) { FournisseurAssiettePeriodique fournisseur = new FournisseurAssiettePeriodique() { @Override/*from w w w. j av a 2 s. co m*/ public FournisseurAssietteCommunale getFournisseurAssietteCommunale() { FournisseurAssietteCommunale fournisseur = new FournisseurAssietteCommunale() { @Override public Map<ICommuneSuisse, Integer> getNbreJourDomicileSurCommune() { Map<ICommuneSuisse, Integer> map = new HashMap<ICommuneSuisse, Integer>(); map.put(commune, 360); return map; } @Override public int getPeriodeFiscale() { return annee; } @Override public Repartition<ForCommunal> getRepartition() { Repartition<ForCommunal> repart = new Repartition<ForCommunal>(); repart.ajouterPart(new ForCommunal(commune), new Part(BigDecimal.ONE)); return repart; } }; return fournisseur; } @Override public int getNombreJourPourAnnualisation() { return 360; } @Override public int getPeriodeFiscale() { return annee; } @Override public BigDecimal getMontantDeterminant() { return new BigDecimal(montantDeterminant); } @Override public BigDecimal getMontantImposable() { return new BigDecimal(montantImposable); } }; return fournisseur; }
From source file:org.efaps.esjp.accounting.transaction.FieldUpdate_Base.java
/** * Method is executed on update trigger for the amount field in the debit * and credit table inside the transaction form. * * @param _parameter Parameter as passed from the eFaps API * @return list for update trigger/*from w w w . j ava 2s . c o m*/ * @throws EFapsException on error */ public Return update4Amount(final Parameter _parameter) throws EFapsException { final Return retVal = new Return(); try { final String postfix = getProperty(_parameter, "TypePostfix"); final String[] amounts = _parameter.getParameterValues("amount_" + postfix); final String[] rates = _parameter.getParameterValues("rate_" + postfix); final String[] ratesInv = _parameter.getParameterValues("rate_" + postfix + RateUI.INVERTEDSUFFIX); final int pos = getSelectedRow(_parameter); final DecimalFormat rateFormater = NumberFormatter.get().getFormatter(0, 8); final DecimalFormat formater = NumberFormatter.get().getTwoDigitsFormatter(); final BigDecimal amount = amounts[pos].isEmpty() ? BigDecimal.ZERO : (BigDecimal) rateFormater.parse(amounts[pos]); BigDecimal rate = rates[pos].isEmpty() ? BigDecimal.ZERO : (BigDecimal) rateFormater.parse(rates[pos]); final boolean rateInv = "true".equalsIgnoreCase(ratesInv[pos]); if (rateInv && rate.compareTo(BigDecimal.ZERO) != 0) { rate = BigDecimal.ONE.divide(rate, 12, BigDecimal.ROUND_HALF_UP); } final List<Map<String, String>> list = new ArrayList<>(); final Instance periodInstance = new Period().evaluateCurrentPeriod(_parameter); final BigDecimal sum = getSum4UI(_parameter, postfix, null, null); final String postfix2 = "Debit".equals(postfix) ? "Credit" : "Debit"; final BigDecimal sum2 = getSum4UI(_parameter, postfix2, null, null); final String sumStr = formater.format(sum) + " " + new Period().getCurrency(periodInstance).getSymbol(); final String sumStr2 = formater.format(sum.subtract(sum2).abs()) + " " + new Period().getCurrency(periodInstance).getSymbol(); final Map<String, String> map = new HashMap<>(); map.put("sum" + postfix, sumStr); map.put("amountRate_" + postfix, formater.format(amount.setScale(8).divide(rate, BigDecimal.ROUND_HALF_UP))); map.put("sumTotal", sumStr2); list.add(map); retVal.put(ReturnValues.VALUES, list); } catch (final ParseException e) { throw new EFapsException(Transaction_Base.class, "update4Amount.ParseException", e); } return retVal; }