|
Author: mrisaliti
Date: Wed Jan 26 18:34:04 2011 New Revision: 1063819 URL: http://svn.apache.org/viewvc?rev=1063819&view=rev Log: Internationalization of java services for hhfacility component (OFBIZ-4091) Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.xml?rev=1063819&r1=1063818&r2=1063819&view=diff ============================================================================== --- ofbiz/trunk/applications/product/config/ProductUiLabels.xml (original) +++ ofbiz/trunk/applications/product/config/ProductUiLabels.xml Wed Jan 26 18:34:04 2011 @@ -12314,6 +12314,18 @@ <value xml:lang="zh">æ´ä¸ªç®å½</value> <value xml:lang="zh_TW">æ´åç®é</value> </property> + <property key="ProductErrorCreatePhysicalInventoryAndVariance"> + <value xml:lang="en">fixProductNegativeQOH failed on createPhysicalInventoryAndVariance invItemId: ${inventoryItemId}</value> + <value xml:lang="it">fixProductNegativeQOH fallito su createPhysicalInventoryAndVariance invItemId: ${inventoryItemId}</value> + </property> + <property key="ProductErrorFailedProductStockTake"> + <value xml:lang="en">updateProductStocktake failed getting inventory items</value> + <value xml:lang="it">updateProductStocktake fallito per ottenere riga inventario</value> + </property> + <property key="ProductErrorUpdateProductStockTake"> + <value xml:lang="en">updateProductStocktake failed getting inventory counts</value> + <value xml:lang="it">updateProductStocktake fallito per ottenere contatori inventario</value> + </property> <property key="ProductErrorFacility"> <value xml:lang="de">Fehler: Einrichtung</value> <value xml:lang="en">Error: facility</value> @@ -14073,6 +14085,10 @@ <value xml:lang="zh">æ è¯ä»£ç </value> <value xml:lang="zh_TW">ID代碼</value> </property> + <property key="ProductIdOrFacilityIdNotFound"> + <value xml:lang="en">productId or facilityId not found</value> + <value xml:lang="it">productId o facilityId non trovato</value> + </property> <property key="ProductIdSeqNum"> <value xml:lang="de">ID Sequenznummer</value> <value xml:lang="en">ID Seq Num</value> Modified: ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java?rev=1063819&r1=1063818&r2=1063819&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java (original) +++ ofbiz/trunk/specialpurpose/hhfacility/src/org/ofbiz/hhfacility/FacilityServices.java Wed Jan 26 18:34:04 2011 @@ -20,11 +20,13 @@ package org.ofbiz.hhfacility; import java.util.List; +import java.util.Locale; import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; @@ -38,6 +40,7 @@ import org.ofbiz.service.ServiceUtil; public class FacilityServices { public static final String module = FacilityServices.class.getName(); + private static final String resource = "ProductUiLabels"; public static Map<String, Object> findProductsById(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); @@ -62,7 +65,7 @@ public class FacilityServices { public static Map<String, Object> fixProductNegativeQOH(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String facilityId = (String) context.get("facilityId"); String productId = (String) context.get("productId"); GenericValue userLogin = (GenericValue) context.get("userLogin"); @@ -84,14 +87,12 @@ public class FacilityServices { if (qoh < 0) { // Got a negative qoh so lets balance if off to zero. - Map<String, Object> contextInput = UtilMisc.toMap("userLogin", userLogin, "inventoryItemId", invItem.get("inventoryItemId"), - "varianceReasonId", "VAR_LOST", "availableToPromiseVar", new Double(qoh*-1), - "quantityOnHandVar", new Double(qoh*-1), "comments", "QOH < 0 stocktake correction"); + Map<String, Object> contextInput = UtilMisc.toMap("userLogin", userLogin, "inventoryItemId", invItem.get("inventoryItemId"), "varianceReasonId", "VAR_LOST", "availableToPromiseVar", new Double(qoh*-1), "quantityOnHandVar", new Double(qoh*-1), "comments", "QOH < 0 stocktake correction"); try { dispatcher.runSync("createPhysicalInventoryAndVariance",contextInput); } catch (GenericServiceException e) { Debug.logError(e, "fixProductNegativeQOH failed on createPhysicalInventoryAndVariance invItemId"+invItem.get("inventoryItemId"), module); - return ServiceUtil.returnError("fixProductNegativeQOH failed on createPhysicalInventoryAndVariance invItemId"+invItem.get("inventoryItemId")); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductErrorCreatePhysicalInventoryAndVariance", UtilMisc.toMap("inventoryItemId", invItem.get("inventoryItemId")), locale)); } } } @@ -102,13 +103,13 @@ public class FacilityServices { public static Map<String, Object> updateProductStocktake(DispatchContext dctx, Map<String, Object> context) { Delegator delegator = dctx.getDelegator(); LocalDispatcher dispatcher = dctx.getDispatcher(); - + Locale locale = (Locale) context.get("locale"); String facilityId = (String) context.get("facilityId"); String productId = (String) context.get("productId"); String locationSeqId = (String) context.get("locationSeqId"); Double quantity = (Double) context.get("quantity"); if (UtilValidate.isEmpty(productId) || UtilValidate.isEmpty(facilityId)) { - return ServiceUtil.returnError("productId or facilityId not found"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductIdOrFacilityIdNotFound", locale)); } // First identify the location and get a list of inventoryItemIds for that location. @@ -124,7 +125,7 @@ public class FacilityServices { invAvailability = dispatcher.runSync("getInventoryAvailableByLocation",contextInput); } catch (GenericServiceException e) { Debug.logError(e, "updateProductStocktake failed getting inventory counts", module); - return ServiceUtil.returnError("updateProductStocktake failed getting inventory counts"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductErrorUpdateProductStockTake", locale)); } int qoh = ((Double)invAvailability.get("quantityOnHandTotal")).intValue(); if (quantity.intValue() == qoh) { @@ -136,11 +137,10 @@ public class FacilityServices { // Now get the inventory items that are found for that location, facility and product List<GenericValue> invItemList = null; try { - invItemList = delegator.findByAnd("InventoryItem", - UtilMisc.toMap("productId", productId, "facilityId", facilityId, "locationSeqId", locationSeqId)); + invItemList = delegator.findByAnd("InventoryItem", UtilMisc.toMap("productId", productId, "facilityId", facilityId, "locationSeqId", locationSeqId)); } catch (GenericEntityException e) { Debug.logError(e, "updateProductStocktake failed getting inventory items", module); - return ServiceUtil.returnError("updateProductStocktake failed getting inventory items"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductErrorFailedProductStockTake", locale)); } for (GenericValue invItem : invItemList) { @@ -152,92 +152,11 @@ public class FacilityServices { } // Check if there is a request to change the locationSeqId try { - dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, - "facilityId", facilityId)); + dispatcher.runSync("getInventoryAvailableByFacility", UtilMisc.toMap("productId", productId, "facilityId", facilityId)); } catch (GenericServiceException e) { Debug.logError(e, module); - return ServiceUtil.returnError("Inventory atp/qoh lookup problem [" + e.getMessage() + "]"); - } - -/* - try { - inventoryTransfer = delegator.findByPrimaryKey("InventoryTransfer", - UtilMisc.toMap("inventoryTransferId", inventoryTransferId)); - inventoryItem = inventoryTransfer.getRelatedOne("InventoryItem"); - destinationFacility = inventoryTransfer.getRelatedOne("ToFacility"); - } catch (GenericEntityException e) { - return ServiceUtil.returnError("Inventory Item/Transfer lookup problem [" + e.getMessage() + "]"); - } - - if (inventoryTransfer == null || inventoryItem == null) { - return ServiceUtil.returnError("ERROR: Lookup of InventoryTransfer and/or InventoryItem failed!"); - } - - String inventoryType = inventoryItem.getString("inventoryItemTypeId"); - - // set the fields on the transfer record - if (inventoryTransfer.get("receiveDate") == null) { - inventoryTransfer.set("receiveDate", UtilDateTime.nowTimestamp()); - } - - if (inventoryType.equals("NON_SERIAL_INV_ITEM")) { - // add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP - double atp = inventoryItem.get("availableToPromiseTotal") == null ? 0 : inventoryItem.getDouble("availableToPromiseTotal").doubleValue(); - double qoh = inventoryItem.get("quantityOnHandTotal") == null ? 0 : inventoryItem.getDouble("quantityOnHandTotal").doubleValue(); - Map createDetailMap = UtilMisc.toMap("availableToPromiseDiff", new Double(qoh - atp), - "inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin); - try { - Map result = dctx.getDispatcher().runSync("createInventoryItemDetail", createDetailMap); - if (ServiceUtil.isError(result)) { - return ServiceUtil.returnError("Inventory Item Detail create problem in complete inventory transfer", null, null, result); - } - } catch (GenericServiceException e1) { - return ServiceUtil.returnError("Inventory Item Detail create problem in complete inventory transfer: [" + e1.getMessage() + "]"); - } - try { - inventoryItem.refresh(); - } catch (GenericEntityException e) { - return ServiceUtil.returnError("Inventory refresh problem [" + e.getMessage() + "]"); - } - } else if (inventoryType.equals("SERIALIZED_INV_ITEM")) { - inventoryItem.set("statusId", "INV_AVAILABLE"); - } - - // set the fields on the item - Map updateInventoryItemMap = UtilMisc.toMap("inventoryItemId", inventoryItem.getString("inventoryItemId"), - "facilityId", inventoryTransfer.get("facilityIdTo"), - "containerId", inventoryTransfer.get("containerIdTo"), - "locationSeqId", inventoryTransfer.get("locationSeqIdTo"), - "userLogin", userLogin); - // if the destination facility's owner is different - // from the inventory item's ownwer, - // the inventory item is assigned to the new owner. - if (destinationFacility != null && destinationFacility.get("ownerPartyId") != null) { - String fromPartyId = inventoryItem.getString("ownerPartyId"); - String toPartyId = destinationFacility.getString("ownerPartyId"); - if (fromPartyId == null || !fromPartyId.equals(toPartyId)) { - updateInventoryItemMap.put("ownerPartyId", toPartyId); - } - } - try { - Map result = dctx.getDispatcher().runSync("updateInventoryItem", updateInventoryItemMap); - if (ServiceUtil.isError(result)) { - return ServiceUtil.returnError("Inventory item store problem", null, null, result); - } - } catch (GenericServiceException exc) { - return ServiceUtil.returnError("Inventory item store problem [" + exc.getMessage() + "]"); - } - - // set the inventory transfer record to complete - inventoryTransfer.set("statusId", "IXF_COMPLETE"); - - // store the entities - try { - inventoryTransfer.store(); - } catch (GenericEntityException e) { - return ServiceUtil.returnError("Inventory store problem [" + e.getMessage() + "]"); + return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ProductInventoryItemLookupProblem", UtilMisc.toMap("errorString", e.getMessage()), locale)); } - */ return ServiceUtil.returnSuccess(); } } |
| Free forum by Nabble | Edit this page |
