Package java.math

Examples of java.math.BigDecimal.divide()


                    if ("SALES_TAX".equals(taxAdjustment.getString("orderAdjustmentTypeId"))) {
                        taxPercentage = taxPercentage.add(taxAdjustment.getBigDecimal("sourcePercentage"));
                        BigDecimal adjAmount = taxAdjustment.getBigDecimal("amount");
                        taxTotal = taxTotal.add(adjAmount);
                        priceWithTax = priceWithTax.add(adjAmount.divide(quantity,salestaxCalcDecimals,salestaxRounding));
                        Debug.logInfo("For productId [" + productId + "] added [" + adjAmount.divide(quantity,salestaxCalcDecimals,salestaxRounding) + "] of tax to price for geoId [" + taxAdjustment.getString("taxAuthGeoId") + "], new price is [" + priceWithTax + "]", module);
                    }
                }
            }
        } catch (GenericEntityException e) {
            Debug.logError(e, "Data error getting tax settings: " + e.toString(), module);
View Full Code Here


                        break;
                    case OPERATOR_MULTIPLY:
                        resultValue = resultValue.multiply(calcop.calcValue(methodContext, scale, roundingMode));
                        break;
                    case OPERATOR_DIVIDE:
                        resultValue = resultValue.divide(calcop.calcValue(methodContext, scale, roundingMode), scale, roundingMode);
                        break;
                    }
                }
                // Debug.logInfo("sub total so far: " + resultValue, module);
            }
View Full Code Here

    ** calculated at bind time to be max(ls+rp-rs+1, 4), where ls,rp,rs
    ** are static data types' sizes, which are predictable and stable
    ** (for the whole result set column, eg.); otherwise dynamically
    ** calculates the scale according to actual values.  Beetle 3901
    */
    result.setBigDecimal(dividendBigDecimal.divide(
                  divisorBigDecimal,
                  scale > -1 ? scale :
                  Math.max((dividendBigDecimal.scale() +
                      SQLDecimal.getWholeDigits(divisorBigDecimal) +
                      1),
View Full Code Here

                    quoteUnitPrice = BigDecimal.ZERO;
                }
                if (amount.compareTo(BigDecimal.ZERO) > 0) {
                    // If, in the quote, an amount is set, we need to
                    // pass to the cart the quoteUnitPrice/amount value.
                    quoteUnitPrice = quoteUnitPrice.divide(amount, generalRounding);
                }

                //rental product data
                Timestamp reservStart = quoteItem.getTimestamp("reservStart");
                BigDecimal reservLength = quoteItem.getBigDecimal("reservLength");
View Full Code Here

                    BigDecimal usageCostAmount = ZERO;
                    if (usageCost != null) {
                        usageCostAmount = usageCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualMilliSeconds.doubleValue()));
                    }
                    BigDecimal fixedAssetCost = setupCostAmount.add(usageCostAmount).setScale(decimals, rounding);
                    fixedAssetCost = fixedAssetCost.divide(BigDecimal.valueOf(3600000), decimals, rounding);
                    // store the cost
                    Map<String, Object> inMap = UtilMisc.<String, Object>toMap("userLogin", userLogin,
                            "workEffortId", productionRunTaskId);
                    inMap.put("costComponentTypeId", "ACTUAL_ROUTE_COST");
                    inMap.put("costUomId", currencyUomId);
View Full Code Here

          nonNull = true;
        }
      }

      if (nonNull) {
        return totalWeight.divide(BigDecimal.valueOf(totalCount));
      } else {
        return null;
      }
    } else {
      throw new EvalException("Don't know how to aggregate with type: " + type);
View Full Code Here

            // Uses first four numbers to check if there is a pattern and to
            // calculate the gap between them. One missing value is allowed.
            if ( b.divide( a ).equals( c.divide( b ) ) ) {
                gap = b.divide( a );
            } else if ( c.divide( b ).equals( d.divide( c ) ) ) {
                gap = c.divide( b );
            } else if ( b.divide( a ).equals( d.divide( c ) ) ) {
                gap = b.divide( a );
            } else {
                // No pattern found.
View Full Code Here

            // calculate the gap between them. One missing value is allowed.
            if ( b.divide( a ).equals( c.divide( b ) ) ) {
                gap = b.divide( a );
            } else if ( c.divide( b ).equals( d.divide( c ) ) ) {
                gap = c.divide( b );
            } else if ( b.divide( a ).equals( d.divide( c ) ) ) {
                gap = b.divide( a );
            } else {
                // No pattern found.
                return null;
            }
View Full Code Here

            BigDecimal second = null;
            for ( int i = 0; i < (numbers.length - 1); i++ ) {
                first = numbers[i];
                second = numbers[i + 1];

                if ( missingNumber == null && !second.divide( first ).equals( gap ) ) {
                    missingNumber = first.multiply( gap );
                } else if ( !second.divide( first ).equals( gap ) && missingNumber != null ) {
                    // Happends if there is no pattern found, or more than 1
                    // missing number.
                    return null;
View Full Code Here

                first = numbers[i];
                second = numbers[i + 1];

                if ( missingNumber == null && !second.divide( first ).equals( gap ) ) {
                    missingNumber = first.multiply( gap );
                } else if ( !second.divide( first ).equals( gap ) && missingNumber != null ) {
                    // Happends if there is no pattern found, or more than 1
                    // missing number.
                    return 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.