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());
}
}
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();
}
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));
}
}
}
}
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;
}
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();
}
Aggregations