svn commit: r425520 - in /incubator/ofbiz/trunk/applications/product/webapp/facility: WEB-INF/actions/inventory/receiveInventory.bsh inventory/receiveInventory.ftl

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r425520 - in /incubator/ofbiz/trunk/applications/product/webapp/facility: WEB-INF/actions/inventory/receiveInventory.bsh inventory/receiveInventory.ftl

sichen
Author: sichen
Date: Tue Jul 25 13:44:53 2006
New Revision: 425520

URL: http://svn.apache.org/viewvc?rev=425520&view=rev
Log:
Add a map of productId to standard cost for the receive inventory forms.  If receiving a single product, use the standard cost instead of 0.0.

Modified:
    incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/receiveInventory.bsh
    incubator/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl

Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/receiveInventory.bsh
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/receiveInventory.bsh?rev=425520&r1=425519&r2=425520&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/receiveInventory.bsh (original)
+++ incubator/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/inventory/receiveInventory.bsh Tue Jul 25 13:44:53 2006
@@ -22,6 +22,7 @@
 import org.ofbiz.service.ServiceUtil;
 
 delegator = request.getAttribute("delegator");
+dispatcher = request.getAttribute("dispatcher");
 facilityId = request.getParameter("facilityId");
 purchaseOrderId = request.getParameter("purchaseOrderId");
 productId = request.getParameter("productId");
@@ -32,6 +33,12 @@
     facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId));
 }
 
+ownerAcctgPref = null;
+if (facility != null) {
+    owner = facility.getRelatedOne("OwnerParty");
+    if (owner != null) ownerAcctgPref = owner.getRelatedOne("PartyAcctgPreference");
+}
+
 purchaseOrder = null;
 if (purchaseOrderId != null && purchaseOrderId.length() > 0) {
     purchaseOrder = delegator.findByPrimaryKey("OrderHeader", UtilMisc.toMap("orderId", purchaseOrderId));
@@ -94,11 +101,8 @@
 }
 // convert the unit prices to that of the facility owner's currency
 if (purchaseOrder != null && facility != null) {
-    owner = facility.getRelatedOne("OwnerParty");
-    acctgPref = null;
-    if (owner != null) acctgPref = owner.getRelatedOne("PartyAcctgPreference");
-    if (acctgPref != null) {
-        ownerCurrencyUomId = acctgPref.get("baseCurrencyUomId");
+    if (ownerAcctgPref != null) {
+        ownerCurrencyUomId = ownerAcctgPref.get("baseCurrencyUomId");
         orderCurrencyUomId = purchaseOrder.get("currencyUom");
         if (!orderCurrencyUomId.equals(ownerCurrencyUomId)) {
             for (iter = purchaseOrderItems.iterator(); iter.hasNext(); ) {
@@ -181,7 +185,36 @@
 
 // facilities
 facilities = delegator.findAll("Facility");
-    
+
+// default per unit cost for both shipment or individual product
+standardCosts = new HashMap();
+if (ownerAcctgPref != null) {
+
+    // get the unit cost of the products in a shipment
+    if (purchaseOrderItems != null) {
+        for (iter = purchaseOrderItems.iterator(); iter.hasNext(); ) {
+            orderItem = iter.next();
+            productId = orderItem.get("productId");
+            if (productId == null) continue;
+
+            result = dispatcher.runSync("getProductCost", UtilMisc.toMap("productId", productId, "currencyUomId", ownerAcctgPref.get("baseCurrencyUomId"),
+                        "costComponentTypePrefix", "EST_STD", "userLogin", request.getAttribute("userLogin")));
+            if (!ServiceUtil.isError(result)) {
+                standardCosts.put(productId, result.get("productCost"));
+            }
+        }
+    }
+
+    // get the unit cost of a single product
+    if (productId != null) {
+        result = dispatcher.runSync("getProductCost", UtilMisc.toMap("productId", productId, "currencyUomId", ownerAcctgPref.get("baseCurrencyUomId"),
+                    "costComponentTypePrefix", "EST_STD", "userLogin", request.getAttribute("userLogin")));
+        if (!ServiceUtil.isError(result)) {
+            standardCosts.put(productId, result.get("productCost"));
+        }
+    }
+}
+
 context.put("facilityId", facilityId);
 context.put("facility", facility);
 context.put("purchaseOrder", purchaseOrder);
@@ -195,3 +228,4 @@
 context.put("rejectReasons", rejectReasons);
 context.put("inventoryItemTypes", inventoryItemTypes);
 context.put("facilities", facilities);
+context.put("standardCosts", standardCosts);

Modified: incubator/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl?rev=425520&r1=425519&r2=425520&view=diff
==============================================================================
--- incubator/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl (original)
+++ incubator/ofbiz/trunk/applications/product/webapp/facility/inventory/receiveInventory.ftl Tue Jul 25 13:44:53 2006
@@ -75,7 +75,7 @@
       <input type="hidden" name="facilityId_o_0" value="${requestParameters.facilityId?if_exists}"/>
       <input type="hidden" name="_rowCount" value="1"/>
       <#if purchaseOrder?has_content>
-      <#assign unitCost = firstOrderItem.unitPrice?default(0)/>
+      <#assign unitCost = firstOrderItem.unitPrice?default(standardCosts.get(firstOrderItem.productId)?default(0))/>
       <input type="hidden" name="orderId_o_0" value="${purchaseOrder.orderId}"/>
       <input type="hidden" name="orderItemSeqId_o_0" value="${firstOrderItem.orderItemSeqId}"/>
       <tr>
@@ -214,7 +214,9 @@
         <td width="6%" align="right" nowrap><div class="tabletext">${uiLabelMap.ProductPerUnitPrice}</div></td>
         <td width="6%">&nbsp;</td>
         <td width="74%">
-          <input type="text" name="unitCost_o_0" size="10" value="${unitCost?default(0)}" class="inputBox"/>
+          <#-- get the default unit cost -->
+          <#if (!unitCost?exists || unitCost == 0.0)><#assign unitCost = standardCosts.get(product.productId)?default(0)/></#if>
+          <input type="text" name="unitCost_o_0" size="10" value="${unitCost}" class="inputBox"/>
         </td>
       </tr>
       <tr>