svn commit: r1617971 - /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1617971 - /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy

jleroux@apache.org
Author: jleroux
Date: Thu Aug 14 15:18:50 2014
New Revision: 1617971

URL: http://svn.apache.org/r1617971
Log:
No functional changes, only blocks moves and formatting

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy?rev=1617971&r1=1617970&r2=1617971&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy Thu Aug 14 15:18:50 2014
@@ -180,6 +180,65 @@ if (orderHeader) {
     shipGroups = delegator.findByAnd("OrderItemShipGroup", [orderId : orderId], ["shipGroupSeqId"], false);
     context.shipGroups = shipGroups;
 
+
+    orderItemDatas = [];
+    orderItemList.each { orderItem ->
+        BigDecimal cancelQuantity = orderItem.get("cancelQuantity");
+        BigDecimal quantity = orderItem.get("quantity");
+        if ( cancelQuantity != null ) {
+            quantityOrdered = quantity.subtract(cancelQuantity);
+        } else {
+            quantityOrdered = quantity;
+        }
+        OISGAssContents = [];
+        shipGroups.each { shipGroup ->
+            OISGAssContents.addAll(EntityUtil.filterByAnd(shipGroup.getRelated("OrderItemShipGroupAssoc"), UtilMisc.toMap("orderItemSeqId", orderItem.getString("orderItemSeqId"))));
+        }
+        BigDecimal totalQuantityPlanned = 0;
+        OISGAssContents.each { OISGAssContent ->
+           BigDecimal cancelQty = OISGAssContent.get("cancelQuantity");
+           BigDecimal qty = OISGAssContent.get("quantity");
+           if (qty != null) {
+               totalQuantityPlanned = totalQuantityPlanned.add(qty);
+           }
+           if (cancelQty != null){
+               OISGAssContent.set("quantity", qty.subtract(cancelQty));
+           } else {
+               OISGAssContent.set("quantity", qty);
+           }
+        }
+        totalQuantityToPlan = totalQuantityPlanned - quantityOrdered;
+        BigDecimal quantityNotAvailable = 0;
+        List<GenericValue> oisgirs = orderItem.getRelated("OrderItemShipGrpInvRes", null, null, false);
+        for (GenericValue oisgir : oisgirs) {
+            if (UtilValidate.isNotEmpty(oisgir.get("quantityNotAvailable"))) {
+                quantityNotAvailable = quantityNotAvailable.add(oisgir.getBigDecimal("quantityNotAvailable"));
+            }
+        }
+        orderItemData = [:];
+        orderItemData.put("orderItem", orderItem);
+        orderItemData.put("OISGAssContents", OISGAssContents);
+        orderItemData.put("product", orderItem.getRelatedOne("Product", false));
+        orderItemData.put("quantityOrdered", quantityOrdered);
+        orderItemData.put("totalQuantityPlanned", totalQuantityPlanned);
+        orderItemData.put("totalQuantityToPlan", totalQuantityToPlan);
+        orderItemData.put("quantityNotAvailable", quantityNotAvailable);
+        orderItemDatas.add(orderItemData);
+    }
+    context.put("orderItemDatas", orderItemDatas);
+    
+    // create the actualDate for calendar
+    actualDateCal = Calendar.getInstance();
+    actualDateCal.setTime(new java.util.Date());
+    actualDateCal.set(Calendar.HOUR_OF_DAY, actualDateCal.getActualMinimum(Calendar.HOUR_OF_DAY));
+    actualDateCal.set(Calendar.MINUTE, actualDateCal.getActualMinimum(Calendar.MINUTE));
+    actualDateCal.set(Calendar.SECOND, actualDateCal.getActualMinimum(Calendar.SECOND));
+    actualDateCal.set(Calendar.MILLISECOND, actualDateCal.getActualMinimum(Calendar.MILLISECOND));
+    actualDateTs = new Timestamp(actualDateCal.getTimeInMillis());
+    actualDateStr = actualDateTs.toString();
+    actualDateStr = actualDateStr.substring(0, actualDateStr.indexOf('.'));
+    context.put("actualDateStr", actualDateStr);
+
     // get Shipment tracking info
     osisCond = EntityCondition.makeCondition([orderId : orderId], EntityOperator.AND);
     osisOrder = ["shipmentId", "shipmentRouteSegmentId", "shipmentPackageSeqId"];
@@ -357,45 +416,8 @@ if (orderHeader) {
         context.requiredProductQuantityMap = FastMap.newInstance();
         context.onOrderProductQuantityMap = FastMap.newInstance();
     }
-}
-
-paramString = "";
-if (orderId) paramString += "orderId=" + orderId;
-if (workEffortId) paramString += "&workEffortId=" + workEffortId;
-if (assignPartyId) paramString += "&partyId=" + assignPartyId;
-if (assignRoleTypeId) paramString += "&roleTypeId=" + assignRoleTypeId;
-if (fromDate) paramString += "&fromDate=" + fromDate;
-context.paramString = paramString;
-
-workEffortStatus = null;
-if (workEffortId && assignPartyId && assignRoleTypeId && fromDate) {
-    fields = [workEffortId : workEffortId, partyId : assignPartyId, roleTypeId : assignRoleTypeId, fromDate : fromDate];
-    wepa = delegator.findOne("WorkEffortPartyAssignment", fields, false);
 
-    if ("CAL_ACCEPTED".equals(wepa?.statusId)) {
-        workEffort = delegator.findOne("WorkEffort", [workEffortId : workEffortId], false);
-        workEffortStatus = workEffort.currentStatusId;
-        if (workEffortStatus) {
-            context.workEffortStatus = workEffortStatus;
-            if (workEffortStatus.equals("WF_RUNNING") || workEffortStatus.equals("WF_SUSPENDED"))
-                context.inProcess = true;
-        }
-
-        if (workEffort) {
-            if ("true".equals(delegate) || "WF_RUNNING".equals(workEffortStatus)) {
-                actFields = [packageId : workEffort.workflowPackageId, packageVersion : workEffort.workflowPackageVersion, processId : workEffort.workflowProcessId, processVersion : workEffort.workflowProcessVersion, activityId : workEffort.workflowActivityId];
-                activity = delegator.findOne("WorkflowActivity", actFields, false);
-                if (activity) {
-                    transitions = activity.getRelated("FromWorkflowTransition", null, ["-transitionId"], false);
-                    context.wfTransitions = transitions;
-                }
-            }
-        }
-    }
-}
-
-if (orderHeader) {
-    // list to find all the POSTAL_ADDRESS for the shipment party.
+        // list to find all the POSTAL_ADDRESS for the shipment party.
     orderParty = delegator.findOne("Party", [partyId : partyId], false);
     shippingContactMechList = ContactHelper.getContactMech(orderParty, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false);
     context.shippingContactMechList = shippingContactMechList;
@@ -428,9 +450,7 @@ if (orderHeader) {
             context.currentCatalogName = currentCatalogName;
         }
     }
-}
 
-if (orderHeader) {
    // list to find all the POSTAL_ADDRESS for the party.
    orderParty = delegator.findOne("Party", [partyId : partyId], false);
    postalContactMechList = ContactHelper.getContactMechByType(orderParty,"POSTAL_ADDRESS", false);
@@ -445,6 +465,41 @@ if (orderHeader) {
    context.emailContactMechList = emailContactMechList;
 }
 
+paramString = "";
+if (orderId) paramString += "orderId=" + orderId;
+if (workEffortId) paramString += "&workEffortId=" + workEffortId;
+if (assignPartyId) paramString += "&partyId=" + assignPartyId;
+if (assignRoleTypeId) paramString += "&roleTypeId=" + assignRoleTypeId;
+if (fromDate) paramString += "&fromDate=" + fromDate;
+context.paramString = paramString;
+
+workEffortStatus = null;
+if (workEffortId && assignPartyId && assignRoleTypeId && fromDate) {
+    fields = [workEffortId : workEffortId, partyId : assignPartyId, roleTypeId : assignRoleTypeId, fromDate : fromDate];
+    wepa = delegator.findOne("WorkEffortPartyAssignment", fields, false);
+
+    if ("CAL_ACCEPTED".equals(wepa?.statusId)) {
+        workEffort = delegator.findOne("WorkEffort", [workEffortId : workEffortId], false);
+        workEffortStatus = workEffort.currentStatusId;
+        if (workEffortStatus) {
+            context.workEffortStatus = workEffortStatus;
+            if (workEffortStatus.equals("WF_RUNNING") || workEffortStatus.equals("WF_SUSPENDED"))
+                context.inProcess = true;
+        }
+
+        if (workEffort) {
+            if ("true".equals(delegate) || "WF_RUNNING".equals(workEffortStatus)) {
+                actFields = [packageId : workEffort.workflowPackageId, packageVersion : workEffort.workflowPackageVersion, processId : workEffort.workflowProcessId, processVersion : workEffort.workflowProcessVersion, activityId : workEffort.workflowActivityId];
+                activity = delegator.findOne("WorkflowActivity", actFields, false);
+                if (activity) {
+                    transitions = activity.getRelated("FromWorkflowTransition", null, ["-transitionId"], false);
+                    context.wfTransitions = transitions;
+                }
+            }
+        }
+    }
+}
+
 if (orderItems) {
     orderItem = EntityUtil.getFirst(orderItems);
     context.orderItem = orderItem;
@@ -453,45 +508,45 @@ if (orderItems) {
 // getting online ship estimates corresponding to this Order from UPS when "Hold" button will be clicked, when user packs from weight package screen.
 // This case comes when order's shipping amount is  more then or less than default percentage (defined in shipment.properties) of online UPS shipping amount.
 
-    condn = EntityCondition.makeCondition([
-                                      EntityCondition.makeCondition("primaryOrderId", EntityOperator.EQUALS, orderId),
-                                      EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "SHIPMENT_PICKED")],
-                                  EntityOperator.AND);
-    shipments = delegator.findList("Shipment", condn, null, null, null, false);
-    if (shipments) {
-        pickedShipmentId = EntityUtil.getFirst(shipments).shipmentId;
-        shipmentRouteSegment = EntityUtil.getFirst(delegator.findList("ShipmentRouteSegment",EntityCondition.makeCondition([shipmentId : pickedShipmentId]), null, null, null, false));
-        context.shipmentRouteSegmentId = shipmentRouteSegment.shipmentRouteSegmentId;
-        context.pickedShipmentId = pickedShipmentId;
-        if (pickedShipmentId && shipmentRouteSegment.trackingIdNumber) {
-            if ("UPS" == shipmentRouteSegment.carrierPartyId && productStore) {
-                resultMap = dispatcher.runSync('upsShipmentAlternateRatesEstimate', [productStoreId: productStore.productStoreId, shipmentId: pickedShipmentId]);
-                shippingRates = resultMap.shippingRates;
-                shippingRateList = [];
-                shippingRates.each { shippingRate ->
-                    shippingMethodAndRate = [:];
-                    serviceCodes = shippingRate.keySet();
-                    serviceCodes.each { serviceCode ->
-                        carrierShipmentMethod = EntityUtil.getFirst(delegator.findByAnd("CarrierShipmentMethod", [partyId : "UPS", carrierServiceCode : serviceCode], null, false));
-                        shipmentMethodTypeId = carrierShipmentMethod.shipmentMethodTypeId;
-                        rate = shippingRate.get(serviceCode);
-                        shipmentMethodDescription = EntityUtil.getFirst(carrierShipmentMethod.getRelated("ShipmentMethodType", null, null, false)).description;
-                        shippingMethodAndRate.shipmentMethodTypeId = carrierShipmentMethod.shipmentMethodTypeId;
-                        shippingMethodAndRate.rate = rate;
-                        shippingMethodAndRate.shipmentMethodDescription = shipmentMethodDescription;
-                        shippingRateList.add(shippingMethodAndRate);
-                    }
-               }
-                context.shippingRateList = shippingRateList;
-            }
+condn = EntityCondition.makeCondition([
+            EntityCondition.makeCondition("primaryOrderId", EntityOperator.EQUALS, orderId),
+            EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "SHIPMENT_PICKED")],
+            EntityOperator.AND);
+shipments = delegator.findList("Shipment", condn, null, null, null, false);
+if (shipments) {
+    pickedShipmentId = EntityUtil.getFirst(shipments).shipmentId;
+    shipmentRouteSegment = EntityUtil.getFirst(delegator.findList("ShipmentRouteSegment",EntityCondition.makeCondition([shipmentId : pickedShipmentId]), null, null, null, false));
+    context.shipmentRouteSegmentId = shipmentRouteSegment.shipmentRouteSegmentId;
+    context.pickedShipmentId = pickedShipmentId;
+    if (pickedShipmentId && shipmentRouteSegment.trackingIdNumber) {
+        if ("UPS" == shipmentRouteSegment.carrierPartyId && productStore) {
+            resultMap = dispatcher.runSync('upsShipmentAlternateRatesEstimate', [productStoreId: productStore.productStoreId, shipmentId: pickedShipmentId]);
+            shippingRates = resultMap.shippingRates;
+            shippingRateList = [];
+            shippingRates.each { shippingRate ->
+                shippingMethodAndRate = [:];
+                serviceCodes = shippingRate.keySet();
+                serviceCodes.each { serviceCode ->
+                    carrierShipmentMethod = EntityUtil.getFirst(delegator.findByAnd("CarrierShipmentMethod", [partyId : "UPS", carrierServiceCode : serviceCode], null, false));
+                    shipmentMethodTypeId = carrierShipmentMethod.shipmentMethodTypeId;
+                    rate = shippingRate.get(serviceCode);
+                    shipmentMethodDescription = EntityUtil.getFirst(carrierShipmentMethod.getRelated("ShipmentMethodType", null, null, false)).description;
+                    shippingMethodAndRate.shipmentMethodTypeId = carrierShipmentMethod.shipmentMethodTypeId;
+                    shippingMethodAndRate.rate = rate;
+                    shippingMethodAndRate.shipmentMethodDescription = shipmentMethodDescription;
+                    shippingRateList.add(shippingMethodAndRate);
+                }
+           }
+            context.shippingRateList = shippingRateList;
         }
     }
+}
 
-    // get orderAdjustmentId for SHIPPING_CHARGES
-    orderAdjustmentId = null;
-    orderAdjustments.each { orderAdjustment ->
-        if(orderAdjustment.orderAdjustmentTypeId.equals("SHIPPING_CHARGES")) {
-            orderAdjustmentId = orderAdjustment.orderAdjustmentId;
-        }
+// get orderAdjustmentId for SHIPPING_CHARGES
+orderAdjustmentId = null;
+orderAdjustments.each { orderAdjustment ->
+    if(orderAdjustment.orderAdjustmentTypeId.equals("SHIPPING_CHARGES")) {
+        orderAdjustmentId = orderAdjustment.orderAdjustmentId;
     }
-    context.orderAdjustmentId = orderAdjustmentId;
+}
+context.orderAdjustmentId = orderAdjustmentId;