Example usage for java.math BigDecimal ZERO

List of usage examples for java.math BigDecimal ZERO

Introduction

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

Prototype

BigDecimal ZERO

To view the source code for java.math BigDecimal ZERO.

Click Source Link

Document

The value 0, with a scale of 0.

Usage

From source file:com.intuit.tank.project.JobDetailFormatter.java

protected static BigDecimal estimateCost(int numInstances, BigDecimal costPerHour, long time) {
    BigDecimal cost = BigDecimal.ZERO;
    // calculate the number of machines and the expected run time
    BigDecimal hours = new BigDecimal(Math.max(1, Math.ceil(time / HOURS)));
    cost = cost.add(costPerHour.multiply(new BigDecimal(numInstances)).multiply(hours));
    // dynamoDB costs about 1.5 times the instance cost
    cost = cost.add(cost.multiply(new BigDecimal(1.5D)));
    return cost;/*from  w  w w .j  a v a  2s  .co  m*/
}

From source file:com.artivisi.biller.simulator.gateway.pln.PlnGateway.java

private StringBuffer createBit48InquiryPostpaidResponse(String bit48Request, Pelanggan p,
        List<TagihanPascabayar> daftarTagihan, List<TagihanPascabayar> tagihanDikirim,
        InquiryPostpaidResponse ipr) {/*w  ww  .j av a  2 s  .  c  om*/
    StringBuffer bit48Response = new StringBuffer();
    bit48Response.append(bit48Request);
    bit48Response.append(tagihanDikirim.size());
    bit48Response.append(StringUtils.leftPad(String.valueOf(daftarTagihan.size()), 2, "0"));
    bit48Response.append(ipr.getId().toUpperCase());
    bit48Response.append(StringUtils.rightPad(p.getNama(), 25, " "));
    bit48Response.append(StringUtils.rightPad(p.getServiceUnit(), 5, " "));
    bit48Response.append(StringUtils.rightPad(p.getServiceUnitPhone(), 15, " "));
    bit48Response.append(StringUtils.rightPad(p.getSubscriberSegmentation(), 4, " "));
    bit48Response.append(StringUtils.leftPad(p.getPowerConsumingCategory(), 9, "0"));
    bit48Response.append(StringUtils.leftPad("", 9, "0")); // total admin charges

    for (TagihanPascabayar t : tagihanDikirim) {
        bit48Response.append(DateTimeFormat.forPattern("yyyyMM").print(t.getBillPeriod().getTime()));
        bit48Response.append(DateTimeFormat.forPattern("ddMMyyyy").print(t.getDueDate().getTime()));
        bit48Response.append(DateTimeFormat.forPattern("ddMMyyyy").print(t.getMeterReadDate().getTime()));
        bit48Response.append(
                StringUtils.leftPad(t.getBill().setScale(0, RoundingMode.HALF_EVEN).toString(), 11, "0"));
        if (BigDecimal.ZERO.compareTo(t.getInsentif()) > 0) {
            bit48Response.append("D");
        } else {
            bit48Response.append("C");
        }
        bit48Response.append(StringUtils
                .leftPad(t.getInsentif().abs().setScale(0, RoundingMode.HALF_EVEN).toString(), 10, "0"));
        bit48Response.append(
                StringUtils.leftPad(t.getVat().setScale(0, RoundingMode.HALF_EVEN).toString(), 10, "0"));
        bit48Response.append(
                StringUtils.leftPad(t.getDenda().setScale(0, RoundingMode.HALF_EVEN).toString(), 10, "0"));
        bit48Response.append(StringUtils.leftPad(t.getPreviousMeterRead1(), 8, "0"));
        bit48Response.append(StringUtils.leftPad(t.getCurrentMeterRead1(), 8, "0"));
        bit48Response.append(StringUtils.leftPad(t.getPreviousMeterRead2(), 8, "0"));
        bit48Response.append(StringUtils.leftPad(t.getCurrentMeterRead2(), 8, "0"));
        bit48Response.append(StringUtils.leftPad(t.getPreviousMeterRead3(), 8, "0"));
        bit48Response.append(StringUtils.leftPad(t.getCurrentMeterRead3(), 8, "0"));
    }
    return bit48Response;
}

From source file:com.exilant.eGov.src.common.EGovernCommon.java

public BigDecimal getAccountBalance(final Date VoucherDate, final String bankAccountId)
        throws TaskFailedException {
    BigDecimal totalAvailable = BigDecimal.ZERO;
    BigDecimal opeAvailable = BigDecimal.ZERO;
    Query pst = null;//from  ww w. j  ava2  s. c o  m
    List<Object[]> resultset = null;
    List<Object[]> resultset1 = null;
    try {
        final SimpleDateFormat formatter = dtFormat;
        final String vcDate = formatter.format(VoucherDate);

        final String str = "SELECT case when sum(openingDebitBalance) = null then 0 else sum(openingDebitBalance) end-  case when sum(openingCreditBalance) = null  then 0 else sum(openingCreditBalance) end AS \"openingBalance\" "
                + "FROM transactionSummary WHERE financialYearId=( SELECT id FROM financialYear WHERE startingDate <=?"
                + "AND endingDate >= ?)  AND glCodeId =(select glcodeid from bankaccount where id=?)";
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("getAccountBalance(EGovernCommon.java): " + str);
        pst = persistenceService.getSession().createSQLQuery(str);
        pst.setString(0, vcDate);
        pst.setString(1, vcDate);
        pst.setString(2, bankAccountId);
        resultset = pst.list();
        for (final Object[] element : resultset)
            opeAvailable = new BigDecimal(element[0].toString());
        if (resultset == null || resultset.size() == 0)
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("Else resultset in getbalance");

        if (LOGGER.isDebugEnabled())
            LOGGER.debug("opening balance  " + opeAvailable);
        // resultset.close();

        final String str1 = "SELECT (case when sum(gl.debitAmount) = null then 0 else sum(gl.debitAmount) end) - (case when sum(gl.creditAmount) = null then 0 else sum(gl.creditAmount) end) + "
                + opeAvailable
                + " as \"totalAmount\" FROM   generalLedger gl, voucherHeader vh WHERE vh.id = gl.voucherHeaderId AND gl.glCodeid = (select glcodeid from bankaccount where id=?) AND  "
                + " vh.voucherDate >=( SELECT TO_CHAR(startingDate, 'dd-Mon-yyyy') FROM financialYear WHERE startingDate <= ? AND endingDate >= ?) AND vh.voucherDate <= ? and vh.status!=4";

        if (LOGGER.isDebugEnabled())
            LOGGER.debug("Curr Yr Bal: " + str1);
        pst = persistenceService.getSession().createSQLQuery(str1);
        pst.setString(0, bankAccountId);
        pst.setString(1, vcDate);
        pst.setString(2, vcDate);
        pst.setString(3, vcDate);
        resultset1 = pst.list();
        for (final Object[] element : resultset1) {
            totalAvailable = new BigDecimal(element[0].toString());
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("total balance  " + totalAvailable);
        }
        if (resultset1 == null || resultset1.size() == 0)
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("Else resultset in getbalance...");

        totalAvailable = totalAvailable.setScale(2, BigDecimal.ROUND_HALF_UP);
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("total balance before return " + totalAvailable);

    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        throw taskExc;
    }
    return totalAvailable;
}

From source file:uk.dsxt.voting.client.web.MockVotingApiResource.java

License:asdf

@POST
@Path("/votingTotalResults")
@Produces("application/json")
public RequestResult votingTotalResults(@FormParam("cookie") String cookie,
        @FormParam("votingId") String votingId) {
    log.debug("votingTotalResults method called. votingId={}", votingId);
    final AnswerWeb[] answers1 = new AnswerWeb[5];
    answers1[0] = new AnswerWeb("1", "answer_1", new BigDecimal(100000));
    answers1[1] = new AnswerWeb("2", "answer_2", new BigDecimal(999999));
    answers1[2] = new AnswerWeb("3", "answer_3", new BigDecimal(777777777.77777777));
    answers1[3] = new AnswerWeb("4", "answer_4", new BigDecimal(0.42353242));
    answers1[4] = new AnswerWeb("5", "answer_5", BigDecimal.ZERO);

    final AnswerWeb[] answers2 = new AnswerWeb[3];
    answers2[0] = new AnswerWeb("1", "yes", new BigDecimal(123546547));
    answers2[1] = new AnswerWeb("2", "no", new BigDecimal(789987342.324));
    answers2[2] = new AnswerWeb("3", "vozderzhalsya", BigDecimal.ZERO);

    final AnswerWeb[] answers3 = new AnswerWeb[3];
    answers3[0] = new AnswerWeb("1", "yes", new BigDecimal(6547));
    answers3[1] = new AnswerWeb("2", "no", new BigDecimal(987342.324));
    answers3[2] = new AnswerWeb("3", "ne sderzhalsya", BigDecimal.ZERO);

    final QuestionWeb[] questions = new QuestionWeb[3];
    questions[0] = new QuestionWeb("1", "question_1_multi", answers1, true, 1);
    questions[1] = new QuestionWeb("2", "question_2_yes_no_1", answers2, false, 1);
    questions[2] = new QuestionWeb("3", "question_3_yes_no_2", answers3, false, 1);
    return new RequestResult<>(new VotingInfoWeb(questions, BigDecimal.ZERO, null), null);
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.ED524BudgetV1_1Generator.java

/**
 * // w w  w.  ja va 2  s .  com
 * This method is used to get 5 Budget years information for the form ED524Budget
 * 
 * @return ed524BudgetDocument {@link XmlObject} of type ED524BudgetDocument.
 */
private ED524BudgetDocument getED524Budget() {

    ED524BudgetDocument ed524BudgetDocument = ED524BudgetDocument.Factory.newInstance();
    ED524Budget ed524Budget = ED524Budget.Factory.newInstance();

    ed524Budget.setFormVersion(FormVersion.v1_1.getVersion());
    if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) {
        ed524Budget.setLEGALNAME(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization()
                .getOrganizationName());
    } else {
        ed524Budget.setLEGALNAME(DEFAULT_LEGAL_NAME);
    }

    ScaleTwoDecimal totalCategoryCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalPersonnel = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalPersonnelCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalFringe = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalFringeCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalTravel = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalTravelCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalEquip = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalEquipCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalSupplies = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalSuppliesCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalContractual = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalContractualCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalConstruction = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalConstructionCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalOther = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalOtherCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalTraining = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalTrainingCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalCostAllYrs = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalCostSharingAllYrs = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalDirectCostAllYrs = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalDirectCostAllYrsCS = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalIndirectCostAllYrs = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal totalIndirectCostAllYrsCS = ScaleTwoDecimal.ZERO;

    ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService
            .getBudget(pdDoc.getDevelopmentProposal());

    if (budget == null) {
        return ed524BudgetDocument;
    }

    for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
        if (budgetPeriod.getBudgetPeriod().equals(BudgetPeriodNum.P1.getNum())) {
            getTotalCosts(budgetPeriod);
            ed524Budget.setBudgetFederalFirstYearAmount(totalCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFirstYearAmount(totalCostSharing.bigDecimalValue());
            ed524Budget.setBudgetFederalDirectFirstYearAmount(totalDirectCost.bigDecimalValue());
            ed524Budget.setBudgetFederalIndirectFirstYearAmount(totalIndirectCost.bigDecimalValue());

            totalCostAllYrs = totalCostAllYrs.add(totalCost);
            totalCostSharingAllYrs = totalCostSharingAllYrs.add(totalCostSharing);
            totalDirectCostAllYrs = totalDirectCostAllYrs.add(totalDirectCost);
            totalIndirectCostAllYrs = totalIndirectCostAllYrs.add(totalIndirectCost);

            // Total Indirect Cost Sharing
            getIndirectCosts(budgetPeriod);
            ed524Budget.setBudgetNonFederalIndirectFirstYearAmount(indirectCS.bigDecimalValue());
            totalIndirectCostAllYrsCS = totalIndirectCostAllYrsCS.add(indirectCS);

            // Supplies
            getSuppliesCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSuppliesFirstYearAmount(supplyCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSuppliesFirstYearAmount(supplyCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(supplyCostCS);
            totalSupplies = totalSupplies.add(supplyCost);
            totalSuppliesCS = totalSuppliesCS.add(supplyCostCS);

            // Construction
            // Set to zero as it set hard coded as 0 in the procedure
            ed524Budget.setBudgetFederalConstructionFirstYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());
            ed524Budget.setBudgetNonFederalConstructionFirstYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());

            // Other
            getOtherCosts(budgetPeriod);
            ed524Budget.setBudgetFederalOtherFirstYearAmount(otherCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalOtherFirstYearAmount(otherCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(otherCostCS);
            totalOther = totalOther.add(otherCost);
            totalOtherCS = totalOtherCS.add(otherCostCS);

            // Equipment
            getEquipmentCosts(budgetPeriod);
            ed524Budget.setBudgetFederalEquipmentFirstYearAmount(equipmentCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalEquipmentFirstYearAmount(equipmentCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(equipmentCostCS);
            totalEquip = totalEquip.add(equipmentCost);
            totalEquipCS = totalEquipCS.add(equipmentCostCS);

            // Contractual
            getContractualCosts(budgetPeriod);
            ed524Budget.setBudgetFederalContractualFirstYearAmount(contractualCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalContractualFirstYearAmount(contractualCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(contractualCostCS);
            totalContractual = totalContractual.add(contractualCost);
            totalContractualCS = totalContractualCS.add(contractualCostCS);

            // Travel
            getTravelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTravelFirstYearAmount(travelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTravelFirstYearAmount(travelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(travelCostCS);
            totalTravel = totalTravel.add(travelCost);
            totalTravelCS = totalTravelCS.add(travelCostCS);

            // Training
            getTrainingCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTrainingFirstYearAmount(trainingCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTrainingFirstYearAmount(trainingCostCS.bigDecimalValue());

            totalTraining = totalTraining.add(trainingCost);
            totalTrainingCS = totalTrainingCS.add(trainingCostCS);

            // Fringe
            ed524Budget.setBudgetFederalFringeFirstYearAmount(categoryCostFringe.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFringeFirstYearAmount(categoryCostCSFringe.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(categoryCostCSFringe);
            totalFringe = totalFringe.add(categoryCostFringe);
            totalFringeCS = totalFringeCS.add(categoryCostCSFringe);

            // Personnel
            getPersonnelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalPersonnelFirstYearAmount(personnelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalPersonnelFirstYearAmount(personnelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(personnelCostCS);
            totalPersonnel = totalPersonnel.add(personnelCost);
            totalPersonnelCS = totalPersonnelCS.add(personnelCostCS);

            ed524Budget.setBudgetNonFederalDirectFirstYearAmount(totalCategoryCS.bigDecimalValue());

        } else if (budgetPeriod.getBudgetPeriod().equals(BudgetPeriodNum.P2.getNum())) {
            totalCategoryCS = ScaleTwoDecimal.ZERO;
            getTotalCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSecondYearAmount(totalCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSecondYearAmount(totalCostSharing.bigDecimalValue());
            ed524Budget.setBudgetFederalDirectSecondYearAmount(totalDirectCost.bigDecimalValue());
            ed524Budget.setBudgetFederalIndirectSecondYearAmount(totalIndirectCost.bigDecimalValue());

            totalCostAllYrs = totalCostAllYrs.add(totalCost);
            totalCostSharingAllYrs = totalCostSharingAllYrs.add(totalCostSharing);
            totalDirectCostAllYrs = totalDirectCostAllYrs.add(totalDirectCost);
            totalIndirectCostAllYrs = totalIndirectCostAllYrs.add(totalIndirectCost);

            // Total Indirect Cost Sharing
            getIndirectCosts(budgetPeriod);
            ed524Budget.setBudgetNonFederalIndirectSecondYearAmount(indirectCS.bigDecimalValue());
            totalIndirectCostAllYrsCS = totalIndirectCostAllYrsCS.add(indirectCS);

            // Supplies
            getSuppliesCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSuppliesSecondYearAmount(supplyCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSuppliesSecondYearAmount(supplyCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(supplyCostCS);
            totalSupplies = totalSupplies.add(supplyCost);
            totalSuppliesCS = totalSuppliesCS.add(supplyCostCS);

            // Construction
            // Set to zero as it set hard coded as 0 in the procedure
            ed524Budget.setBudgetFederalConstructionSecondYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());
            ed524Budget.setBudgetNonFederalConstructionSecondYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());

            // Other
            getOtherCosts(budgetPeriod);
            if (otherCost.longValue() < 0) {
                ed524Budget.setBudgetFederalOtherSecondYearAmount(BigDecimal.ZERO);
            } else {
                ed524Budget.setBudgetFederalOtherSecondYearAmount(otherCost.bigDecimalValue());
            }

            ed524Budget.setBudgetNonFederalOtherSecondYearAmount(otherCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(otherCostCS);
            totalOther = totalOther.add(otherCost);
            totalOtherCS = totalOtherCS.add(otherCostCS);

            // Equipment
            getEquipmentCosts(budgetPeriod);
            ed524Budget.setBudgetFederalEquipmentSecondYearAmount(equipmentCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalEquipmentSecondYearAmount(equipmentCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(equipmentCostCS);
            totalEquip = totalEquip.add(equipmentCost);
            totalEquipCS = totalEquipCS.add(equipmentCostCS);

            // Contractual
            getContractualCosts(budgetPeriod);
            ed524Budget.setBudgetFederalContractualSecondYearAmount(contractualCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalContractualSecondYearAmount(contractualCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(contractualCostCS);
            totalContractual = totalContractual.add(contractualCost);
            totalContractualCS = totalContractualCS.add(contractualCostCS);

            // Travel
            getTravelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTravelSecondYearAmount(travelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTravelSecondYearAmount(travelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(travelCostCS);
            totalTravel = totalTravel.add(travelCost);
            totalTravelCS = totalTravelCS.add(travelCostCS);

            // Training
            ed524Budget.setBudgetFederalTrainingSecondYearAmount(trainingCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTrainingSecondYearAmount(trainingCostCS.bigDecimalValue());

            totalTraining = totalTraining.add(trainingCost);
            totalTrainingCS = totalTrainingCS.add(trainingCostCS);

            // Fringe
            ed524Budget.setBudgetFederalFringeSecondYearAmount(categoryCostFringe.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFringeSecondYearAmount(categoryCostCSFringe.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(categoryCostCSFringe);
            totalFringe = totalFringe.add(categoryCostFringe);
            totalFringeCS = totalFringeCS.add(categoryCostCSFringe);

            // Personnel
            getPersonnelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalPersonnelSecondYearAmount(personnelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalPersonnelSecondYearAmount(personnelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(personnelCostCS);
            totalPersonnel = totalPersonnel.add(personnelCost);
            totalPersonnelCS = totalPersonnelCS.add(personnelCostCS);

            ed524Budget.setBudgetNonFederalDirectSecondYearAmount(totalCategoryCS.bigDecimalValue());
        } else if (budgetPeriod.getBudgetPeriod().equals(BudgetPeriodNum.P3.getNum())) {
            totalCategoryCS = ScaleTwoDecimal.ZERO;
            getTotalCosts(budgetPeriod);
            ed524Budget.setBudgetFederalThirdYearAmount(totalCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalThirdYearAmount(totalCostSharing.bigDecimalValue());
            ed524Budget.setBudgetFederalDirectThirdYearAmount(totalDirectCost.bigDecimalValue());
            ed524Budget.setBudgetFederalIndirectThirdYearAmount(totalIndirectCost.bigDecimalValue());

            totalCostAllYrs = totalCostAllYrs.add(totalCost);
            totalCostSharingAllYrs = totalCostSharingAllYrs.add(totalCostSharing);
            totalDirectCostAllYrs = totalDirectCostAllYrs.add(totalDirectCost);
            totalIndirectCostAllYrs = totalIndirectCostAllYrs.add(totalIndirectCost);

            // Total Indirect Cost Sharing
            getIndirectCosts(budgetPeriod);
            ed524Budget.setBudgetNonFederalIndirectThirdYearAmount(indirectCS.bigDecimalValue());
            totalIndirectCostAllYrsCS = totalIndirectCostAllYrsCS.add(indirectCS);

            // Supplies
            getSuppliesCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSuppliesThirdYearAmount(supplyCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSuppliesThirdYearAmount(supplyCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(supplyCostCS);
            totalSupplies = totalSupplies.add(supplyCost);
            totalSuppliesCS = totalSuppliesCS.add(supplyCostCS);

            // Construction
            // Set to zero as it set hard coded as 0 in the procedure
            ed524Budget.setBudgetFederalConstructionThirdYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());
            ed524Budget.setBudgetNonFederalConstructionThirdYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());

            // Other
            getOtherCosts(budgetPeriod);
            if (otherCost.longValue() < 0) {
                ed524Budget.setBudgetFederalOtherThirdYearAmount(BigDecimal.ZERO);
            } else {
                ed524Budget.setBudgetFederalOtherThirdYearAmount(otherCost.bigDecimalValue());
            }
            ed524Budget.setBudgetNonFederalOtherThirdYearAmount(otherCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(otherCostCS);
            totalOther = totalOther.add(otherCost);
            totalOtherCS = totalOtherCS.add(otherCostCS);

            // Equipment
            getEquipmentCosts(budgetPeriod);
            ed524Budget.setBudgetFederalEquipmentThirdYearAmount(equipmentCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalEquipmentThirdYearAmount(equipmentCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(equipmentCostCS);
            totalEquip = totalEquip.add(equipmentCost);
            totalEquipCS = totalEquipCS.add(equipmentCostCS);

            // Contractual
            getContractualCosts(budgetPeriod);
            ed524Budget.setBudgetFederalContractualThirdYearAmount(contractualCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalContractualThirdYearAmount(contractualCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(contractualCostCS);
            totalContractual = totalContractual.add(contractualCost);
            totalContractualCS = totalContractualCS.add(contractualCostCS);

            // Travel
            getTravelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTravelThirdYearAmount(travelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTravelThirdYearAmount(travelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(travelCostCS);
            totalTravel = totalTravel.add(travelCost);
            totalTravelCS = totalTravelCS.add(travelCostCS);

            // Training
            ed524Budget.setBudgetFederalTrainingThirdYearAmount(trainingCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTrainingThirdYearAmount(trainingCostCS.bigDecimalValue());

            totalTraining = totalTraining.add(trainingCost);
            totalTrainingCS = totalTrainingCS.add(trainingCostCS);

            // Fringe
            ed524Budget.setBudgetFederalFringeThirdYearAmount(categoryCostFringe.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFringeThirdYearAmount(categoryCostCSFringe.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(categoryCostCSFringe);
            totalFringe = totalFringe.add(categoryCostFringe);
            totalFringeCS = totalFringeCS.add(categoryCostCSFringe);

            // Personnel
            getPersonnelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalPersonnelThirdYearAmount(personnelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalPersonnelThirdYearAmount(personnelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(personnelCostCS);
            totalPersonnel = totalPersonnel.add(personnelCost);
            totalPersonnelCS = totalPersonnelCS.add(personnelCostCS);

            ed524Budget.setBudgetNonFederalDirectThirdYearAmount(totalCategoryCS.bigDecimalValue());
        } else if (budgetPeriod.getBudgetPeriod().equals(BudgetPeriodNum.P4.getNum())) {
            totalCategoryCS = ScaleTwoDecimal.ZERO;
            getTotalCosts(budgetPeriod);
            ed524Budget.setBudgetFederalFourthYearAmount(totalCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFourthYearAmount(totalCostSharing.bigDecimalValue());
            ed524Budget.setBudgetFederalDirectFourthYearAmount(totalDirectCost.bigDecimalValue());
            ed524Budget.setBudgetFederalIndirectFourthYearAmount(totalIndirectCost.bigDecimalValue());

            totalCostAllYrs = totalCostAllYrs.add(totalCost);
            totalCostSharingAllYrs = totalCostSharingAllYrs.add(totalCostSharing);
            totalDirectCostAllYrs = totalDirectCostAllYrs.add(totalDirectCost);
            totalIndirectCostAllYrs = totalIndirectCostAllYrs.add(totalIndirectCost);

            // Total Indirect Cost Sharing
            getIndirectCosts(budgetPeriod);
            ed524Budget.setBudgetNonFederalIndirectFourthYearAmount(indirectCS.bigDecimalValue());
            totalIndirectCostAllYrsCS = totalIndirectCostAllYrsCS.add(indirectCS);

            // Supplies
            getSuppliesCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSuppliesFourthYearAmount(supplyCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSuppliesFourthYearAmount(supplyCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(supplyCostCS);
            totalSupplies = totalSupplies.add(supplyCost);
            totalSuppliesCS = totalSuppliesCS.add(supplyCostCS);

            // Construction
            // Set to zero as it set hard coded as 0 in the procedure
            ed524Budget.setBudgetFederalConstructionFourthYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());
            ed524Budget.setBudgetNonFederalConstructionFourthYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());

            // Other
            getOtherCosts(budgetPeriod);
            ed524Budget.setBudgetFederalOtherFourthYearAmount(otherCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalOtherFourthYearAmount(otherCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(otherCostCS);
            totalOther = totalOther.add(otherCost);
            totalOtherCS = totalOtherCS.add(otherCostCS);

            // Equipment
            getEquipmentCosts(budgetPeriod);
            ed524Budget.setBudgetFederalEquipmentFourthYearAmount(equipmentCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalEquipmentFourthYearAmount(equipmentCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(equipmentCostCS);
            totalEquip = totalEquip.add(equipmentCost);
            totalEquipCS = totalEquipCS.add(equipmentCostCS);

            // Contractual
            getContractualCosts(budgetPeriod);
            ed524Budget.setBudgetFederalContractualFourthYearAmount(contractualCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalContractualFourthYearAmount(contractualCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(contractualCostCS);
            totalContractual = totalContractual.add(contractualCost);
            totalContractualCS = totalContractualCS.add(contractualCostCS);

            // Travel
            getTravelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTravelFourthYearAmount(travelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTravelFourthYearAmount(travelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(travelCostCS);
            totalTravel = totalTravel.add(travelCost);
            totalTravelCS = totalTravelCS.add(travelCostCS);

            // Training
            ed524Budget.setBudgetFederalTrainingFourthYearAmount(trainingCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTrainingFourthYearAmount(trainingCostCS.bigDecimalValue());

            totalTraining = totalTraining.add(trainingCost);
            totalTrainingCS = totalTrainingCS.add(trainingCostCS);

            // Fringe
            ed524Budget.setBudgetFederalFringeFourthYearAmount(categoryCostFringe.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFringeFourthYearAmount(categoryCostCSFringe.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(categoryCostCSFringe);
            totalFringe = totalFringe.add(categoryCostFringe);
            totalFringeCS = totalFringeCS.add(categoryCostCSFringe);

            // Personnel
            getPersonnelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalPersonnelFourthYearAmount(personnelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalPersonnelFourthYearAmount(personnelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(personnelCostCS);
            totalPersonnel = totalPersonnel.add(personnelCost);
            totalPersonnelCS = totalPersonnelCS.add(personnelCostCS);

            ed524Budget.setBudgetNonFederalDirectFourthYearAmount(totalCategoryCS.bigDecimalValue());
        } else if (budgetPeriod.getBudgetPeriod().equals(BudgetPeriodNum.P5.getNum())) {
            totalCategoryCS = ScaleTwoDecimal.ZERO;
            getTotalCosts(budgetPeriod);
            ed524Budget.setBudgetFederalFifthYearAmount(totalCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFifthYearAmount(totalCostSharing.bigDecimalValue());
            ed524Budget.setBudgetFederalDirectFifthYearAmount(totalDirectCost.bigDecimalValue());
            ed524Budget.setBudgetFederalIndirectFifthYearAmount(totalIndirectCost.bigDecimalValue());

            totalCostAllYrs = totalCostAllYrs.add(totalCost);
            totalCostSharingAllYrs = totalCostSharingAllYrs.add(totalCostSharing);
            totalDirectCostAllYrs = totalDirectCostAllYrs.add(totalDirectCost);
            totalIndirectCostAllYrs = totalIndirectCostAllYrs.add(totalIndirectCost);

            // Total Indirect Cost Sharing
            getIndirectCosts(budgetPeriod);
            ed524Budget.setBudgetNonFederalIndirectFifthYearAmount(indirectCS.bigDecimalValue());
            totalIndirectCostAllYrsCS.add(indirectCS);

            // Supplies
            getSuppliesCosts(budgetPeriod);
            ed524Budget.setBudgetFederalSuppliesFifthYearAmount(supplyCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalSuppliesFifthYearAmount(supplyCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(supplyCostCS);
            totalSupplies = totalSupplies.add(supplyCost);
            totalSuppliesCS = totalSuppliesCS.add(supplyCostCS);

            // Construction
            // Set to zero as it set hard coded as 0 in the procedure

            ed524Budget.setBudgetFederalConstructionFifthYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());
            ed524Budget.setBudgetNonFederalConstructionFifthYearAmount(ScaleTwoDecimal.ZERO.bigDecimalValue());

            // Other
            getOtherCosts(budgetPeriod);
            ed524Budget.setBudgetFederalOtherFifthYearAmount(otherCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalOtherFifthYearAmount(otherCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(otherCostCS);
            totalOther = totalOther.add(otherCost);
            totalOtherCS = totalOtherCS.add(otherCostCS);

            // Equipment
            getEquipmentCosts(budgetPeriod);
            ed524Budget.setBudgetFederalEquipmentFifthYearAmount(equipmentCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalEquipmentFifthYearAmount(equipmentCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(equipmentCostCS);
            totalEquip = totalEquip.add(equipmentCost);
            totalEquipCS = totalEquipCS.add(equipmentCostCS);

            // Contractual
            getContractualCosts(budgetPeriod);
            ed524Budget.setBudgetFederalContractualFifthYearAmount(contractualCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalContractualFifthYearAmount(contractualCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(contractualCostCS);
            totalContractual = totalContractual.add(contractualCost);
            totalContractualCS = totalContractualCS.add(contractualCostCS);

            // Travel
            getTravelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalTravelFifthYearAmount(travelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTravelFifthYearAmount(travelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(travelCostCS);
            totalTravel = totalTravel.add(travelCost);
            totalTravelCS = totalTravelCS.add(travelCostCS);

            // Training
            ed524Budget.setBudgetFederalTrainingFifthYearAmount(trainingCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalTrainingFifthYearAmount(trainingCostCS.bigDecimalValue());

            totalTraining = totalTraining.add(trainingCost);
            totalTrainingCS = totalTrainingCS.add(trainingCostCS);

            // Fringe
            ed524Budget.setBudgetFederalFringeFifthYearAmount(categoryCostFringe.bigDecimalValue());
            ed524Budget.setBudgetNonFederalFringeFifthYearAmount(categoryCostCSFringe.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(categoryCostCSFringe);
            totalFringe = totalFringe.add(categoryCostFringe);
            totalFringeCS = totalFringeCS.add(categoryCostCSFringe);

            // Personnel
            getPersonnelCosts(budgetPeriod);
            ed524Budget.setBudgetFederalPersonnelFifthYearAmount(personnelCost.bigDecimalValue());
            ed524Budget.setBudgetNonFederalPersonnelFifthYearAmount(personnelCostCS.bigDecimalValue());

            totalCategoryCS = totalCategoryCS.add(personnelCostCS);
            totalPersonnel = totalPersonnel.add(personnelCost);
            totalPersonnelCS = totalPersonnelCS.add(personnelCostCS);

            ed524Budget.setBudgetNonFederalDirectFifthYearAmount(totalCategoryCS.bigDecimalValue());
        }
    } // end of main for loop
    ed524Budget.setBudgetFederalPersonnelTotalAmount(totalPersonnel.bigDecimalValue());
    ed524Budget.setBudgetNonFederalPersonnelTotalAmount(totalPersonnelCS.bigDecimalValue());
    ed524Budget.setBudgetFederalFringeTotalAmount(totalFringe.bigDecimalValue());
    ed524Budget.setBudgetNonFederalFringeTotalAmount(totalFringeCS.bigDecimalValue());
    ed524Budget.setBudgetFederalTravelTotalAmount(totalTravel.bigDecimalValue());

    ed524Budget.setBudgetNonFederalTravelTotalAmount(totalTravelCS.bigDecimalValue());
    ed524Budget.setBudgetFederalEquipmentTotalAmount(totalEquip.bigDecimalValue());
    ed524Budget.setBudgetNonFederalEquipmentTotalAmount(totalEquipCS.bigDecimalValue());
    ed524Budget.setBudgetFederalContractualTotalAmount(totalContractual.bigDecimalValue());

    ed524Budget.setBudgetNonFederalContractualTotalAmount(totalContractualCS.bigDecimalValue());
    ed524Budget.setBudgetFederalSuppliesTotalAmount(totalSupplies.bigDecimalValue());
    ed524Budget.setBudgetNonFederalSuppliesTotalAmount(totalSuppliesCS.bigDecimalValue());
    ed524Budget.setBudgetFederalConstructionTotalAmount(totalConstruction.bigDecimalValue());

    ed524Budget.setBudgetNonFederalConstructionTotalAmount(totalConstructionCS.bigDecimalValue());
    ed524Budget.setBudgetFederalTrainingTotalAmount(totalTraining.bigDecimalValue());
    ed524Budget.setBudgetNonFederalTrainingTotalAmount(totalTrainingCS.bigDecimalValue());
    if (totalOther.longValue() < 0) {
        ed524Budget.setBudgetFederalOtherTotalAmount(BigDecimal.ZERO);
    } else {
        ed524Budget.setBudgetFederalOtherTotalAmount(totalOther.bigDecimalValue());
    }
    ed524Budget.setBudgetNonFederalOtherTotalAmount(totalOtherCS.bigDecimalValue());

    totalDirectCostAllYrsCS = totalPersonnelCS.add(totalFringeCS).add(totalTravelCS).add(totalEquipCS)
            .add(totalContractualCS).add(totalConstructionCS).add(totalSuppliesCS).add(totalOtherCS);
    ed524Budget.setBudgetNonFederalDirectTotalAmount(totalDirectCostAllYrsCS.bigDecimalValue());
    ed524Budget.setBudgetNonFederalIndirectTotalAmount(totalIndirectCostAllYrsCS.bigDecimalValue());
    ed524Budget.setBudgetFederalIndirectTotalAmount(totalIndirectCostAllYrs.bigDecimalValue());
    ed524Budget.setBudgetFederalTotalAmount(totalCostAllYrs.bigDecimalValue());

    ed524Budget.setBudgetFederalDirectTotalAmount(totalDirectCostAllYrs.bigDecimalValue());
    ed524Budget.setBudgetNonFederalTotalAmount(totalCostSharingAllYrs.bigDecimalValue());
    /***************************************************************************************************************************
     * ** INDIRECT COST INFO
     **************************************************************************************************************************/

    IndirectCost indirectCost = IndirectCost.Factory.newInstance();
    ApprovingFederalAgency approvingFederalAgency = ApprovingFederalAgency.Factory.newInstance();
    OtherApprovingFederalAgency otherAgency = OtherApprovingFederalAgency.Factory.newInstance();
    IndirectCostRateAgreementFromDate fromDate = IndirectCostRateAgreementFromDate.Factory.newInstance();
    String restrictedQuestion = RESTIRCTED_QUESTION;
    String agencyName = getAgencyName();
    String indirectCostRateAgreement = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization().getIndirectCostRateAgreement();
    if (indirectCostRateAgreement != null
            && indirectCostRateAgreement.equals(INDIRECT_COST_RATE_AGREEMENT_NONE)) {
        approvingFederalAgency.setIsIndirectCostRateAgreementApproved(YesNoDataType.N_NO);
    } else {
        fromDate.setCalendarValue(s2SDateTimeService.convertDateStringToCalendar(indirectCostRateAgreement));
        fromDate.setIsIndirectCostRateAgreementApproved(YesNoDataType.Y_YES);
        if (fromDate.getCalendarValue() != null) {
            indirectCost.setIndirectCostRateAgreementFromDate(fromDate);
        }
        approvingFederalAgency.setIsIndirectCostRateAgreementApproved(YesNoDataType.Y_YES);
        if (agencyName.equals(APPROVING_FEDERAL_AGENCY_ED)) {
            approvingFederalAgency.setStringValue(APPROVING_FEDERAL_AGENCY_ED);
        } else {
            approvingFederalAgency.setStringValue(APPROVING_FEDERAL_AGENCY_OTHER);
            otherAgency.setApprovingFederalAgency(ApprovingFederalAgency.OTHER);
            otherAgency.setStringValue(agencyName);
            indirectCost.setOtherApprovingFederalAgency(otherAgency);
            indirectCost.setIsIndirectCostRateAgreementApproved(YesNoDataType.Y_YES);
            if (restrictedQuestion.length() > 1) {
                indirectCost.setRestrictedIndirectCostRate(
                        RestrictedIndirectCostRate.COMPLIES_WITH_34_CFR_76_564_C_2);
            }
            indirectCost.setApprovingFederalAgency(approvingFederalAgency);
            ed524Budget.setIndirectCost(indirectCost);
        }
    }
    ed524BudgetDocument.setED524Budget(ed524Budget);
    return ed524BudgetDocument;
}

From source file:com.heliumv.api.production.ProductionApi.java

private void gebeMaterialNachtraeglichAus(Integer stockId, LosDto losDto, ArtikelDto itemDto,
        MontageartDto montageartDto, BigDecimal amount, List<IdentityAmountEntry> identities)
        throws NamingException, RemoteException, EJBExceptionLP {
    BigDecimal sollPreis = getSollPreis(itemDto.getIId(), stockId);

    LossollmaterialDto lossollmaterialDto = new LossollmaterialDto();
    lossollmaterialDto.setBNachtraeglich(Helper.boolean2Short(true));
    lossollmaterialDto.setArtikelIId(itemDto.getIId());
    lossollmaterialDto.setEinheitCNr(itemDto.getEinheitCNr());
    lossollmaterialDto.setLosIId(losDto.getIId());
    lossollmaterialDto.setMontageartIId(montageartDto.getIId());
    lossollmaterialDto.setNMenge(amount);
    lossollmaterialDto.setNSollpreis(sollPreis);

    LosistmaterialDto losistmaterialDto = createLosistmaterialDto(stockId, amount);

    List<SeriennrChargennrMitMengeDto> hvIdentities = null;
    if (itemDto.istArtikelSnrOderchargentragend()) {
        hvIdentities = transform(identities);
        //         lossollmaterialDto.setNMenge(BigDecimal.ZERO);
    }//  ww  w . j ava 2s .  c o m

    lossollmaterialDto.setNMenge(BigDecimal.ZERO);
    fertigungCall.gebeMaterialNachtraeglichAus(lossollmaterialDto, losistmaterialDto, hvIdentities, false);
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getHighwayTollTotalUnPaidInvAmount() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(highwayTollInvs)) {
        for (int i = 0; i < highwayTollInvs.length; i++) {
            if ("N".equals(highwayTollInvs[i].getPaidIndicator())) {
                amount = amount.add(highwayTollInvs[i].getAmount());
            }/* w  ww.j a v a  2s . co  m*/
        }
    }
    return amount;
}

From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java

public Money waive(final MonetaryCurrency currency) {
    Money amountWaivedToDate = Money.of(currency, this.amountWaived);
    Money amountOutstanding = Money.of(currency, this.amountOutstanding);
    this.amountWaived = amountWaivedToDate.plus(amountOutstanding).getAmount();
    this.amountOutstanding = BigDecimal.ZERO;
    this.waived = true;

    resetPropertiesForRecurringFees();/*from   w  w w .  ja  va2  s.co  m*/
    updateNextDueDateForRecurringFees();

    return amountOutstanding;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRBudgetV1_0Generator.java

/**
 * This method gets BudgetSummary details such as
 * CumulativeTotalFundsRequestedSeniorKeyPerson,CumulativeTotalFundsRequestedOtherPersonnel
 * CumulativeTotalNoOtherPersonnel,CumulativeTotalFundsRequestedPersonnel,CumulativeEquipments,CumulativeTravels
 * CumulativeTrainee,CumulativeOtherDirect,CumulativeTotalFundsRequestedDirectCosts,CumulativeTotalFundsRequestedIndirectCost
 * CumulativeTotalFundsRequestedDirectIndirectCosts and CumulativeFee based
 * on BudgetSummaryInfo for the RRBudget.
 * //  w  w  w. j  ava2 s  .  co m
 * @param budgetSummaryData
 *            (BudgetSummaryInfo) budget summary info entry.
 * @return BudgetSummary details corresponding to the BudgetSummaryInfo
 *         object.
 */
private BudgetSummary getBudgetSummary(BudgetSummaryDto budgetSummaryData) {

    BudgetSummary budgetSummary = BudgetSummary.Factory.newInstance();
    // Set default values for mandatory fields
    budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(BigDecimal.ZERO);
    budgetSummary.setCumulativeTotalFundsRequestedPersonnel(BigDecimal.ZERO);
    budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(BigDecimal.ZERO);

    if (budgetSummaryData != null) {
        if (budgetSummaryData.getCumTotalFundsForSrPersonnel() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(
                    budgetSummaryData.getCumTotalFundsForSrPersonnel().bigDecimalValue());
        }
        if (budgetSummaryData.getCumTotalFundsForOtherPersonnel() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedOtherPersonnel(
                    budgetSummaryData.getCumTotalFundsForOtherPersonnel().bigDecimalValue());
        }
        if (budgetSummaryData.getCumNumOtherPersonnel() != null) {
            budgetSummary
                    .setCumulativeTotalNoOtherPersonnel(budgetSummaryData.getCumNumOtherPersonnel().intValue());
        }
        if (budgetSummaryData.getCumTotalFundsForPersonnel() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedPersonnel(
                    budgetSummaryData.getCumTotalFundsForPersonnel().bigDecimalValue());
        }
        budgetSummary.setCumulativeEquipments(getCumulativeEquipments(budgetSummaryData));
        budgetSummary.setCumulativeTravels(getCumulativeTravels(budgetSummaryData));
        budgetSummary.setCumulativeTrainee(getCumulativeTrainee(budgetSummaryData));
        budgetSummary.setCumulativeOtherDirect(getCumulativeOtherDirect(budgetSummaryData));
        if (budgetSummaryData.getCumTotalDirectCosts() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(
                    budgetSummaryData.getCumTotalDirectCosts().bigDecimalValue());
        }
        if (budgetSummaryData.getCumTotalIndirectCosts() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedIndirectCost(
                    budgetSummaryData.getCumTotalIndirectCosts().bigDecimalValue());
        }
        if (budgetSummaryData.getCumTotalCosts() != null) {
            budgetSummary.setCumulativeTotalFundsRequestedDirectIndirectCosts(
                    budgetSummaryData.getCumTotalCosts().bigDecimalValue());
        }
        if (budgetSummaryData.getCumFee() != null) {
            budgetSummary.setCumulativeFee(budgetSummaryData.getCumFee().bigDecimalValue());
        }
    }
    return budgetSummary;
}

From source file:com.gst.portfolio.loanaccount.loanschedule.service.LoanScheduleAssembler.java

private LoanApplicationTerms assembleLoanApplicationTermsFrom(final JsonElement element,
        final LoanProduct loanProduct) {

    final MonetaryCurrency currency = loanProduct.getCurrency();
    final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository
            .findOneWithNotFoundDetection(currency);

    // loan terms
    final Integer loanTermFrequency = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("loanTermFrequency",
            element);/*from  w w  w.  ja  v  a2s .  c  om*/
    final Integer loanTermFrequencyType = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("loanTermFrequencyType", element);
    final PeriodFrequencyType loanTermPeriodFrequencyType = PeriodFrequencyType.fromInt(loanTermFrequencyType);

    final Integer numberOfRepayments = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("numberOfRepayments", element);
    final Integer repaymentEvery = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("repaymentEvery",
            element);
    final Integer repaymentFrequencyType = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("repaymentFrequencyType", element);
    final PeriodFrequencyType repaymentPeriodFrequencyType = PeriodFrequencyType
            .fromInt(repaymentFrequencyType);
    final Integer nthDay = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("repaymentFrequencyNthDayType",
            element);
    final Integer dayOfWeek = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("repaymentFrequencyDayOfWeekType", element);
    final DayOfWeekType weekDayType = DayOfWeekType.fromInt(dayOfWeek);

    final Integer amortizationType = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("amortizationType",
            element);
    final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(amortizationType);

    // interest terms
    final Integer interestType = this.fromApiJsonHelper.extractIntegerWithLocaleNamed("interestType", element);
    final InterestMethod interestMethod = InterestMethod.fromInt(interestType);

    final Integer interestCalculationPeriodType = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("interestCalculationPeriodType", element);
    final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod
            .fromInt(interestCalculationPeriodType);
    Boolean allowPartialPeriodInterestCalcualtion = this.fromApiJsonHelper
            .extractBooleanNamed(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element);
    if (allowPartialPeriodInterestCalcualtion == null) {
        allowPartialPeriodInterestCalcualtion = loanProduct.getLoanProductRelatedDetail()
                .isAllowPartialPeriodInterestCalcualtion();
    }

    final BigDecimal interestRatePerPeriod = this.fromApiJsonHelper
            .extractBigDecimalWithLocaleNamed("interestRatePerPeriod", element);
    final PeriodFrequencyType interestRatePeriodFrequencyType = loanProduct.getInterestPeriodFrequencyType();

    BigDecimal annualNominalInterestRate = BigDecimal.ZERO;
    if (interestRatePerPeriod != null) {
        annualNominalInterestRate = this.aprCalculator.calculateFrom(interestRatePeriodFrequencyType,
                interestRatePerPeriod);
    }

    // disbursement details
    final BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("principal", element);
    final Money principalMoney = Money.of(currency, principal);

    final LocalDate expectedDisbursementDate = this.fromApiJsonHelper
            .extractLocalDateNamed("expectedDisbursementDate", element);
    final LocalDate repaymentsStartingFromDate = this.fromApiJsonHelper
            .extractLocalDateNamed("repaymentsStartingFromDate", element);
    LocalDate calculatedRepaymentsStartingFromDate = repaymentsStartingFromDate;

    final Boolean synchDisbursement = this.fromApiJsonHelper.extractBooleanNamed("syncDisbursementWithMeeting",
            element);
    final Long calendarId = this.fromApiJsonHelper.extractLongNamed("calendarId", element);
    Calendar calendar = null;

    final String loanTypeParameterName = "loanType";
    final String loanTypeStr = this.fromApiJsonHelper.extractStringNamed(loanTypeParameterName, element);

    final AccountType loanType = AccountType.fromName(loanTypeStr);

    /*
     * If it is JLG loan/Group Loan then make sure loan frequency is same as
     * Group/Center meeting frequency or multiple of it. TODO: Check should
     * be either same frequency or loan freq is multiple of center/group
     * meeting freq multiples
     */
    if ((loanType.isJLGAccount() || loanType.isGroupAccount()) && calendarId != null) {
        calendar = this.calendarRepository.findOne(calendarId);
        if (calendar == null) {
            throw new CalendarNotFoundException(calendarId);
        }
        final PeriodFrequencyType meetingPeriodFrequency = CalendarUtils
                .getMeetingPeriodFrequencyType(calendar.getRecurrence());
        validateRepaymentFrequencyIsSameAsMeetingFrequency(meetingPeriodFrequency.getValue(),
                repaymentFrequencyType, CalendarUtils.getInterval(calendar.getRecurrence()), repaymentEvery);
    } else {
        if (repaymentPeriodFrequencyType == PeriodFrequencyType.MONTHS && nthDay != null
                && nthDay != NthDayType.INVALID.getValue()) {
            LocalDate calendarStartDate = repaymentsStartingFromDate;
            if (calendarStartDate == null)
                calendarStartDate = expectedDisbursementDate;
            calendar = createLoanCalendar(calendarStartDate, repaymentEvery, CalendarFrequencyType.MONTHLY,
                    dayOfWeek, nthDay);
        }
    }

    /*
     * If user has not passed the first repayments date then then derive the
     * same based on loan type.
     */
    if (calculatedRepaymentsStartingFromDate == null) {
        calculatedRepaymentsStartingFromDate = deriveFirstRepaymentDate(loanType, repaymentEvery,
                expectedDisbursementDate, repaymentPeriodFrequencyType,
                loanProduct.getMinimumDaysBetweenDisbursalAndFirstRepayment(), calendar);
    }

    /*
     * If it is JLG loan/Group Loan synched with a meeting, then make sure
     * first repayment falls on meeting date
     */
    final Long groupId = this.fromApiJsonHelper.extractLongNamed("groupId", element);
    Group group = null;
    if (groupId != null) {
        group = this.groupRepository.findOneWithNotFoundDetection(groupId);
    }

    Boolean isSkipMeetingOnFirstDay = false;
    Integer numberOfDays = 0;
    boolean isSkipRepaymentOnFirstMonthEnabled = configurationDomainService
            .isSkippingMeetingOnFirstDayOfMonthEnabled();
    if (isSkipRepaymentOnFirstMonthEnabled) {
        isSkipMeetingOnFirstDay = this.loanUtilService.isLoanRepaymentsSyncWithMeeting(group, calendar);
        if (isSkipMeetingOnFirstDay) {
            numberOfDays = configurationDomainService.retreivePeroidInNumberOfDaysForSkipMeetingDate()
                    .intValue();
        }
    }
    if ((loanType.isJLGAccount() || loanType.isGroupAccount()) && calendar != null) {
        validateRepaymentsStartDateWithMeetingDates(calculatedRepaymentsStartingFromDate, calendar,
                isSkipMeetingOnFirstDay, numberOfDays);

        /*
         * If disbursement is synced on meeting, make sure disbursement date
         * is on a meeting date
         */
        if (synchDisbursement != null && synchDisbursement.booleanValue()) {
            validateDisbursementDateWithMeetingDates(expectedDisbursementDate, calendar,
                    isSkipMeetingOnFirstDay, numberOfDays);
        }
    }

    validateMinimumDaysBetweenDisbursalAndFirstRepayment(expectedDisbursementDate,
            calculatedRepaymentsStartingFromDate,
            loanProduct.getMinimumDaysBetweenDisbursalAndFirstRepayment());

    // grace details
    final Integer graceOnPrincipalPayment = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("graceOnPrincipalPayment", element);
    final Integer recurringMoratoriumOnPrincipalPeriods = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("recurringMoratoriumOnPrincipalPeriods", element);
    final Integer graceOnInterestPayment = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("graceOnInterestPayment", element);
    final Integer graceOnInterestCharged = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed("graceOnInterestCharged", element);
    final LocalDate interestChargedFromDate = this.fromApiJsonHelper
            .extractLocalDateNamed("interestChargedFromDate", element);
    final Boolean isInterestChargedFromDateSameAsDisbursalDateEnabled = this.configurationDomainService
            .isInterestChargedFromDateSameAsDisbursementDate();

    final Integer graceOnArrearsAgeing = this.fromApiJsonHelper
            .extractIntegerWithLocaleNamed(LoanProductConstants.graceOnArrearsAgeingParameterName, element);

    // other
    final BigDecimal inArrearsTolerance = this.fromApiJsonHelper
            .extractBigDecimalWithLocaleNamed("inArrearsTolerance", element);
    final Money inArrearsToleranceMoney = Money.of(currency, inArrearsTolerance);

    final BigDecimal emiAmount = this.fromApiJsonHelper
            .extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element);
    final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper
            .extractBigDecimalWithLocaleNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element);

    final List<DisbursementData> disbursementDatas = fetchDisbursementData(element.getAsJsonObject());

    /**
     * Interest recalculation settings copy from product definition
     */
    final DaysInMonthType daysInMonthType = loanProduct.fetchDaysInMonthType();

    final DaysInYearType daysInYearType = loanProduct.fetchDaysInYearType();

    final boolean isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled();
    RecalculationFrequencyType recalculationFrequencyType = null;
    CalendarInstance restCalendarInstance = null;
    RecalculationFrequencyType compoundingFrequencyType = null;
    CalendarInstance compoundingCalendarInstance = null;
    InterestRecalculationCompoundingMethod compoundingMethod = null;
    boolean allowCompoundingOnEod = false;
    if (isInterestRecalculationEnabled) {
        LoanProductInterestRecalculationDetails loanProductInterestRecalculationDetails = loanProduct
                .getProductInterestRecalculationDetails();
        recalculationFrequencyType = loanProductInterestRecalculationDetails.getRestFrequencyType();
        Integer repeatsOnDay = null;
        Integer recalculationFrequencyNthDay = loanProductInterestRecalculationDetails.getRestFrequencyOnDay();
        if (recalculationFrequencyNthDay == null) {
            recalculationFrequencyNthDay = loanProductInterestRecalculationDetails.getRestFrequencyNthDay();
            repeatsOnDay = loanProductInterestRecalculationDetails.getRestFrequencyWeekday();
        }
        Integer frequency = loanProductInterestRecalculationDetails.getRestInterval();
        if (recalculationFrequencyType.isSameAsRepayment()) {
            restCalendarInstance = createCalendarForSameAsRepayment(repaymentEvery,
                    repaymentPeriodFrequencyType, expectedDisbursementDate);
        } else {
            LocalDate calendarStartDate = expectedDisbursementDate;
            restCalendarInstance = createInterestRecalculationCalendarInstance(calendarStartDate,
                    recalculationFrequencyType, frequency, recalculationFrequencyNthDay, repeatsOnDay);
        }
        compoundingMethod = InterestRecalculationCompoundingMethod
                .fromInt(loanProductInterestRecalculationDetails.getInterestRecalculationCompoundingMethod());
        if (compoundingMethod.isCompoundingEnabled()) {
            Integer compoundingRepeatsOnDay = null;
            Integer recalculationCompoundingFrequencyNthDay = loanProductInterestRecalculationDetails
                    .getCompoundingFrequencyOnDay();
            if (recalculationCompoundingFrequencyNthDay == null) {
                recalculationCompoundingFrequencyNthDay = loanProductInterestRecalculationDetails
                        .getCompoundingFrequencyNthDay();
                compoundingRepeatsOnDay = loanProductInterestRecalculationDetails
                        .getCompoundingFrequencyWeekday();
            }
            compoundingFrequencyType = loanProductInterestRecalculationDetails.getCompoundingFrequencyType();
            if (compoundingFrequencyType.isSameAsRepayment()) {
                compoundingCalendarInstance = createCalendarForSameAsRepayment(repaymentEvery,
                        repaymentPeriodFrequencyType, expectedDisbursementDate);
            } else {
                LocalDate calendarStartDate = expectedDisbursementDate;
                compoundingCalendarInstance = createInterestRecalculationCalendarInstance(calendarStartDate,
                        compoundingFrequencyType,
                        loanProductInterestRecalculationDetails.getCompoundingInterval(),
                        recalculationCompoundingFrequencyNthDay, compoundingRepeatsOnDay);
            }
            allowCompoundingOnEod = loanProductInterestRecalculationDetails.allowCompoundingOnEod();
        }
    }

    final BigDecimal principalThresholdForLastInstalment = loanProduct
            .getPrincipalThresholdForLastInstallment();

    final Integer installmentAmountInMultiplesOf = loanProduct.getInstallmentAmountInMultiplesOf();

    List<LoanTermVariationsData> loanTermVariations = new ArrayList<>();
    if (loanProduct.isLinkedToFloatingInterestRate()) {
        final BigDecimal interestRateDiff = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
                LoanApiConstants.interestRateDifferentialParameterName, element);
        final Boolean isFloatingInterestRate = this.fromApiJsonHelper
                .extractBooleanNamed(LoanApiConstants.isFloatingInterestRateParameterName, element);
        List<FloatingRatePeriodData> baseLendingRatePeriods = null;
        try {
            baseLendingRatePeriods = this.floatingRatesReadPlatformService.retrieveBaseLendingRate()
                    .getRatePeriods();
        } catch (final FloatingRateNotFoundException ex) {
            // Do not do anything
        }
        FloatingRateDTO floatingRateDTO = new FloatingRateDTO(isFloatingInterestRate, expectedDisbursementDate,
                interestRateDiff, baseLendingRatePeriods);
        Collection<FloatingRatePeriodData> applicableRates = loanProduct.fetchInterestRates(floatingRateDTO);

        LocalDate interestRateStartDate = DateUtils.getLocalDateOfTenant();
        final LocalDate dateValue = null;
        final boolean isSpecificToInstallment = false;
        for (FloatingRatePeriodData periodData : applicableRates) {
            LoanTermVariationsData loanTermVariation = new LoanTermVariationsData(
                    LoanEnumerations.loanvariationType(LoanTermVariationType.INTEREST_RATE),
                    periodData.getFromDateAsLocalDate(), periodData.getInterestRate(), dateValue,
                    isSpecificToInstallment);
            if (!interestRateStartDate.isBefore(periodData.getFromDateAsLocalDate())) {
                interestRateStartDate = periodData.getFromDateAsLocalDate();
                annualNominalInterestRate = periodData.getInterestRate();
            }
            loanTermVariations.add(loanTermVariation);
        }
    }

    final Long clientId = this.fromApiJsonHelper.extractLongNamed("clientId", element);
    Client client = null;
    Long officeId = null;
    if (clientId != null) {
        client = this.clientRepository.findOneWithNotFoundDetection(clientId);
        officeId = client.getOffice().getId();
    } else if (groupId != null) {
        group = this.groupRepository.findOneWithNotFoundDetection(groupId);
        officeId = group.getOffice().getId();
    }
    final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
    final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
            expectedDisbursementDate.toDate(), HolidayStatusType.ACTIVE.getValue());
    final WorkingDays workingDays = this.workingDaysRepository.findOne();
    HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
    return LoanApplicationTerms.assembleFrom(applicationCurrency, loanTermFrequency,
            loanTermPeriodFrequencyType, numberOfRepayments, repaymentEvery, repaymentPeriodFrequencyType,
            nthDay, weekDayType, amortizationMethod, interestMethod, interestRatePerPeriod,
            interestRatePeriodFrequencyType, annualNominalInterestRate, interestCalculationPeriodMethod,
            allowPartialPeriodInterestCalcualtion, principalMoney, expectedDisbursementDate,
            repaymentsStartingFromDate, calculatedRepaymentsStartingFromDate, graceOnPrincipalPayment,
            recurringMoratoriumOnPrincipalPeriods, graceOnInterestPayment, graceOnInterestCharged,
            interestChargedFromDate, inArrearsToleranceMoney, loanProduct.isMultiDisburseLoan(), emiAmount,
            disbursementDatas, maxOutstandingBalance, graceOnArrearsAgeing, daysInMonthType, daysInYearType,
            isInterestRecalculationEnabled, recalculationFrequencyType, restCalendarInstance, compoundingMethod,
            compoundingCalendarInstance, compoundingFrequencyType, principalThresholdForLastInstalment,
            installmentAmountInMultiplesOf, loanProduct.preCloseInterestCalculationStrategy(), calendar,
            BigDecimal.ZERO, loanTermVariations, isInterestChargedFromDateSameAsDisbursalDateEnabled,
            numberOfDays, isSkipMeetingOnFirstDay, detailDTO, allowCompoundingOnEod);
}