[OFBiz] SVN: r6017 - in trunk/applications/order: webapp/ordermgr/WEB-INF webapp/ordermgr/WEB-INF/actions/quote webapp/ordermgr/lookup webapp/ordermgr/quote webapp/ordermgr/request widget/ordermgr

jacopo at svn.ofbiz.org jacopo at svn.ofbiz.org
Tue Oct 25 03:03:54 EDT 2005


Author: jacopo
Date: 2005-10-25 02:03:32 -0500 (Tue, 25 Oct 2005)
New Revision: 6017

Added:
   trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh
   trunk/applications/order/webapp/ordermgr/quote/ViewQuoteProfit.ftl
Modified:
   trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
   trunk/applications/order/webapp/ordermgr/lookup/FieldLookupForms.xml
   trunk/applications/order/webapp/ordermgr/quote/QuoteForms.xml
   trunk/applications/order/webapp/ordermgr/quote/QuoteTabBar.ftl
   trunk/applications/order/webapp/ordermgr/request/RequestForms.xml
   trunk/applications/order/widget/ordermgr/QuoteScreens.xml
Log:
Added new quote screen page to show the real profit of a given quote: for every quote item, the average cost (valid when thew quote was issued), price and the margin (expressed as an amount and a perc) are shown.
Also the aggregate values are shown.
 

Added: trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh
===================================================================
--- trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh	2005-10-25 07:03:32 UTC (rev 6017)
@@ -0,0 +1,113 @@
+/*
+ *  Copyright (c) 2003-2005 The Open For Business Project - www.ofbiz.org
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included
+ *  in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *@author     Jacopo Cappellato (tiz at sastau.it)
+*/
+
+import java.util.Date;
+import java.sql.Timestamp;
+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) {
+        costMult += value;
+    }
+}
+double totalProfit = 0.0;
+double costToPriceMult = 1.0;
+if (costMult != 100) {
+    costToPriceMult = 100 / (100 - costMult);
+}
+
+Timestamp issueDate = quote.getTimestamp("issueDate");
+if (issueDate == null) {
+    issueDate = new Timestamp((new Date()).getTime());
+}
+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();
+    }
+
+    try {
+        if (currency != null && quoteItem.get("productId") != null) {
+            productPrices = delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", quoteItem.getString("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();
+            }
+        }
+        //defaultQuoteUnitPrice = averageCost * costToPriceMult * selectedAmount;
+        totalCost += (averageCost * quantity);
+        totalPrice += (unitPrice * quantity);
+    } catch(Exception exc) {
+        Debug.logError("Problems getting the averageCost for quoteItem: " + quoteItem);
+    }
+    profit = unitPrice - averageCost;
+    percProfit = averageCost != 0? (profit / averageCost) * 100.00: 0.00;
+    quoteItemAndCostInfo = new java.util.HashMap(quoteItem);
+    quoteItemAndCostInfo.put("averageCost", averageCost);
+    quoteItemAndCostInfo.put("profit", profit);
+    quoteItemAndCostInfo.put("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? (totalProfit / totalCost) * 100.00: 0.00);
+//context.put("totalCostMult", (totalCost != 0? totalPrice / totalCost: 0));
+


Property changes on: trunk/applications/order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + "Date Rev Author URL Id"
Name: svn:eol-style
   + native

Modified: trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
===================================================================
--- trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml	2005-10-25 07:03:32 UTC (rev 6017)
@@ -922,6 +922,7 @@
     <!-- =============== Quote mapping =================-->
     <request-map uri="FindQuote"><security https="true" auth="true"/><response name="success" type="view" value="FindQuote"/></request-map>
     <request-map uri="ViewQuote"><security https="true" auth="true"/><response name="success" type="view" value="ViewQuote"/></request-map>
+    <request-map uri="ViewQuoteProfit"><security https="true" auth="true"/><response name="success" type="view" value="ViewQuoteProfit"/></request-map>
 
     <request-map uri="EditQuote"><security https="true" auth="true"/><response name="success" type="view" value="EditQuote"/></request-map>
     <request-map uri="createQuote">
@@ -1203,6 +1204,7 @@
     <view-map name="ManageQuotePrices" type="screen" page="component://order/widget/ordermgr/QuoteScreens.xml#ManageQuotePrices"/>
     <view-map name="ListQuoteAdjustments" type="screen" page="component://order/widget/ordermgr/QuoteScreens.xml#ListQuoteAdjustments"/>
     <view-map name="EditQuoteAdjustment" type="screen" page="component://order/widget/ordermgr/QuoteScreens.xml#EditQuoteAdjustment"/>
+    <view-map name="ViewQuoteProfit" type="screen" page="component://order/widget/ordermgr/QuoteScreens.xml#ViewQuoteProfit"/>
 
     <view-map name="FindRequest" type="screen" page="component://order/widget/ordermgr/RequestScreens.xml#FindRequest"/>
     <view-map name="ViewRequest" type="screen" page="component://order/widget/ordermgr/RequestScreens.xml#ViewRequest"/>

Modified: trunk/applications/order/webapp/ordermgr/lookup/FieldLookupForms.xml
===================================================================
--- trunk/applications/order/webapp/ordermgr/lookup/FieldLookupForms.xml	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/lookup/FieldLookupForms.xml	2005-10-25 07:03:32 UTC (rev 6017)
@@ -306,7 +306,7 @@
                 </entity-options>
             </drop-down>
         </field>
-        <field name="productStoreId" title="${uiLabelMap.QuoteProductStoreId}">
+        <field name="productStoreId" title="${uiLabelMap.ProductProductStore}">
             <drop-down allow-empty="true">
                 <entity-options description="${storeName}" entity-name="ProductStore" key-field-name="productStoreId"/>
             </drop-down>

Modified: trunk/applications/order/webapp/ordermgr/quote/QuoteForms.xml
===================================================================
--- trunk/applications/order/webapp/ordermgr/quote/QuoteForms.xml	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/quote/QuoteForms.xml	2005-10-25 07:03:32 UTC (rev 6017)
@@ -57,6 +57,13 @@
         <field name="description"><hidden/></field>
         <field name="validFromDate"><hidden/></field>
         <field name="validThruDate"><hidden/></field>
+        <field name="productStoreId" title="${uiLabelMap.ProductProductStore}">
+            <drop-down allow-empty="true">
+                <entity-options description="${storeName}" entity-name="ProductStore" key-field-name="productStoreId">
+                    <entity-order-by field-name="storeName"/>
+                </entity-options>
+            </drop-down>
+        </field>
         <field name="submitButton" title="${uiLabelMap.CommonFind}" widget-style="smallSubmit">
             <submit button-type="button"/>
         </field>
@@ -106,7 +113,7 @@
                 </entity-options>
             </drop-down>
         </field>
-        <field name="productStoreId" title="${uiLabelMap.QuoteProductStoreId}">
+        <field name="productStoreId" title="${uiLabelMap.ProductProductStore}">
             <drop-down allow-empty="false">
                 <entity-options description="${storeName}" entity-name="ProductStore" key-field-name="productStoreId">
                     <entity-order-by field-name="storeName"/>
@@ -358,4 +365,24 @@
         </field>
         <field name="submitButton" title="Submit" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
+    <form name="ViewQuoteProfit" title="" type="list"
+            list-name="quoteItemAndCostInfos" target="" paginate-target="ViewQuoteProfit"
+            default-title-style="tableheadtext" default-tooltip-style="tabletext" default-widget-style="tabletext">
+        <field name="custRequestId" title="${uiLabelMap.OrderOrderQuoteViewRequest}" widget-style="buttontext">
+            <hyperlink target-type="inter-app" also-hidden="false" description="${custRequestId}-${custRequestItemSeqId}" target="/workeffort/control/requestitem?custRequestId=${custRequestId}&amp;custRequestItemSeqId=${custRequestItemSeqId}"/>
+        </field>
+        <field name="custRequestItemSeqId"><hidden/></field>
+        <field name="quoteId"><hidden/></field>
+        <field name="quoteItemSeqId" title="${uiLabelMap.OrderOrderQuoteItemSeqId}" widget-style="buttontext">
+            <hyperlink also-hidden="true" description="${quoteItemSeqId}" target="EditQuoteItem?quoteId=${quoteId}&amp;quoteItemSeqId=${quoteItemSeqId}"/>
+        </field>
+        <field name="productId" title="${uiLabelMap.ProductProductId}">
+            <display-entity entity-name="Product" key-field-name="productId" description="${productId} - ${internalName}"/>
+        </field>
+        <field name="quantity" title="${uiLabelMap.CommonQuantity}"><display/></field>
+        <field name="averageCost" title="${uiLabelMap.OrderOrderQuoteAverageCost}"><display/></field>
+        <field name="quoteUnitPrice" title="${uiLabelMap.OrderOrderQuoteUnitPrice}"><display/></field>
+        <field name="profit" title="${uiLabelMap.OrderOrderQuoteProfit}"><display/></field>
+        <field name="percProfit" title="${uiLabelMap.OrderOrderQuotePercProfit}"><display/></field>
+    </form>
 </forms>

Modified: trunk/applications/order/webapp/ordermgr/quote/QuoteTabBar.ftl
===================================================================
--- trunk/applications/order/webapp/ordermgr/quote/QuoteTabBar.ftl	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/quote/QuoteTabBar.ftl	2005-10-25 07:03:32 UTC (rev 6017)
@@ -38,6 +38,7 @@
         <a href="<@ofbizUrl>ListQuoteCoefficients?quoteId=${quote.quoteId}</@ofbizUrl>" class="${selectedClassMap.ListQuoteCoefficients?default(unselectedClassName)}">${uiLabelMap.OrderOrderQuoteCoefficients}</a>
         <a href="<@ofbizUrl>ManageQuotePrices?quoteId=${quote.quoteId}</@ofbizUrl>" class="${selectedClassMap.ManageQuotePrices?default(unselectedClassName)}">${uiLabelMap.OrderOrderQuotePrices}</a>
         <a href="<@ofbizUrl>ListQuoteAdjustments?quoteId=${quote.quoteId}</@ofbizUrl>" class="${selectedClassMap.ListQuoteAdjustments?default(unselectedClassName)}">${uiLabelMap.OrderOrderQuoteAdjustments}</a>
+        <a href="<@ofbizUrl>ViewQuoteProfit?quoteId=${quote.quoteId}</@ofbizUrl>" class="${selectedClassMap.ViewQuoteProfit?default(unselectedClassName)}">${uiLabelMap.OrderViewQuoteProfit}</a>
         </#if>
         <a href="<@ofbizUrl>ListQuoteWorkEfforts?quoteId=${quote.quoteId}</@ofbizUrl>" class="${selectedClassMap.QuoteWorkEfforts?default(unselectedClassName)}">${uiLabelMap.OrderOrderQuoteWorkEfforts}</a>
     </div>

Added: trunk/applications/order/webapp/ordermgr/quote/ViewQuoteProfit.ftl
===================================================================
--- trunk/applications/order/webapp/ordermgr/quote/ViewQuoteProfit.ftl	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/quote/ViewQuoteProfit.ftl	2005-10-25 07:03:32 UTC (rev 6017)
@@ -0,0 +1,38 @@
+<#--
+ *  Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a 
+ *  copy of this software and associated documentation files (the "Software"), 
+ *  to deal in the Software without restriction, including without limitation 
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
+ *  and/or sell copies of the Software, and to permit persons to whom the 
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included 
+ *  in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
+ *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+ *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+ *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
+ *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
+ *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
+ *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *@author     Jacopo Cappellato (tiz at sastau.it)
+ *@version    $Rev$
+-->
+
+<#list quoteCoefficients as quoteCoefficient>
+    <div class="tabletext">${quoteCoefficient.coeffName}:&nbsp;${quoteCoefficient.coeffValue}</div>
+</#list>
+<br/>
+<div class="tableheadtext">${uiLabelMap.totCostMult}:&nbsp;${costMult}</div>
+<div class="tableheadtext">${uiLabelMap.costToPriceMult}:&nbsp;${costToPriceMult}</div>
+<br/>
+<div class="tableheadtext">${uiLabelMap.TotalCost}:&nbsp;<@ofbizCurrency amount=totalCost isoCode=quote.currencyUomId/></div>
+<div class="tableheadtext">${uiLabelMap.TotalAmount}:&nbsp;<@ofbizCurrency amount=totalPrice isoCode=quote.currencyUomId/></div>
+<br/>
+<div class="tableheadtext">${uiLabelMap.TotalProfit}:&nbsp;<@ofbizCurrency amount=totalProfit isoCode=quote.currencyUomId/></div>
+<div class="tableheadtext">${uiLabelMap.TotalPercProfit}:&nbsp;${totalPercProfit}%</div>
+<br/>


Property changes on: trunk/applications/order/webapp/ordermgr/quote/ViewQuoteProfit.ftl
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + "Date Rev Author URL Id"
Name: svn:eol-style
   + native

Modified: trunk/applications/order/webapp/ordermgr/request/RequestForms.xml
===================================================================
--- trunk/applications/order/webapp/ordermgr/request/RequestForms.xml	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/webapp/ordermgr/request/RequestForms.xml	2005-10-25 07:03:32 UTC (rev 6017)
@@ -54,6 +54,13 @@
         <field name="createdByUserLogin"><hidden/></field>
         <field name="lastModifiedDate"><hidden/></field>
         <field name="lastModifiedByUserLogin"><hidden/></field>
+        <field name="productStoreId" title="${uiLabelMap.ProductProductStore}">
+            <drop-down allow-empty="true">
+                <entity-options description="${storeName}" entity-name="ProductStore" key-field-name="productStoreId">
+                    <entity-order-by field-name="storeName"/>
+                </entity-options>
+            </drop-down>
+        </field>
         <field name="submitButton" title="Find" widget-style="smallSubmit">
             <submit button-type="button"/>
         </field>
@@ -173,7 +180,7 @@
                 </entity-options>
             </drop-down>
         </field>
-        <field name="productStoreId" title="${uiLabelMap.QuoteProductStoreId}">
+        <field name="productStoreId" title="${uiLabelMap.ProductProductStore}">
             <drop-down allow-empty="false">
                 <entity-options description="${storeName}" entity-name="ProductStore" key-field-name="productStoreId"/>
             </drop-down>

Modified: trunk/applications/order/widget/ordermgr/QuoteScreens.xml
===================================================================
--- trunk/applications/order/widget/ordermgr/QuoteScreens.xml	2005-10-25 05:48:33 UTC (rev 6016)
+++ trunk/applications/order/widget/ordermgr/QuoteScreens.xml	2005-10-25 07:03:32 UTC (rev 6017)
@@ -476,5 +476,40 @@
             </widgets>
         </section>
     </screen>
+    <screen name="ViewQuoteProfit">
+        <section>
+            <actions>
+                <set field="title" value="View Quote Profit"/>
+                <set field="titleProperty" value="PageTitleViewQuoteProfit"/>
+                <set field="headerItem" value="quote"/>
+                <set field="tabButtonItem" value="ViewQuoteProfit"/>
+                <set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer"/>
+                <set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="50"/>
+    
+                <entity-one entity-name="Quote" value-name="quote" auto-field-map="true"/>
+                <entity-and entity-name="QuoteItem" list-name="quoteItems">
+                    <field-map env-name="quote.quoteId" field-name="quoteId"/>
+                    <order-by field-name="custRequestId"/>
+                    <order-by field-name="custRequestItemSeqId"/>
+                </entity-and>
+                <entity-and entity-name="QuoteCoefficient" list-name="quoteCoefficients">
+                    <field-map env-name="quote.quoteId" field-name="quoteId"/>
+                </entity-and>
+                <set from-field="quote.quoteId" field="quoteId"/>
+
+                <script location="component://order/webapp/ordermgr/WEB-INF/actions/quote/ViewQuoteProfit.bsh"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonQuotePriceDecorator">
+                    <decorator-section name="body">
+                        <platform-specific>
+                            <html><html-template location="component://order/webapp/ordermgr/quote/ViewQuoteProfit.ftl"/></html>
+                        </platform-specific>
+                        <include-form name="ViewQuoteProfit" location="component://order/webapp/ordermgr/quote/QuoteForms.xml"/>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>
 



More information about the Svn mailing list