Package java.math

Examples of java.math.BigDecimal.abs()


                    // If the absolute invoiced amount >= the abs of the adjustment amount, the full amount has already been invoiced,
                    //  so skip this adjustment
                    if (adj.get("amount") == null) { // JLR 17/4/7 : fix a bug coming from POS in case of use of a discount (on item(s) or sale, item(s) here) and a cash amount higher than total (hence issuing change)
                        continue;
                    }
                    if (adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, ROUNDING).abs()) > 0) {
                        continue;
                    }

                    BigDecimal amount = ZERO;
                    if (adj.get("amount") != null) {
View Full Code Here


                // If the absolute invoiced amount >= the abs of the adjustment amount, the full amount has already been invoiced,
                //  so skip this adjustment
                if (null == adj.get("amount")) { // JLR 17/4/7 : fix a bug coming from POS in case of use of a discount (on item(s) or sale, sale here) and a cash amount higher than total (hence issuing change)
                    continue;
                }
                if (adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, ROUNDING).abs()) > 0) {
                    continue;
                }

                if ("SHIPPING_CHARGES".equals(adj.getString("orderAdjustmentTypeId"))) {
                    shipAdjustments.put(adj, adjAlreadyInvoicedAmount);
View Full Code Here

    {
      throw new EvaluationException(LibFormulaErrorValue.ERROR_INVALID_ARGUMENT_VALUE);
    }

    final BigDecimal num = NumberUtil.getAsBigDecimal(result);
    return new TypeValuePair(NumberType.GENERIC_NUMBER, num.abs());
  }

  public String getCanonicalName()
  {
    return "ABS";
View Full Code Here

        if ((returnAmountByOrder != null) && (returnAmountByOrder.keySet() != null)) {
            Iterator<String> orderIterator = returnAmountByOrder.keySet().iterator();
            while (orderIterator.hasNext()) {
                String orderId = orderIterator.next();
                BigDecimal returnAmount = returnAmountByOrder.get(orderId);
                if (returnAmount.abs().compareTo(new BigDecimal("0.000001")) < 0) {
                    Debug.logError("Order [" + orderId + "] refund amount[ " + returnAmount + "] less than zero", module);
                    return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,
                            "OrderReturnTotalCannotLessThanZero", locale));
                }
                OrderReadHelper helper = new OrderReadHelper(delegator, orderId);
View Full Code Here

   */
  public void testAbsNeg() {
    String a = "-123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "123809648392384754573567356745735635678902957849027687.87678287";
    assertEquals("incorrect value", result, aNumber.abs().toString());
  }

  /**
   * Abs() of a positive BigDecimal.
   */
 
View Full Code Here

   */
  public void testAbsPos() {
    String a = "123809648392384754573567356745735.63567890295784902768787678287E+21";
    BigDecimal aNumber = new BigDecimal(a);
    String result = "123809648392384754573567356745735635678902957849027687.87678287";
    assertEquals("incorrect value", result, aNumber.abs().toString());
  }

  /**
   * Compare to a number of an equal scale.
   */
 
View Full Code Here

  }

  private void assertEquals(BigDecimal expected, BigDecimal actual,
      double delta) {
    BigDecimal actualDeltaDecimal = actual.subtract(expected);
    double actualDelta = actualDeltaDecimal.abs().doubleValue();
    if (actualDelta >= delta) {
      fail("expected=" + expected + " actual=" + actual + " delta="
          + actualDelta);
    }
  }
View Full Code Here

        if ((returnAmountByOrder != null) && (returnAmountByOrder.keySet() != null)) {
            Iterator orderIterator = returnAmountByOrder.keySet().iterator();
            while (orderIterator.hasNext()) {
                String orderId = (String) orderIterator.next();
                BigDecimal returnAmount = (BigDecimal) returnAmountByOrder.get(orderId);
                if (returnAmount.abs().compareTo(new BigDecimal("0.000001")) < 0) {
                    Debug.logError("Order [" + orderId + "] refund amount[ " + returnAmount + "] less than zero", module);
                    return ServiceUtil.returnError(UtilProperties.getMessage(resource_error, "OrderReturnTotalCannotLessThanZero", locale));
                }
                OrderReadHelper helper = new OrderReadHelper(delegator, orderId);
                BigDecimal grandTotal = helper.getOrderGrandTotal();
View Full Code Here

            BigDecimal quantity = (BigDecimal)context.get("quantity");
            quantity = quantity == null ? BigDecimal.ONE : quantity;
            boolean negative = amount.signum() < 0;
            // Ensure that price and quantity are positive since the terms may not be linear.
            amount = amount.abs();
            quantity = quantity.abs();
            String productId = (String) context.get("productId");
            String invoiceItemTypeId = (String) context.get("invoiceItemTypeId");
           
            // Collect agreementItems applicable to this orderItem/returnItem
            // TODO: partyIds should be part of this query!
View Full Code Here

                        // If the absolute invoiced amount >= the abs of the adjustment amount, the full amount has already been invoiced,
                        //  so skip this adjustment
                        if (adj.get("amount") == null) { // JLR 17/4/7 : fix a bug coming from POS in case of use of a discount (on item(s) or sale, item(s) here) and a cash amount higher than total (hence issuing change)
                            continue;
                        }                       
                        if (adjAlreadyInvoicedAmount.abs().compareTo(adj.getBigDecimal("amount").setScale(invoiceTypeDecimals, rounding).abs()) > 0) {
                            continue;
                        }
       
                        BigDecimal amount = ZERO;
                        if (adj.get("amount") != null) {
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.