Search in sources :

Example 1 with GeneralException

use of org.apache.ofbiz.base.util.GeneralException in project ofbiz-framework by apache.

the class VerifyPickServices method completeVerifiedPick.

public static Map<String, Object> completeVerifiedPick(DispatchContext dctx, Map<String, ? extends Object> context) {
    Locale locale = (Locale) context.get("locale");
    String shipmentId = null;
    VerifyPickSession pickSession = (VerifyPickSession) context.get("verifyPickSession");
    String orderId = (String) context.get("orderId");
    try {
        shipmentId = pickSession.complete(orderId, locale);
        Map<String, Object> shipment = new HashMap<String, Object>();
        shipment.put("shipmentId", shipmentId);
        pickSession.clearAllRows();
        return shipment;
    } catch (GeneralException ex) {
        return ServiceUtil.returnError(ex.getMessage(), ex.getMessageList());
    }
}
Also used : Locale(java.util.Locale) GeneralException(org.apache.ofbiz.base.util.GeneralException) HashMap(java.util.HashMap)

Example 2 with GeneralException

use of org.apache.ofbiz.base.util.GeneralException in project ofbiz-framework by apache.

the class VerifyPickServices method verifySingleItem.

public static Map<String, Object> verifySingleItem(DispatchContext dctx, Map<String, ? extends Object> context) {
    Locale locale = (Locale) context.get("locale");
    VerifyPickSession pickSession = (VerifyPickSession) context.get("verifyPickSession");
    String orderId = (String) context.get("orderId");
    String shipGroupSeqId = (String) context.get("shipGroupSeqId");
    String productId = (String) context.get("productId");
    String originGeoId = (String) context.get("originGeoId");
    BigDecimal quantity = (BigDecimal) context.get("quantity");
    if (quantity != null) {
        try {
            pickSession.createRow(orderId, null, shipGroupSeqId, productId, originGeoId, quantity, locale);
        } catch (GeneralException e) {
            return ServiceUtil.returnError(e.getMessage());
        }
    }
    return ServiceUtil.returnSuccess();
}
Also used : Locale(java.util.Locale) GeneralException(org.apache.ofbiz.base.util.GeneralException) BigDecimal(java.math.BigDecimal)

Example 3 with GeneralException

use of org.apache.ofbiz.base.util.GeneralException in project ofbiz-framework by apache.

the class VerifyPickSessionRow method issueItemToShipment.

protected void issueItemToShipment(String shipmentId, String picklistBinId, GenericValue userLogin, BigDecimal quantity, LocalDispatcher dispatcher, Locale locale) throws GeneralException {
    if (quantity == null) {
        quantity = this.getReadyToVerifyQty();
    }
    Map<String, Object> issueOrderItemMap = new HashMap<String, Object>();
    issueOrderItemMap.put("shipmentId", shipmentId);
    issueOrderItemMap.put("orderId", this.getOrderId());
    issueOrderItemMap.put("orderItemSeqId", this.getOrderItemSeqId());
    issueOrderItemMap.put("shipGroupSeqId", this.getShipGroupSeqId());
    issueOrderItemMap.put("inventoryItemId", this.getInventoryItemId());
    issueOrderItemMap.put("quantity", quantity);
    issueOrderItemMap.put("userLogin", userLogin);
    Map<String, Object> issueOrderItemResp = dispatcher.runSync("issueOrderItemShipGrpInvResToShipment", issueOrderItemMap);
    if (ServiceUtil.isError(issueOrderItemResp)) {
        throw new GeneralException(ServiceUtil.getErrorMessage(issueOrderItemResp));
    }
    String shipmentItemSeqId = (String) issueOrderItemResp.get("shipmentItemSeqId");
    if (shipmentItemSeqId == null) {
        throw new GeneralException(UtilProperties.getMessage("ProductErrorUiLabels", "ProductErrorIssueItemDidNotReturnAValidShipmentItemSeqId", locale));
    } else {
        this.setShipmentItemSeqId(shipmentItemSeqId);
    }
    if (picklistBinId != null) {
        // find the pick list item
        Delegator delegator = dispatcher.getDelegator();
        Map<String, Object> picklistItemMap = new HashMap<String, Object>();
        picklistItemMap.put("picklistBinId", picklistBinId);
        picklistItemMap.put("orderId", this.getOrderId());
        picklistItemMap.put("orderItemSeqId", this.getOrderItemSeqId());
        picklistItemMap.put("shipGroupSeqId", this.getShipGroupSeqId());
        picklistItemMap.put("inventoryItemId", this.getInventoryItemId());
        GenericValue picklistItem = EntityQuery.use(delegator).from("PicklistItem").where(picklistItemMap).cache(true).queryOne();
        if (UtilValidate.isNotEmpty(picklistItem)) {
            BigDecimal itemQty = picklistItem.getBigDecimal("quantity");
            if (itemQty.compareTo(quantity) == 0) {
                // set to complete
                picklistItemMap.put("itemStatusId", "PICKITEM_COMPLETED");
            } else {
                picklistItemMap.put("itemStatusId", "PICKITEM_CANCELLED");
            }
            picklistItemMap.put("userLogin", userLogin);
            Map<String, Object> picklistItemResp = dispatcher.runSync("updatePicklistItem", picklistItemMap);
            if (ServiceUtil.isError(picklistItemResp)) {
                throw new GeneralException(ServiceUtil.getErrorMessage(picklistItemResp));
            }
        }
    }
}
Also used : GenericValue(org.apache.ofbiz.entity.GenericValue) GeneralException(org.apache.ofbiz.base.util.GeneralException) Delegator(org.apache.ofbiz.entity.Delegator) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal)

Example 4 with GeneralException

use of org.apache.ofbiz.base.util.GeneralException in project ofbiz-framework by apache.

the class WeightPackageSession method upsShipmentConfirm.

protected BigDecimal upsShipmentConfirm() throws GeneralException {
    Delegator delegator = this.getDelegator();
    BigDecimal actualCost = BigDecimal.ZERO;
    List<GenericValue> shipmentRouteSegments = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId).queryList();
    if (UtilValidate.isNotEmpty(shipmentRouteSegments)) {
        for (GenericValue shipmentRouteSegment : shipmentRouteSegments) {
            Map<String, Object> shipmentRouteSegmentMap = new HashMap<String, Object>();
            shipmentRouteSegmentMap.put("shipmentId", shipmentId);
            shipmentRouteSegmentMap.put("shipmentRouteSegmentId", shipmentRouteSegment.getString("shipmentRouteSegmentId"));
            shipmentRouteSegmentMap.put("userLogin", userLogin);
            Map<String, Object> shipmentRouteSegmentResult = this.getDispatcher().runSync("upsShipmentConfirm", shipmentRouteSegmentMap);
            if (ServiceUtil.isError(shipmentRouteSegmentResult)) {
                throw new GeneralException(ServiceUtil.getErrorMessage(shipmentRouteSegmentResult));
            }
            GenericValue shipRouteSeg = EntityQuery.use(delegator).from("ShipmentRouteSegment").where("shipmentId", shipmentId, "shipmentRouteSegmentId", shipmentRouteSegment.getString("shipmentRouteSegmentId")).queryOne();
            actualCost = actualCost.add(shipRouteSeg.getBigDecimal("actualCost"));
        }
    }
    return actualCost;
}
Also used : GenericValue(org.apache.ofbiz.entity.GenericValue) GeneralException(org.apache.ofbiz.base.util.GeneralException) Delegator(org.apache.ofbiz.entity.Delegator) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal)

Example 5 with GeneralException

use of org.apache.ofbiz.base.util.GeneralException in project ofbiz-framework by apache.

the class PackingServices method addPackLine.

public static Map<String, Object> addPackLine(DispatchContext dctx, Map<String, ? extends Object> context) {
    PackingSession session = (PackingSession) context.get("packingSession");
    String shipGroupSeqId = (String) context.get("shipGroupSeqId");
    String orderId = (String) context.get("orderId");
    String productId = (String) context.get("productId");
    BigDecimal quantity = (BigDecimal) context.get("quantity");
    BigDecimal weight = (BigDecimal) context.get("weight");
    Integer packageSeq = (Integer) context.get("packageSeq");
    // set the instructions -- will clear out previous if now null
    String instructions = (String) context.get("handlingInstructions");
    session.setHandlingInstructions(instructions);
    // set the picker party id -- will clear out previous if now null
    String pickerPartyId = (String) context.get("pickerPartyId");
    session.setPickerPartyId(pickerPartyId);
    if (quantity == null) {
        quantity = BigDecimal.ONE;
    }
    Debug.logInfo("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] Pack input [" + productId + "] @ [" + quantity + "] packageSeq [" + packageSeq + "] weight [" + weight + "]", module);
    if (weight == null) {
        Debug.logWarning("OrderId [" + orderId + "] ship group [" + shipGroupSeqId + "] product [" + productId + "] being packed without a weight, assuming 0", module);
        weight = BigDecimal.ZERO;
    }
    try {
        session.addOrIncreaseLine(orderId, null, shipGroupSeqId, productId, quantity, packageSeq.intValue(), weight, false);
    } catch (GeneralException e) {
        Debug.logError(e, module);
        return ServiceUtil.returnError(e.getMessage());
    }
    return ServiceUtil.returnSuccess();
}
Also used : GeneralException(org.apache.ofbiz.base.util.GeneralException) BigDecimal(java.math.BigDecimal)

Aggregations

GeneralException (org.apache.ofbiz.base.util.GeneralException)216 GenericValue (org.apache.ofbiz.entity.GenericValue)133 Delegator (org.apache.ofbiz.entity.Delegator)101 Locale (java.util.Locale)81 HashMap (java.util.HashMap)71 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)68 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)68 IOException (java.io.IOException)65 BigDecimal (java.math.BigDecimal)55 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)54 Writer (java.io.Writer)29 LinkedList (java.util.LinkedList)29 Map (java.util.Map)29 Timestamp (java.sql.Timestamp)26 StringWriter (java.io.StringWriter)19 Environment (freemarker.core.Environment)15 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 ShoppingCart (org.apache.ofbiz.order.shoppingcart.ShoppingCart)14 HttpSession (javax.servlet.http.HttpSession)13 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)13