Example usage for java.math BigDecimal ONE

List of usage examples for java.math BigDecimal ONE

Introduction

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

Prototype

BigDecimal ONE

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

Click Source Link

Document

The value 1, with a scale of 0.

Usage

From source file:com.ugam.collage.plus.service.people_count.impl.PeopleAccountingServiceImpl.java

/**
 * @param yearId/*from   www .  ja  v a  2s .  com*/
 * @param monthId
 * @param costCentreId
 * @param empcntClientProjectDataVoList
 * @param empcntClientProjectDataList
 * @param employeeIdList
 * @param employeeMonthlyAssignmentCount
 */
private void defaultRule(Integer yearId, Integer monthId, String costCentreId,
        List<EmpcntClientProjectDataVo> empcntClientProjectDataVoList,
        List<EmpcntClientProjectData> empOpenCntClientProjectDataList,
        List<EmpcntClientProjectData> empCloseCntClientProjectDataList,
        List<EmpcntClientProjectData> empAverageCntClientProjectDataList, List<Integer> employeeIdList,
        EmployeeMonthlyAssignment employeeMonthlyAssignmentCount, Integer countTypeId,
        Map<String, EmployeePcTagsTeamStruct> employeePcTagsTeamStructMap) {

    long averageCount = 0;
    for (Integer i : employeeIdList) {
        logger.debug("defaultRule employeeId===>" + i);
    }

    // get the employee aligned project for opening count
    List<EmpClientProjectTeamStruct> empClientProjectTeamStructList = empClientProjectTeamStructDao
            .findByYearMonthTypeEmps(yearId, monthId, countTypeId, employeeIdList);

    // Get available project under billed project
    List<CollageProjectRevenue> collageProjectRevenueList = collageProjectRevenueDao.findByYearIdMonthId(yearId,
            monthId);

    // Get all revenue project ids
    Set<Integer> revenueProjects = new HashSet<Integer>();
    for (CollageProjectRevenue collageProjectRevenue : collageProjectRevenueList) {
        revenueProjects.add(collageProjectRevenue.getProjectMaster().getProjectId());
    }

    EmployeeMaster employee = employeeMonthlyAssignmentCount.getEmployeeMaster();
    TabMonth month = employeeMonthlyAssignmentCount.getTabMonth();
    TabYear year = employeeMonthlyAssignmentCount.getTabYear();
    CostCentre costCentre = employeeMonthlyAssignmentCount.getCostCentre();
    CountClassification countType = new CountClassification();
    countType.setId(countTypeId);

    BigDecimal allignedTimeZero = BigDecimal.ZERO;
    BigDecimal assistedTimeZero = BigDecimal.ZERO;
    BigDecimal apportionedTimeZero = BigDecimal.ZERO;
    BigDecimal allignedTimeOne = BigDecimal.ONE;
    BigDecimal apportionedTimeOne = BigDecimal.ONE;
    BigDecimal totalTimeOne = BigDecimal.ONE;
    if (empClientProjectTeamStructList.isEmpty()) {
        // logger.debug("Assigned count is zero===>");
        getZeroProjectsDetail(yearId, monthId, costCentreId, empOpenCntClientProjectDataList,
                empCloseCntClientProjectDataList, employee, month, year, costCentre, countType,
                allignedTimeZero, assistedTimeZero, apportionedTimeOne, totalTimeOne, countTypeId,
                employeePcTagsTeamStructMap);
    }

    // check for count ==1
    else if (empClientProjectTeamStructList.size() == 1) {
        // logger.debug("Assigned count is one===>");
        getSingleProjectDetail(empOpenCntClientProjectDataList, empCloseCntClientProjectDataList,
                empClientProjectTeamStructList, employee, month, year, costCentre, countType, allignedTimeZero,
                assistedTimeZero, apportionedTimeZero, allignedTimeOne, totalTimeOne, countTypeId,
                employeePcTagsTeamStructMap);

    }
    // check for count >1
    else if (empClientProjectTeamStructList.size() > 1) {
        // logger.debug("Assigned count is greater one===>");
        getMultipleProjectDetail(empOpenCntClientProjectDataList, empCloseCntClientProjectDataList,
                empClientProjectTeamStructList, employee, month, year, costCentre, countType, allignedTimeZero,
                assistedTimeZero, apportionedTimeZero, allignedTimeOne, totalTimeOne, countTypeId,
                employeePcTagsTeamStructMap);
    }
    // Validate result
    List<EmployeeSummaryCssplit> employeeSummaryCssplitList = employeeSummaryCssplitDao
            .findByYearIdMonthIdConstCentreId(yearId, monthId, costCentreId);
    // Validate opening count and closing count and generate Average list
    EmployeeSummaryCssplit employeeSummaryCssplit = employeeSummaryCssplitList.get(0);

}

From source file:com.lp.server.artikel.ejbfac.WebshopItemServiceEjb.java

private List<PriceInfo> calculatePricelistPrices(ArtikelDto itemDto, Integer preislisteIId,
        java.sql.Date normalizedSqlDate) throws RemoteException {
    List<PriceInfo> preisInfos = new ArrayList<PriceInfo>();

    Integer mwstsatzbezIId = itemDto.getMwstsatzbezIId();

    VkpfMengenstaffelDto[] staffelnDto = getVkPreisfindungFac()
            .vkpfMengenstaffelFindByArtikelIIdGueltigkeitsdatum(itemDto.getIId(), normalizedSqlDate,
                    preislisteIId, webClientDto);
    if (staffelnDto.length > 0) {
        for (VkpfMengenstaffelDto vkpfMengenstaffelDto : staffelnDto) {
            VkpreisfindungDto vkpreisfindungDto = getVkPreisfindungFac().verkaufspreisfindungWeb(
                    itemDto.getIId(), null, vkpfMengenstaffelDto.getNMenge(), normalizedSqlDate, preislisteIId,
                    mwstsatzbezIId, webClientDto.getSMandantenwaehrung(), webClientDto);
            BigDecimal price = getPriceFromPreisfindung(vkpreisfindungDto);
            preisInfos.add(new PriceInfo(null, preislisteIId, vkpfMengenstaffelDto.getNMenge(), price));
        }/*w w w .  j a v  a2 s.c om*/
    }

    VkpreisfindungDto vkpreisfindungDto = getVkPreisfindungFac().verkaufspreisfindungWeb(itemDto.getIId(), null,
            BigDecimal.ONE, normalizedSqlDate, preislisteIId, mwstsatzbezIId,
            webClientDto.getSMandantenwaehrung(), webClientDto);
    BigDecimal price = getPriceFromPreisfindung(vkpreisfindungDto);
    preisInfos.add(new PriceInfo(null, preislisteIId, BigDecimal.ONE, price));

    return preisInfos;
}

From source file:org.nd4j.linalg.util.BigDecimalMath.java

/**
 * The trigonometric tangent./* ww  w .  ja va 2  s  . c o m*/
 *
 * @param x the argument in radians.
 * @return the tan(x)
 */
static public BigDecimal tan(final BigDecimal x) {
    if (x.compareTo(BigDecimal.ZERO) == 0) {
        return BigDecimal.ZERO;
    } else if (x.compareTo(BigDecimal.ZERO) < 0) {
        return tan(x.negate()).negate();
    } else {
        /* reduce modulo pi
         */
        BigDecimal res = modpi(x);
        /* absolute error in the result is err(x)/cos^2(x) to lowest order
         */
        final double xDbl = res.doubleValue();
        final double xUlpDbl = x.ulp().doubleValue() / 2.;
        final double eps = xUlpDbl / 2. / Math.pow(Math.cos(xDbl), 2.);
        if (xDbl > 0.8) {
            /* tan(x) = 1/cot(x) */
            BigDecimal co = cot(x);
            MathContext mc = new MathContext(err2prec(1. / co.doubleValue(), eps));
            return BigDecimal.ONE.divide(co, mc);
        } else {
            final BigDecimal xhighpr = scalePrec(res, 2);
            final BigDecimal xhighprSq = multiplyRound(xhighpr, xhighpr);
            BigDecimal resul = xhighpr.plus();
            /* x^(2i+1) */
            BigDecimal xpowi = xhighpr;
            Bernoulli b = new Bernoulli();
            /* 2^(2i) */
            BigInteger fourn = new BigInteger("4");
            /* (2i)! */
            BigInteger fac = new BigInteger("2");
            for (int i = 2;; i++) {
                Rational f = b.at(2 * i).abs();
                fourn = fourn.shiftLeft(2);
                fac = fac.multiply(new BigInteger("" + (2 * i))).multiply(new BigInteger("" + (2 * i - 1)));
                f = f.multiply(fourn).multiply(fourn.subtract(BigInteger.ONE)).divide(fac);
                xpowi = multiplyRound(xpowi, xhighprSq);
                BigDecimal c = multiplyRound(xpowi, f);
                resul = resul.add(c);
                if (Math.abs(c.doubleValue()) < 0.1 * eps) {
                    break;
                }
            }
            MathContext mc = new MathContext(err2prec(resul.doubleValue(), eps));
            return resul.round(mc);
        }
    }
}

From source file:net.rptools.maptool.client.functions.InputFunction.java

@Override
public Object childEvaluate(Parser parser, String functionName, List<Object> parameters)
        throws EvaluationException, ParserException {
    // Extract the list of specifier strings from the parameters
    // "name | value | prompt | inputType | options"
    List<String> varStrings = new ArrayList<String>();
    for (Object param : parameters) {
        String paramStr = (String) param;
        if (StringUtils.isEmpty(paramStr)) {
            continue;
        }//from w w w. j a v a2 s  .  co m
        // Multiple vars can be packed into a string, separated by "##"
        List<String> substrings = new ArrayList<String>();
        StrListFunctions.parse(paramStr, substrings, "##");
        for (String varString : substrings) {
            if (StringUtils.isEmpty(paramStr)) {
                continue;
            }
            varStrings.add(varString);
        }
    }

    // Create VarSpec objects from each variable's specifier string
    List<VarSpec> varSpecs = new ArrayList<VarSpec>();
    for (String specifier : varStrings) {
        VarSpec vs;
        try {
            vs = new VarSpec(specifier);
        } catch (VarSpec.SpecifierException se) {
            throw new ParameterException(se.msg);
        } catch (InputType.OptionException oe) {
            throw new ParameterException(I18N.getText("macro.function.input.invalidOptionType", oe.key,
                    oe.value, oe.type, specifier));
        }
        varSpecs.add(vs);
    }

    // Check if any variables were defined
    if (varSpecs.isEmpty())
        return BigDecimal.ONE; // No work to do, so treat it as a successful invocation.

    // UI step 1 - First, see if a token is in context.
    VariableResolver varRes = parser.getVariableResolver();
    Token tokenInContext = null;
    if (varRes instanceof MapToolVariableResolver) {
        tokenInContext = ((MapToolVariableResolver) varRes).getTokenInContext();
    }
    String dialogTitle = "Input Values";
    if (tokenInContext != null) {
        String name = tokenInContext.getName(), gm_name = tokenInContext.getGMName();
        boolean isGM = MapTool.getPlayer().isGM();
        String extra = "";

        if (isGM && gm_name != null && gm_name.compareTo("") != 0)
            extra = " for " + gm_name;
        else if (name != null && name.compareTo("") != 0)
            extra = " for " + name;

        dialogTitle = dialogTitle + extra;
    }

    // UI step 2 - build the panel with the input fields
    InputPanel ip = new InputPanel(varSpecs);

    // Calculate the height
    // TODO: remove this workaround
    int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
    int maxHeight = screenHeight * 3 / 4;
    Dimension ipPreferredDim = ip.getPreferredSize();
    if (maxHeight < ipPreferredDim.height) {
        ip.modifyMaxHeightBy(maxHeight - ipPreferredDim.height);
    }

    // UI step 3 - show the dialog
    JOptionPane jop = new JOptionPane(ip, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    JDialog dlg = jop.createDialog(MapTool.getFrame(), dialogTitle);

    // Set up callbacks needed for desired runtime behavior
    dlg.addComponentListener(new FixupComponentAdapter(ip));

    dlg.setVisible(true);
    int dlgResult = JOptionPane.CLOSED_OPTION;
    try {
        dlgResult = (Integer) jop.getValue();
    } catch (NullPointerException npe) {
    }
    dlg.dispose();

    if (dlgResult == JOptionPane.CANCEL_OPTION || dlgResult == JOptionPane.CLOSED_OPTION)
        return BigDecimal.ZERO;

    // Finally, assign values from the dialog box to the variables
    for (ColumnPanel cp : ip.columnPanels) {
        List<VarSpec> panelVars = cp.varSpecs;
        List<JComponent> panelControls = cp.inputFields;
        int numPanelVars = panelVars.size();
        StringBuilder allAssignments = new StringBuilder(); // holds all values assigned in this tab

        for (int varCount = 0; varCount < numPanelVars; varCount++) {
            VarSpec vs = panelVars.get(varCount);
            JComponent comp = panelControls.get(varCount);
            String newValue = null;
            switch (vs.inputType) {
            case TEXT: {
                newValue = ((JTextField) comp).getText();
                break;
            }
            case LIST: {
                Integer index = ((JComboBox) comp).getSelectedIndex();
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case CHECK: {
                Integer value = ((JCheckBox) comp).isSelected() ? 1 : 0;
                newValue = value.toString();
                break;
            }
            case RADIO: {
                // This code assumes that the Box container returns components
                // in the same order that they were added.
                Component[] comps = ((Box) comp).getComponents();
                int componentCount = 0;
                Integer index = 0;
                for (Component c : comps) {
                    if (c instanceof JRadioButton) {
                        JRadioButton radio = (JRadioButton) c;
                        if (radio.isSelected())
                            index = componentCount;
                    }
                    componentCount++;
                }
                if (vs.optionValues.optionEquals("VALUE", "STRING")) {
                    newValue = vs.valueList.get(index);
                } else { // default is "NUMBER"
                    newValue = index.toString();
                }
                break;
            }
            case LABEL: {
                newValue = null;
                // The variable name is ignored and not set.
                break;
            }
            case PROPS: {
                // Read out and assign all the subvariables.
                // The overall return value is a property string (as in StrPropFunctions.java) with all the new settings.
                Component[] comps = ((JPanel) comp).getComponents();
                StringBuilder sb = new StringBuilder();
                int setVars = 0; // "NONE", no assignments made
                if (vs.optionValues.optionEquals("SETVARS", "SUFFIXED"))
                    setVars = 1;
                if (vs.optionValues.optionEquals("SETVARS", "UNSUFFIXED"))
                    setVars = 2;
                if (vs.optionValues.optionEquals("SETVARS", "TRUE"))
                    setVars = 2; // for backward compatibility
                for (int compCount = 0; compCount < comps.length; compCount += 2) {
                    String key = ((JLabel) comps[compCount]).getText().split("\\:")[0]; // strip trailing colon
                    String value = ((JTextField) comps[compCount + 1]).getText();
                    sb.append(key);
                    sb.append("=");
                    sb.append(value);
                    sb.append(" ; ");
                    switch (setVars) {
                    case 0:
                        // Do nothing
                        break;
                    case 1:
                        parser.setVariable(key + "_", value);
                        break;
                    case 2:
                        parser.setVariable(key, value);
                        break;
                    }
                }
                newValue = sb.toString();
                break;
            }
            default:
                // should never happen
                newValue = null;
                break;
            }
            // Set the variable to the value we got from the dialog box.
            if (newValue != null) {
                parser.setVariable(vs.name, newValue.trim());
                allAssignments.append(vs.name + "=" + newValue.trim() + " ## ");
            }
        }
        if (cp.tabVarSpec != null) {
            parser.setVariable(cp.tabVarSpec.name, allAssignments.toString());
        }
    }

    return BigDecimal.ONE; // success

    // for debugging:
    //return debugOutput(varSpecs);
}

From source file:de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartServiceTest.java

@Test
public void shouldEstimateTaxesWithCache() {
    given(commerceCartEstimateTaxesStrategy.estimateTaxes(cartModel, "11211", "US")).willReturn(BigDecimal.TEN);
    final CommerceOrderParameter orderParameter = new CommerceOrderParameter();
    orderParameter.setOrder(cartModel);//from ww  w  .j av  a2 s.  c  om
    orderParameter.setAdditionalValues(Arrays.asList("11211", "US"));

    given(commerceCartHashCalculationStrategy.buildHashForAbstractOrder(any(CommerceOrderParameter.class)))
            .willReturn("hash");
    final DefaultCommerceCartService.HashAndTaxEstimate hashAndTaxEstimate = new DefaultCommerceCartService.HashAndTaxEstimate(
            "hash", BigDecimal.ONE);
    given(sessionService.getAttribute(DefaultCommerceCartService.ESTIMATED_TAXES))
            .willReturn(hashAndTaxEstimate);
    final CommerceCartParameter parameter = new CommerceCartParameter();
    parameter.setEnableHooks(true);
    parameter.setCart(cartModel);
    parameter.setDeliveryZipCode("11211");
    parameter.setDeliveryCountryIso("US");
    final BigDecimal estimatedTaxes = commerceCartService.estimateTaxes(parameter).getTax();
    Assert.assertThat(estimatedTaxes, CoreMatchers.equalTo(BigDecimal.ONE));
}

From source file:org.libreplan.business.planner.entities.Task.java

private boolean advancePercentageIsOne() {
    return this.getAdvancePercentage().compareTo(BigDecimal.ONE) == 0;
}

From source file:org.openconcerto.sql.model.SQLTable.java

public final BigDecimal getOrderULP() {
    return BigDecimal.ONE.scaleByPowerOfTen(-this.getOrderDecimalDigits());
}

From source file:com.lp.server.artikel.ejbfac.WebshopItemServiceEjb.java

private List<PriceInfo> calculateKundeSokoPrices(List<Kundesoko> kundesokos, ArtikelDto itemDto,
        Integer preislisteIId, java.sql.Date normalizedSqlDate) throws RemoteException {

    List<PriceInfo> preisInfos = new ArrayList<PriceInfo>();

    for (Kundesoko kundesoko : kundesokos) {
        Integer kundeIId = kundesoko.getKundeIId();
        Integer mwstsatzbezIId = itemDto.getMwstsatzbezIId();
        if (mwstsatzbezIId == null) {
            KundeDto kundeDto = getKundeFac().kundeFindByPrimaryKey(kundeIId, webClientDto);
            mwstsatzbezIId = kundeDto.getMwstsatzbezIId();
        }//  w  w w  .  ja  v  a2  s .c o  m

        VkpfMengenstaffelDto[] staffelnDto = getVkPreisfindungFac()
                .vkpfMengenstaffelFindByArtikelIIdGueltigkeitsdatum(itemDto.getIId(), normalizedSqlDate,
                        preislisteIId, webClientDto);
        if (staffelnDto.length > 0) {
            for (VkpfMengenstaffelDto vkpfMengenstaffelDto : staffelnDto) {
                VkpreisfindungDto vkpreisfindungDto = getVkPreisfindungFac().verkaufspreisfindung(
                        itemDto.getIId(), kundeIId, vkpfMengenstaffelDto.getNMenge(), normalizedSqlDate,
                        preislisteIId, mwstsatzbezIId, webClientDto.getSMandantenwaehrung(), webClientDto);
                BigDecimal price = getPriceFromPreisfindung(vkpreisfindungDto);
                preisInfos.add(new PriceInfo(kundeIId, preislisteIId, vkpfMengenstaffelDto.getNMenge(), price));
            }
        }

        VkpreisfindungDto vkpreisfindungDto = getVkPreisfindungFac().verkaufspreisfindung(itemDto.getIId(),
                kundeIId, BigDecimal.ONE, normalizedSqlDate, preislisteIId, mwstsatzbezIId,
                webClientDto.getSMandantenwaehrung(), webClientDto);
        BigDecimal price = getPriceFromPreisfindung(vkpreisfindungDto);
        preisInfos.add(new PriceInfo(kundeIId, preislisteIId, BigDecimal.ONE, price));
    }

    return preisInfos;
}

From source file:de.hybris.platform.commerceservices.order.impl.DefaultCommerceCartServiceTest.java

@Test
public void shouldEstimateTaxesWithInvalidCache() {
    given(commerceCartEstimateTaxesStrategy.estimateTaxes(cartModel, "11211", "US")).willReturn(BigDecimal.TEN);
    given(commerceCartHashCalculationStrategy.buildHashForAbstractOrder(any(CommerceOrderParameter.class)))
            .willReturn("invalidhash");
    final DefaultCommerceCartService.HashAndTaxEstimate hashAndTaxEstimate = new DefaultCommerceCartService.HashAndTaxEstimate(
            "hash", BigDecimal.ONE);
    given(sessionService.getAttribute(DefaultCommerceCartService.ESTIMATED_TAXES))
            .willReturn(hashAndTaxEstimate);
    final CommerceCartParameter parameter = new CommerceCartParameter();
    parameter.setEnableHooks(true);//  w  w w  . j  a  v  a2  s  .com
    parameter.setCart(cartModel);
    parameter.setDeliveryZipCode("11211");
    parameter.setDeliveryCountryIso("US");
    final BigDecimal estimatedTaxes = commerceCartService.estimateTaxes(parameter).getTax();
    Assert.assertThat(estimatedTaxes, CoreMatchers.equalTo(BigDecimal.TEN));
}

From source file:org.finra.herd.dao.helper.EmrPricingHelperTest.java

@Test
public void testGetEmrClusterPricesWithinLowestCoreInstancePriceThresholdSinglePricing() throws Exception {
    List<EmrClusterPriceDto> pricingList = Arrays
            .asList(createSimpleEmrClusterPrice(AVAILABILITY_ZONE_1, BigDecimal.ONE));
    List<EmrClusterPriceDto> lowestCoreInstancePriceClusters = emrPricingHelper
            .getEmrClusterPricesWithinLowestCoreInstancePriceThreshold(pricingList, TEN_PERCENT);

    assertEquals(1, lowestCoreInstancePriceClusters.size());
    assertEquals(AVAILABILITY_ZONE_1, lowestCoreInstancePriceClusters.get(0).getAvailabilityZone());
}