List of usage examples for java.math BigDecimal multiply
public BigDecimal multiply(BigDecimal multiplicand)
(this × multiplicand)
, and whose scale is (this.scale() + multiplicand.scale()) . From source file:org.kuali.kpme.tklm.leave.calendar.validation.LeaveCalendarValidationUtil.java
public static List<String> validateAvailableLeaveBalanceForUsage(String earnCode, String leaveStartDateString, String leaveEndDateString, BigDecimal leaveAmount, LeaveBlock updatedLeaveBlock) { List<String> errors = new ArrayList<String>(); boolean earnCodeChanged = false; BigDecimal oldAmount = null;//w w w .ja va 2 s.c o m if (leaveAmount == null) { leaveAmount = TKUtils.getHoursBetween(TKUtils.formatDateString(leaveStartDateString).toDate().getTime(), TKUtils.formatDateString(leaveEndDateString).toDate().getTime()); } if (updatedLeaveBlock != null) { if (!updatedLeaveBlock.getEarnCode().equals(earnCode)) { earnCodeChanged = true; } if (!updatedLeaveBlock.getLeaveAmount().equals(leaveAmount)) { oldAmount = updatedLeaveBlock.getLeaveAmount(); } } LocalDate startDate = TKUtils.formatDateString(leaveStartDateString); LocalDate endDate = TKUtils.formatDateString(leaveEndDateString); long daysSpan = TKUtils.getDaysBetween(startDate, endDate); EarnCodeContract earnCodeObj = HrServiceLocator.getEarnCodeService().getEarnCode(earnCode, endDate); if (earnCodeObj != null && earnCodeObj.getAllowNegativeAccrualBalance().equals("N")) { AccrualCategoryContract accrualCategory = HrServiceLocator.getAccrualCategoryService() .getAccrualCategory(earnCodeObj.getAccrualCategory(), endDate); if (accrualCategory != null) { AccrualEarnInterval accrualEarnInterval = AccrualEarnInterval .fromCode(accrualCategory.getAccrualEarnInterval()); DateTime nextIntervalDate; if (accrualEarnInterval != null && AccrualEarnInterval.PAY_CAL.equals(accrualEarnInterval)) { RateRangeAggregateContract rrAggregate = LmServiceLocator.getAccrualService() .buildRateRangeAggregate(HrContext.getTargetPrincipalId(), startDate.toDateTimeAtStartOfDay(), endDate.toDateTimeAtStartOfDay()); PrincipalHRAttributesContract phra = rrAggregate.getRateOnDate(endDate.toDateTimeAtStartOfDay()) .getPrincipalHRAttributes(); nextIntervalDate = LmServiceLocator.getAccrualService().getNextIntervalDate( endDate.toDateTimeAtStartOfDay(), accrualEarnInterval.getCode(), phra.getPayCalendar(), rrAggregate.getCalEntryMap()); } else { nextIntervalDate = LmServiceLocator.getAccrualService().getNextAccrualIntervalDate( accrualCategory.getAccrualEarnInterval(), endDate.toDateTimeAtStartOfDay()); } // get the usage checking cut off Date, normally it's the day before the next interval date DateTime usageEndDate = nextIntervalDate; if (nextIntervalDate.compareTo(endDate.toDateTimeAtCurrentTime()) > 0) { usageEndDate = nextIntervalDate.minusDays(1); } // use the end of the year as the interval date for usage checking of no-accrual hours, // normally no-accrual hours are from banked/transferred system scheduled time offs if (accrualCategory.getAccrualEarnInterval().equals(AccrualEarnInterval.NO_ACCRUAL.getCode())) { usageEndDate = endDate.toDateTimeAtStartOfDay().withMonthOfYear(DateTimeConstants.DECEMBER) .withDayOfMonth(31); } BigDecimal availableBalance = LmServiceLocator.getLeaveSummaryService() .getLeaveBalanceForAccrCatUpToDate(HrContext.getTargetPrincipalId(), startDate, endDate, accrualCategory.getAccrualCategory(), usageEndDate.toLocalDate()); if (oldAmount != null) { if (!earnCodeChanged || (updatedLeaveBlock.getAccrualCategory() != null && updatedLeaveBlock .getAccrualCategory().equals(accrualCategory.getAccrualCategory()))) { availableBalance = availableBalance.add(oldAmount.abs()); } } //multiply by days in span in case the user has also edited the start/end dates. // daySpan for the same start/end dates is 0 so we need to add 1 to it BigDecimal desiredUsage = leaveAmount.multiply(new BigDecimal(daysSpan + 1)); // BigDecimal desiredUsage =null; // if(!HrConstants.EARN_CODE_TIME.equals(earnCodeObj.getRecordMethod())) { // desiredUsage = leaveAmount.multiply(new BigDecimal(daysSpan+1)); // } else { // desiredUsage = leaveAmount.multiply(new BigDecimal(daysSpan)); // } if (desiredUsage.compareTo(availableBalance) > 0) { errors.add("Requested leave amount " + desiredUsage.toString() + " is greater than available leave balance " + availableBalance.toString()); //errorMessages } } } return errors; }
From source file:com.lp.server.lieferschein.ejbfac.LieferscheinFacBean.java
/** * Den Umsatz der Lieferscheine in einem gewissen Zeitraum berechnen. <br> * Der Umsatz wird in Mandantenwaehrung angezeigt. * /*from ww w .ja va 2s . com*/ * @param gcVonI * ab diesem Datum inklusive * @param gcBisI * bis zu diesem Datum inklusive * @param theClientDto * der aktuelle Benutzer * @return BigDecimal der Umsatz * @throws EJBExceptionLP * Ausnahme */ public BigDecimal berechneUmsatz(GregorianCalendar gcVonI, GregorianCalendar gcBisI, TheClientDto theClientDto) throws EJBExceptionLP { final String METHOD_NAME = "berechneUmsatz"; myLogger.entry(); if (gcVonI == null) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_PARAMETER_IS_NULL, new Exception("gcVonI == null")); } if (gcBisI == null) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_PARAMETER_IS_NULL, new Exception("gcBisI == null")); } BigDecimal bdUmsatzO = Helper.getBigDecimalNull(); // Schritt 1: Alle relevanten Lieferscheine besorgen Query query = em.createNamedQuery("LieferscheinfindByMandantVonBisStatus1Status2Status3Status4"); query.setParameter(1, theClientDto.getMandant()); query.setParameter(2, new java.sql.Date(gcVonI.getTimeInMillis())); query.setParameter(3, new java.sql.Date(gcBisI.getTimeInMillis())); query.setParameter(4, LieferscheinFac.LSSTATUS_OFFEN); query.setParameter(5, LieferscheinFac.LSSTATUS_GELIEFERT); query.setParameter(6, LieferscheinFac.LSSTATUS_VERRECHNET); query.setParameter(7, LieferscheinFac.LSSTATUS_ERLEDIGT); Collection<?> cl = query.getResultList(); Iterator<?> it = cl.iterator(); while (it.hasNext()) { // Schritt 2: Jeden einzelnen relevanten Lieferschein // beruecksichtigen Lieferschein oLieferschein = (Lieferschein) it.next(); // fuer jeden Lieferschein ist sein Umsatz fuer jeden dieser Stati // in // Lieferscheinwaehrung in der DB abgelegt BigDecimal bdBeitragDiesesLieferscheins = oLieferschein.getNGesamtwertinlieferscheinwaehrung(); if (bdBeitragDiesesLieferscheins != null) { // den Beitrag normieren auf Mandantenwaehrung BigDecimal bdWechselkurs = Helper.getKehrwert(new BigDecimal( oLieferschein.getFWechselkursmandantwaehrungzulieferscheinwaehrung().doubleValue())); bdBeitragDiesesLieferscheins = bdBeitragDiesesLieferscheins.multiply(bdWechselkurs); bdBeitragDiesesLieferscheins = Helper.rundeKaufmaennisch(bdBeitragDiesesLieferscheins, 4); checkNumberFormat(bdBeitragDiesesLieferscheins); bdUmsatzO = bdUmsatzO.add(bdBeitragDiesesLieferscheins); } } return bdUmsatzO; }
From source file:com.salesmanager.core.service.order.OrderService.java
@Transactional private OrderTotalSummary calculateOrderTotal(Order order, Collection<OrderProduct> products, Customer customer, Shipping shipping, String currency, Locale locale) throws Exception { OrderTotalSummary summary = new OrderTotalSummary(order.getCurrency()); if (products != null) { Iterator i = products.iterator(); // calculates oneTimeSubTotal // BigDecimal oneTimeSubTotal = summary.getOneTimeSubTotal(); while (i.hasNext()) { OrderProduct product = (OrderProduct) i.next(); product.setApplicableCreditOneTimeCharge(new BigDecimal("0")); product.setSoldPrice(new BigDecimal("0")); if (product.isShipping()) { summary.setShipping(true); }//from ww w .j a v a 2 s . com // get unit price BigDecimal price = product.getProductPrice(); // get the prices for each Set productPrices = product.getPrices(); boolean defaultPriceMet = false; if (productPrices != null && productPrices.size() > 0) { Iterator it = productPrices.iterator(); while (it.hasNext()) { OrderProductPrice pp = (OrderProductPrice) it.next(); PriceModule priceModule = (PriceModule) SpringUtil.getBean(pp.getProductPriceModuleName()); if (priceModule == null) { log.warn("Price Module " + pp.getProductPriceModuleName() + " is not defined in sm-core-beans.xml"); continue; } // price module will set the price in order summary summary = priceModule.calculateOrderPrice(order, summary, product, pp, currency, locale); if (pp.isDefaultPrice()) { defaultPriceMet = true; // BigDecimal t = summary.getOneTimeSubTotal(); // t = t.add(product.getProductPrice()).multiply( // new BigDecimal(product.getProductQuantity())); // summary.setOneTimeSubTotal(t); } } } else {// consider the price submited as one time if (summary.getOneTimeSubTotal() == null) { BigDecimal oneTimeSubTotal = new BigDecimal(0); //oneTimeSubTotal.setScale(0, BigDecimal.ROUND_DOWN); summary.setOneTimeSubTotal(oneTimeSubTotal); } BigDecimal t = summary.getOneTimeSubTotal(); BigDecimal subTotal = price.multiply(new BigDecimal(product.getProductQuantity())); t = t.add(subTotal); summary.setOneTimeSubTotal(t); defaultPriceMet = true; // check for regular discount // Special sp = product.getBasePriceSpecial(); java.util.Date spdate = null; java.util.Date spenddate = null; BigDecimal bddiscountprice = null; if (product.getProductSpecialNewPrice() != null) { bddiscountprice = product.getProductSpecialNewPrice(); spdate = product.getProductSpecialDateAvailable(); spenddate = product.getProductSpecialDateExpire(); if (spdate != null && spdate.before(new Date()) && spdate != null && spenddate.after(new Date())) { OrderTotalLine line = new OrderTotalLine(); BigDecimal st = product.getOriginalProductPrice() .multiply(new BigDecimal(product.getProductQuantity())); BigDecimal creditSubTotal = bddiscountprice .multiply(new BigDecimal(product.getProductQuantity())); BigDecimal credit = subTotal.subtract(creditSubTotal); // BigDecimal credit = // product.getOriginalProductPrice().subtract(bddiscountprice); StringBuffer spacialNote = new StringBuffer(); spacialNote.append("<font color=\"red\">["); spacialNote.append(product.getProductName()); spacialNote.append(" "); spacialNote.append(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); spacialNote.append("]</font>"); line.setCost(credit); line.setText(spacialNote.toString()); line.setCostFormated(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); summary.addDueNowCredits(line); BigDecimal oneTimeCredit = product.getApplicableCreditOneTimeCharge(); oneTimeCredit = oneTimeCredit.add(credit); product.setApplicableCreditOneTimeCharge(oneTimeCredit); } } } if (!defaultPriceMet) { BigDecimal t = summary.getOneTimeSubTotal(); BigDecimal subTotal = price.multiply(new BigDecimal(product.getProductQuantity())); t = t.add(subTotal); /** t = t.add(price); **/ summary.setOneTimeSubTotal(t); // check for regular discount // Special sp = product.getBasePriceSpecial(); java.util.Date spdate = null; java.util.Date spenddate = null; BigDecimal bddiscountprice = null; if (product.getProductSpecialNewPrice() != null) { bddiscountprice = product.getProductSpecialNewPrice(); spdate = product.getProductSpecialDateAvailable(); spenddate = product.getProductSpecialDateExpire(); if (spdate != null && spdate.before(new Date()) && spdate != null && spenddate.after(new Date())) { OrderTotalLine line = new OrderTotalLine(); // BigDecimal credit = // product.getOriginalProductPrice().subtract(bddiscountprice); BigDecimal st = product.getOriginalProductPrice() .multiply(new BigDecimal(product.getProductQuantity())); // BigDecimal attributes = // product.getAttributeAdditionalCost(); // if(attributes!=null) { // attributes = attributes.multiply(new // BigDecimal(product.getProductQuantity())); // st = st.subtract(attributes); // } BigDecimal creditSubTotal = bddiscountprice .multiply(new BigDecimal(product.getProductQuantity())); // BigDecimal credit = // subTotal.subtract(creditSubTotal); BigDecimal credit = st.subtract(creditSubTotal); StringBuffer spacialNote = new StringBuffer(); spacialNote.append("<font color=\"red\">["); spacialNote.append(product.getProductName()); spacialNote.append(" "); spacialNote.append(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); spacialNote.append("]</font>"); line.setCost(credit); line.setText(spacialNote.toString()); line.setCostFormated(CurrencyUtil.displayFormatedAmountWithCurrency(credit, currency)); summary.addDueNowCredits(line); BigDecimal oneTimeCredit = product.getApplicableCreditOneTimeCharge(); oneTimeCredit = oneTimeCredit.add(credit); product.setApplicableCreditOneTimeCharge(oneTimeCredit); } } } } // reajust order total with credits Iterator prIterator = products.iterator(); BigDecimal credit = new BigDecimal("0"); while (prIterator.hasNext()) { OrderProduct op = (OrderProduct) prIterator.next(); credit = credit.add(op.getApplicableCreditOneTimeCharge()); } BigDecimal otSummary = summary.getOneTimeSubTotal(); otSummary = otSummary.subtract(credit); summary.setOneTimeSubTotal(otSummary); // @todo why shipping is not null for subscriptions ? if (shipping != null) { if (shipping.getShippingCost() != null) { BigDecimal totalShipping = shipping.getShippingCost(); if (shipping.getHandlingCost() != null) { totalShipping = totalShipping.add(shipping.getHandlingCost()); } // shippingInformation.setShippingCost(totalShipping); summary.setShippingTotal(totalShipping); } } if (customer != null) { // calculate tax on subtotal + shipping if applies TaxService tservice = (TaxService) ServiceFactory.getService(ServiceFactory.TaxService); summary = tservice.calculateTax(summary, products, customer, order.getMerchantId(), locale, currency); } // calculate total // subtotal + shipping + tax BigDecimal total = summary.getOneTimeSubTotal().add(summary.getShippingTotal()) .add(summary.getTaxTotal()); summary.setTotal(total); } return summary; }
From source file:org.egov.services.recoveries.RecoveryService.java
public BigDecimal getDeductionAmount(final String recoveryCode, final String partyType, final String subPartyType, final String docType, final BigDecimal grossAmount, final Date asOnDate) throws Exception { final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy", Constants.LOCALE); BigDecimal incomeTax = new BigDecimal(0); BigDecimal surcharge = new BigDecimal(0); BigDecimal education = new BigDecimal(0); BigDecimal total = new BigDecimal(0); BigDecimal deductionAmt = new BigDecimal(0); EgDeductionDetails egDeductionDetails = null; if (null == recoveryCode || recoveryCode.trim().equals("")) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Recovery Code is missing"); throw new ValidationException(EMPTY, "Recovery Code is missing"); }// www . j av a 2 s.com if (null == partyType || partyType.trim().equals("")) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Party Type is missing"); throw new ValidationException(EMPTY, "Party Type is missing"); } if (null == grossAmount) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Gross Amount is missing"); throw new ValidationException(EMPTY, "Gross Amount is missing"); } if (null == asOnDate) { if (LOGGER.isDebugEnabled()) LOGGER.debug("AsOnDate is missing"); throw new ValidationException(EMPTY, "AsOnDate is missing"); } if (LOGGER.isDebugEnabled()) LOGGER.debug("getDeductionAmount() -> recoveryCode :" + recoveryCode + " | partyType :" + partyType + " | grossAmount :" + grossAmount + " | asOnDate :" + dateFormatter.format(asOnDate) + " | docType :" + docType); EgwTypeOfWork egwTypeOfWork = null; EgPartytype egSubPartytype = null; final EgPartytype egPartytype = getPartytypeByCode(partyType); final Recovery recovery = getTdsByTypeAndPartyType(recoveryCode, egPartytype); if (recovery == null) throw new ValidationException(EMPTY, "Recovery with " + recoveryCode + " code and " + egPartytype + " party type is invalid."); if (recovery.getRecoveryMode() == 'M') return BigDecimal.valueOf(-1); if (null != docType) egwTypeOfWork = getTypeOfWorkByCode(docType); if (null != subPartyType) egSubPartytype = getSubPartytypeByCode(subPartyType); try { egDeductionDetails = egDeductionDetHibernateDao.findEgDeductionDetailsForDeduAmt(recovery, egPartytype, egSubPartytype, egwTypeOfWork, asOnDate); } catch (final Exception e) { LOGGER.error("Exception in egDeductionDetails fetching :" + e); throw new ValidationException(EMPTY, "Error while fetching the date for this " + recoveryCode + " code for this " + dateFormatter.format(asOnDate) + " date. " + e.getMessage()); } if (null == egDeductionDetails) throw new ValidationException(EMPTY, "There is no data for this " + recoveryCode + " code for this " + dateFormatter.format(asOnDate) + " date."); if (null != recovery.getCalculationType() && recovery.getCalculationType().equalsIgnoreCase("flat")) { if (null != egDeductionDetails.getFlatAmount()) deductionAmt = egDeductionDetails.getFlatAmount(); } else { if (null != egDeductionDetails.getIncometax()) incomeTax = egDeductionDetails.getIncometax(); if (null != egDeductionDetails.getSurcharge()) surcharge = egDeductionDetails.getSurcharge(); if (null != egDeductionDetails.getEducation()) education = egDeductionDetails.getEducation(); total = incomeTax.add(surcharge).add(education); if (LOGGER.isDebugEnabled()) LOGGER.debug("total IT/SC/EC " + total); deductionAmt = grossAmount.multiply(total.divide(new BigDecimal(100))); } if (LOGGER.isDebugEnabled()) LOGGER.debug("deductionAmt :" + deductionAmt); return deductionAmt = deductionAmt.setScale(2, BigDecimal.ROUND_HALF_UP); }
From source file:org.mifos.application.servicefacade.LoanAccountServiceFacadeWebTier.java
private void checkScheduleForMembers(LoanSchedule loanSchedule, LoanBO loan, List<GroupMemberLoanDetail> individualMembersOfGroupLoan, List<BigDecimal> radio) { for (int i = 0; i < loan.getNoOfInstallments(); ++i) { BigDecimal principal = loanSchedule.getRoundedLoanSchedules().get(i).getPrincipal().getAmount(); BigDecimal interest = loanSchedule.getRoundedLoanSchedules().get(i).getInterest().getAmount(); BigDecimal miscFee = loanSchedule.getRoundedLoanSchedules().get(i).getMiscFee().getAmount(); BigDecimal miscPenalty = loanSchedule.getRoundedLoanSchedules().get(i).getMiscPenalty().getAmount(); for (GroupMemberLoanDetail groupMemberLoanDetail : individualMembersOfGroupLoan) { LoanScheduleEntity loanScheduleEntity = groupMemberLoanDetail.getMemberSchedule() .getRoundedLoanSchedules().get(i); principal = principal.subtract(loanScheduleEntity.getPrincipal().getAmount()); interest = interest.subtract(loanScheduleEntity.getInterest().getAmount()); miscFee = miscFee.subtract(loanScheduleEntity.getMiscFee().getAmount()); miscPenalty = miscPenalty.subtract(loanScheduleEntity.getMiscPenalty().getAmount()); }//from w w w . j ava2s .co m if (principal.compareTo(BigDecimal.ZERO) != 0) { for (int j = 0; j < individualMembersOfGroupLoan.size(); ++j) { Money oldPrincipal = individualMembersOfGroupLoan.get(j).getMemberSchedule() .getRoundedLoanSchedules().get(i).getPrincipal(); Money newPrincipal = oldPrincipal .add(new Money(loan.getCurrency(), principal.multiply(radio.get(j)))); individualMembersOfGroupLoan.get(j).getMemberSchedule().getRoundedLoanSchedules().get(i) .setPrincipal(newPrincipal); } } if (interest.compareTo(BigDecimal.ZERO) != 0) { for (int j = 0; j < individualMembersOfGroupLoan.size(); ++j) { Money oldinterest = individualMembersOfGroupLoan.get(j).getMemberSchedule() .getRoundedLoanSchedules().get(i).getInterest(); Money newInterest = oldinterest .add(new Money(loan.getCurrency(), interest.multiply(radio.get(j)))); individualMembersOfGroupLoan.get(j).getMemberSchedule().getRoundedLoanSchedules().get(i) .setInterest(newInterest); } } if (miscFee.compareTo(BigDecimal.ZERO) != 0) { for (int j = 0; j < individualMembersOfGroupLoan.size(); ++j) { Money oldMiscFee = individualMembersOfGroupLoan.get(j).getMemberSchedule() .getRoundedLoanSchedules().get(i).getMiscFee(); Money newMiscFee = oldMiscFee .add(new Money(loan.getCurrency(), miscFee.multiply(radio.get(j)))); individualMembersOfGroupLoan.get(j).getMemberSchedule().getRoundedLoanSchedules().get(i) .setMiscFee(newMiscFee); } } if (miscPenalty.compareTo(BigDecimal.ZERO) != 0) { for (int j = 0; j < individualMembersOfGroupLoan.size(); ++j) { Money oldMiscPenalty = individualMembersOfGroupLoan.get(j).getMemberSchedule() .getRoundedLoanSchedules().get(i).getMiscPenalty(); Money newMiscPenalty = oldMiscPenalty .add(new Money(loan.getCurrency(), miscPenalty.multiply(radio.get(j)))); individualMembersOfGroupLoan.get(j).getMemberSchedule().getRoundedLoanSchedules().get(i) .setMiscPenalty(newMiscPenalty); } } } }
From source file:com.lp.server.auftrag.ejbfac.AuftragFacBean.java
/** * Berechnung des Materialwerts eines Auftrags in Mandantenwaehrung. <br> * Der Materialwert ist die Summe ueber die Materialwerte der enthaltenen * Artikelpositionen. <br>//w w w .java 2s .co m * Der Materialwert einer Artikelposition errechnet sich aus Menge x * Gestehungspreis des enthaltenen Artikels. <br> * Der Gestehungspreis eines Artikels ist in Mandantenwaehrung abgelegt. * * @param iIdAuftragI * pk des Auftrags * @param theClientDto * der aktuelle Benutzer * @throws EJBExceptionLP * Ausnahme * @return BigDecimal der Materialwert in der gewuenschten Waehrung */ public BigDecimal berechneMaterialwertGesamt(Integer iIdAuftragI, TheClientDto theClientDto) throws EJBExceptionLP { checkAuftragIId(iIdAuftragI); BigDecimal materialwert = new BigDecimal(0); try { AuftragpositionDto[] aAuftragpositionDto = getAuftragpositionFac() .auftragpositionFindByAuftrag(iIdAuftragI); AuftragDto aDto = auftragFindByPrimaryKey(iIdAuftragI); // das Hauptlager des Mandanten bestimmen LagerDto lagerDto = getLagerFac().lagerFindByPrimaryKey(aDto.getLagerIIdAbbuchungslager()); for (int i = 0; i < aAuftragpositionDto.length; i++) { AuftragpositionDto auftragpositionDto = aAuftragpositionDto[i]; // alle positiven mengenbehafteten Positionen beruecksichtigen if (auftragpositionDto.getNMenge() != null && auftragpositionDto.getNMenge().doubleValue() > 0 && !auftragpositionDto.isPosition()) { if (auftragpositionDto.isIntelligenteZwischensumme()) { continue; } BigDecimal menge = auftragpositionDto.getNMenge(); // Grundlage ist der Gestehungspreis des Artikels am // Hauptlager des Mandanten BigDecimal gestehungspreis = getLagerFac().getGemittelterGestehungspreisEinesLagers( auftragpositionDto.getArtikelIId(), lagerDto.getIId(), theClientDto); BigDecimal wertDerPosition = menge.multiply(gestehungspreis); materialwert = materialwert.add(wertDerPosition); } } // checknumberformat: 1 die Nachkommastellen kappen materialwert = Helper.rundeKaufmaennisch(materialwert, 4); // checknumberformat: 2 passt der Wert in die DB? checkNumberFormat(materialwert); } catch (RemoteException ex) { throwEJBExceptionLPRespectOld(ex); } catch (Throwable t) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_BEIM_ANLEGEN, new Exception(t)); } return materialwert; }
From source file:com.lp.server.auftrag.ejbfac.AuftragFacBean.java
/** * Hier wird der Auftragsnettowert fuer eine Hibernate Liste von * eingegangenen Auftraegen bestimmt (Status Offen, Teilerledigt, Erledigt). <br> * Dabei werden alle Auftragswerte in Mandantenwaehrung beruecksichtigt. * //from w w w .ja va 2s . co m * @param listFLRAuftragFuerUebersichtI * Liste von FLRAuftragFuerUebersicht Objekten * @param theClientDto * der aktuelle Benutzer * @return BigDecimal der offene Auftragsnettowert * @throws Throwable * Ausnahme */ private BigDecimal berechneAuftragsnettowertEingang(List<?> listFLRAuftragFuerUebersichtI, TheClientDto theClientDto) throws Throwable { BigDecimal nSummeAuftragsnettowert = new BigDecimal(0); if (listFLRAuftragFuerUebersichtI != null) { Iterator<?> it = listFLRAuftragFuerUebersichtI.iterator(); while (it.hasNext()) { FLRAuftragFuerUebersicht flrauftrag = (FLRAuftragFuerUebersicht) it.next(); // der Gesamtwert wurde bei der Aktivierung in Auftragswaehrung // hinterlegt BigDecimal nBeitragDiesesAuftrags = flrauftrag.getN_gesamtauftragswertinauftragswaehrung(); // Umrechnen des Beitrags in Mandantenwaehrung Double ddWechselkursReziprok = flrauftrag.getF_wechselkursmandantwaehrungzuauftragswaehrung(); if (ddWechselkursReziprok != null && ddWechselkursReziprok.doubleValue() != 1) { ddWechselkursReziprok = new Double(1 / ddWechselkursReziprok.doubleValue()); nBeitragDiesesAuftrags = nBeitragDiesesAuftrags .multiply(new BigDecimal(ddWechselkursReziprok.doubleValue())); } nBeitragDiesesAuftrags = Helper.rundeKaufmaennisch(nBeitragDiesesAuftrags, 4); checkNumberFormat(nBeitragDiesesAuftrags); nSummeAuftragsnettowert = nSummeAuftragsnettowert.add(nBeitragDiesesAuftrags); } } return nSummeAuftragsnettowert; }
From source file:com.lp.server.auftrag.ejbfac.AuftragFacBean.java
@Override public void berechneBeleg(Integer iIdAuftragI, TheClientDto theClientDto) throws EJBExceptionLP, RemoteException { Auftrag oAuftrag = em.find(Auftrag.class, iIdAuftragI); myLogger.entry();// w w w. j a va2s. c o m if (oAuftrag.getAuftragstatusCNr().equals(AuftragServiceFac.AUFTRAGSTATUS_ANGELEGT)) { BigDecimal bdAuftragswertInAuftragswaehrung = berechneNettowertGesamt(oAuftrag.getIId(), theClientDto); // Berechnung in // Auftragswaehrung if (oAuftrag.getNKorrekturbetrag() != null) { bdAuftragswertInAuftragswaehrung = bdAuftragswertInAuftragswaehrung .add(oAuftrag.getNKorrekturbetrag()); } BigDecimal bdWechselkurs = Helper.getKehrwert( new BigDecimal(oAuftrag.getFWechselkursmandantwaehrungzuauftragswaehrung().doubleValue())); BigDecimal bdAuftragswertInMandantenwaehrung = bdAuftragswertInAuftragswaehrung.multiply(bdWechselkurs); bdAuftragswertInMandantenwaehrung = Helper.rundeKaufmaennisch(bdAuftragswertInMandantenwaehrung, 4); checkNumberFormat(bdAuftragswertInMandantenwaehrung); BigDecimal bdMaterialwertInMandantenwaehrung = berechneMaterialwertGesamt(oAuftrag.getIId(), theClientDto); // in // Mandantenwaehrung oAuftrag.setNGesamtauftragswertinauftragswaehrung(bdAuftragswertInAuftragswaehrung); oAuftrag.setNMaterialwertinmandantenwaehrung(bdMaterialwertInMandantenwaehrung); BigDecimal bdRohdeckungInMandantenwaehrung = bdAuftragswertInMandantenwaehrung .subtract(bdMaterialwertInMandantenwaehrung); bdRohdeckungInMandantenwaehrung = Helper.rundeKaufmaennisch(bdRohdeckungInMandantenwaehrung, 4); checkNumberFormat(bdRohdeckungInMandantenwaehrung); if (oAuftrag.getNRohdeckungaltinmandantenwaehrung() == null) { oAuftrag.setNRohdeckunginmandantenwaehrung(bdRohdeckungInMandantenwaehrung); oAuftrag.setNRohdeckungaltinmandantenwaehrung(bdRohdeckungInMandantenwaehrung); } em.merge(oAuftrag); em.flush(); } }
From source file:org.egov.dao.budget.BudgetDetailsHibernateDAO.java
/** * returns sum(approved BE/RE amount + appropriated (addition-deduction) * amount)* mutliplicationFactor if budget and reappropriation both doesnot * exist it will return zero//w ww .j a va 2 s .c om * * @param fundId * @param deptId * @param asOnDate * @return */ @Override public BigDecimal getPlannigBudgetBy(final Integer fundId, final Integer deptId, Date asOnDate1) { // 0.Validated Date asOnDate = new Date(); if (fundId == null || fundId == -1) throw new IllegalArgumentException("fundId"); if (deptId == null || deptId == -1) throw new IllegalArgumentException("deptId"); if (asOnDate1 != null) asOnDate = asOnDate1; BigDecimal amount; // 1. get the FinancialYear for the date final CFinancialYear finYear = financialYearHibDAO.getFinYearByDate(asOnDate); // 2. check does approved RE Existis and set budgeting type final boolean hasApprovedReForYear = budgetService.hasApprovedReAsonDate(finYear.getId(), asOnDate); String isbere = hasApprovedReForYear ? "RE" : "BE"; // 3. get Budget approvedAmount amount = (BigDecimal) persistenceService.find( "select sum(approvedAmount) from BudgetDetail bd where bd.executingDepartment.id=? and bd.fund.id=?" + " and bd.budget.financialYear=? and bd.budget.isbere=? ", deptId, fundId, finYear, isbere); if (LOGGER.isDebugEnabled()) LOGGER.debug("Approved " + isbere + " Amount" + amount); amount = amount == null ? BigDecimal.ZERO : amount; // 4. Reappropriated amounts BigDecimal reappAmount = (BigDecimal) persistenceService.find( "select sum(additionAmount-deductionAmount) from BudgetReAppropriation br where br.budgetDetail.executingDepartment.id=? and br.budgetDetail.fund.id=?" + " and br.budgetDetail.budget.financialYear=? and br.budgetDetail.budget.isbere=? and br.status.description='Approved' and to_date(br.modifiedDate)<=? ", deptId, fundId, finYear, isbere, asOnDate); if (LOGGER.isDebugEnabled()) LOGGER.debug("Approved Reappropriation Amount" + reappAmount); reappAmount = reappAmount == null ? BigDecimal.ZERO : reappAmount; // 5. Multiply with mutiplication factor final BigDecimal multiplicationFactor = BigDecimal .valueOf(Double.parseDouble(getAppConfigFor("EGF", "planning_budget_multiplication_factor"))); amount = amount.add(reappAmount); amount = amount.multiply(multiplicationFactor); return amount; }
From source file:org.egov.ptis.service.es.PropertyTaxElasticSearchIndexService.java
/** * Prepare list of TaxPayerDetails for each bill collector by summing up the values in each ward for the respective bil * collector/* www. java 2 s.c o m*/ * * @param collectionDetailsRequest * @param billCollectorWiseMap * @param billCollectorWiseTaxPayerDetails */ private void prepareTaxersInfoForBillCollectors(final CollectionDetailsRequest collectionDetailsRequest, final Map<String, List<TaxPayerDetails>> billCollectorWiseMap, final List<TaxPayerDetails> billCollectorWiseTaxPayerDetails) { BigDecimal cytdColl; BigDecimal lytdColl; BigDecimal cytdDmd; BigDecimal totalDmd; TaxPayerDetails taxPayerDetails; String[] userNameNumberArr; for (final Entry<String, List<TaxPayerDetails>> entry : billCollectorWiseMap.entrySet()) { taxPayerDetails = new TaxPayerDetails(); cytdColl = BigDecimal.ZERO; lytdColl = BigDecimal.ZERO; cytdDmd = BigDecimal.ZERO; totalDmd = BigDecimal.ZERO; userNameNumberArr = entry.getKey().split("~"); for (final TaxPayerDetails taxPayer : entry.getValue()) { totalDmd = totalDmd.add(taxPayer.getTotalDmd() == null ? BigDecimal.ZERO : taxPayer.getTotalDmd()); cytdColl = cytdColl.add(taxPayer.getCytdColl() == null ? BigDecimal.ZERO : taxPayer.getCytdColl()); cytdDmd = cytdDmd.add(taxPayer.getCytdDmd() == null ? BigDecimal.ZERO : taxPayer.getCytdDmd()); lytdColl = lytdColl.add(taxPayer.getLytdColl() == null ? BigDecimal.ZERO : taxPayer.getLytdColl()); } if (DASHBOARD_GROUPING_BILLCOLLECTORWISE.equalsIgnoreCase(collectionDetailsRequest.getType())) { taxPayerDetails .setBillCollector(userNameNumberArr.length > 0 ? userNameNumberArr[0] : StringUtils.EMPTY); taxPayerDetails .setBillCollMobNo(userNameNumberArr.length > 1 ? userNameNumberArr[1] : StringUtils.EMPTY); taxPayerDetails.setBillCollectorCode( userNameNumberArr.length > 2 ? userNameNumberArr[2] : StringUtils.EMPTY); } else if (DASHBOARD_GROUPING_REVENUEINSPECTORWISE .equalsIgnoreCase(collectionDetailsRequest.getType())) { taxPayerDetails.setRevenueInspector( userNameNumberArr.length > 0 ? userNameNumberArr[0] : StringUtils.EMPTY); taxPayerDetails.setRevInspectorMobNo( userNameNumberArr.length > 1 ? userNameNumberArr[1] : StringUtils.EMPTY); taxPayerDetails.setRevenueInspectorCode( userNameNumberArr.length > 2 ? userNameNumberArr[2] : StringUtils.EMPTY); } else if (DASHBOARD_GROUPING_REVENUEOFFICERWISE.equalsIgnoreCase(collectionDetailsRequest.getType())) { taxPayerDetails .setRevenueOfficer(userNameNumberArr.length > 0 ? userNameNumberArr[0] : StringUtils.EMPTY); taxPayerDetails.setRevOfficerMobNo( userNameNumberArr.length > 1 ? userNameNumberArr[1] : StringUtils.EMPTY); taxPayerDetails.setRevenueOfficerCode( userNameNumberArr.length > 2 ? userNameNumberArr[2] : StringUtils.EMPTY); } taxPayerDetails.setRegionName(collectionDetailsRequest.getRegionName()); taxPayerDetails.setDistrictName(collectionDetailsRequest.getDistrictName()); taxPayerDetails.setUlbGrade(collectionDetailsRequest.getUlbGrade()); taxPayerDetails.setCytdColl(cytdColl); taxPayerDetails.setCytdDmd(cytdDmd); taxPayerDetails.setCytdBalDmd(cytdDmd.subtract(cytdColl)); taxPayerDetails.setTotalDmd(totalDmd); taxPayerDetails.setLytdColl(lytdColl); if (cytdDmd.compareTo(BigDecimal.ZERO) > 0) taxPayerDetails.setAchievement( cytdColl.multiply(BIGDECIMAL_100).divide(cytdDmd, 1, BigDecimal.ROUND_HALF_UP)); if (lytdColl.compareTo(BigDecimal.ZERO) == 0) taxPayerDetails.setLyVar(BIGDECIMAL_100); else taxPayerDetails.setLyVar(cytdColl.subtract(lytdColl).multiply(BIGDECIMAL_100).divide(lytdColl, 1, BigDecimal.ROUND_HALF_UP)); billCollectorWiseTaxPayerDetails.add(taxPayerDetails); } }