Package java.math

Examples of java.math.BigDecimal.negate()


        } 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


                                    txCtx.put("finAccountTransTypeId", "ADJUSTMENT");
                                    txCtx.put("finAccountId", finAccountId);
                                    txCtx.put("orderId", orderId);
                                    txCtx.put("orderItemSeqId", orderItemSeqId);
                                    txCtx.put("paymentId", paymentId);
                                    txCtx.put("amount", refAmt.negate());
                                    txCtx.put("partyId", finAccount.getString("ownerPartyId"));
                                    txCtx.put("userLogin", userLogin);

                                    Map txResp = dispatcher.runSync("createFinAccountTrans", txCtx);
                                    if (ServiceUtil.isError(txResp)) {
View Full Code Here

                    } 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

            for (int i = k; i < m; i++) {
                int scale = MatrixBigDecimal.GLOBAL_SCALE;
                s = s.add(QR[i][k].multiply(X[i][j]), new MathContext(scale));
            }
            int scale = Math.max(s.scale(), QR[k][k].scale());
            s = s.negate().divide(QR[k][k], scale, roundingMode);
            for (int i = k; i < m; i++) {
                int scale2 = MatrixBigDecimal.GLOBAL_SCALE;
                X[i][j] = X[i][j].add(s.multiply(QR[i][k], new MathContext(scale2)));
            }
         }
View Full Code Here

         }

         if (nrm.compareTo(BigDecimal.ZERO) != 0.0) {
            // Form k-th Householder vector.
            if (QR[k][k].compareTo(BigDecimal.ZERO) < 0) {
               nrm = nrm.negate();
            }
            for (int i = k; i < m; i++) {
                int scale = MatrixBigDecimal.GLOBAL_SCALE;
               QR[i][k] = QR[i][k].divide(nrm, scale, roundingMode);
            }
View Full Code Here

               for (int i = k; i < m; i++) {
                   int scale = MatrixBigDecimal.GLOBAL_SCALE;
                   s = s.add(QR[i][k].multiply(QR[i][j], new MathContext(scale)));
               }
               int scale = MatrixBigDecimal.GLOBAL_SCALE;
               s = s.negate().divide(QR[k][k], scale, roundingMode);
               for (int i = k; i < m; i++) {
                   int scale2 = MatrixBigDecimal.GLOBAL_SCALE;
                   QR[i][j] = QR[i][j].add(s.multiply(QR[i][k], new MathContext(scale2)));
               }
            }
View Full Code Here

                    bigDecimalResult = bigDecimalResult.divide(getBigDecimalMultiplier(), roundingMode);
                }
            }

            if (!status[STATUS_POSITIVE]) {
                bigDecimalResult = bigDecimalResult.negate();
            }
            return bigDecimalResult;
        } else {
            boolean gotDouble = true;
            boolean gotLongMinimum = false;
View Full Code Here

                    BigDecimal borrow =
                        buf[i].abs().divide(
                            FACTORS[i - 1],
                            BigDecimal.ROUND_UP);
                    if (buf[i].signum() > 0) {
                        borrow = borrow.negate();
                    }

                    // update values
                    buf[i - 1] = buf[i - 1].subtract(borrow);
                    buf[i] = buf[i].add(borrow.multiply(FACTORS[i - 1]));
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

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.