Author: lektran
Date: Tue Jul 15 04:03:43 2008 New Revision: 676868 URL: http://svn.apache.org/viewvc?rev=676868&view=rev Log: A few more bsh -> groovy conversions Added: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy - copied, changed from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy - copied, changed from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy - copied, changed from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy - copied, changed from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh Removed: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh Modified: ofbiz/trunk/applications/order/widget/ordermgr/QuoteScreens.xml Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy (from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh&r1=676509&r2=676868&rev=676868&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy Tue Jul 15 04:03:43 2008 @@ -20,11 +20,11 @@ import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.party.contact.ContactHelper; -if (party != null) { +if (party) { address = EntityUtil.getFirst(ContactHelper.getContactMech(party, "GENERAL_LOCATION", "POSTAL_ADDRESS", false)); - if (address != null) { + if (address) { toPostalAddress = address.getRelatedOne("PostalAddress"); - context.put("toPostalAddress", toPostalAddress); + context.toPostalAddress = toPostalAddress; } } Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy (from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh&r1=676509&r2=676868&rev=676868&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy Tue Jul 15 04:03:43 2008 @@ -20,10 +20,10 @@ import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.party.contact.ContactHelper; -if (party != null) { +if (party) { emailAddress = EntityUtil.getFirst(ContactHelper.getContactMech(party, "PRIMARY_EMAIL", "EMAIL_ADDRESS", false)); - if (emailAddress != null) { - context.put("sendTo", emailAddress.getString("infoString")); + if (emailAddress) { + context.sendTo = emailAddress.infoString; } } Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy (from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh&r1=676509&r2=676868&rev=676868&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy Tue Jul 15 04:03:43 2008 @@ -20,55 +20,43 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.util.EntityUtil; -quoteCoefficientsIt = quoteCoefficients.iterator(); costMult = 0.0; -while (quoteCoefficientsIt.hasNext()) { - quoteCoefficient = quoteCoefficientsIt.next(); - value = quoteCoefficient.getDouble("coeffValue"); - if (value != null) { +quoteCoefficients.each { quoteCoefficient -> + value = quoteCoefficient.coeffValue; + if (value) { costMult += value; } } -double costToPriceMult = 1.0; +costToPriceMult = 1.0; if (costMult != 100) { costToPriceMult = 100 / (100 - costMult); } -double totalCost = 0.0; -double totalPrice = 0.0; -double totalCostMult = 0.0; -currency = quote.getString("currencyUomId"); -quoteItemAndCostInfos = new java.util.ArrayList(); -quoteItemsIt = quoteItems.iterator(); -while (quoteItemsIt.hasNext()) { - quoteItem = quoteItemsIt.next(); - double defaultQuoteUnitPrice = 0.0; - double averageCost = 0.0; - double unitPrice = 0.0; - double quantity = 1.0; - double selectedAmount = 1.0; - if (quoteItem.get("quantity") != null) { - quantity = (quoteItem.getDouble("quantity")).doubleValue(); +totalCost = 0.0; +totalPrice = 0.0; +totalCostMult = 0.0; +currency = quote.currencyUomId; +quoteItemAndCostInfos = []; +quoteItems.each { quoteItem -> + defaultQuoteUnitPrice = 0.0; + averageCost = 0.0; + unitPrice = 0.0; + quantity = 1.0; + selectedAmount = quoteItem.selectedAmount ?: 1.0; + if (quoteItem.quantity != null) { + quantity = quoteItem.quantity; } - if (quoteItem.get("selectedAmount") != null) { - selectedAmount = (quoteItem.getDouble("selectedAmount")).doubleValue(); - } - if (selectedAmount == 0.0) { - selectedAmount = 1.0; - } - if (quoteItem.get("quoteUnitPrice") != null) { - unitPrice = (quoteItem.getDouble("quoteUnitPrice")).doubleValue(); + if (quoteItem.quoteUnitPrice != null) { + unitPrice = quoteItem.quoteUnitPrice; } try { - if (currency != null && quoteItem.get("productId") != null) { - productPrices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", quoteItem.getString("productId"), - "currencyUomId", currency, - "productPriceTypeId", "AVERAGE_COST")); + if (currency && quoteItem.productId) { + productPrices = delegator.findByAnd("ProductPrice", [productId : quoteItem.productId, currencyUomId : currency, productPriceTypeId : "AVERAGE_COST"]); productPrices = EntityUtil.filterByDate(productPrices); productPrice = EntityUtil.getFirst(productPrices); - if (productPrice != null && productPrice.get("price") != null) { - averageCost = (productPrice.getDouble("price")).doubleValue(); + if (productPrice?.price != null) { + averageCost = productPrice.price; } } defaultQuoteUnitPrice = averageCost * costToPriceMult * selectedAmount; @@ -79,17 +67,17 @@ } quoteItemAndCostInfo = new java.util.HashMap(quoteItem); - quoteItemAndCostInfo.put("averageCost", averageCost); - quoteItemAndCostInfo.put("costToPriceMult", costToPriceMult); - quoteItemAndCostInfo.put("defaultQuoteUnitPrice", defaultQuoteUnitPrice); + quoteItemAndCostInfo.averageCost = averageCost; + quoteItemAndCostInfo.costToPriceMult = costToPriceMult; + quoteItemAndCostInfo.defaultQuoteUnitPrice = defaultQuoteUnitPrice; quoteItemAndCostInfos.add(quoteItemAndCostInfo); } -context.put("costMult", costMult); -context.put("costToPriceMult", costToPriceMult); -context.put("quoteItemAndCostInfos", quoteItemAndCostInfos); - -context.put("totalCost", totalCost); -context.put("totalPrice", totalPrice); -context.put("totalCostMult", (totalCost != 0? totalPrice / totalCost: 0)); +context.costMult = costMult; +context.costToPriceMult = costToPriceMult; +context.quoteItemAndCostInfos = quoteItemAndCostInfos; + +context.totalCost = totalCost; +context.totalPrice = totalPrice; +context.totalCostMult = (totalCost != 0 ? totalPrice / totalCost : 0); Copied: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy (from r676509, ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh) URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy?p2=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy&p1=ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh&r1=676509&r2=676868&rev=676868&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy Tue Jul 15 04:03:43 2008 @@ -23,63 +23,43 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.util.EntityUtil; -quoteCoefficientsIt = quoteCoefficients.iterator(); costMult = 0.0; -while (quoteCoefficientsIt.hasNext()) { - quoteCoefficient = quoteCoefficientsIt.next(); - value = quoteCoefficient.getDouble("coeffValue"); - if (value != null) { +quoteCoefficients.each { quoteCoefficient -> + value = quoteCoefficient.coeffValue; + if (value) { costMult += value; } } -double totalProfit = 0.0; -double costToPriceMult = 1.0; +totalProfit = 0.0; +costToPriceMult = 1.0; if (costMult != 100) { costToPriceMult = 100 / (100 - costMult); } -Timestamp issueDate = quote.getTimestamp("issueDate"); -if (issueDate == null) { - issueDate = UtilDateTime.nowTimestamp(); -} -double totalCost = 0.0; -double totalPrice = 0.0; -double totalCostMult = 0.0; -currency = quote.getString("currencyUomId"); -quoteItemAndCostInfos = new java.util.ArrayList(); -quoteItemsIt = quoteItems.iterator(); -while (quoteItemsIt.hasNext()) { - quoteItem = quoteItemsIt.next(); - double defaultQuoteUnitPrice = 0.0; - double averageCost = 0.0; - double unitPrice = 0.0; - double quantity = 1.0; - double profit = 0.0; - double percProfit = 0.0; - double selectedAmount = 1.0; - if (quoteItem.get("quantity") != null) { - quantity = (quoteItem.getDouble("quantity")).doubleValue(); - } - if (quoteItem.get("selectedAmount") != null) { - selectedAmount = (quoteItem.getDouble("selectedAmount")).doubleValue(); - } - if (selectedAmount == 0.0) { - selectedAmount = 1.0; - } - if (quoteItem.get("quoteUnitPrice") != null) { - unitPrice = (quoteItem.getDouble("quoteUnitPrice")).doubleValue(); - } +issueDate = quote.issueDate ?: nowTimestamp; +totalCost = 0.0; +totalPrice = 0.0; +totalCostMult = 0.0; +currency = quote.currencyUomId; +quoteItemAndCostInfos = []; +quoteItems.each { quoteItem -> + defaultQuoteUnitPrice = 0.0; + averageCost = 0.0; + unitPrice = quoteItem.quoteUnitPrice ?: 0.0; + quantity = quoteItem.quantity ?: 1.0; + selectedAmount = quoteItem.selectedAmount ?: 1.0; + profit = 0.0; + percProfit = 0.0; try { - if (currency != null && quoteItem.get("productId") != null) { - productPrices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", quoteItem.getString("productId"), - "currencyUomId", currency, - "productPriceTypeId", "AVERAGE_COST")); + if (currency && quoteItem.productId) { + productPrices = delegator.findByAnd("ProductPrice", [productId : quoteItem.productId, + currencyUomId : currency, + productPriceTypeId : "AVERAGE_COST"]); productPrices = EntityUtil.filterByDate(productPrices, issueDate); productPrice = EntityUtil.getFirst(productPrices); - if (productPrice != null && productPrice.get("price") != null) { - averageCost = (productPrice.getDouble("price")).doubleValue(); - averageCost = averageCost * selectedAmount; + if (productPrice?.price != null) { + averageCost = productPrice.price * selectedAmount; } } //defaultQuoteUnitPrice = averageCost * costToPriceMult * selectedAmount; @@ -89,21 +69,20 @@ Debug.logError("Problems getting the averageCost for quoteItem: " + quoteItem); } profit = unitPrice - averageCost; - percProfit = averageCost != 0? (unitPrice / averageCost) * 100.00: 0.00; + percProfit = averageCost != 0 ? (unitPrice / averageCost) * 100.00 : 0.00; quoteItemAndCostInfo = new java.util.HashMap(quoteItem); - quoteItemAndCostInfo.put("averageCost", averageCost); - quoteItemAndCostInfo.put("profit", profit); - quoteItemAndCostInfo.put("percProfit", percProfit); + quoteItemAndCostInfo.averageCost = averageCost; + quoteItemAndCostInfo.profit = profit; + quoteItemAndCostInfo.percProfit = percProfit; quoteItemAndCostInfos.add(quoteItemAndCostInfo); } totalProfit = totalPrice - totalCost; -context.put("costMult", costMult); -context.put("costToPriceMult", costToPriceMult); -context.put("quoteItemAndCostInfos", quoteItemAndCostInfos); - -context.put("totalCost", totalCost); -context.put("totalPrice", totalPrice); -context.put("totalProfit", totalProfit); -context.put("totalPercProfit", totalCost != 0? (totalPrice / totalCost) * 100.00: 0.00); - +context.costMult = costMult; +context.costToPriceMult = costToPriceMult; +context.quoteItemAndCostInfos = quoteItemAndCostInfos; + +context.totalCost = totalCost; +context.totalPrice = totalPrice; +context.totalProfit = totalProfit; +context.totalPercProfit = totalCost != 0 ? (totalPrice / totalCost) * 100.00: 0.00; Modified: ofbiz/trunk/applications/order/widget/ordermgr/QuoteScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/QuoteScreens.xml?rev=676868&r1=676867&r2=676868&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/QuoteScreens.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/QuoteScreens.xml Tue Jul 15 04:03:43 2008 @@ -161,7 +161,7 @@ <get-related value-name="quote" relation-name="QuoteItem" list-name="quoteItems" order-by-list-name="listOrderBy"/> <get-related value-name="quote" relation-name="QuoteAdjustment" list-name="quoteAdjustments"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/getPartyAddress.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyAddress.groovy"/> <!-- <get-related value-name="quote" relation-name="QuoteRole" list-name="quoteRoles"/> <get-related value-name="quote" relation-name="QuoteAttribute" list-name="quoteAttributes"/> @@ -567,7 +567,7 @@ </entity-and> <set from-field="quote.quoteId" field="quoteId"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/ManageQuotePrices.groovy"/> </actions> <widgets> <decorator-screen name="CommonQuotePriceDecorator" location="${parameters.mainDecoratorLocation}"> @@ -710,7 +710,7 @@ </entity-and> <set from-field="quote.quoteId" field="quoteId"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy"/> </actions> <widgets> <decorator-screen name="CommonQuotePriceDecorator" location="${parameters.mainDecoratorLocation}"> @@ -747,7 +747,7 @@ <set field="quoteId" from-field="parameters.quoteId"/> <entity-one entity-name="Quote" value-name="quote"/> <get-related-one value-name="quote" relation-name="Party" to-value-name="party"/> - <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/getPartyEmailAddress.bsh"/> + <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/GetPartyEmailAddress.groovy"/> </actions> <widgets> <decorator-screen name="CommonQuoteDecorator" location="${parameters.mainDecoratorLocation}"> |
Free forum by Nabble | Edit this page |