/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import org.ofbiz.entity.*; import org.ofbiz.entity.util.*; import org.ofbiz.base.util.*; delegator = request.getAttribute("delegator"); facilityId = request.getParameter("facilityId"); returnId = request.getParameter("returnId"); facility = null; if (facilityId != null) { facility = delegator.findByPrimaryKey("Facility", UtilMisc.toMap("facilityId", facilityId)); } returnHeader = null; returnItems = null; if (returnId != null) { returnHeader = delegator.findByPrimaryKey("ReturnHeader", UtilMisc.toMap("returnId", returnId)); if (returnHeader != null) { if (returnHeader.getString("statusId").equals("RETURN_ACCEPTED")) { returnItems = returnHeader.getRelated("ReturnItem"); } else if (!returnHeader.getString("statusId").equals("RETURN_REQUESTED")) { uiLabelMap = UtilProperties.getResourceBundleMap("ProductErrorUiLabels", locale); ProductReturnNotYetAcceptedOrAlreadyReceived = uiLabelMap.get("ProductReturnNotYetAcceptedOrAlreadyReceived"); request.setAttribute("_ERROR_MESSAGE_", ProductReturnNotYetAcceptedOrAlreadyReceived + " (#" + returnId.toString() + ")" ); } else { uiLabelMap = UtilProperties.getResourceBundleMap("ProductErrorUiLabels", locale); ProductReturnRequestedOK = uiLabelMap.get("ProductReturnRequestedOK"); request.setAttribute("_EVENT_MESSAGE_", ProductReturnRequestedOK + " (#" + returnId.toString() + ")" ); } } } receivedQuantities = new HashMap(); if (returnItems != null && returnItems.size() > 0) { context.put("firstOrderItem", EntityUtil.getFirst(returnItems)); context.put("returnItemsSize", returnItems.size()); itemsIter = returnItems.iterator(); while (itemsIter.hasNext()) { totalReceived = 0.0; thisItem = itemsIter.next(); receipts = thisItem.getRelated("ShipmentReceipt"); if (receipts != null && receipts.size() > 0) { recIter = receipts.iterator(); while (recIter.hasNext()) { rec = recIter.next(); accepted = rec.getDouble("quantityAccepted"); rejected = rec.getDouble("quantityRejected"); if (accepted != null) totalReceived += accepted.doubleValue(); if (rejected != null) totalReceived += rejected.doubleValue(); } } receivedQuantities.put(thisItem.getString("returnItemSeqId"), new Double(totalReceived)); } } receivedItems = null; if (returnHeader != null) { receivedItems = delegator.findByAnd("ShipmentReceipt", UtilMisc.toMap("returnId", returnId)); context.put("receivedItems", receivedItems); } // facilities facilities = delegator.findAll("Facility"); //all possible inventory item types inventoryItemTypes = delegator.findAllCache("InventoryItemType", UtilMisc.toList("description")); context.put("facilityId", facilityId); context.put("facility", facility); context.put("returnHeader", returnHeader); context.put("returnItems", returnItems); context.put("receivedQuantities", receivedQuantities); context.put("facilities", facilities); context.put("inventoryItemTypes", inventoryItemTypes);