Author: jleroux
Date: Tue Feb 24 07:00:52 2015
New Revision: 1661853

URL: http://svn.apache.org/r1661853
Log:
A patch from Pierre Smits for "Quote profit percentage is calculated wrong" 
https://issues.apache.org/jira/browse/OFBIZ-5858

When reviewing the profit page of a quote the profit percentage is calculated 
wrong. Instead of dividing the profit by the quote amount giving the margin, 
the quote amount is divided by the average cost (when provided). Thus giving 
the quote (amount) to cost ratio.

jleroux: there was an interesting discussion with Divesh Dutta who suggested to 
calculate the profit mark-up instead of the profit margin as done here.I agree 
we want the profit margin

Modified:
    
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy

Modified: 
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy?rev=1661853&r1=1661852&r2=1661853&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy
 (original)
+++ 
ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.groovy
 Tue Feb 24 07:00:52 2015
@@ -69,7 +69,7 @@ quoteItems.each { quoteItem ->
         Debug.logError("Problems getting the averageCost for quoteItem: " + 
quoteItem);
     }
     profit = unitPrice - averageCost;
-    percProfit = averageCost != 0 ? (unitPrice / averageCost) * 100.00 : 0.00;
+    percProfit = averageCost != 0 ? (profit / unitPrice) * 100.00 : 0.00;
     quoteItemAndCostInfo = new java.util.HashMap(quoteItem);
     quoteItemAndCostInfo.averageCost = averageCost;
     quoteItemAndCostInfo.profit = profit;
@@ -85,4 +85,4 @@ context.quoteItemAndCostInfos = quoteIte
 context.totalCost = totalCost;
 context.totalPrice = totalPrice;
 context.totalProfit = totalProfit;
-context.totalPercProfit = totalCost != 0 ? (totalPrice / totalCost) * 100.00: 
0.00;
+context.totalPercProfit = totalCost != 0 ? (totalProfit / totalPrice) * 
100.00: 0.00;


Reply via email to