Example usage for java.math BigDecimal multiply

List of usage examples for java.math BigDecimal multiply

Introduction

In this page you can find the example usage for java.math BigDecimal multiply.

Prototype

public BigDecimal multiply(BigDecimal multiplicand) 

Source Link

Document

Returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()) .

Usage

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private void addNodes(ManageablePortfolioNode rootNode, String underlying, boolean includeUnderlying,
        Period[] expiries) {//from   w  w w  . j  a  va 2 s .  c  o  m
    ExternalId ticker = ExternalSchemes.bloombergTickerSecurityId(underlying);
    ManageableSecurity underlyingSecurity = null;
    if (includeUnderlying) {
        underlyingSecurity = getOrLoadEquity(ticker);
    }

    ExternalIdBundle bundle = underlyingSecurity == null ? ExternalIdBundle.of(ticker)
            : underlyingSecurity.getExternalIdBundle();
    HistoricalTimeSeriesInfoDocument timeSeriesInfo = getOrLoadTimeSeries(ticker, bundle);
    double estimatedCurrentStrike = getOrLoadMostRecentPoint(timeSeriesInfo);
    Set<ExternalId> optionChain = getOptionChain(ticker);

    //TODO: reuse positions/nodes?
    String longName = underlyingSecurity == null ? "" : underlyingSecurity.getName();
    String formattedName = MessageFormatter.format("[{}] {}", underlying, longName);
    ManageablePortfolioNode equityNode = new ManageablePortfolioNode(formattedName);

    BigDecimal underlyingAmount = VALUE_OF_UNDERLYING.divide(BigDecimal.valueOf(estimatedCurrentStrike),
            BigDecimal.ROUND_HALF_EVEN);

    if (includeUnderlying) {
        addPosition(equityNode, underlyingAmount, ticker);
    }

    TreeMap<LocalDate, Set<BloombergTickerParserEQOption>> optionsByExpiry = new TreeMap<LocalDate, Set<BloombergTickerParserEQOption>>();
    for (ExternalId optionTicker : optionChain) {
        s_logger.debug("Got option {}", optionTicker);

        BloombergTickerParserEQOption optionInfo = BloombergTickerParserEQOption.getOptionParser(optionTicker);
        s_logger.debug("Got option info {}", optionInfo);

        LocalDate key = optionInfo.getExpiry();
        Set<BloombergTickerParserEQOption> set = optionsByExpiry.get(key);
        if (set == null) {
            set = new HashSet<BloombergTickerParserEQOption>();
            optionsByExpiry.put(key, set);
        }
        set.add(optionInfo);
    }
    Set<ExternalId> tickersToLoad = new HashSet<ExternalId>();

    BigDecimal expiryCount = BigDecimal.valueOf(expiries.length);
    BigDecimal defaultAmountAtExpiry = underlyingAmount.divide(expiryCount, BigDecimal.ROUND_DOWN);
    BigDecimal spareAmountAtExpiry = defaultAmountAtExpiry.add(BigDecimal.ONE);
    int spareCount = underlyingAmount.subtract(defaultAmountAtExpiry.multiply(expiryCount)).intValue();

    for (int i = 0; i < expiries.length; i++) {
        Period bucketPeriod = expiries[i];

        ManageablePortfolioNode bucketNode = new ManageablePortfolioNode(bucketPeriod.toString().substring(1));

        LocalDate nowish = LocalDate.now().withDayOfMonth(20); //This avoids us picking different options every time this script is run
        LocalDate targetExpiry = nowish.plus(bucketPeriod);
        LocalDate chosenExpiry = optionsByExpiry.floorKey(targetExpiry);
        if (chosenExpiry == null) {
            s_logger.warn("No options for {} on {}", targetExpiry, underlying);
            continue;
        }
        s_logger.info("Using time {} for bucket {} ({})",
                new Object[] { chosenExpiry, bucketPeriod, targetExpiry });

        Set<BloombergTickerParserEQOption> optionsAtExpiry = optionsByExpiry.get(chosenExpiry);
        TreeMap<Double, Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> optionsByStrike = new TreeMap<Double, Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
        for (BloombergTickerParserEQOption option : optionsAtExpiry) {
            //        s_logger.info("option {}", option);
            double key = option.getStrike();
            Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike.get(key);
            if (pair == null) {
                pair = Pair.of(null, null);
            }
            if (option.getOptionType() == OptionType.CALL) {
                pair = Pair.of(option, pair.getSecond());
            } else {
                pair = Pair.of(pair.getFirst(), option);
            }
            optionsByStrike.put(key, pair);
        }

        //cascading collar?
        BigDecimal amountAtExpiry = spareCount-- > 0 ? spareAmountAtExpiry : defaultAmountAtExpiry;

        s_logger.info(" est strike {}", estimatedCurrentStrike);
        Double[] strikes = optionsByStrike.keySet().toArray(new Double[0]);

        int strikeIndex = Arrays.binarySearch(strikes, estimatedCurrentStrike);
        if (strikeIndex < 0) {
            strikeIndex = -(1 + strikeIndex);
        }
        s_logger.info("strikes length {} index {} strike of index {}",
                new Object[] { Integer.valueOf(strikes.length), Integer.valueOf(strikeIndex),
                        Double.valueOf(strikes[strikeIndex]) });

        int minIndex = strikeIndex - _numOptions;
        minIndex = Math.max(0, minIndex);
        int maxIndex = strikeIndex + _numOptions;
        maxIndex = Math.min(strikes.length - 1, maxIndex);

        s_logger.info("min {} max {}", Integer.valueOf(minIndex), Integer.valueOf(maxIndex));
        StringBuffer sb = new StringBuffer("strikes: [");
        for (int j = minIndex; j <= maxIndex; j++) {
            sb.append(" ");
            sb.append(strikes[j]);
        }
        sb.append(" ]");
        s_logger.info(sb.toString());

        //Short Calls
        ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> calls = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
        for (int j = minIndex; j < strikeIndex; j++) {
            Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike
                    .get(strikes[j]);
            if (pair == null) {
                throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
            }
            calls.add(pair);
        }
        spreadOptions(bucketNode, calls, OptionType.CALL, -1, tickersToLoad, amountAtExpiry, includeUnderlying,
                calls.size());

        // Long Puts
        ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> puts = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
        for (int j = strikeIndex + 1; j <= maxIndex; j++) {
            Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike
                    .get(strikes[j]);
            if (pair == null) {
                throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
            }
            puts.add(pair);
        }
        spreadOptions(bucketNode, puts, OptionType.PUT, 1, tickersToLoad, amountAtExpiry, includeUnderlying,
                puts.size());

        if (bucketNode.getChildNodes().size() + bucketNode.getPositionIds().size() > 0) {
            equityNode.addChildNode(bucketNode); //Avoid generating empty nodes   
        }
    }

    for (ExternalId optionTicker : tickersToLoad) {
        ManageableSecurity loaded = getOrLoadSecurity(optionTicker);
        if (loaded == null) {
            throw new OpenGammaRuntimeException("Unexpected option type " + loaded);
        }

        //TODO [LAPANA-29] Should be able to do this for index options too
        if (includeUnderlying) {
            try {
                HistoricalTimeSeriesInfoDocument loadedTs = getOrLoadTimeSeries(optionTicker,
                        loaded.getExternalIdBundle());
                if (loadedTs == null) {
                    throw new OpenGammaRuntimeException("Failed to get time series for " + loaded);
                }
            } catch (Exception ex) {
                s_logger.error("Failed to get time series for " + loaded, ex);
            }
        }
    }

    if (equityNode.getPositionIds().size() + equityNode.getChildNodes().size() > 0) {
        rootNode.addChildNode(equityNode);
    }
}

From source file:fsm.series.Series_CF.java

public double getF1Value(double y, int m, int n) {

    double um = getMu_m(m);
    double un = getMu_m(n);
    double alphaM = (sin(um) + sinh(um)) / (cos(um) + cosh(um));

    double alphaN = (sin(un) + sinh(un)) / (cos(un) + cosh(un));
    double km = um / a;
    double kn = un / a;

    BigDecimal Ym;
    BigDecimal Yn;//from  w  w  w . j ava 2s  . com

    BigDecimal cosh = new BigDecimal(-alphaM * -cosh(km * y));
    BigDecimal sinh = new BigDecimal(-sinh(km * y));
    BigDecimal sin = new BigDecimal(sin(km * y));
    BigDecimal cos = new BigDecimal(-alphaM * cos(km * y));

    Ym = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y));
    BigDecimal sinhN = new BigDecimal(-sinh(kn * y));
    BigDecimal sinN = new BigDecimal(sin(kn * y));
    BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y));

    Yn = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ym.multiply(Yn);

    return ans.doubleValue();
}

From source file:org.libreplan.web.orders.ManageOrderElementAdvancesModel.java

@Override
public BigDecimal getPercentageAdvanceMeasurement(AdvanceMeasurement advanceMeasurement) {
    AdvanceAssignment assignment = advanceMeasurement.getAdvanceAssignment();
    if (assignment == null) {
        return BigDecimal.ZERO;
    }// w  w  w .j  a v  a  2  s . c om

    BigDecimal maxValue;
    if (assignment instanceof IndirectAdvanceAssignment) {

        maxValue = orderElement.calculateFakeDirectAdvanceAssignment((IndirectAdvanceAssignment) assignment)
                .getMaxValue();
    } else {
        maxValue = ((DirectAdvanceAssignment) assignment).getMaxValue();
    }

    if (maxValue.compareTo(BigDecimal.ZERO) <= 0) {
        return BigDecimal.ZERO;
    }

    BigDecimal value = advanceMeasurement.getValue();
    if (value == null) {
        return BigDecimal.ZERO;
    }

    BigDecimal division = value.divide(maxValue.setScale(2), 4, RoundingMode.DOWN);
    return (division.multiply(new BigDecimal(100))).setScale(2, RoundingMode.DOWN);

}

From source file:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java

@Override
@Transactional(rollbackFor = { NoEstaAbiertaException.class, ProductoNoSoportaFraccionException.class })
public LoteEntrada creaLote(LoteEntrada lote)
        throws ProductoNoSoportaFraccionException, NoEstaAbiertaException {
    log.debug("Creando lote {}", lote);
    lote.setProducto((Producto) currentSession().get(Producto.class, lote.getProducto().getId()));
    lote.setEntrada((Entrada) currentSession().get(Entrada.class, lote.getEntrada().getId()));
    if (lote.getEntrada().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();
            }/*from www .  ja  va2 s .  c  o m*/
        }

        BigDecimal subtotal = lote.getPrecioUnitario().multiply(lote.getCantidad());
        BigDecimal iva = subtotal.multiply(lote.getProducto().getIva()).setScale(2, RoundingMode.HALF_UP);
        lote.setIva(iva);
        lote.setFechaCreacion(new Date());

        currentSession().save(lote);

        return lote;
    } else {
        throw new NoEstaAbiertaException("No se puede crear un lote en una entrada que no este abierta");
    }
}

From source file:com.opengamma.examples.bloomberg.loader.DemoEquityOptionCollarPortfolioLoader.java

private void addNodes(final ManageablePortfolioNode rootNode, final String underlying,
        final boolean includeUnderlying, final Period[] expiries) {
    final ExternalId ticker = ExternalSchemes.bloombergTickerSecurityId(underlying);
    ManageableSecurity underlyingSecurity = null;
    if (includeUnderlying) {
        underlyingSecurity = getOrLoadEquity(ticker);
    }//from  www.j a v a2s  .co m

    final ExternalIdBundle bundle = underlyingSecurity == null ? ExternalIdBundle.of(ticker)
            : underlyingSecurity.getExternalIdBundle();
    final HistoricalTimeSeriesInfoDocument timeSeriesInfo = getOrLoadTimeSeries(ticker, bundle);
    final double estimatedCurrentStrike = getOrLoadMostRecentPoint(timeSeriesInfo);
    final Set<ExternalId> optionChain = getOptionChain(ticker);

    //TODO: reuse positions/nodes?
    final String longName = underlyingSecurity == null ? "" : underlyingSecurity.getName();
    final String formattedName = MessageFormatter.format("[{}] {}", underlying, longName).getMessage();
    final ManageablePortfolioNode equityNode = new ManageablePortfolioNode(formattedName);

    final BigDecimal underlyingAmount = VALUE_OF_UNDERLYING.divide(BigDecimal.valueOf(estimatedCurrentStrike),
            BigDecimal.ROUND_HALF_EVEN);

    if (includeUnderlying) {
        addPosition(equityNode, underlyingAmount, ticker);
    }

    final TreeMap<LocalDate, Set<BloombergTickerParserEQOption>> optionsByExpiry = new TreeMap<LocalDate, Set<BloombergTickerParserEQOption>>();
    for (final ExternalId optionTicker : optionChain) {
        s_logger.debug("Got option {}", optionTicker);

        final BloombergTickerParserEQOption optionInfo = BloombergTickerParserEQOption
                .getOptionParser(optionTicker);
        s_logger.debug("Got option info {}", optionInfo);

        final LocalDate key = optionInfo.getExpiry();
        Set<BloombergTickerParserEQOption> set = optionsByExpiry.get(key);
        if (set == null) {
            set = new HashSet<BloombergTickerParserEQOption>();
            optionsByExpiry.put(key, set);
        }
        set.add(optionInfo);
    }
    final Set<ExternalId> tickersToLoad = new HashSet<ExternalId>();

    final BigDecimal expiryCount = BigDecimal.valueOf(expiries.length);
    final BigDecimal defaultAmountAtExpiry = underlyingAmount.divide(expiryCount, BigDecimal.ROUND_DOWN);
    final BigDecimal spareAmountAtExpiry = defaultAmountAtExpiry.add(BigDecimal.ONE);
    int spareCount = underlyingAmount.subtract(defaultAmountAtExpiry.multiply(expiryCount)).intValue();

    for (final Period bucketPeriod : expiries) {
        final ManageablePortfolioNode bucketNode = new ManageablePortfolioNode(
                bucketPeriod.toString().substring(1));

        final LocalDate nowish = LocalDate.now().withDayOfMonth(20); //This avoids us picking different options every time this script is run
        final LocalDate targetExpiry = nowish.plus(bucketPeriod);
        final LocalDate chosenExpiry = optionsByExpiry.floorKey(targetExpiry);
        if (chosenExpiry == null) {
            s_logger.info("No options for {} on {}", targetExpiry, underlying);
            continue;
        }
        s_logger.info("Using time {} for bucket {} ({})",
                new Object[] { chosenExpiry, bucketPeriod, targetExpiry });

        final Set<BloombergTickerParserEQOption> optionsAtExpiry = optionsByExpiry.get(chosenExpiry);
        final TreeMap<Double, Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> optionsByStrike = new TreeMap<>();
        for (final BloombergTickerParserEQOption option : optionsAtExpiry) {
            //        s_logger.info("option {}", option);
            final double key = option.getStrike();
            Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike.get(key);
            if (pair == null) {
                pair = Pair.of(null, null);
            }
            if (option.getOptionType() == OptionType.CALL) {
                pair = Pair.of(option, pair.getSecond());
            } else {
                pair = Pair.of(pair.getFirst(), option);
            }
            optionsByStrike.put(key, pair);
        }

        //cascading collar?
        final BigDecimal amountAtExpiry = spareCount-- > 0 ? spareAmountAtExpiry : defaultAmountAtExpiry;

        s_logger.info(" est strike {}", estimatedCurrentStrike);
        final Double[] strikes = optionsByStrike.keySet().toArray(new Double[0]);

        int strikeIndex = Arrays.binarySearch(strikes, estimatedCurrentStrike);
        if (strikeIndex < 0) {
            strikeIndex = -(1 + strikeIndex);
        }
        s_logger.info("strikes length {} index {} strike of index {}",
                new Object[] { Integer.valueOf(strikes.length), Integer.valueOf(strikeIndex),
                        Double.valueOf(strikes[strikeIndex]) });

        int minIndex = strikeIndex - _numOptions;
        minIndex = Math.max(0, minIndex);
        int maxIndex = strikeIndex + _numOptions;
        maxIndex = Math.min(strikes.length - 1, maxIndex);

        s_logger.info("min {} max {}", Integer.valueOf(minIndex), Integer.valueOf(maxIndex));
        final StringBuffer sb = new StringBuffer("strikes: [");
        for (int j = minIndex; j <= maxIndex; j++) {
            sb.append(" ");
            sb.append(strikes[j]);
        }
        sb.append(" ]");
        s_logger.info(sb.toString());

        //Short Calls
        final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> calls = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
        for (int j = minIndex; j < strikeIndex; j++) {
            final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike
                    .get(strikes[j]);
            if (pair == null) {
                throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
            }
            calls.add(pair);
        }
        spreadOptions(bucketNode, calls, OptionType.CALL, -1, tickersToLoad, amountAtExpiry, includeUnderlying,
                calls.size());

        // Long Puts
        final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> puts = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>();
        for (int j = strikeIndex + 1; j <= maxIndex; j++) {
            final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike
                    .get(strikes[j]);
            if (pair == null) {
                throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]);
            }
            puts.add(pair);
        }
        spreadOptions(bucketNode, puts, OptionType.PUT, 1, tickersToLoad, amountAtExpiry, includeUnderlying,
                puts.size());

        if (bucketNode.getChildNodes().size() + bucketNode.getPositionIds().size() > 0) {
            equityNode.addChildNode(bucketNode); //Avoid generating empty nodes
        }
    }

    for (final ExternalId optionTicker : tickersToLoad) {
        final ManageableSecurity loaded = getOrLoadSecurity(optionTicker);
        if (loaded == null) {
            throw new OpenGammaRuntimeException("Unexpected option type " + loaded);
        }

        //TODO [LAPANA-29] Should be able to do this for index options too
        if (includeUnderlying) {
            try {
                final HistoricalTimeSeriesInfoDocument loadedTs = getOrLoadTimeSeries(optionTicker,
                        loaded.getExternalIdBundle());
                if (loadedTs == null) {
                    throw new OpenGammaRuntimeException("Failed to get time series for " + loaded);
                }
            } catch (final Exception ex) {
                s_logger.info("Failed to get time series for " + loaded, ex);
            }
        }
    }

    if (equityNode.getPositionIds().size() + equityNode.getChildNodes().size() > 0) {
        rootNode.addChildNode(equityNode);
    }
}

From source file:com.esd.cs.audit.AuditsController.java

/**
 * ??/*from   w ww  .  ja  va2s  .  co m*/
 * 
 * @param companyCode
 * @return
 */
private BigDecimal getSectionPaid(String year, Integer companyId, List<AccountModel> sb) {
    BigDecimal amount = new BigDecimal(0.00);
    // List<Accounts> audits =
    // accountsService.getUnauditByCompany(companyId, year,
    // Constants.PROCESS_STATIC_BFJK);
    List<Accounts> accounts = accountsService.getByYearAndCompany(year, companyId,
            Constants.PROCESS_STATIC_BFJK);
    Map<String, Accounts> map = new HashMap<>();
    for (Accounts group : accounts) {
        Object obj = map.get(group.getYear());
        if (obj == null) {
            map.put(group.getYear(), group);
        } else {
            Accounts a = (Accounts) obj;
            a.setTotalMoney(a.getTotalMoney().add(group.getTotalMoney()));
        }
    }
    for (Accounts a : map.values()) {
        BigDecimal paymentTotal = paymentService.getEffPaid(null, a.getYear(), companyId);// 
        BigDecimal qj = a.getTotalMoney().subtract(paymentTotal);
        AuditParameter auditParameter = auditParameterService.getByYear(a.getYear());
        Date auditDelayDate = auditParameter.getAuditDelayDate();
        int days = CalendarUtil.getDaySub(auditDelayDate, new Date());
        BigDecimal penalty = qj.multiply(auditParameter.getAuditDelayRate()).multiply(new BigDecimal(days));
        BigDecimal total = qj.add(penalty);
        AccountModel am = new AccountModel();
        am.setYear(a.getYear());
        am.setDays(String.valueOf(days));
        am.setMoney(df.format(qj));
        am.setPenalty(df.format(penalty));
        am.setProp(df4.format(auditParameter.getAuditDelayRate()));
        am.setTotal(df.format(total));
        sb.add(am);
        amount = amount.add(total);
    }
    if (amount.compareTo(new BigDecimal(0.00)) != 0) {
        AccountModel am = new AccountModel();
        am.setTotal(df.format(amount));
        sb.add(am);
    }
    return amount;
}

From source file:org.apache.fineract.portfolio.servicecharge.service.ServiceChargeJournalDetailsReadPlatformServiceImpl.java

public void computeFinalCalculations(ServiceChargeFinalSheetData sheetData) {
    BigDecimal mobilizationCostPercent, avgDLRePm, lsCostPa, lsCostPerLoan, totalNoDlLoans, reForPeriod,
            reCostPer100;//from   w  w  w.  ja  va 2  s  .  c om
    try {
        List<BigDecimal> columnEntry;
        BigDecimal lsCostOnACBf = sheetData.getColumnValue(ServiceChargeReportTableHeaders.LSCOST_ON_ACCOUNT_BF,
                0);

        columnEntry = new ArrayList<>(1);
        mobilizationCostPercent = sheetData
                .getColumnValue(ServiceChargeReportTableHeaders.ALLOCATION_MOBILIZATION, 1);
        mobilizationCostPercent = mobilizationCostPercent.multiply(new BigDecimal("4"));
        columnEntry.add(mobilizationCostPercent);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.TOTAL_MOBILIZATION, columnEntry);

        columnEntry = new ArrayList<>(1);
        avgDLRePm = scLoanDetailsReadPlatformService.getAllLoansRepaymentData();
        columnEntry.add(avgDLRePm);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.AVG_REPAYMENT, columnEntry);

        columnEntry = new ArrayList<>(1);
        mobilizationCostPercent = ServiceChargeOperationUtils
                .divideNonZeroValues(mobilizationCostPercent, avgDLRePm).multiply(HUNDRED);
        columnEntry.add(mobilizationCostPercent);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.MOBILIZATION_PERCENT, columnEntry);

        columnEntry = new ArrayList<>(1);
        lsCostPa = sheetData.getColumnValue(ServiceChargeReportTableHeaders.ALLOCATION_SUBTOTAL, 1);
        lsCostPa = lsCostPa.multiply(new BigDecimal("4"));
        columnEntry.add(lsCostPa);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.LOAN_SERVICING_PA, columnEntry);

        columnEntry = new ArrayList<>(1);
        totalNoDlLoans = scLoanDetailsReadPlatformService.getTotalLoansForCurrentQuarter();
        columnEntry.add(totalNoDlLoans);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.TOTAL_LOANS, columnEntry);

        columnEntry = new ArrayList<>(1);
        lsCostPerLoan = ServiceChargeOperationUtils.divideNonZeroValues(lsCostPa, totalNoDlLoans);
        columnEntry.add(lsCostPerLoan);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.LOAN_SERVICING_PER_LOAN, columnEntry);

        columnEntry = new ArrayList<>(1);
        reForPeriod = scLoanDetailsReadPlatformService.getAllLoansRepaymentData();
        columnEntry.add(reForPeriod);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.TOTAL_REPAYMENT, columnEntry);

        columnEntry = new ArrayList<>(1);
        reCostPer100 = ServiceChargeOperationUtils.divideNonZeroValues(lsCostOnACBf, reForPeriod);
        columnEntry.add(reCostPer100);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.REPAYMENT_PER_100, columnEntry);

        columnEntry = new ArrayList<>(1);
        columnEntry.add(mobilizationCostPercent);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.ANNUALIZED_COST_I, columnEntry);

        columnEntry = new ArrayList<>(1);
        BigDecimal eac2 = ServiceChargeOperationUtils.divideNonZeroValues(lsCostPa, avgDLRePm)
                .multiply(HUNDRED);
        columnEntry.add(eac2);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.ANNUALIZED_COST_II, columnEntry);

        columnEntry = new ArrayList<>(1);
        BigDecimal eac3 = ServiceChargeOperationUtils.divideNonZeroValues(lsCostOnACBf, avgDLRePm)
                .multiply(HUNDRED);
        columnEntry.add(eac3);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.ANNUALIZED_COST_III, columnEntry);

        columnEntry = new ArrayList<>(1);
        BigDecimal total = mobilizationCostPercent.add(eac2).add(eac3);
        columnEntry.add(total);
        sheetData.setColumnValue(ServiceChargeReportTableHeaders.ANNUALIZED_COST_TOTAL, columnEntry);

    } catch (Exception ex) {
        // Any exception means that input data is wrong so ignoring it
        logger.error(ex.getMessage(), ex);
    }
}

From source file:fsm.series.Series_CF.java

public double getF2Value(double y, int m, int n) {
    double Pi = Math.PI;

    double um = getMu_m(m);
    double un = getMu_m(n);
    double alphaM = (sin(um) + sinh(um)) / (cos(um) + cosh(um));

    double alphaN = (sin(un) + sinh(un)) / (cos(un) + cosh(un));
    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd2;
    BigDecimal Yn;//from  w  w  w.  j a v a2s  . c o  m

    BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(-km * km * sin(km * y));
    BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y));

    Ymd2 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y));
    BigDecimal sinhN = new BigDecimal(-sinh(kn * y));
    BigDecimal sinN = new BigDecimal(sin(kn * y));
    BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y));

    Yn = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd2.multiply(Yn);

    return ans.doubleValue();
}

From source file:fsm.series.Series_CF.java

public double getF5Value(double y, int m, int n) {

    double um = getMu_m(m);
    double un = getMu_m(n);
    double alphaM = (sin(um) + sinh(um)) / (cos(um) + cosh(um));

    double alphaN = (sin(un) + sinh(un)) / (cos(un) + cosh(un));
    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd1;
    BigDecimal Ynd1;// ww  w .  j  a v a 2 s .c  om

    BigDecimal cosh = new BigDecimal(-km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(alphaM * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(alphaM * km * sin(km * y));
    BigDecimal cos = new BigDecimal(km * cos(km * y));

    Ymd1 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-kn * cosh(kn * y));

    BigDecimal sinhN = new BigDecimal(alphaN * kn * sinh(kn * y));
    BigDecimal sinN = new BigDecimal(alphaN * kn * sin(kn * y));
    BigDecimal cosN = new BigDecimal(kn * cos(kn * y));

    Ynd1 = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd1.multiply(Ynd1);

    return ans.doubleValue();

}

From source file:com.esd.cs.audit.AuditsController.java

/**
 * ?/* ww  w .ja  va 2s.  com*/
 * 
 * @param year
 * @param companyCode
 * @param total
 * @return
 */
private BigDecimal getUnAudits(String year, Integer companyId, BigDecimal total, List<AccountModel> sb) {
    BigDecimal amount = new BigDecimal(0.00);
    // ??
    AuditParameter auditParameter = auditParameterService.getByYear(year);
    BigDecimal averageSalary = auditParameter.getAverageSalary();
    // ?
    // 
    BigDecimal putScale = auditParameter.getPutScale();
    // ??*(?*)?? 
    BigDecimal payableAmount = averageSalary.multiply(total.multiply(putScale));
    String[] unAudits = companyService.getUnauditYearByCompany(companyId, year);
    if (unAudits != null) {
        for (String unYear : unAudits) {
            AuditParameter oldAuditParameter = auditParameterService.getByYear(unYear);
            Date auditDelayDate = oldAuditParameter.getAuditDelayDate();
            int days = CalendarUtil.getDaySub(auditDelayDate, new Date());
            // =?**
            BigDecimal penalty = payableAmount.multiply(oldAuditParameter.getAuditDelayRate())
                    .multiply(new BigDecimal(days));
            BigDecimal unYearTotal = payableAmount.add(penalty);
            logger.debug("payableAmount:{},year:{} date:{} penalty:{} unYearTotal:{}", payableAmount, unYear,
                    days, penalty, unYearTotal);
            AccountModel am = new AccountModel();
            am.setYear(unYear);
            am.setDays(String.valueOf(days));
            am.setMoney(df.format(payableAmount));
            am.setPenalty(df.format(penalty));
            am.setProp(df4.format(oldAuditParameter.getAuditDelayRate()));
            am.setTotal(df.format(unYearTotal));
            sb.add(am);
            amount = amount.add(unYearTotal);
        }
    }
    if (amount.compareTo(new BigDecimal(0.00)) != 0) {
        AccountModel am = new AccountModel();
        am.setTotal(df.format(amount));
        sb.add(am);
    }
    return amount;
}