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.nkapps.billing.dao.OverpaymentDaoImpl.java

private void returnStateRevert(Session session, BankStatement bs, BigDecimal overpaymentSum,
        Long issuerSerialNumber, String issuerIp, LocalDateTime dateTime) throws Exception {
    if (!bs.getBankStatementPayments().isEmpty()) { // if bankstatement has payments
        String q = " SELECT p.id AS id, p.tin AS tin, p.paymentNum AS paymentNum, p.paymentDate AS paymentDate,"
                + "  p.paymentSum AS paymentSum, p.sourceCode AS sourceCode,"
                + " p.state AS state, p.tinDebtor as tinDebtor,p.claim as claim, p.issuerSerialNumber as issuerSerialNumber,"
                + " p.issuerIp as issuerIp,p.dateCreated AS dateCreated, p.dateUpdated as dateUpdated, "
                + " p.paymentSum - COALESCE((SELECT SUM(paidSum) FROM KeyPayment kp WHERE kp.payment = p),0) AS overSum "
                + " FROM Payment p JOIN p.bankStatementPayment bsp " + " WHERE p.claim = 0 "
                + " AND bsp.id.bankStatement = :bs" + " ORDER BY p.paymentDate, p.paymentNum ";
        Query query = session.createQuery(q);
        query.setParameter("bs", bs);
        query.setResultTransformer(Transformers.aliasToBean(Payment.class));
        List<Payment> paymentList = query.list();

        int listSize = paymentList.size();
        int currentIndex = 0;
        BigDecimal keyCost = new BigDecimal(bankStatementDao.getKeyCost());

        for (Payment payment : paymentList) {
            currentIndex++;/*from  ww  w . j  av a  2 s.com*/

            overpaymentSum = overpaymentSum.subtract(payment.getOverSum());

            if (currentIndex == listSize) {
                if (payment.getState() == 3) {
                    if (payment.getPaymentSum().compareTo(BigDecimal.ZERO) > 0) {
                        payment.setState((short) 2);
                    } else {
                        payment.setState((short) 1);
                    }
                }
                payment.setPaymentSum(payment.getPaymentSum().add(overpaymentSum));
                payment.setIssuerSerialNumber(issuerSerialNumber);
                payment.setIssuerIp(issuerIp);
                payment.setDateUpdated(dateTime);

                session.update(payment);

                overpaymentSum = BigDecimal.ZERO;

            } else {
                if (payment.getPaymentSum().compareTo(keyCost) < 0) {

                    BigDecimal paymentSum = payment.getPaymentSum();

                    if (overpaymentSum.add(paymentSum).compareTo(keyCost) <= 0) {
                        if (payment.getState() == 3) {
                            if (payment.getPaymentSum().compareTo(BigDecimal.ZERO) > 0) {
                                payment.setState((short) 2);
                            } else {
                                payment.setState((short) 1);
                            }
                        }
                        payment.setPaymentSum(overpaymentSum.add(paymentSum));
                        payment.setIssuerSerialNumber(issuerSerialNumber);
                        payment.setIssuerIp(issuerIp);
                        payment.setDateUpdated(dateTime);

                        session.update(payment);

                        overpaymentSum = BigDecimal.ZERO;
                    } else {
                        if (payment.getState() == 3) {
                            if (payment.getPaymentSum().compareTo(BigDecimal.ZERO) > 0) {
                                payment.setState((short) 2);
                            } else {
                                payment.setState((short) 1);
                            }
                        }
                        payment.setPaymentSum(keyCost);
                        payment.setIssuerSerialNumber(issuerSerialNumber);
                        payment.setIssuerIp(issuerIp);
                        payment.setDateUpdated(dateTime);

                        session.update(payment);

                        overpaymentSum = overpaymentSum.add(paymentSum).subtract(keyCost);
                    }
                }
            }

            if (overpaymentSum.compareTo(BigDecimal.ZERO) <= 0) {
                break;
            }
        }
    }
}

From source file:com.rcv.ResultsWriter.java

private void generateSummarySpreadsheet(Map<Integer, Map<String, BigDecimal>> roundTallies, String precinct,
        String outputPath) throws IOException {
    String csvPath = outputPath + ".csv";
    Logger.log(Level.INFO, "Generating summary spreadsheets: %s...", csvPath);

    // Get all candidates sorted by their first round tally. This determines the display order.
    // container for firstRoundTally
    Map<String, BigDecimal> firstRoundTally = roundTallies.get(1);
    // candidates sorted by first round tally
    List<String> sortedCandidates = sortCandidatesByTally(firstRoundTally);

    // totalActiveVotesPerRound is a map of round to total votes cast in each round
    Map<Integer, BigDecimal> totalActiveVotesPerRound = new HashMap<>();
    // round indexes over all rounds plus final results round
    for (int round = 1; round <= numRounds; round++) {
        // tally is map of candidate to tally for the current round
        Map<String, BigDecimal> tallies = roundTallies.get(round);
        // total will contain total votes for all candidates in this round
        // this is used for calculating other derived data
        BigDecimal total = BigDecimal.ZERO;
        // tally indexes over all tallies for the current round
        for (BigDecimal tally : tallies.values()) {
            total = total.add(tally);//from w w w.ja va 2s.co m
        }
        totalActiveVotesPerRound.put(round, total);
    }

    // csvPrinter will be used to write output to csv file
    CSVPrinter csvPrinter;
    try {
        BufferedWriter writer = Files.newBufferedWriter(Paths.get(csvPath));
        csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT);
    } catch (IOException exception) {
        Logger.log(Level.SEVERE, "Error creating CSV file: %s\n%s", csvPath, exception.toString());
        throw exception;
    }

    // print contest info
    addHeaderRows(csvPrinter, precinct);

    // add a row header for the round column labels
    csvPrinter.print("Rounds");
    // round indexes over all rounds
    for (int round = 1; round <= numRounds; round++) {
        // label string will have the actual text which goes in the cell
        String label = String.format("Round %d", round);
        // cell for round label
        csvPrinter.print(label);
    }
    csvPrinter.println();

    // actions don't make sense in individual precinct results
    if (precinct == null || precinct.isEmpty()) {
        addActionRows(csvPrinter);
    }

    final BigDecimal totalActiveVotesFirstRound = totalActiveVotesPerRound.get(1);

    // For each candidate: for each round: output total votes
    // candidate indexes over all candidates
    for (String candidate : sortedCandidates) {
        // show each candidate row with their totals for each round
        // text for the candidate name
        String candidateDisplayName = this.config.getNameForCandidateID(candidate);
        csvPrinter.print(candidateDisplayName);

        // round indexes over all rounds
        for (int round = 1; round <= numRounds; round++) {
            // vote tally this round
            BigDecimal thisRoundTally = roundTallies.get(round).get(candidate);
            // not all candidates may have a tally in every round
            if (thisRoundTally == null) {
                thisRoundTally = BigDecimal.ZERO;
            }
            // total votes cell
            csvPrinter.print(thisRoundTally.toString());
        }
        // advance to next line
        csvPrinter.println();
    }

    // row for the inactive CVR counts
    // inactive CVR header cell
    csvPrinter.print("Inactive ballots");

    // round indexes through all rounds
    for (int round = 1; round <= numRounds; round++) {
        // count of votes inactive this round
        BigDecimal thisRoundInactive = BigDecimal.ZERO;

        if (round > 1) {
            // Exhausted count is the difference between the total votes in round 1 and the total votes
            // in the current round.
            thisRoundInactive = totalActiveVotesFirstRound.subtract(totalActiveVotesPerRound.get(round))
                    .subtract(roundToResidualSurplus.get(round));
        }
        // total votes cell
        csvPrinter.print(thisRoundInactive.toString());
    }
    csvPrinter.println();

    // row for residual surplus (if needed)
    // We check if we accumulated any residual surplus over the course of the tabulation by testing
    // whether the value in the final round is positive.
    if (roundToResidualSurplus.get(numRounds).signum() == 1) {
        csvPrinter.print("Residual surplus");
        for (int round = 1; round <= numRounds; round++) {
            csvPrinter.print(roundToResidualSurplus.get(round).toString());
        }
        csvPrinter.println();
    }

    // write xls to disk
    try {
        // output stream is used to write data to disk
        csvPrinter.flush();
        csvPrinter.close();
    } catch (IOException exception) {
        Logger.log(Level.SEVERE, "Error saving file: %s\n%s", outputPath, exception.toString());
        throw exception;
    }
}

From source file:org.yes.cart.payment.impl.PayPalExpressCheckoutPaymentGatewayImpl.java

/**
 * Support for pp express checkout. In case if gateway not support this operation , return will be empty hashmap.
 *
 * All info about SetExpressCheckout see here:
 * https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout
 *
 * @param amount       amount/*from   w  w w . ja v a 2  s .  c  o  m*/
 * @param currencyCode currecny
 * @return map with auth token
 * @throws java.io.IOException in case of errors
 */
public Map<String, String> setExpressCheckoutMethod(final BigDecimal amount, final String currencyCode)
        throws IOException {

    Assert.notNull(amount, "Amount must be provided");
    Assert.isTrue(amount.compareTo(BigDecimal.ZERO) > 0, "Amount must be positive");
    Assert.notNull(currencyCode, "Currency code must be provided");

    final StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append(PP_EC_PAYMENTREQUEST_0_AMT);
    stringBuilder.append(EQ);
    stringBuilder.append(URLEncoder.encode("" + amount));
    stringBuilder.append(AND);

    stringBuilder.append(PP_EC_PAYMENTREQUEST_0_PAYMENTACTION);
    stringBuilder.append(EQ);
    stringBuilder.append("Sale");
    stringBuilder.append(AND);

    stringBuilder.append(PP_EC_RETURNURL);
    stringBuilder.append(EQ);
    stringBuilder.append(URLEncoder.encode(getParameterValue(PP_EC_RETURNURL)));
    stringBuilder.append(AND);

    stringBuilder.append(PP_EC_CANCELURL);
    stringBuilder.append(EQ);
    stringBuilder.append(URLEncoder.encode(getParameterValue(PP_EC_CANCELURL)));
    stringBuilder.append(AND);

    stringBuilder.append(PP_EC_NOSHIPPING);
    stringBuilder.append(EQ);
    stringBuilder.append("1");
    stringBuilder.append(AND);

    stringBuilder.append(PP_EC_PAYMENTREQUEST_0_CURRENCYCODE);
    stringBuilder.append(EQ);
    stringBuilder.append(currencyCode);

    return performHttpCall("SetExpressCheckout", stringBuilder.toString());
}

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

private SavingsAccountCharge(final SavingsAccount savingsAccount, final Charge chargeDefinition,
        final BigDecimal amount, final ChargeTimeType chargeTime, final ChargeCalculationType chargeCalculation,
        final LocalDate dueDate, final boolean status, MonthDay feeOnMonthDay, final Integer feeInterval) {

    this.savingsAccount = savingsAccount;
    this.charge = chargeDefinition;
    this.penaltyCharge = chargeDefinition.isPenalty();
    this.chargeTime = (chargeTime == null) ? chargeDefinition.getChargeTimeType() : chargeTime.getValue();

    if (isOnSpecifiedDueDate()) {
        if (dueDate == null) {
            final String defaultUserMessage = "Savings Account charge is missing due date.";
            throw new SavingsAccountChargeWithoutMandatoryFieldException("savingsaccount.charge",
                    dueAsOfDateParamName, defaultUserMessage, chargeDefinition.getId(),
                    chargeDefinition.getName());
        }/* w  w w.j  av a 2 s .  co m*/

    }

    if (isAnnualFee() || isMonthlyFee()) {
        feeOnMonthDay = (feeOnMonthDay == null) ? chargeDefinition.getFeeOnMonthDay() : feeOnMonthDay;
        if (feeOnMonthDay == null) {
            final String defaultUserMessage = "Savings Account charge is missing due date.";
            throw new SavingsAccountChargeWithoutMandatoryFieldException("savingsaccount.charge",
                    dueAsOfDateParamName, defaultUserMessage, chargeDefinition.getId(),
                    chargeDefinition.getName());
        }

        this.feeOnMonth = feeOnMonthDay.getMonthOfYear();
        this.feeOnDay = feeOnMonthDay.getDayOfMonth();

    } else if (isWeeklyFee()) {
        if (dueDate == null) {
            final String defaultUserMessage = "Savings Account charge is missing due date.";
            throw new SavingsAccountChargeWithoutMandatoryFieldException("savingsaccount.charge",
                    dueAsOfDateParamName, defaultUserMessage, chargeDefinition.getId(),
                    chargeDefinition.getName());
        }
        /**
         * For Weekly fee feeOnDay is ISO standard day of the week.
         * Monday=1, Tuesday=2
         */
        this.feeOnDay = dueDate.getDayOfWeek();
    } else {
        this.feeOnDay = null;
        this.feeOnMonth = null;
        this.feeInterval = null;
    }

    if (isMonthlyFee() || isWeeklyFee()) {
        this.feeInterval = (feeInterval == null) ? chargeDefinition.feeInterval() : feeInterval;
    }

    this.dueDate = (dueDate == null) ? null : dueDate.toDate();

    this.chargeCalculation = chargeDefinition.getChargeCalculation();
    if (chargeCalculation != null) {
        this.chargeCalculation = chargeCalculation.getValue();
    }

    BigDecimal chargeAmount = chargeDefinition.getAmount();
    if (amount != null) {
        chargeAmount = amount;
    }

    final BigDecimal transactionAmount = new BigDecimal(0);

    populateDerivedFields(transactionAmount, chargeAmount);

    if (this.isWithdrawalFee() || this.isSavingsNoActivity()) {
        this.amountOutstanding = BigDecimal.ZERO;
    }

    this.paid = determineIfFullyPaid();
    this.status = status;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRBudget10V1_1Generator.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 RRBudget10.
 * /*from  ww  w .j av a2  s  .  co  m*/
 * @param budgetSummaryData
 *            (BudgetSummaryInfo) budget summary entry.
 * @return BudgetSummary details corresponding to the BudgetSummaryInfo
 *         object.
 */
private BudgetSummary getBudgetSummary(BudgetSummaryDto budgetSummaryData) {

    BudgetSummary budgetSummary = BudgetSummary.Factory.newInstance();
    OtherDirectCostInfoDto otherDirectCosts = null;
    if (budgetSummaryData != null) {
        if (budgetSummaryData.getOtherDirectCosts() != null
                && budgetSummaryData.getOtherDirectCosts().size() > 0) {
            otherDirectCosts = budgetSummaryData.getOtherDirectCosts().get(0);
        }
        if (otherDirectCosts != null) {

            budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(BigDecimal.ZERO);
            budgetSummary.setCumulativeTotalFundsRequestedPersonnel(BigDecimal.ZERO);

            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.setCumulativeTotalFundsRequestedEquipment(
                    budgetSummaryData.getCumEquipmentFunds().bigDecimalValue());
            budgetSummary
                    .setCumulativeTotalFundsRequestedTravel(budgetSummaryData.getCumTravel().bigDecimalValue());
            budgetSummary.setCumulativeDomesticTravelCosts(
                    budgetSummaryData.getCumDomesticTravel().bigDecimalValue());
            budgetSummary
                    .setCumulativeForeignTravelCosts(budgetSummaryData.getCumForeignTravel().bigDecimalValue());
            budgetSummary.setCumulativeTotalFundsRequestedTraineeCosts(budgetSummaryData.getpartOtherCost()
                    .add(budgetSummaryData.getpartStipendCost().add(budgetSummaryData.getpartTravelCost().add(
                            budgetSummaryData.getPartTuition().add(budgetSummaryData.getPartSubsistence()))))
                    .bigDecimalValue());
            budgetSummary.setCumulativeTraineeStipends(otherDirectCosts.getPartStipends().bigDecimalValue());
            budgetSummary
                    .setCumulativeTraineeSubsistence(otherDirectCosts.getPartSubsistence().bigDecimalValue());
            budgetSummary.setCumulativeTraineeTravel(otherDirectCosts.getPartTravel().bigDecimalValue());
            budgetSummary.setCumulativeTraineeTuitionFeesHealthInsurance(
                    otherDirectCosts.getPartTuition().bigDecimalValue());
            budgetSummary.setCumulativeOtherTraineeCost(budgetSummaryData.getpartOtherCost().bigDecimalValue());
            budgetSummary.setCumulativeNoofTrainees(budgetSummaryData.getparticipantCount());
            budgetSummary.setCumulativeTotalFundsRequestedOtherDirectCosts(
                    otherDirectCosts.gettotalOtherDirect().bigDecimalValue());
            budgetSummary.setCumulativeMaterialAndSupplies(otherDirectCosts.getmaterials().bigDecimalValue());
            budgetSummary.setCumulativePublicationCosts(otherDirectCosts.getpublications().bigDecimalValue());
            budgetSummary.setCumulativeConsultantServices(otherDirectCosts.getConsultants().bigDecimalValue());
            budgetSummary.setCumulativeADPComputerServices(otherDirectCosts.getcomputer().bigDecimalValue());
            budgetSummary.setCumulativeSubawardConsortiumContractualCosts(
                    otherDirectCosts.getsubAwards().bigDecimalValue());
            budgetSummary.setCumulativeEquipmentFacilityRentalFees(
                    otherDirectCosts.getEquipRental().bigDecimalValue());
            budgetSummary.setCumulativeAlterationsAndRenovations(
                    otherDirectCosts.getAlterations().bigDecimalValue());
            List<Map<String, String>> cvOthers = otherDirectCosts.getOtherCosts();
            for (int j = 0; j < cvOthers.size(); j++) {
                Map<String, String> hmCosts = cvOthers.get(j);
                if (j == 0) {
                    budgetSummary
                            .setCumulativeOther1DirectCost(new BigDecimal(hmCosts.get(CostConstants.KEY_COST)));
                } else if (j == 1) {
                    budgetSummary
                            .setCumulativeOther2DirectCost(new BigDecimal(hmCosts.get(CostConstants.KEY_COST)));
                } else {
                    budgetSummary
                            .setCumulativeOther3DirectCost(new BigDecimal(hmCosts.get(CostConstants.KEY_COST)));
                }
            }
            budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(
                    budgetSummaryData.getCumTotalDirectCosts().bigDecimalValue());
            budgetSummary.setCumulativeTotalFundsRequestedIndirectCost(
                    budgetSummaryData.getCumTotalIndirectCosts().bigDecimalValue());
            budgetSummary.setCumulativeTotalFundsRequestedDirectIndirectCosts(
                    budgetSummaryData.getCumTotalCosts().bigDecimalValue());
            if (budgetSummaryData.getCumFee() != null) {
                budgetSummary.setCumulativeFee(budgetSummaryData.getCumFee().bigDecimalValue());
            }
        }
    }
    return budgetSummary;
}

From source file:org.openvpms.archetype.rules.party.CustomerMergerTestCase.java

/**
 * Verifies that the 'to' customer includes the 'from' customer's balance
 * after the merge, and that any opening and closing balance acts on or
 * after the first transaction of the from customer are removed.
 *///from w  w  w  . j a v a 2 s  .c  om
@Test
public void testMergeAccounts() {
    final Money eighty = new Money(80);
    final Money forty = new Money(40);
    final Money fifty = new Money(50);
    final Money ninety = new Money(90);
    Party from = TestHelper.createCustomer();
    Party fromPatient = TestHelper.createPatient();
    Party to = TestHelper.createCustomer();
    Party toPatient = TestHelper.createPatient();
    Product product = TestHelper.createProduct();

    // add some transaction history for the 'from' customer
    Date firstStartTime = getDatetime("2007-01-02 10:0:0");
    addInvoice(firstStartTime, eighty, from, fromPatient, product);
    addPayment(getDatetime("2007-01-02 11:0:0"), forty, from);

    runEOP(from, getDate("2007-02-01"));

    // ... and the 'to' customer
    addInvoice(getDatetime("2007-01-01 10:0:0"), fifty, to, toPatient, product);
    runEOP(to, getDate("2007-01-01"));
    runEOP(to, getDate("2007-02-01"));

    // verify balances prior to merge
    assertEquals(0, forty.compareTo(customerAccountRules.getBalance(from)));
    assertEquals(0, fifty.compareTo(customerAccountRules.getBalance(to)));

    to = checkMerge(from, to);

    // verify balances after merge
    assertEquals(0, BigDecimal.ZERO.compareTo(customerAccountRules.getBalance(from)));
    assertEquals(0, ninety.compareTo(customerAccountRules.getBalance(to)));

    // now verify that the only opening and closing balance acts for the
    // to customer are prior to the first act of the from customer
    ArchetypeQuery query = CustomerAccountQueryFactory.createQuery(to, new String[] {
            CustomerAccountArchetypes.OPENING_BALANCE, CustomerAccountArchetypes.CLOSING_BALANCE });
    IMObjectQueryIterator<Act> iter = new IMObjectQueryIterator<Act>(query);
    int count = 0;
    while (iter.hasNext()) {
        Act act = iter.next();
        long startTime = act.getActivityStartTime().getTime();
        assertTrue(startTime < firstStartTime.getTime());
        ++count;
    }
    assertEquals(2, count); // expect a closing and opening balance

    // verify there are no acts associated with the removed 'from' customer
    assertEquals(0, countParticipations(from));
}

From source file:com.axelor.apps.account.service.payment.PayboxService.java

/**
 * Procdure permettant de vrifier que les champs de la saisie paiement necessaire  Paybox sont bien remplis
 * @param paymentVoucher//from   w ww. j  av a  2s .co m
 * @throws AxelorException
 */
public void checkPayboxPaymentVoucherFields(PaymentVoucher paymentVoucher) throws AxelorException {
    if (paymentVoucher.getPaidAmount() == null
            || paymentVoucher.getPaidAmount().compareTo(BigDecimal.ZERO) > 1) {
        throw new AxelorException(String.format(I18n.get(IExceptionMessage.PAYBOX_1),
                GeneralServiceImpl.EXCEPTION, paymentVoucher.getRef()), IException.CONFIGURATION_ERROR);
    }
}

From source file:com.sisrni.managedbean.BecaMB.java

public void inicializador() {
    //para el becario
    becario = new Persona();
    facultadSelectedBecario = new Facultad();
    telefonoFijoBecario = new Telefono();
    telefonoCelularBecario = new Telefono();
    carreraSelected = new Carrera();

    //para la beca
    beca = new Beca();
    beca.setMontoInterno(BigDecimal.ZERO);
    beca.setMontoInterno(BigDecimal.ZERO);
    beca.setMontoTotal(BigDecimal.ZERO);
    paisCooperanteSelected = new Pais();
    programaBecaSelected = new ProgramaBeca();
    paisDestinoSelected = new Pais();
    universidadSelected = new Organismo();
    tipoModalidaBecaSelected = new TipoModalidaBeca();
    tipoBecaSelected = new TipoBeca();
    tipoCambioSelected = new TipoCambio();
    yearActual = getYearOfDate(new Date());
    anio = "";//from   www. ja  va  2s.  com

    //para el referente interno
    asesorInterno = new Persona();
    facultadSelectedAsesorInterno = new Facultad();
    escuelaDeptoInterno = new EscuelaDepartamento();
    telefonoFijoAsesorInterno = new Telefono();
    telefonoCelularAsesorInterno = new Telefono();

    //para el asesor externo
    asesorExterno = new Persona();
    entidadInstitucionSelected = new Organismo();
    telefonoFijoAsesorExterno = new Telefono();
    telefonoCelularAsesorExterno = new Telefono();

    //para los listados
    facultadList = facultadService.getFacultadesByUniversidad(1);
    carreraList = new ArrayList<Carrera>();
    //        paisList = paisService.findAll();
    paisList = paisService.getCountriesOrderByNameAsc();
    programaBecaList = programaBecaService.findAll();
    universidadList = new ArrayList<Organismo>();
    tipoModalidadBecaList = tipoModalidadBecaService.findAll();
    unidadListAsesorInterno = unidadService.findAll();
    organismoList = organismoService.findAll();
    facultadesUnidadesList = getListFacultadesUnidades(facultadList, unidadListAsesorInterno);
    escuelaDepartamentoList = new ArrayList<EscuelaDepartamento>();
    organismoCooperanteSelected = new Organismo();
    tipoBecaList = tipoBecaService.findAll();
    tipoCambioList = tipoCambioService.findAll();

    mostrarmonto = true;

    //para buscar personas
    docBecarioSearch = "";
    docInternoSearch = "";
    docExternoSearch = "";
    existeBecario = false;
    existeInterno = false;
    existeExterno = false;

    //para listar becas
    becaTableList = becaService.getBecas(0);

    //inicializar bandera para actualizar
    actualizar = Boolean.FALSE;
    tabInternoBoolean = Boolean.FALSE;
    mostrarTabInterno = Boolean.FALSE;

    tabExternoBoolean = Boolean.FALSE;
    mostrarTabExterno = Boolean.FALSE;
    esFacultad = Boolean.FALSE;
    listAll = new ArrayList<Persona>();

    //variables de buscadores
    banderasBecarioFalsas();
    becarioAux = new Persona();

    disableBecarioInputs = Boolean.TRUE;
    disableInternoInputs = Boolean.TRUE;
    disableExternoInputs = Boolean.TRUE;

    renderNuevaPersonaBecarioButton = Boolean.FALSE;
    renderActualizarPersonaBecarioButton = Boolean.FALSE;
    renderNuevaPersonaInternaButton = Boolean.FALSE;
    renderActualizarPersonaInternaButton = Boolean.FALSE;
    renderNuevaPersonaExternaButton = Boolean.FALSE;
    renderActualizarPersonaExternaButton = Boolean.FALSE;

    presionoNuevoBecario = Boolean.FALSE;
    presionoActualizarBecario = Boolean.FALSE;
    presionoNuevoInterno = Boolean.FALSE;
    presionoActualizarInterno = Boolean.FALSE;
    presionoNuevoExterno = Boolean.FALSE;
    presionoActualizarExterno = Boolean.FALSE;

    remplazarBecario = Boolean.FALSE;
    remplazarInterno = Boolean.FALSE;
    remplazarExterno = Boolean.FALSE;

    desvinculoInterno = Boolean.FALSE;
    desvinculoExterno = Boolean.FALSE;
    //Mascara de telenonos de personas externas
    codigoPais = "";
    mascaraTelefono = "";
}

From source file:com.qcadoo.mes.materialRequirements.print.pdf.MaterialRequirementPdfService.java

private void addOrderSeries(final Document document, final Entity materialRequirement,
        final Map<String, HeaderAlignment> headersWithAlignments) throws DocumentException {
    List<Entity> orders = materialRequirement.getManyToManyField(MaterialRequirementFields.ORDERS);
    Collections.sort(orders, new EntityOrderNumberComparator());

    List<String> headers = Lists.newLinkedList(headersWithAlignments.keySet());
    PdfPTable table = pdfHelper.createTableWithHeader(headersWithAlignments.size(), headers, true,
            defaultMatReqHeaderColumnWidth, headersWithAlignments);

    for (Entity order : orders) {
        table.addCell(new Phrase(order.getStringField(OrderFields.NUMBER), FontUtils.getDejavuRegular7Dark()));
        table.addCell(new Phrase(order.getStringField(OrderFields.NAME), FontUtils.getDejavuRegular7Dark()));
        Entity product = (Entity) order.getField(OrderFields.PRODUCT);
        if (product == null) {
            table.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark()));
            BigDecimal plannedQuantity = order.getDecimalField(OrderFields.PLANNED_QUANTITY);
            plannedQuantity = (plannedQuantity == null) ? BigDecimal.ZERO : plannedQuantity;
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(new Phrase(numberService.format(plannedQuantity), FontUtils.getDejavuRegular7Dark()));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark()));
        } else {/*from ww w  . j  a  v  a 2s. c  o m*/
            table.addCell(
                    new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark()));
            BigDecimal plannedQuantity = order.getDecimalField(OrderFields.PLANNED_QUANTITY);
            plannedQuantity = (plannedQuantity == null) ? BigDecimal.ZERO : plannedQuantity;
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(new Phrase(numberService.format(plannedQuantity), FontUtils.getDejavuRegular7Dark()));
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            String unit = product.getStringField(ProductFields.UNIT);
            if (unit == null) {
                table.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark()));
            } else {
                table.addCell(new Phrase(unit, FontUtils.getDejavuRegular7Dark()));
            }
        }

    }
    document.add(table);
}

From source file:net.sourceforge.fenixedu.domain.Shift.java

public BigDecimal getUnitHours() {
    BigDecimal hours = BigDecimal.ZERO;
    Collection<Lesson> lessons = getAssociatedLessonsSet();
    for (Lesson lesson : lessons) {
        hours = hours.add(lesson.getUnitHours());
    }/*from   ww w .  j a  v a  2s  .co  m*/
    return hours;
}