Package java.math

Examples of java.math.BigDecimal.subtract()


                    acctgTransEntry = (GenericValue) acctgTransEntryItr.next();
                    debitCreditFlag = (String) acctgTransEntry.getString("debitCreditFlag");
                    if ("D".equalsIgnoreCase(debitCreditFlag)) {
                        amount = amount.add(acctgTransEntry.getBigDecimal("amount")); //for debit
                    } else {
                          amount = amount.subtract(acctgTransEntry.getBigDecimal("amount")); //for credit
                    }
                }
            }
            reconciledBalance = reconciledBalance.add(amount)//total balance per glAccountId
        } catch (GenericEntityException e) {
View Full Code Here


            }

            if (((Boolean) results.get("finished")).booleanValue()) finished += 1;
            if (((Boolean) results.get("errors")).booleanValue()) hadError += 1;
            if (results.get("messages") != null) messages.addAll((List) results.get("messages"));
            if (results.get("processAmount") != null) totalRemaining = totalRemaining.subtract(((BigDecimal) results.get("processAmount")));
        }

        Debug.logInfo("Finished with auth(s) checking results", module);

        // add messages to the result
View Full Code Here

                String parentProductId = cartItem.getParentProductId();
                if (!cartItem.getIsPromo() &&
                        (productIds.contains(cartItem.getProductId()) || (parentProductId != null && productIds.contains(parentProductId))) &&
                        (product == null || !"N".equals(product.getString("includeInPromotions")))) {
                    // reduce quantity still needed to qualify for promo (quantityNeeded)
                    quantityNeeded = quantityNeeded.subtract(cartItem.addPromoQuantityCandidateUse(quantityNeeded, productPromoCond, false));
                }
            }

            // if quantityNeeded > 0 then the promo condition failed, so remove candidate promo uses and increment the promoQuantityUsed to restore it
            if (quantityNeeded.compareTo(BigDecimal.ZERO) > 0) {
View Full Code Here

        }

        String itemStatus = orderItem.getString("statusId");
        BigDecimal orderQty = orderItem.getBigDecimal("quantity");
        if (orderItem.getBigDecimal("cancelQuantity") != null) {
            orderQty = orderQty.subtract(orderItem.getBigDecimal("cancelQuantity"));
        }

        // get the returnable quantity
        BigDecimal returnableQuantity = BigDecimal.ZERO;
        if (returnable && (itemStatus.equals("ITEM_APPROVED") || itemStatus.equals("ITEM_COMPLETED"))) {
View Full Code Here

                    case OPERATOR_ADD:
                        resultValue = resultValue.add(calcop.calcValue(methodContext, scale, roundingMode));
                        break;
                    case OPERATOR_SUBTRACT:
                    case OPERATOR_NEGATIVE:
                        resultValue = resultValue.subtract(calcop.calcValue(methodContext, scale, roundingMode));
                        break;
                    case OPERATOR_MULTIPLY:
                        resultValue = resultValue.multiply(calcop.calcValue(methodContext, scale, roundingMode));
                        break;
                    case OPERATOR_DIVIDE:
View Full Code Here

                size = toNum - fromNum + 1;
            } else if (from instanceof BigDecimal || to instanceof BigDecimal) {
                // let's fast calculate the size
                BigDecimal fromNum = new BigDecimal("" + from);
                BigDecimal toNum = new BigDecimal("" + to);
                BigInteger sizeNum = toNum.subtract(fromNum).add(new BigDecimal(1.0)).toBigInteger();
                size = sizeNum.intValue();
            } else {
                // let's lazily calculate the size
                size = 0;
                Comparable first = from;
View Full Code Here

        while (localIter.hasNext()) {
            ShoppingCartItem item = (ShoppingCartItem) localIter.next();

            if (quantityToKeep.compareTo(item.getQuantity()) >= 0) {
                // quantityToKeep sufficient to keep it all... just reduce quantityToKeep and move on
                quantityToKeep = quantityToKeep.subtract(item.getQuantity());
            } else {
                // there is more in this than we want to keep, so reduce the quantity, or remove altogether...
                if (quantityToKeep.compareTo(BigDecimal.ZERO) == 0) {
                    // nothing left to keep, just remove it...
                    quantityRemoved = quantityRemoved.add(item.getQuantity());
View Full Code Here

  BigDecimal maxDoubleThatWorks = new BigDecimal(maxAsDoubleString);
  // This loop will execute 1024 times
  while (!baseTypeUnsignedLong.isValueOK(maxDoubleThatWorks.doubleValue()))
  {
      assertFalse(baseTypeUnsignedLong.isValueOK(maxDoubleThatWorks.doubleValue()));
      maxDoubleThatWorks = maxDoubleThatWorks.subtract(BigDecimal.ONE);
  }
 
  // maxDoubleThatWorks now represents a BigDecimal whose doubleValue() will make isValueOK(double) true.
  // Just FYI, that's 18446744073709550591.0D. Hopefully all values < 18446744073709550591.0D
  // will also make isValueOK(double) true.
View Full Code Here

  long count = 0;
  BigDecimal bigDecimalToTest = maxDoubleThatWorks;
  while (baseTypeUnsignedLong.isValueOK(maxDoubleThatWorks.doubleValue()))
  {
      assertTrue(baseTypeUnsignedLong.isValueOK(bigDecimalToTest.doubleValue()));
      bigDecimalToTest = bigDecimalToTest.subtract(valToSubtract);
      count++;
      if (bigDecimalToTest.compareTo(BigDecimal.ZERO) < 0)
      {
    break;
      }
View Full Code Here

        double absDiff;
       
        BigDecimal absWeightThis = this.getAbsWeightMeasure();
        BigDecimal absWeightOther = other.getAbsWeightMeasure();
       
        absDiff = Math.abs(absWeightOther.subtract(absWeightThis).doubleValue());
       
        DiffMeasure measure = new DiffMeasure(
                neuroCountDiff,
                this.firstDiffDecimal(absWeightThis, absWeightOther),
                absDiff);
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.