Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Some more double -> BigDecimal conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
lektran committed Jan 4, 2009
1 parent 4ac904b commit 5e990d9
Show file tree
Hide file tree
Showing 45 changed files with 606 additions and 551 deletions.
Expand Up @@ -83,8 +83,8 @@ under the License.
<set field="showCredit" value="${bsh:(postedBalance &gt;= 0 &amp;&amp; org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)) || (postedBalance &lt; 0 &amp;&amp; org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount))}" type="Boolean"/>
<set field="absolutePostedBalance" value="${bsh:(postedBalance.abs())}" type="BigDecimal"/>
<set field="showTotals" value="${bsh:(isLastRow != null &amp;&amp; isLastRow==true)}" type="Boolean"/>
<set field="debitTotal" from-field="parameters.debitTotal" type="Double"/>
<set field="creditTotal" from-field="parameters.creditTotal" type="Double"/>
<set field="debitTotal" from-field="parameters.debitTotal" type="BigDecimal"/>
<set field="creditTotal" from-field="parameters.creditTotal" type="BigDecimal"/>
<set field="parameters.debitTotal" value="${bsh:(showDebit? (debitTotal.add(absolutePostedBalance)): (debitTotal))}" type="BigDecimal"/>
<set field="parameters.creditTotal" value="${bsh:(showCredit? (creditTotal.add(absolutePostedBalance)): (creditTotal))}" type="BigDecimal"/>
</row-actions>
Expand Down
Expand Up @@ -982,18 +982,15 @@
<log level="info" message="textDataLen:${textDataLen}"/>
<property-to-field resource="forum" property="descriptLen" field-name="descriptLen" />
<log level="info" message="descriptLen:${descriptLen}"/>
<set field="dblTextDataLen" from-field="textDataLen" type="Double"/>
<set field="dblDescriptLen" from-field="descriptLen" type="Double"/>
<call-class-method method-name="min" class-name="java.lang.Math" ret-field-name="subStringLen">
<field field-name="dblTextDataLen" type="double"/>
<field field-name="dblDescriptLen" type="double"/>
<field field-name="textDataLen" type="int"/>
<field field-name="descriptLen" type="int"/>
</call-class-method>
<set field="intSubStringLen" from-field="subStringLen" type="Integer"/>
<log level="info" message="subStringLen:${subStringLen}"/>
<set field="zeroValue" value="0" type="Integer"/>
<call-object-method method-name="substring" obj-field-name="parameters.textData" ret-field-name="subDescript">
<field field-name="zeroValue" type="int"/>
<field field-name="intSubStringLen" type="int"/>
<field field-name="subStringLen" type="int"/>
</call-object-method>
<log level="info" message="subDescript:${subDescript}"/>
<if-compare operator="equals" field="contentAssocTypeId" value="PUBLISH_LINK">
Expand Down
Expand Up @@ -1112,18 +1112,18 @@ under the License.

<call-bsh><![CDATA[
Map shipCost = org.ofbiz.order.shoppingcart.shipping.ShippingEvents.getShipGroupEstimate(dispatcher, delegator, shoppingCart, 0);
Double shippingTotal = (Double) shipCost.get("shippingTotal");
shippingTotal = shipCost.get("shippingTotal");
if (shippingTotal == null) {
shippingTotal = new Double(0.00);
shippingTotal = 0.00;
}
shoppingCart.setItemShipGroupEstimate(shippingTotal.doubleValue(), 0);
parameters.put("shippingTotal", org.ofbiz.base.util.UtilFormatOut.formatCurrency(shippingTotal.doubleValue(), isoCode, locale));
shoppingCart.setItemShipGroupEstimate(shippingTotal, 0);
parameters.put("shippingTotal", org.ofbiz.base.util.UtilFormatOut.formatCurrency(shippingTotal, isoCode, locale));
checkOutHelper = new org.ofbiz.order.shoppingcart.CheckOutHelper(dispatcher, delegator, shoppingCart);
// Calculate and add the tax adjustments
checkOutHelper.calcAndAddTax();
double salesTax = shoppingCart.getTotalSalesTax();
salesTax = shoppingCart.getTotalSalesTax();
totalSalesTax = org.ofbiz.base.util.UtilFormatOut.formatCurrency(salesTax, isoCode, locale);
parameters.put("totalSalesTax", totalSalesTax);
Expand Down
Expand Up @@ -103,7 +103,7 @@ orh = new OrderReadHelper(orderAdjustments, orderItems);
context.localOrderReadHelper = orh;
context.orderShippingTotal = cart.getTotalShipping();
context.orderTaxTotal = cart.getTotalSalesTax();
context.orderGrandTotal = new Double(cart.getGrandTotal());
context.orderGrandTotal = cart.getGrandTotal();

// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_");
Expand Up @@ -233,13 +233,13 @@ function getConfigDetails(event) {
<#if totalPrice?exists>
<div>${uiLabelMap.ProductAggregatedPrice}: <span id='totalPrice' class='basePrice'><@ofbizCurrency amount=totalPrice isoCode=totalPrice.currencyUsed/></span></div>
<#else>
<#if price.competitivePrice?exists && price.price?exists && price.price?double < price.competitivePrice?double>
<#if price.competitivePrice?exists && price.price?exists && price.price < price.competitivePrice>
<div>${uiLabelMap.ProductCompareAtPrice}: <span class='basePrice'><@ofbizCurrency amount=price.competitivePrice isoCode=price.currencyUsed/></span></div>
</#if>
<#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double>
<#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
<div>${uiLabelMap.ProductListPrice}: <span class='basePrice'><@ofbizCurrency amount=price.listPrice isoCode=price.currencyUsed/></span></div>
</#if>
<#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price?double < price.defaultPrice?double && price.defaultPrice?double < price.listPrice?double>
<#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price < price.defaultPrice && price.defaultPrice < price.listPrice>
<div>${uiLabelMap.ProductRegularPrice}: <span class='basePrice'><@ofbizCurrency amount=price.defaultPrice isoCode=price.currencyUsed/></span></div>
</#if>
<div>
Expand All @@ -253,15 +253,15 @@ function getConfigDetails(event) {
${uiLabelMap.OrderYourPrice}: <#if "Y" = product.isVirtual?if_exists> from </#if><span class='${priceStyle}'><@ofbizCurrency amount=price.price isoCode=price.currencyUsed/></span>
</b>
</div>
<#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double>
<#assign priceSaved = price.listPrice?double - price.price?double>
<#assign percentSaved = (priceSaved?double / price.listPrice?double) * 100>
<#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
<#assign priceSaved = price.listPrice - price.price>
<#assign percentSaved = (priceSaved / price.listPrice) * 100>
<div>${uiLabelMap.OrderSave}: <span class="basePrice"><@ofbizCurrency amount=priceSaved isoCode=price.currencyUsed/> (${percentSaved?int}%)</span></div>
</#if>
</#if>
<#-- Included quantities/pieces -->
<#if product.quantityIncluded?exists && product.quantityIncluded?double != 0>
<#if product.quantityIncluded?exists && product.quantityIncluded != 0>
<div>${uiLabelMap.OrderIncludes}:
${product.quantityIncluded?if_exists}
${product.quantityUomId?if_exists}
Expand Down Expand Up @@ -610,7 +610,7 @@ function getConfigDetails(event) {
<tr>
<td colspan="2">
<div>${uiLabelMap.OrderCustomerReviews}:</div>
<#if averageRating?exists && (averageRating?double > 0) && numRatings?exists && (numRatings?double > 1)>
<#if averageRating?exists && (averageRating > 0) && numRatings?exists && (numRatings > 1)>
<div>${uiLabelMap.OrderAverageRating}: ${averageRating} <#if numRatings?exists>(${uiLabelMap.CommonFrom} ${numRatings} ${uiLabelMap.OrderRatings})</#if></div>
</#if>
</td>
Expand Down
26 changes: 13 additions & 13 deletions applications/ecommerce/webapp/ecommerce/catalog/productdetail.ftl
Expand Up @@ -315,13 +315,13 @@ ${virtualJavaScript?if_exists}
- if price < defaultPrice and defaultPrice < listPrice, show default
- if isSale show price with salePrice style and print "On Sale!"
-->
<#if price.competitivePrice?exists && price.price?exists && price.price?double < price.competitivePrice?double>
<#if price.competitivePrice?exists && price.price?exists && price.price < price.competitivePrice>
<div>${uiLabelMap.ProductCompareAtPrice}: <span class="basePrice"><@ofbizCurrency amount=price.competitivePrice isoCode=price.currencyUsed/></span></div>
</#if>
<#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double>
<#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
<div>${uiLabelMap.ProductListPrice}: <span class="basePrice"><@ofbizCurrency amount=price.listPrice isoCode=price.currencyUsed/></span></div>
</#if>
<#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price?double < price.defaultPrice?double && price.defaultPrice?double < price.listPrice?double>
<#if price.listPrice?exists && price.defaultPrice?exists && price.price?exists && price.price < price.defaultPrice && price.defaultPrice < price.listPrice>
<div>${uiLabelMap.ProductRegularPrice}: <span class="basePrice"><@ofbizCurrency amount=price.defaultPrice isoCode=price.currencyUsed/></span></div>
</#if>
<#if price.specialPromoPrice?exists>
Expand All @@ -343,9 +343,9 @@ ${virtualJavaScript?if_exists}
</#if>
</b>
</div>
<#if price.listPrice?exists && price.price?exists && price.price?double < price.listPrice?double>
<#assign priceSaved = price.listPrice?double - price.price?double>
<#assign percentSaved = (priceSaved?double / price.listPrice?double) * 100>
<#if price.listPrice?exists && price.price?exists && price.price < price.listPrice>
<#assign priceSaved = price.listPrice - price.price>
<#assign percentSaved = (priceSaved / price.listPrice) * 100>
<div>${uiLabelMap.OrderSave}: <span class="basePrice"><@ofbizCurrency amount=priceSaved isoCode=price.currencyUsed/> (${percentSaved?int}%)</span></div>
</#if>
<#-- show price details ("showPriceDetails" field can be set in the screen definition) -->
Expand All @@ -363,32 +363,32 @@ ${virtualJavaScript?if_exists}
${uiLabelMap.OrderPieces}: ${product.piecesIncluded}
</div>
</#if>
<#if (product.quantityIncluded?exists && product.quantityIncluded?double != 0) || product.quantityUomId?has_content>
<#if (product.quantityIncluded?exists && product.quantityIncluded != 0) || product.quantityUomId?has_content>
<#assign quantityUom = product.getRelatedOneCache("QuantityUom")?if_exists/>
<div>
${uiLabelMap.CommonQuantity}: ${product.quantityIncluded?if_exists} ${((quantityUom.abbreviation)?default(product.quantityUomId))?if_exists}
</div>
</#if>
<#if (product.weight?exists && product.weight?double != 0) || product.weightUomId?has_content>
<#if (product.weight?exists && product.weight != 0) || product.weightUomId?has_content>
<#assign weightUom = product.getRelatedOneCache("WeightUom")?if_exists/>
<div>
${uiLabelMap.CommonWeight}: ${product.weight?if_exists} ${((weightUom.abbreviation)?default(product.weightUomId))?if_exists}
</div>
</#if>
<#if (product.productHeight?exists && product.productHeight?double != 0) || product.heightUomId?has_content>
<#if (product.productHeight?exists && product.productHeight != 0) || product.heightUomId?has_content>
<#assign heightUom = product.getRelatedOneCache("HeightUom")?if_exists/>
<div>
${uiLabelMap.CommonHeight}: ${product.productHeight?if_exists} ${((heightUom.abbreviation)?default(product.heightUomId))?if_exists}
</div>
</#if>
<#if (product.productWidth?exists && product.productWidth?double != 0) || product.widthUomId?has_content>
<#if (product.productWidth?exists && product.productWidth != 0) || product.widthUomId?has_content>
<#assign widthUom = product.getRelatedOneCache("WidthUom")?if_exists/>
<div>
${uiLabelMap.CommonWidth}: ${product.productWidth?if_exists} ${((widthUom.abbreviation)?default(product.widthUomId))?if_exists}
</div>
</#if>
<#if (product.productDepth?exists && product.productDepth?double != 0) || product.depthUomId?has_content>
<#if (product.productDepth?exists && product.productDepth != 0) || product.depthUomId?has_content>
<#assign depthUom = product.getRelatedOneCache("DepthUom")?if_exists/>
<div>
${uiLabelMap.CommonDepth}: ${product.productDepth?if_exists} ${((depthUom.abbreviation)?default(product.depthUomId))?if_exists}
Expand Down Expand Up @@ -474,7 +474,7 @@ ${virtualJavaScript?if_exists}
<#else>
<input type="hidden" name="product_id" value="${product.productId}"/>
<input type="hidden" name="add_product_id" value="${product.productId}"/>
<#assign isStoreInventoryNotAvailable = !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, product, 1.0?double))>
<#assign isStoreInventoryNotAvailable = !(Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryAvailable(request, product, 1.0))>
<#assign isStoreInventoryRequired = Static["org.ofbiz.product.store.ProductStoreWorker"].isStoreInventoryRequired(request, product)>
<#if isStoreInventoryNotAvailable>
<#if isStoreInventoryRequired>
Expand Down Expand Up @@ -618,7 +618,7 @@ ${virtualJavaScript?if_exists}
<#-- Product Reviews -->
<div id="reviews">
<div>${uiLabelMap.OrderCustomerReviews}:</div>
<#if averageRating?exists && (averageRating?double > 0) && numRatings?exists && (numRatings?double > 1)>
<#if averageRating?exists && (averageRating > 0) && numRatings?exists && (numRatings > 1)>
<div>${uiLabelMap.OrderAverageRating}: ${averageRating} <#if numRatings?exists>(${uiLabelMap.CommonFrom} ${numRatings} ${uiLabelMap.OrderRatings})</#if></div>
</#if>
<tr><td colspan="2"><hr/></td></tr>
Expand Down
4 changes: 2 additions & 2 deletions applications/ecommerce/webapp/ecommerce/forum/forumPaging.ftl
Expand Up @@ -25,8 +25,8 @@ under the License.
<#assign listSize = forumMessages?size/>
<#if highIndex gt listSize><#assign highIndex = listSize></#if>
<div class="product-prevnext">
<#assign r = listSize?double / viewSize?double />
<#assign viewIndexMax = Static["java.lang.Math"].ceil(r?double)>
<#assign r = listSize / viewSize />
<#assign viewIndexMax = Static["java.lang.Math"].ceil(r)>
<select name="pageSelect" class="selectBox" onchange="window.location=this[this.selectedIndex].value;">
<option value="#">${uiLabelMap.CommonPage} ${viewIndex?int+1} ${uiLabelMap.CommonOf} ${viewIndexMax}</option>
<#list 1..viewIndexMax as curViewNum>
Expand Down
3 changes: 2 additions & 1 deletion applications/ecommerce/webapp/ecommerce/makebogodata.jsp
Expand Up @@ -22,6 +22,7 @@ under the License.
<%@ page import="org.ofbiz.entity.*" %>
<%@ page import="org.ofbiz.base.util.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.math.BigDecimal" %>

<jsp:useBean id="delegator" type="org.ofbiz.entity.GenericDelegator" scope="request" />

Expand Down Expand Up @@ -59,7 +60,7 @@ under the License.
int wordNum = (int)(Math.random()*(longWordBag.length-1));
longDesc += (" " + longWordBag[wordNum]);
}
Double price = new Double(2.99 + prod);
BigDecimal price = new BigDecimal("2.99").add(BigDecimal.valueOf(prod));
GenericValue product = delegator.create("Product", UtilMisc.toMap("productId", "" + (cat*100 + prod), "primaryProductCategoryId", "" + (cat), "productName", "Product " + "" + (cat*100 + prod), "description", desc, "longDescription", longDesc, "defaultPrice", price));
KeywordIndex.indexKeywords(product);
delegator.create("ProductCategoryMember", UtilMisc.toMap("productId", "" + (cat*100 + prod), "productCategoryId", "" + (cat)));
Expand Down
Expand Up @@ -168,7 +168,7 @@ function submitForm(form, mode, value) {
<td>
&nbsp;
<span class="tabletext">
<b>${uiLabelMap.OrderBillUpTo}:</b> <input type="text" size="5" class="inputBox" name="amount_${paymentMethod.paymentMethodId}" value="<#if (cart.getPaymentAmount(paymentMethod.paymentMethodId)?default(0) > 0)>${cart.getPaymentAmount(paymentMethod.paymentMethodId)?double?string("##0.00")}</#if>">
<b>${uiLabelMap.OrderBillUpTo}:</b> <input type="text" size="5" class="inputBox" name="amount_${paymentMethod.paymentMethodId}" value="<#if (cart.getPaymentAmount(paymentMethod.paymentMethodId)?default(0) > 0)>${cart.getPaymentAmount(paymentMethod.paymentMethodId)?string("##0.00")}</#if>">
</span>
</td>
</tr>
Expand All @@ -191,7 +191,7 @@ function submitForm(form, mode, value) {
<td>
&nbsp;
<span class="tabletext">
<b>${uiLabelMap.OrderBillUpTo}:</b> <input type="text" size="5" class="inputBox" name="amount_${paymentMethod.paymentMethodId}" value="<#if (cart.getPaymentAmount(paymentMethod.paymentMethodId)?default(0) > 0)>${cart.getPaymentAmount(paymentMethod.paymentMethodId)?double?string("##0.00")}</#if>">
<b>${uiLabelMap.OrderBillUpTo}:</b> <input type="text" size="5" class="inputBox" name="amount_${paymentMethod.paymentMethodId}" value="<#if (cart.getPaymentAmount(paymentMethod.paymentMethodId)?default(0) > 0)>${cart.getPaymentAmount(paymentMethod.paymentMethodId)?string("##0.00")}</#if>">
</span>
</td>
</tr>
Expand Down Expand Up @@ -226,8 +226,8 @@ function submitForm(form, mode, value) {
<select name="billingAccountId">
<option value=""></option>
<#list billingAccountList as billingAccount>
<#assign availableAmount = billingAccount.accountBalance?double>
<#assign accountLimit = billingAccount.accountLimit?double>
<#assign availableAmount = billingAccount.accountBalance>
<#assign accountLimit = billingAccount.accountLimit>
<option value="${billingAccount.billingAccountId}" <#if billingAccount.billingAccountId == selectedBillingAccountId?default("")>selected</#if>>${billingAccount.description?default("")} [${billingAccount.billingAccountId}] Available: <@ofbizCurrency amount=availableAmount isoCode=billingAccount.accountCurrencyUomId/> Limit: <@ofbizCurrency amount=accountLimit isoCode=billingAccount.accountCurrencyUomId/></option>
</#list>
</select>
Expand Down

0 comments on commit 5e990d9

Please sign in to comment.