List of usage examples for java.math RoundingMode HALF_UP
RoundingMode HALF_UP
To view the source code for java.math RoundingMode HALF_UP.
Click Source Link
From source file:service.AdService.java
public void create(Boolean isAutherized, Long catId, String email, String phone, String price, MultipartFile previews[], String name, String desc, Long booleanIds[], String booleanVals[], Long stringIds[], String stringVals[], Long numIds[], String snumVals[], Long dateIds[], Date dateVals[], Long selIds[], Long selVals[], Long multyIds[], String multyVals[], Date dateFrom, Date dateTo, Long localIds[]) throws IOException { Boolean newUser = false;//w w w. ja v a 2s.co m if (catId != null) { Category cat = catDao.find(catId); if (cat != null) { if (isAutherized || (!isAutherized && email != null && !email.equals(""))) { PhoneEditor phe = new PhoneEditor(); phone = phe.getPhone(phone); addError(phe.error); if ((phone == null || phone.equals("")) && (email == null || email.equals(""))) { addError( " email ? "); } User user = userService.getUserByMail(email); if (!isAutherized && user == null) { user = userService.registerStandardUser(email); newUser = true; List<String> userErrors = userService.getErrors(); if (!userErrors.isEmpty()) { for (String er : userErrors) { addError("user_service: " + er + "; "); } } } Ad ad = new Ad(); ad.setInsertDate(new Date()); ad.setShowCount((long) 0); ad.setStatus(Ad.NEW); ad.setDateFrom(dateFrom); ad.setDateTo(dateTo); ad.setEmail(email); ad.setPhone(phone); ad.setAuthor(user); ad.setCat(cat); Set<Locality> locals = new HashSet(); /*if (region != null) { if (region.isAllRussia()) { locals.addAll(locDao.getAll()); } else { locals.addAll(region.getLocalities()); } }*/ if (localIds != null && localIds.length > 0) { locals.addAll(locDao.getLocs(localIds)); } else { addError(" ? "); } ad.setLocalities(locals); ad.setName(name); ad.setDescription(desc); ad.setPrice(getNumFromString(price, true)); ad.setValues(new HashSet()); if (validate(ad) && getErrors().isEmpty()) { adDao.save(ad); List<Long> reqParamIds = catDao.getRequiredParamsIds(catId); List<Parametr> catParams = paramDao.getParamsFromCat(catId); int i = 0; ArrayList<String> paramValsErrs = new ArrayList(); // ? ?? ? ? ? ??, ?, ? ? //? ad ArrayList<ParametrValue> list4Save = new ArrayList(); // if (booleanIds != null) { if (booleanVals == null) { booleanVals = new String[booleanIds.length]; } while (i < booleanIds.length) { Parametr p = paramDao.find(booleanIds[i]); if (catParams.contains(p) && Parametr.BOOL == p.getParamType()) { Long val = ParametrValue.NO; String sval = ""; if (booleanVals[i] != null) { val = ParametrValue.YES; sval = ""; } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setSelectVal(val); pv.setStringVal(sval); if (validate(pv)) { list4Save.add(pv); } } i++; } } if (stringVals != null && stringVals.length > 0) { i = 0; while (i < stringIds.length) { Long paramId = stringIds[i]; Parametr p = paramDao.find(paramId); if (catParams.contains(p) && Parametr.TEXT == p.getParamType()) { String val = stringVals[i]; if (val != null && !val.equals("")) { if (reqParamIds.contains(paramId)) { reqParamIds.remove(paramId); } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setStringVal(val); if (validate(pv)) { list4Save.add(pv); } } } i++; } } if (snumVals != null && snumVals.length > 0) { i = 0; while (i < numIds.length) { Long paramId = numIds[i]; Parametr p = paramDao.find(paramId); if (catParams.contains(p) && Parametr.NUM == p.getParamType()) { String sval = snumVals[i]; if (sval != null && !sval.equals("")) { Double val = getNumFromString(sval, true); if (reqParamIds.contains(paramId)) { reqParamIds.remove(paramId); } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setNumVal(val); pv.setStringVal(StringAdapter.getString(val)); if (validate(pv)) { list4Save.add(pv); } } } i++; } if (!getErrors().isEmpty()) { for (String e : getErrors()) { paramValsErrs.add(e); } } } if (dateVals != null && dateVals.length > 0) { i = 0; while (i < dateIds.length) { Long paramId = dateIds[i]; Parametr p = paramDao.find(paramId); if (catParams.contains(p) && Parametr.DATE == p.getParamType()) { Date val = dateVals[i]; if (val != null) { if (reqParamIds.contains(paramId)) { reqParamIds.remove(paramId); } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setDateVal(val); pv.setStringVal(DateAdapter.formatByDate(val, DateAdapter.SMALL_FORMAT)); if (validate(pv)) { list4Save.add(pv); } } } i++; } } if (selVals != null && selVals.length > 0) { i = 0; while (i < selIds.length) { Long paramId = selIds[i]; Parametr p = paramDao.find(paramId); if (catParams.contains(p) && Parametr.SELECTING == p.getParamType()) { Long val = selVals[i]; if (val != null && !val.equals(0L)) { if (reqParamIds.contains(paramId)) { reqParamIds.remove(paramId); } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setSelectVal(val); pv.setStringVal(paramSelDao.find(val).getName()); if (validate(pv)) { list4Save.add(pv); } } } i++; } } //? ? //TO DO (??) if (multyVals != null && multyVals.length > 0) { for (String rawVal : multyVals) { String idValArr[] = rawVal.split("_"); if (idValArr.length == 2) { String strId = idValArr[0]; String strVal = idValArr[1]; Long paramId = Long.valueOf(strId); Long val = Long.valueOf(strVal); Parametr p = paramDao.find(paramId); if (catParams.contains(p) && Parametr.MULTISELECTING == p.getParamType()) { if (reqParamIds.contains(paramId) && val != null) { reqParamIds.remove(paramId); } ParametrValue pv = new ParametrValue(); pv.setAd(ad); pv.setParametr(p); pv.setSelectVal(val); pv.setStringVal(paramSelDao.find(val).getName()); if (validate(pv)) { list4Save.add(pv); } } } } } //? ? ? ? if (!reqParamIds.isEmpty() || !paramValsErrs.isEmpty()) { for (Long id : reqParamIds) { addError(" " + paramDao.find(id).getName() + "; "); } //? adDao.delete(ad); } else { for (ParametrValue pv : list4Save) { paramValueDao.save(pv); } File file = new File("/usr/local/seller/preview/" + ad.getId() + "/"); if (file.exists()) { for (File f : file.listFiles()) { f.delete(); } file.delete(); } file.mkdirs(); if (previews != null && previews.length > 0) { i = 0; while (i < 10 && i < previews.length) { MultipartFile prev = previews[i]; if (prev != null && 0L < prev.getSize()) { if (prev.getSize() <= (long) 3 * 1024 * 1024) { File f = new File( "/usr/local/seller/preview/" + ad.getId() + "/supPreview"); if (f.exists()) { f.delete(); } prev.transferTo(f); //to do ? - ?? try { BufferedImage bi = ImageIO.read(f); BigDecimal x = BigDecimal.valueOf(0); BigDecimal y = BigDecimal.valueOf(0); BigDecimal h = BigDecimal.valueOf(bi.getHeight()); BigDecimal w = BigDecimal.valueOf(bi.getWidth()); if (h.compareTo(w) > 0) { y = (h.subtract(w)).divide(BigDecimal.valueOf(2), RoundingMode.HALF_UP); h = w; } else if (h.compareTo(w) < 0) { x = (w.subtract(h)).divide(BigDecimal.valueOf(2), RoundingMode.HALF_UP); w = h; } bi = bi.getSubimage(x.intValue(), y.intValue(), w.intValue(), h.intValue()); f.delete(); f = new File("/usr/local/seller/preview/" + ad.getId() + "/" + i); ImageIO.write(bi, "png", f); } catch (Exception e) { addError( "? ? " + prev.getName() + /*"; s="+prev.getSize()+"; t="+prev.getContentType()+"; l="+previews.length+*/ "; " + StringAdapter.getStackTraceException(e)); } } else { addError(" " + prev.getName() + " , ? 3 ."); } } i++; } } if (newUser) { userService.notifyAboutRegistration(email); } } } /* else { addError("user:" + user.getId() + " " + user.getName()); }*/ } else { addError( "? ?? email"); } } else { addError("? ? " + catId + " ."); } } else { addError("? "); } }
From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java
private Activo deprecia(Activo activo, Date fecha) { // depreciacion anual BigDecimal porciento = activo.getPorciento(); log.trace("Activo - MOI - Porciento: {} - {} - {}", new Object[] { activo.getId(), activo.getMoi(), porciento }); BigDecimal depreciacionAnual = activo.getMoi().multiply(porciento); log.trace("DepreciacionAnual: {}", depreciacionAnual); // depreciacion mensual BigDecimal depreciacionMensual = BigDecimal.ZERO; Date fechaCompra = activo.getFechaCompra(); if (fechaCompra.before(fecha) && days360(fechaCompra, fecha) / 30 < activo.getVidaUtil()) { depreciacionMensual = depreciacionAnual.divide(new BigDecimal("12"), 2, RoundingMode.HALF_UP); }//from w ww .j a v a2 s .c om log.trace("DepreciacionMensual: {}", depreciacionMensual); // depreciacion acumulada BigDecimal depreciacionAcumulada; Long meses = 0L; if ((fechaCompra.before(fecha) && !activo.getInactivo()) || (fechaCompra.before(fecha) && activo.getInactivo() && activo.getFechaInactivo().after(fecha))) { meses = days360(fechaCompra, fecha) / 30; } else if (fechaCompra.before(fecha) && activo.getInactivo() && activo.getFechaInactivo().before(fecha)) { meses = days360(fechaCompra, activo.getFechaInactivo()) / 30; } if (meses < activo.getVidaUtil()) { depreciacionAcumulada = depreciacionMensual.multiply(new BigDecimal(meses)); } else { depreciacionAcumulada = activo.getMoi(); } log.trace("DepreciacionAcumulada: {}", depreciacionAcumulada); // valor neto BigDecimal valorNeto = activo.getMoi().subtract(depreciacionAcumulada); log.trace("ValorNeto: {}", valorNeto); activo.setFechaDepreciacion(fecha); activo.setDepreciacionAnual(depreciacionAnual); activo.setDepreciacionMensual(depreciacionMensual); activo.setDepreciacionAcumulada(depreciacionAcumulada); activo.setValorNeto(valorNeto); return activo; }
From source file:org.yes.cart.payment.impl.CyberSourcePaymentGatewayImpl.java
/** * {@inheritDoc}//w ww.ja v a2 s.com */ public Payment capture(final Payment payment) { final Logger log = ShopCodeContext.getLog(this); if (log.isDebugEnabled()) { log.debug("Capture " + payment); } final HashMap<String, String> request = new HashMap<String, String>(); request.put("ccCaptureService_run", "true"); request.put("ccCaptureService_authRequestID", payment.getTransactionAuthorizationCode()); request.put("ccCaptureService_authRequestToken", payment.getTransactionRequestToken()); request.put("purchaseTotals_currency", payment.getOrderCurrency()); request.put("purchaseTotals_grandTotalAmount", payment.getPaymentAmount().setScale(2, RoundingMode.HALF_UP).toString()); request.put("merchantID", (String) getProperties().get(CS_MERCHANT_ID)); request.put("requestID", payment.getTransactionAuthorizationCode()); request.put("requestToken", payment.getTransactionRequestToken()); request.put("merchantReferenceCode", payment.getTransactionReferenceId()); return runTransaction(request, payment, CAPTURE); }
From source file:com.sunchenbin.store.feilong.core.lang.NumberUtil.java
/** * ? ??? {@link RoundingMode#HALF_UP} ??. * //w w w . j a v a2 s. c om * <p> * ?>=0.5? ??<br> * </p> * * <p style="color:red"> * ?{@link RoundingMode#HALF_UP} -2.5 ??-3, Math.round(-2.5) -2 * </p> * * @param number * number * @param scale * ?? * @return the big decimal * @see <a href="#RoundingMode">JAVA 8??</a> * @see java.math.RoundingMode#HALF_UP * @see java.math.BigDecimal#ROUND_HALF_UP */ private static BigDecimal setScale(BigDecimal number, int scale) { RoundingMode roundingMode = RoundingMode.HALF_UP; return setScale(number, scale, roundingMode); }
From source file:org.sakaiproject.profile2.job.KudosJob.java
/** * Gets the score out of ten as an int, and rounded up * @param score score for user/*from w w w . j a v a 2 s .c o m*/ * @param total total possible score * @return */ private static int getScoreOutOfTen(BigDecimal score, BigDecimal total) { return score.divide(total, 1, RoundingMode.HALF_UP).multiply(new BigDecimal("10")).intValue(); }
From source file:org.egov.ptis.domain.service.report.ReportService.java
private void buildCollectionReport(final List<BillCollectorDailyCollectionReportResult> listBcPayment, final int noofDays) { for (final BillCollectorDailyCollectionReportResult bcResult : listBcPayment) { if (bcResult.getTarget_arrears_demand() == null) bcResult.setTarget_arrears_demand(0.0); if (bcResult.getTarget_current_demand() == null) bcResult.setTarget_current_demand(0.0); bcResult.setTarget_total_demand( bcResult.getTarget_arrears_demand() + bcResult.getTarget_current_demand()); if (bcResult.getToday_arrears_collection() == null) bcResult.setToday_arrears_collection(0.0); if (bcResult.getToday_currentyear_collection() == null) bcResult.setToday_currentyear_collection(0.0); bcResult.setToday_total_collection( bcResult.getToday_arrears_collection() + bcResult.getToday_currentyear_collection()); if (bcResult.getCummulative_arrears_collection() == null) bcResult.setCummulative_arrears_collection(0.0); if (bcResult.getCummulative_currentyear_collection() == null) bcResult.setCummulative_currentyear_collection(0.0); bcResult.setCummulative_total_Collection(bcResult.getCummulative_arrears_collection() + bcResult.getCummulative_currentyear_collection()); if (noofDays > 0) bcResult.setDay_target(BigDecimal .valueOf(bcResult.getTarget_total_demand() - bcResult.getCummulative_total_Collection()) .divide(BigDecimal.valueOf(noofDays), 4, RoundingMode.HALF_UP) .setScale(2, RoundingMode.HALF_UP)); else//from ww w . j av a 2 s .co m bcResult.setDay_target(ZERO); if (bcResult.getCummulative_total_Collection() > 0) bcResult.setCummulative_currentYear_Percentage(BigDecimal .valueOf(bcResult.getCummulative_total_Collection()) .divide(BigDecimal.valueOf(bcResult.getTarget_total_demand()), 4, RoundingMode.HALF_UP) .multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); if (bcResult.getLastyear_collection() == null) bcResult.setLastyear_collection(0.0); else bcResult.setLastyear_collection((double) Math.round(bcResult.getLastyear_collection())); if (bcResult.getLastyear_cummulative_collection() == null) bcResult.setLastyear_cummulative_collection(0.0); else bcResult.setLastyear_cummulative_collection( (double) Math.round(bcResult.getLastyear_cummulative_collection())); bcResult.setPercentage_compareWithLastYear( bcResult.getCummulative_total_Collection() - bcResult.getLastyear_cummulative_collection()); if (bcResult.getLastyear_cummulative_collection() > 0) bcResult.setGrowth(BigDecimal .valueOf(bcResult.getCummulative_total_Collection() - bcResult.getLastyear_cummulative_collection()) .divide(BigDecimal.valueOf(bcResult.getLastyear_cummulative_collection()), 4, RoundingMode.HALF_UP) .multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP)); else bcResult.setGrowth(ZERO); } for (final BillCollectorDailyCollectionReportResult bcResult : listBcPayment) { bcResult.setTarget_arrears_demand(formatAmt(bcResult.getTarget_arrears_demand()).doubleValue()); bcResult.setTarget_current_demand(formatAmt(bcResult.getTarget_current_demand()).doubleValue()); bcResult.setTarget_total_demand(formatAmt(bcResult.getTarget_total_demand()).doubleValue()); bcResult.setDay_target(formatAmt(bcResult.getDay_target().doubleValue())); bcResult.setToday_total_collection(formatAmt(bcResult.getToday_total_collection()).doubleValue()); bcResult.setCummulative_arrears_collection( formatAmt(bcResult.getCummulative_arrears_collection()).doubleValue()); bcResult.setCummulative_currentyear_collection( formatAmt(bcResult.getCummulative_currentyear_collection()).doubleValue()); bcResult.setCummulative_total_Collection( formatAmt(bcResult.getCummulative_total_Collection()).doubleValue()); bcResult.setPercentage_compareWithLastYear( formatAmt(bcResult.getPercentage_compareWithLastYear()).doubleValue()); bcResult.setLastyear_collection(formatAmt(bcResult.getLastyear_collection()).doubleValue()); bcResult.setLastyear_cummulative_collection( formatAmt(bcResult.getLastyear_cummulative_collection()).doubleValue()); } }
From source file:org.yes.cart.payment.impl.PayflowPaymentGatewayImpl.java
/** * Fill delivery details in invoice from payment. * * @param paymentIn payment//from w w w. j av a2s . c o m * @param invoice invoice to fill */ private void fillDeliveryDetails(final Payment paymentIn, final paypal.payflow.Invoice invoice) { for (PaymentLine line : paymentIn.getOrderItems()) { paypal.payflow.LineItem lineItem = new paypal.payflow.LineItem(); lineItem.setSku(line.getSkuCode()); lineItem.setDesc(line.getSkuName()); lineItem.setQty(line.getQuantity().longValue()); lineItem.setCost( new paypal.payflow.Currency(line.getUnitPrice().doubleValue(), paymentIn.getOrderCurrency())); lineItem.setAmt(new paypal.payflow.Currency(line.getQuantity().multiply(line.getUnitPrice()) .setScale(2, RoundingMode.HALF_UP).doubleValue(), paymentIn.getOrderCurrency())); invoice.addLineItem(lineItem); } }
From source file:mx.edu.um.mateo.inventario.dao.impl.SalidaDaoHibernate.java
@Override @Transactional(rollbackFor = { NoEstaAbiertaException.class, ProductoNoSoportaFraccionException.class }) public LoteSalida creaLote(LoteSalida lote) throws ProductoNoSoportaFraccionException, NoEstaAbiertaException { if (lote.getSalida().getEstatus().getNombre().equals(Constantes.ABIERTA)) { if (!lote.getProducto().getFraccion()) { BigDecimal[] resultado = lote.getCantidad().divideAndRemainder(new BigDecimal("1")); if (resultado[1].doubleValue() > 0) { throw new ProductoNoSoportaFraccionException(); }//ww w . j a v a2s.c om } lote.setPrecioUnitario(lote.getProducto().getPrecioUnitario()); BigDecimal subtotal = lote.getPrecioUnitario().multiply(lote.getCantidad()); BigDecimal iva = subtotal.multiply(lote.getProducto().getIva()).setScale(2, RoundingMode.HALF_UP); lote.setIva(iva); BigDecimal total = subtotal.add(iva).setScale(2, RoundingMode.HALF_UP); lote.setFechaCreacion(new Date()); currentSession().save(lote); Salida salida = lote.getSalida(); salida.setIva(salida.getIva().add(iva)); salida.setTotal(salida.getTotal().add(total)); currentSession().save(salida); currentSession().flush(); return lote; } else { throw new NoEstaAbiertaException("No se puede crear un lote en una salida que no este abierta"); } }
From source file:org.zephyrsoft.trackworktime.timer.TimerManager.java
/** * Get the normal work time (in minutes) for a specific week day. *///from w ww .j a va2 s.com public int getNormalWorkDurationFor(WeekDayEnum weekDay) { if (isWorkDay(weekDay)) { String targetValueString = preferences.getString(Key.FLEXI_TIME_TARGET.getName(), "0:00"); targetValueString = DateTimeUtil.refineHourMinute(targetValueString); TimeSum targetValue = parseHoursMinutesString(targetValueString); BigDecimal minutes = new BigDecimal(targetValue.getAsMinutes()).divide(new BigDecimal(countWorkDays()), RoundingMode.HALF_UP); return minutes.intValue(); } else { return 0; } }
From source file:org.kuali.ole.select.document.web.struts.OleInvoiceAction.java
/** * Add a new item to the document./*from w w w.ja va 2s.co m*/ * * @param mapping An ActionMapping * @param form An ActionForm * @param request The HttpServletRequest * @param response The HttpServletResponse * @return An ActionForward * @throws Exception */ public ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { OleInvoiceForm purchasingForm = (OleInvoiceForm) form; OleInvoiceItem item = (OleInvoiceItem) purchasingForm.getNewPurchasingItemLine(); // purchasingForm.getNewPurchasingItemLine().setItemDescription((item.getBibInfoBean().getTitle() != null ? // item.getBibInfoBean().getTitle() : "") + (item.getBibInfoBean().getAuthor() != null ? "," + // item.getBibInfoBean().getAuthor() : "") + (item.getBibInfoBean().getPublisher() != null ? "," + // item.getBibInfoBean().getPublisher() : "") + (item.getBibInfoBean().getIsbn() != null ? "," + // item.getBibInfoBean().getIsbn() : "")); OleInvoiceDocument document = (OleInvoiceDocument) purchasingForm.getDocument(); BibInfoWrapperService docStore = SpringContext.getBean(BibInfoWrapperServiceImpl.class); FileProcessingService fileProcessingService = SpringContext.getBean(FileProcessingService.class); String titleId = null; boolean isBibFileExist = false; Iterator itemIterator = document.getItems().iterator(); int itemCounter = 0; while (itemIterator.hasNext()) { OleInvoiceItem tempItem = (OleInvoiceItem) itemIterator.next(); if (tempItem.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ITEM_CODE) || tempItem .getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_UNORDERED_ITEM_CODE)) { itemCounter++; } } String itemNo = String.valueOf(itemCounter); //String itemNo = String.valueOf(document.getItems().size() - 8); HashMap<String, String> dataMap = new HashMap<String, String>(); item.setBibInfoBean(new BibInfoBean()); if (item.getBibInfoBean().getDocStoreOperation() == null) { item.getBibInfoBean().setDocStoreOperation(OleSelectConstant.DOCSTORE_OPERATION_STAFF); } String fileName = document.getDocumentNumber() + "_" + itemNo; setItemDescription(item, fileName); /*dataMap.put(OleSelectConstant.FILEPATH, fileProcessingService.getMarcXMLFileDirLocation()); dataMap.put(OleSelectConstant.FILENAME, fileName); if (fileProcessingService.isCreateFileExist(dataMap)) { isBibFileExist = true; } if (isBibFileExist) { titleId = docStore.getTitleIdByMarcXMLFileProcessing(item.getBibInfoBean(), dataMap); item.setItemTitleId(titleId); BibInfoBean xmlBibInfoBean = new BibInfoBean(); dataMap.put(OleSelectConstant.TITLE_ID, titleId); dataMap.put(OleSelectConstant.DOC_CATEGORY_TYPE, OleSelectConstant.DOC_CATEGORY_TYPE_ITEMLINKS); xmlBibInfoBean = docStore.getBibInfo(dataMap); item.setBibInfoBean(xmlBibInfoBean); purchasingForm.getNewPurchasingItemLine().setItemDescription((item.getBibInfoBean().getTitle() != null ? item.getBibInfoBean().getTitle() : "") + (item.getBibInfoBean().getAuthor() != null ? "," + item.getBibInfoBean().getAuthor() : "") + (item.getBibInfoBean().getPublisher() != null ? "," + item.getBibInfoBean().getPublisher() : "") + (item.getBibInfoBean().getIsbn() != null ? "," + item.getBibInfoBean().getIsbn() : "")); HashMap<String,String> queryMap = new HashMap<String,String>(); queryMap.put(OleSelectConstant.DocStoreDetails.ITEMLINKS_KEY, item.getItemTitleId()); List<DocInfoBean> docStoreResult = docStore.searchBibInfo(queryMap); Iterator bibIdIterator = docStoreResult.iterator(); if(bibIdIterator.hasNext()){ DocInfoBean docInfoBean = (DocInfoBean)bibIdIterator.next(); item.setBibUUID(docInfoBean.getUniqueId()); } }*/ boolean ruleFlag = getKualiRuleService().applyRules(new OleInvoiceDescEvent(document, item)); if (ruleFlag) { if ((document.getVendorDetail() == null) || (document.getVendorDetail().getVendorName() != null && !document.getVendorDetail().getVendorHeader().getVendorForeignIndicator())) { boolean rulePassed = getKualiRuleService().applyRules(new OleDiscountInvoiceEvent(document, item)); if (rulePassed) { purchasingForm.getNewPurchasingItemLine() .setItemUnitPrice(SpringContext.getBean(OlePurapService.class).calculateDiscount(item)); item = (OleInvoiceItem) purchasingForm.getAndResetNewPurchasingItemLine(); document.addItem(item); } } else { boolean rulePassed = getKualiRuleService() .applyRules(new OleForeignCurrencyInvoiceEvent(document, item)); if (rulePassed) { LOG.debug("###########Foreign Currency Field Calculation for Invoice ###########"); SpringContext.getBean(OlePurapService.class).calculateForeignCurrency(item); Long id = document.getVendorDetail().getCurrencyType().getCurrencyTypeId(); Map documentNumberMap = new HashMap(); documentNumberMap.put(OleSelectConstant.CURRENCY_TYPE_ID, id); BusinessObjectService businessObjectService = SpringContext .getBean(BusinessObjectService.class); List<OleExchangeRate> exchangeRateList = (List) businessObjectService.findMatchingOrderBy( OleExchangeRate.class, documentNumberMap, OleSelectConstant.EXCHANGE_RATE_DATE, false); Iterator iterator = exchangeRateList.iterator(); if (iterator.hasNext()) { OleExchangeRate tempOleExchangeRate = (OleExchangeRate) iterator.next(); item.setItemExchangeRate(new KualiDecimal(tempOleExchangeRate.getExchangeRate())); } if (item.getItemExchangeRate() != null && item.getItemForeignUnitCost() != null) { item.setItemUnitCostUSD(new KualiDecimal(item.getItemForeignUnitCost().bigDecimalValue() .divide(item.getItemExchangeRate().bigDecimalValue(), 4, RoundingMode.HALF_UP))); item.setItemUnitPrice(item.getItemUnitCostUSD().bigDecimalValue()); item.setItemListPrice(item.getItemUnitCostUSD()); } item = (OleInvoiceItem) purchasingForm.getAndResetNewPurchasingItemLine(); document.addItem(item); } } } return mapping.findForward(OLEConstants.MAPPING_BASIC); }