Package java.math

Examples of java.math.BigDecimal.negate()


                    } else if (fieldObj instanceof String) {
                        resultValue = new BigDecimal((String) fieldObj);
                    } else if (fieldObj instanceof BigDecimal) {
                        resultValue = (BigDecimal) fieldObj;
                    }
                    if (operator == OPERATOR_NEGATIVE) resultValue = resultValue.negate();
                    isFirst = false;
                } else {
                    if (Debug.infoOn()) Debug.logInfo("Field not found with field-name " + fieldAcsr + ", and map-name " + mapAcsr + "using a default of 0", module);
                }
            }
View Full Code Here


            }

            for (SubCalc calcop: calcops) {
                if (isFirst) {
                    resultValue = calcop.calcValue(methodContext, scale, roundingMode);
                    if (operator == OPERATOR_NEGATIVE) resultValue = resultValue.negate();
                    isFirst = false;
                } else {
                    switch (operator) {
                    case OPERATOR_ADD:
                        resultValue = resultValue.add(calcop.calcValue(methodContext, scale, roundingMode));
View Full Code Here

                        String productId =  genericResult.getString("productId");
                        BigDecimal eventQuantityTmp = genericResult.getBigDecimal("quantity");
                        if (productId == null || eventQuantityTmp == null) {
                            continue;
                        }
                        eventQuantityTmp = eventQuantityTmp.negate();
                        parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", customTimePeriod.getDate("fromDate"), "mrpEventTypeId", "SALES_FORECAST");
                        try {
                            InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("salesForecastDetailId"), false, delegator);
                        } catch (GenericEntityException e) {
                            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap("mrpEventTypeId", "SALES_FORECAST"), locale));
View Full Code Here

                    parameters.put("mrpId", mrpId);
                    parameters.put("eventDate", eventDate);
                    parameters.put("mrpEventTypeId", "MRP_REQUIREMENT");
                    BigDecimal componentEventQuantity = node.getQuantity();
                    try {
                        InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), null, product.get("productId") + ": " + eventDate, false, delegator);
                    } catch (GenericEntityException e) {
                        Debug.logError("Error : findByPrimaryKey(\"MrpEvent\", parameters) ="+parameters+"--"+e.getMessage(), module);
                        logMrpError(mrpId, node.getProduct().getString("productId"), "Unable to create event (processBomComponent)", delegator);
                    }
                }
View Full Code Here

        try {
            BigDecimal percScrapFactor = node.getBigDecimal("scrapFactor");

            // A negative scrap factor is a salvage factor
            BigDecimal bdHundred = new BigDecimal("100");
            if (percScrapFactor.compareTo(bdHundred.negate()) > 0 && percScrapFactor.compareTo(bdHundred) < 0) {
                percScrapFactor = BigDecimal.ONE.add(percScrapFactor.movePointLeft(2));
            } else {
                Debug.logWarning("A scrap factor of [" + percScrapFactor + "] was ignored", module);
                percScrapFactor = BigDecimal.ONE;
            }
View Full Code Here

                    String direction = temp.toString().substring(4);
                    //Decimal Degrees = Degrees + minutes/60
                    BigDecimal convertedCoordinates = degrees.add(minutes.divide(sixty, new MathContext(5)));
                    //negate coordinate if it is -> South
                    if (direction.toLowerCase().equals("s")) {
                        convertedCoordinates.negate();
                    }
                    mainTable.setValueAt(convertedCoordinates, i, selectedColIndex);
                } else if (temp != null && temp.toString().length() == 7) {//latitude with seconds

                    //Uses BigDecimal in order to enabe control of precision after the .
View Full Code Here

                    //Decimal Degrees = Degrees + minutes/60
                    BigDecimal convertedCoordinates = degrees.add(minutes.add(seconds), new MathContext(5));

                    //negate coordinate if it is -> South
                    if (direction.toLowerCase().equals("s")) {
                        convertedCoordinates.negate();
                    }
                    mainTable.setValueAt(convertedCoordinates, i, selectedColIndex);
                } else {
                    statusBar.setMessage("Data in selected column does not seem to be of appropriate type.");
                    return;
View Full Code Here

                    //Decimal Degrees = Degrees + minutes/60
                    BigDecimal convertedCoordinates = degrees.add(minutes, new MathContext(5));

                    //negate coordinate if it is -> West
                    if (direction.toLowerCase().equals("w")) {
                        convertedCoordinates = convertedCoordinates.negate();
                    }
                    mainTable.setValueAt(convertedCoordinates, i, selectedColIndex);
                } else if (temp != null && temp.toString().length() == 8) {//Longitude with seconds
                    //Uses BigDecimal in order to enabe control of precision after the .
                    //and get precise coordinate value
View Full Code Here

                    //Decimal Degrees = Degrees + minutes/60 + seconds/3600
                    BigDecimal convertedCoordinates = degrees.add(minutes.add(seconds), new MathContext(5));

                    //negate coordinate if it is -> West
                    if (direction.toLowerCase().equals("w")) {
                        convertedCoordinates = convertedCoordinates.negate();
                    }
                    mainTable.setValueAt(convertedCoordinates, i, selectedColIndex);
                } else {
                    statusBar.setMessage("Data in selected column does not seem to be of appropriate type.");
                    return;
View Full Code Here

        } else if ("PROMO_ORDER_AMOUNT".equals(productPromoActionEnumId)) {
            BigDecimal amount = (productPromoAction.get("amount") == null ? BigDecimal.ZERO : productPromoAction.getBigDecimal("amount")).negate();
            // if amount is greater than the order sub total, set equal to order sub total, this normally wouldn't happen because there should be a condition that the order total be above a certain amount, but just in case...
            BigDecimal subTotal = cart.getSubTotalForPromotions();
            if (amount.negate().compareTo(subTotal) > 0) {
                amount = subTotal.negate();
            }
            if (amount.compareTo(BigDecimal.ZERO) != 0) {
                doOrderPromoAction(productPromoAction, cart, amount, "amount", delegator);
                actionResultInfo.ranAction = true;
                actionResultInfo.totalDiscountAmount = amount;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.