You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by si...@apache.org on 2007/03/14 18:48:09 UTC
svn commit: r518237 - in /ofbiz/trunk/applications/product:
config/ProductUiLabels.properties
webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh
webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl
Author: sichen
Date: Wed Mar 14 10:48:08 2007
New Revision: 518237
URL: http://svn.apache.org/viewvc?view=rev&rev=518237
Log:
Receive inventory against PO:
- Add a back-ordered quantity column
- JS alerts and error/info messages on: attempt to receive product/goodId not in order; attempt to receive > order quantity; part or all of qty to receive going to back-order
- If productId to receive is not in the order, check for goodIds
Modified:
ofbiz/trunk/applications/product/config/ProductUiLabels.properties
ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh
ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl
Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=518237&r1=518236&r2=518237
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Wed Mar 14 10:48:08 2007
@@ -615,6 +615,7 @@
ProductGlobal=Global
ProductGlobalPriceRule=Global Price Rule
ProductGlobalPriceRules=Global Price Rules
+ProductGoodIdentification=Good Identification
ProductGoToFeatureCategory=Go to Feature Category
ProductGrams=Grams
ProductGroupMemberMaintenance=Group Member Maintenance
Modified: ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh?view=diff&rev=518237&r1=518236&r2=518237
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh (original)
+++ ofbiz/trunk/applications/product/webapp/facility/WEB-INF/actions/shipment/ReceiveInventoryAgainstPurchaseOrder.bsh Wed Mar 14 10:48:08 2007
@@ -17,6 +17,7 @@
* under the License.
*/
+import org.ofbiz.entity.condition.*;
import org.ofbiz.entity.util.*;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.base.util.*;
@@ -126,6 +127,9 @@
ordered = orderItemAndShipGroupAssoc.getDouble("quantity");
if (ordered != null)
totalOrdered += ordered.doubleValue();
+ cancelled = orderItemAndShipGroupAssoc.getDouble("cancelQuantity");
+ if (cancelled != null)
+ totalOrdered -= cancelled.doubleValue();
// Get the item quantity received from all shipments via the ShipmentReciept entity
totalReceived = 0.0;
@@ -153,6 +157,18 @@
}
}
+ // Retrieve the backordered quantity
+ // TODO: limit to a facility? The shipment destination facility is not necessarily the same facility as the inventory
+ conditions = UtilMisc.toList(new EntityExpr("productId", EntityOperator.EQUALS, product.get("productId")), new EntityExpr("availableToPromiseTotal", EntityOperator.LESS_THAN, new Double(0)));
+ negativeInventoryItems = delegator.findByCondition("InventoryItem", new EntityConditionList(conditions, EntityOperator.AND), null, null);
+ backOrderedQuantity = 0;
+ niit = negativeInventoryItems.iterator();
+ while (niit.hasNext()) {
+ negativeInventoryItem = niit.next();
+ backOrderedQuantity += negativeInventoryItem.getDouble("availableToPromiseTotal").doubleValue();
+ }
+ orderItemData.put("backOrderedQuantity", Math.abs(backOrderedQuantity));
+
// Calculate how many units it should be possible to recieve for this purchase order
availableToReceive = totalOrdered - totalReceived;
totalAvailableToReceive += availableToReceive;
@@ -171,19 +187,39 @@
// Get the first order item with the productId
orderItem = EntityUtil.getFirst(EntityUtil.filterByAnd(orderItems, UtilMisc.toMap("productId", productIdToReceive)));
+
+ // If the productId as given isn't found in the order, try any goodIdentifications and use the first match
+ if (UtilValidate.isEmpty(orderItem)) {
+ goodIdentifications = delegator.findByAnd("GoodIdentification", UtilMisc.toMap("idValue", productIdToReceive));
+ if (! UtilValidate.isEmpty(goodIdentifications)) {
+ giit = goodIdentifications.iterator();
+ while (giit.hasNext()) {
+ goodIdentification = giit.next();
+ orderItem = EntityUtil.getFirst(EntityUtil.filterByAnd(orderItems, UtilMisc.toMap("productId", goodIdentification.get("productId"))));
+ if (! UtilValidate.isEmpty(orderItem)) {
+ productIdToReceive = goodIdentification.get("productId");
+ break;
+ }
+ }
+ }
+ }
+
if (! UtilValidate.isEmpty(orderItem)) {
orderItemSeqId = orderItem.getString("orderItemSeqId");
+ oldQuantity = 0;
newQuantity = 0;
+ quantity = 0;
if (! UtilValidate.isEmpty(productQtyToReceive)) {
try {
quantity = Double.parseDouble(productQtyToReceive);
} catch (Exception e) {
- quantity = 0;
+ // Ignore the quantity update if there's a problem parsing it
}
if (itemQuantitiesToReceive.containsKey(orderItemSeqId)) {
try {
- newQuantity = itemQuantitiesToReceive.get(orderItemSeqId) + quantity;
+ oldQuantity = itemQuantitiesToReceive.get(orderItemSeqId);
+ newQuantity = oldQuantity + quantity;
} catch (Exception e) {
// Ignore the quantity update if there's a problem parsing it
}
@@ -199,6 +235,18 @@
// If the new quantity would be more than the quantity left to receive for this purchase order item, add an error message to the context
context.put("newQuantity", newQuantity);
context.put("ProductReceiveInventoryAgainstPurchaseOrderQuantityExceedsAvailableToReceive", true);
+ return;
+ }
+
+ // Notify if some or all of the quantity to receive for the item will go to a backorder
+ oldBackOrderedQuantity = orderItemDatas.get(orderItemSeqId).get("backOrderedQuantity") - oldQuantity;
+ if (oldBackOrderedQuantity < 0) oldBackOrderedQuantity = new Double(0).doubleValue();
+ newBackOrderedQuantity = orderItemDatas.get(orderItemSeqId).get("backOrderedQuantity") - newQuantity;
+ if (newBackOrderedQuantity < 0) newBackOrderedQuantity = new Double(0).doubleValue();
+ if (oldBackOrderedQuantity != newBackOrderedQuantity) {
+ context.put("quantityToReceive", quantity);
+ context.put("quantityToBackOrder", (oldBackOrderedQuantity - newBackOrderedQuantity));
+ context.put("ProductReceiveInventoryAgainstPurchaseOrderQuantityGoesToBackOrder", true);
}
} else {
Modified: ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl?view=diff&rev=518237&r1=518236&r2=518237
==============================================================================
--- ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/facility/shipment/ReceiveInventoryAgainstPurchaseOrder.ftl Wed Mar 14 10:48:08 2007
@@ -30,10 +30,18 @@
<#assign uiLabelWithVar=uiLabelMap.ProductErrorOrderNotPurchaseOrder?interpret><@uiLabelWithVar/>
<#elseif ProductReceiveInventoryAgainstPurchaseOrderProductNotFound?exists>
<#assign uiLabelWithVar=uiLabelMap.ProductReceiveInventoryAgainstPurchaseOrderProductNotFound?interpret><@uiLabelWithVar/>
+ <script type="text/javascript">window.onload=function(){alert('<@uiLabelWithVar/>')};</script>
<#elseif ProductReceiveInventoryAgainstPurchaseOrderQuantityExceedsAvailableToReceive?exists>
<#assign uiLabelWithVar=uiLabelMap.ProductReceiveInventoryAgainstPurchaseOrderQuantityExceedsAvailableToReceive?interpret><@uiLabelWithVar/>
+ <script type="text/javascript">window.onload=function(){alert('<@uiLabelWithVar/>')};</script>
</#if>
</div>
+ <#if ProductReceiveInventoryAgainstPurchaseOrderQuantityGoesToBackOrder?exists>
+ <div class="errorMessage" style="color:green">
+ <#assign uiLabelWithVar=uiLabelMap.ProductReceiveInventoryAgainstPurchaseOrderQuantityGoesToBackOrder?interpret><@uiLabelWithVar/>
+ <script type="text/javascript">window.onload=function(){alert('<@uiLabelWithVar/>')};</script>
+ </div>
+ </#if>
<form name="ReceiveInventoryAgainstPurchaseOrder" action="<@o...@ofbizUrl>">
<input type="hidden" name="clearAll" value="Y"/>
@@ -65,6 +73,7 @@
<tr>
<td><div class="tableheadtext">${uiLabelMap.ProductProduct}</div></td>
<td><div class="tableheadtext">${uiLabelMap.OrderOrder}</div></td>
+ <td><div class="tableheadtext">${uiLabelMap.OrderBackOrdered}</div></td>
<td><div class="tableheadtext">${uiLabelMap.CommonReceived}</div></td>
<td><div class="tableheadtext">${uiLabelMap.ProductOpenQuantity}</div></td>
<td><div class="tableheadtext">${uiLabelMap.CommonReceive}</div></td>
@@ -80,12 +89,18 @@
<#assign product = orderItemData.product?if_exists>
<#assign totalQuantityReceived = orderItemData.totalQuantityReceived?default(0)>
<#assign availableToReceive = orderItemData.availableToReceive?default(0)>
+ <#assign backOrderedQuantity = orderItemData.backOrderedQuantity?default(0)>
<tr>
<td><div class="tabletext">${(product.internalName)?if_exists} [${orderItemAndShipGroupAssoc.productId?default("N/A")}]</div></td>
<td>
<div class="tabletext">
- ${orderItemAndShipGroupAssoc.quantity}
+ ${orderItemAndShipGroupAssoc.quantity - orderItemAndShipGroupAssoc.cancelQuantity?default(0)}
+ </div>
+ </td>
+ <td>
+ <div class="tabletext ${(backOrderedQuantity > 0)?string(" errorMessage","")}">
+ ${backOrderedQuantity}
</div>
</td>
<td>
@@ -140,7 +155,7 @@
</#list>
<#if itemsAvailableToReceive>
<tr>
- <td colspan="7" align="right">
+ <td colspan="8" align="right">
<a href="<@o...@ofbizUrl>" class="buttontext">${uiLabelMap.CommonClearAll}</a>
</td>
<td align="right">
@@ -160,7 +175,7 @@
<input type="hidden" name="purchaseOrderId" value="${orderId}"/>
<div class="tabletext">
<span class="tabletext">
- ${uiLabelMap.ProductProductId} <input type="text" class="inputBox" size="20" id="productId" name="productId" value=""/>
+ ${uiLabelMap.ProductProductId}/${uiLabelMap.ProductGoodIdentification} <input type="text" class="inputBox" size="20" id="productId" name="productId" value=""/>
@
<input type="text" class="inputBox" name="quantity" size="6" maxlength="6" value="1" tabindex="0"/>
<input type="submit" value="${uiLabelMap.CommonAdd}" class="smallSubmit"/>