You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Deepak Dixit <de...@hotwaxsystems.com> on 2015/06/21 07:10:34 UTC
Re: svn commit: r1686635 - in /ofbiz/trunk/applications/order:
servicedef/ src/org/ofbiz/order/order/ webapp/ordermgr/WEB-INF/
webapp/ordermgr/WEB-INF/actions/order/ webapp/ordermgr/order/
Please do not use javolution classes.
Thanks & Regards
--
Deepak Dixit
On Saturday, June 20, 2015, <di...@apache.org> wrote:
> Author: diveshdutta
> Date: Sat Jun 20 14:58:45 2015
> New Revision: 1686635
>
> URL: http://svn.apache.org/r1686635
> Log:
> [OFBIZ-5347] 1) Fixed issue: Shipping costs not recalculated after
> changing sales order shipment method. For this introduced new service as
> per the design in this task. 2) This service will loads the cart save new
> shipping method in cart, re-do all the calculations for tax and promotion,
> and saves the cart again in order. 3) Also adding new SECA rule which will
> trigger resetGrandTotal service on new service updateShipGroupShipInfo.
>
> Modified:
> ofbiz/trunk/applications/order/servicedef/secas.xml
> ofbiz/trunk/applications/order/servicedef/services.xml
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
>
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
>
> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
>
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
>
> Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
> +++ ofbiz/trunk/applications/order/servicedef/secas.xml Sat Jun 20
> 14:58:45 2015
> @@ -451,4 +451,7 @@ under the License.
> <condition field-name="orderTypeId" operator="equals"
> value="SALES_ORDER"/>
> <action service="checkOrderItemForProductGroupOrder" mode="sync"/>
> </eca>
> + <eca service="updateShipGroupShipInfo" event="commit">
> + <action service="resetGrandTotal" mode="sync"/>
> + </eca>
> </service-eca>
>
> Modified: ofbiz/trunk/applications/order/servicedef/services.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> --- ofbiz/trunk/applications/order/servicedef/services.xml (original)
> +++ ofbiz/trunk/applications/order/servicedef/services.xml Sat Jun 20
> 14:58:45 2015
> @@ -1187,4 +1187,12 @@ under the License.
> <attribute name="quantity" type="BigDecimal" mode="IN"/>
> </service>
>
> + <service name="updateShipGroupShipInfo" engine="java"
> location="org.ofbiz.order.order.OrderServices"
> invoke="updateShipGroupShipInfo" auth="true">
> + <description>Update Shipping Information on Order
> View</description>
> + <attribute name="contactMechId" type="String" mode="IN"
> optional="false"/>
> + <attribute name="orderId" type="String" mode="IN"
> optional="true"/>
> + <attribute name="oldContactMechId" type="String" mode="IN"
> optional="true"/>
> + <attribute name="shipGroupSeqId" type="String" mode="IN"
> optional="true"/>
> + <attribute name="shipmentMethod" type="String" mode="IN"
> optional="true"/>
> + </service>
> </services>
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> Sat Jun 20 14:58:45 2015
> @@ -33,6 +33,8 @@ import java.util.Locale;
> import java.util.Map;
> import java.util.Set;
>
> +import javolution.util.FastList;
> +
> import org.ofbiz.base.util.Debug;
> import org.ofbiz.base.util.UtilDateTime;
> import org.ofbiz.base.util.UtilFormatOut;
> @@ -3012,4 +3014,17 @@ public class OrderReadHelper {
> }
> }
>
> + public List<BigDecimal> getShippableSizes(String shipGrouSeqId) {
> + List<BigDecimal> shippableSizes = FastList.newInstance();
> +
> + List<GenericValue> validItems = getValidOrderItems(shipGrouSeqId);
> + if (validItems != null) {
> + Iterator<GenericValue> i = validItems.iterator();
> + while (i.hasNext()) {
> + GenericValue item = i.next();
> + shippableSizes.add(this.getItemSize(item));
> + }
> + }
> + return shippableSizes;
> + }
> }
>
> Modified:
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> (original)
> +++
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> Sat Jun 20 14:58:45 2015
> @@ -6371,4 +6371,110 @@ public class OrderServices {
>
> return ServiceUtil.returnSuccess();
> }
> +
> + /**
> + * This service runs when you update shipping method of Order from
> order view page.
> + */
> + public static Map<String, Object>
> updateShipGroupShipInfo(DispatchContext dctx, Map<String, ? extends Object>
> context) {
> + LocalDispatcher dispatcher = dctx.getDispatcher();
> + Delegator delegator = dctx.getDelegator();
> + Locale locale = (Locale) context.get("locale");
> + GenericValue userLogin = (GenericValue)context.get("userLogin");
> + String orderId = (String)context.get("orderId");
> + String shipGroupSeqId = (String)context.get("shipGroupSeqId");
> + String contactMechId = (String)context.get("contactMechId");
> + String oldContactMechId = (String)context.get("oldContactMechId");
> + String shipmentMethod = (String)context.get("shipmentMethod");
> +
> + //load cart from order to update new shipping method or address
> + ShoppingCart shoppingCart = null;
> + try {
> + shoppingCart = loadCartForUpdate(dispatcher, delegator,
> userLogin, orderId);
> + } catch(GeneralException e) {
> + Debug.logError(e, module);
> + }
> +
> + String message = null;
> + if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
> + OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
> + List<GenericValue> shippingMethods = null;
> + String shipmentMethodTypeId = null;
> + String carrierPartyId = null;
> +
> + // get shipment method from OrderItemShipGroup, if not
> available in parameters
> + if (UtilValidate.isNotEmpty(shipmentMethod)) {
> + String[] arr = shipmentMethod.split( "@" );
> + shipmentMethodTypeId = arr[0];
> + carrierPartyId = arr[1];
> + } else {
> + GenericValue orderItemshipGroup =
> orh.getOrderItemShipGroup(shipGroupSeqId);
> + shipmentMethodTypeId =
> orderItemshipGroup.getString("shipmentMethodTypeId");
> + carrierPartyId =
> orderItemshipGroup.getString("carrierPartyId");
> + }
> + int groupIdx =Integer.parseInt(shipGroupSeqId);
> +
> + /* check whether new selected contact address is same as old
> contact.
> + If contact address is different, get applicable ship
> methods for changed contact */
> + if (UtilValidate.isNotEmpty(oldContactMechId) &&
> oldContactMechId.equals(contactMechId)) {
> + shoppingCart.setShipmentMethodTypeId(groupIdx - 1,
> shipmentMethodTypeId);
> + shoppingCart.setCarrierPartyId(groupIdx - 1,
> carrierPartyId);
> + } else {
> + Map<String, BigDecimal> shippableItemFeatures =
> orh.getFeatureIdQtyMap(shipGroupSeqId);
> + BigDecimal shippableTotal =
> orh.getShippableTotal(shipGroupSeqId);
> + BigDecimal shippableWeight =
> orh.getShippableWeight(shipGroupSeqId);
> + List<BigDecimal> shippableItemSizes =
> orh.getShippableSizes(shipGroupSeqId);
> +
> + GenericValue shippingAddress = null;
> + if(UtilValidate.isEmpty(shippingAddress)) {
> + shippingAddress =
> orh.getShippingAddress(shipGroupSeqId);
> + }
> +
> + shippingMethods =
> ProductStoreWorker.getAvailableStoreShippingMethods(delegator,
> orh.getProductStoreId(),
> + shippingAddress, shippableItemSizes,
> shippableItemFeatures, shippableWeight, shippableTotal);
> +
> + boolean isShippingMethodAvailable = false;
> + // search shipping method for ship group is applicable to
> new address or not.
> + for (GenericValue shippingMethod : shippingMethods) {
> + isShippingMethodAvailable =
> shippingMethod.getString("partyId").equals(carrierPartyId) &&
> shippingMethod.getString("shipmentMethodTypeId").equals(shipmentMethodTypeId);
> + if (isShippingMethodAvailable) {
> + shoppingCart.setShipmentMethodTypeId(groupIdx -
> 1, shipmentMethodTypeId);
> + shoppingCart.setCarrierPartyId(groupIdx - 1,
> carrierPartyId);
> + break;
> + }
> + }
> +
> + // set first shipping method from list, if shipping
> method for ship group is not applicable to new ship address.
> + if(!isShippingMethodAvailable) {
> + shoppingCart.setShipmentMethodTypeId(groupIdx - 1,
> shippingMethods.get(0).getString("shipmentMethodTypeId"));
> + shoppingCart.setCarrierPartyId(groupIdx - 1,
> shippingMethods.get(0).getString("carrierPartyId"));
> +
> + String newShipMethTypeDesc =null;
> + String shipMethTypeDesc=null;
> + try {
> + shipMethTypeDesc =
> delegator.findOne("ShipmentMethodType",
> UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId),
> false).getString("description");
> + newShipMethTypeDesc =
> delegator.findOne("ShipmentMethodType",
> UtilMisc.toMap("shipmentMethodTypeId",
> shippingMethods.get(0).getString("shipmentMethodTypeId")),
> false).getString("description");
> + } catch(GenericEntityException e) {
> + Debug.logError(e, module);
> + }
> + // message to notify user for not applicability of
> shipping method
> + message= "Shipping Method "+carrierPartyId+"
> "+shipMethTypeDesc+" is not applicable to shipping address.
> "+shippingMethods.get(0).getString("carrierPartyId")+"
> "+newShipMethTypeDesc+" has been set for shipping address.";
> + }
> + shoppingCart.setShippingContactMechId(groupIdx-1,
> contactMechId);
> + }
> + }
> +
> + // save cart after updating shipping method and shipping address.
> + Map<String, Object> changeMap = new HashMap<String, Object>();
> + try {
> + saveUpdatedCartToOrder(dispatcher, delegator, shoppingCart,
> locale, userLogin, orderId, changeMap, true, false);
> + } catch(GeneralException e) {
> + Debug.logError(e, module);
> + }
> +
> + if (UtilValidate.isNotEmpty(message)) {
> + return ServiceUtil.returnSuccess(message);
> + } else {
> + return ServiceUtil.returnSuccess();
> + }
> + }
> }
>
> 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=1686635&r1=1686634&r2=1686635&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
> Sat Jun 20 14:58:45 2015
> @@ -29,6 +29,7 @@ import org.ofbiz.order.order.*;
> import org.ofbiz.party.contact.*;
> import org.ofbiz.product.inventory.InventoryWorker;
> import org.ofbiz.product.catalog.CatalogWorker;
> +import org.ofbiz.product.store.ProductStoreWorker;
> import org.ofbiz.accounting.payment.*;
>
> orderId = parameters.orderId;
> @@ -420,8 +421,19 @@ if (orderHeader) {
> context.shippingContactMechList = shippingContactMechList;
>
> // list to find all the shipmentMethods from the view named
> "ProductStoreShipmentMethView".
> - if (productStore) {
> - context.productStoreShipmentMethList =
> from("ProductStoreShipmentMethView").where("productStoreId",
> productStore.productStoreId).orderBy("sequenceNumber").cache(true).queryList();
> + shipGroupShippingMethods = [:];
> + shipGroups.each { shipGroup ->
> + shipGroupSeqId = shipGroup.shipGroupSeqId;
> + shippableItemFeatures =
> orderReadHelper.getFeatureIdQtyMap(shipGroupSeqId);
> + shippableTotal =
> orderReadHelper.getShippableTotal(shipGroupSeqId);
> + shippableWeight =
> orderReadHelper.getShippableWeight(shipGroupSeqId);
> + shippableItemSizes =
> orderReadHelper.getShippableSizes(shipGroupSeqId);
> + shippingAddress =
> orderReadHelper.getShippingAddress(shipGroupSeqId);
> +
> + List<GenericValue> productStoreShipmentMethList =
> ProductStoreWorker.getAvailableStoreShippingMethods(delegator,
> orderReadHelper.getProductStoreId(),
> + shippingAddress, shippableItemSizes,
> shippableItemFeatures, shippableWeight, shippableTotal);
> + shipGroupShippingMethods.put(shipGroupSeqId,
> productStoreShipmentMethList);
> + context.shipGroupShippingMethods = shipGroupShippingMethods;
> }
>
> // Get a map of returnable items
>
> Modified:
> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> (original)
> +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> Sat Jun 20 14:58:45 2015
> @@ -1701,7 +1701,7 @@ under the License.
> <request-map uri="addShippingAddress">
> <security https="true" auth="true"/>
> <event type="service" invoke="createUpdateShippingAddress"/>
> - <response name="success" type="request"
> value="updateOrderItemShipGroup"/>
> + <response name="success" type="request"
> value="updateShipGroupShipInfo"/>
> <response name="error" type="view" value="orderview"/>
> </request-map>
> <request-map uri="getAssociatedStateList">
> @@ -1888,6 +1888,13 @@ under the License.
> <response name="success" type="view" value="splitship"/>
> <response name="error" type="request" value="splitship"/>
> </request-map>
> +
> + <request-map uri="updateShipGroupShipInfo">
> + <security https="true" auth="true"/>
> + <event type="service" invoke="updateShipGroupShipInfo"/>
> + <response name="success" type="view" value="orderview"/>
> + <response name="error" type="view" value="orderview"/>
> + </request-map>
>
> <!--
> These are just examples of reports developed using JasperReport
> and not really
>
> Modified:
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl?rev=1686635&r1=1686634&r2=1686635&view=diff
>
> ==============================================================================
> ---
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> (original)
> +++
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> Sat Jun 20 14:58:45 2015
> @@ -353,7 +353,7 @@ under the License.
> <br class="clear"/>
> </div>
> <div class="screenlet-body"
> id="ShipGroupScreenletBody_${shipGroup.shipGroupSeqId}">
> - <form name="updateOrderItemShipGroup" method="post"
> action="<@o...@ofbizUrl>">
> + <form name="updateOrderItemShipGroup" method="post"
> action="<@o...@ofbizUrl>">
> <input type="hidden" name="orderId" value="${orderId!}"/>
> <input type="hidden" name="shipGroupSeqId"
> value="${shipGroup.shipGroupSeqId!}"/>
> <input type="hidden" name="contactMechPurposeTypeId"
> value="SHIPPING_LOCATION"/>
> @@ -404,7 +404,7 @@ under the License.
> <#if
> shipGroup.shipmentMethodTypeId?has_content>
> <option
> value="${shipGroup.shipmentMethodTypeId}@${shipGroup.carrierPartyId!}@${shipGroup.carrierRoleTypeId!}"><#if
> shipGroup.carrierPartyId?? && shipGroup.carrierPartyId !=
> "_NA_">${shipGroup.carrierPartyId!}</#if> ${shipmentMethodType.get("description",locale)!}</option>
> </#if>
> - <#list productStoreShipmentMethList as
> productStoreShipmentMethod>
> + <#list
> shipGroupShippingMethods[shipGroup.shipGroupSeqId] as
> productStoreShipmentMethod>
> <#assign shipmentMethodTypeAndParty =
> productStoreShipmentMethod.shipmentMethodTypeId + "@" +
> productStoreShipmentMethod.partyId + "@" +
> productStoreShipmentMethod.roleTypeId>
> <#if
> productStoreShipmentMethod.partyId?has_content ||
> productStoreShipmentMethod?has_content>
> <option
> value="${shipmentMethodTypeAndParty!}"><#if
> productStoreShipmentMethod.partyId !=
> "_NA_">${productStoreShipmentMethod.partyId!}</#if> ${productStoreShipmentMethod.get("description",locale)?default("")}</option>
>
>
>
--
Thanks & Regards
--
Deepak Dixit
www.hotwaxsystems.com
Re: svn commit: r1686635 - in /ofbiz/trunk/applications/order:
servicedef/ src/org/ofbiz/order/order/ webapp/ordermgr/WEB-INF/
webapp/ordermgr/WEB-INF/actions/order/ webapp/ordermgr/order/
Posted by Divesh Dutta <di...@hotwaxsystems.com>.
Thanks Deepak. Will change the code accordingly.
Thanks
--
Divesh Dutta.
On Sun, Jun 21, 2015 at 10:40 AM, Deepak Dixit <
deepak.dixit@hotwaxsystems.com> wrote:
> Please do not use javolution classes.
>
> Thanks & Regards
> --
> Deepak Dixit
>
> On Saturday, June 20, 2015, <di...@apache.org> wrote:
>
> > Author: diveshdutta
> > Date: Sat Jun 20 14:58:45 2015
> > New Revision: 1686635
> >
> > URL: http://svn.apache.org/r1686635
> > Log:
> > [OFBIZ-5347] 1) Fixed issue: Shipping costs not recalculated after
> > changing sales order shipment method. For this introduced new service as
> > per the design in this task. 2) This service will loads the cart save new
> > shipping method in cart, re-do all the calculations for tax and
> promotion,
> > and saves the cart again in order. 3) Also adding new SECA rule which
> will
> > trigger resetGrandTotal service on new service updateShipGroupShipInfo.
> >
> > Modified:
> > ofbiz/trunk/applications/order/servicedef/secas.xml
> > ofbiz/trunk/applications/order/servicedef/services.xml
> >
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> >
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> >
> >
> ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
> > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> >
> >
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> >
> > Modified: ofbiz/trunk/applications/order/servicedef/secas.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/secas.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > --- ofbiz/trunk/applications/order/servicedef/secas.xml (original)
> > +++ ofbiz/trunk/applications/order/servicedef/secas.xml Sat Jun 20
> > 14:58:45 2015
> > @@ -451,4 +451,7 @@ under the License.
> > <condition field-name="orderTypeId" operator="equals"
> > value="SALES_ORDER"/>
> > <action service="checkOrderItemForProductGroupOrder"
> mode="sync"/>
> > </eca>
> > + <eca service="updateShipGroupShipInfo" event="commit">
> > + <action service="resetGrandTotal" mode="sync"/>
> > + </eca>
> > </service-eca>
> >
> > Modified: ofbiz/trunk/applications/order/servicedef/services.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > --- ofbiz/trunk/applications/order/servicedef/services.xml (original)
> > +++ ofbiz/trunk/applications/order/servicedef/services.xml Sat Jun 20
> > 14:58:45 2015
> > @@ -1187,4 +1187,12 @@ under the License.
> > <attribute name="quantity" type="BigDecimal" mode="IN"/>
> > </service>
> >
> > + <service name="updateShipGroupShipInfo" engine="java"
> > location="org.ofbiz.order.order.OrderServices"
> > invoke="updateShipGroupShipInfo" auth="true">
> > + <description>Update Shipping Information on Order
> > View</description>
> > + <attribute name="contactMechId" type="String" mode="IN"
> > optional="false"/>
> > + <attribute name="orderId" type="String" mode="IN"
> > optional="true"/>
> > + <attribute name="oldContactMechId" type="String" mode="IN"
> > optional="true"/>
> > + <attribute name="shipGroupSeqId" type="String" mode="IN"
> > optional="true"/>
> > + <attribute name="shipmentMethod" type="String" mode="IN"
> > optional="true"/>
> > + </service>
> > </services>
> >
> > Modified:
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> > (original)
> > +++
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
> > Sat Jun 20 14:58:45 2015
> > @@ -33,6 +33,8 @@ import java.util.Locale;
> > import java.util.Map;
> > import java.util.Set;
> >
> > +import javolution.util.FastList;
> > +
> > import org.ofbiz.base.util.Debug;
> > import org.ofbiz.base.util.UtilDateTime;
> > import org.ofbiz.base.util.UtilFormatOut;
> > @@ -3012,4 +3014,17 @@ public class OrderReadHelper {
> > }
> > }
> >
> > + public List<BigDecimal> getShippableSizes(String shipGrouSeqId) {
> > + List<BigDecimal> shippableSizes = FastList.newInstance();
> > +
> > + List<GenericValue> validItems =
> getValidOrderItems(shipGrouSeqId);
> > + if (validItems != null) {
> > + Iterator<GenericValue> i = validItems.iterator();
> > + while (i.hasNext()) {
> > + GenericValue item = i.next();
> > + shippableSizes.add(this.getItemSize(item));
> > + }
> > + }
> > + return shippableSizes;
> > + }
> > }
> >
> > Modified:
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> > (original)
> > +++
> >
> ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
> > Sat Jun 20 14:58:45 2015
> > @@ -6371,4 +6371,110 @@ public class OrderServices {
> >
> > return ServiceUtil.returnSuccess();
> > }
> > +
> > + /**
> > + * This service runs when you update shipping method of Order from
> > order view page.
> > + */
> > + public static Map<String, Object>
> > updateShipGroupShipInfo(DispatchContext dctx, Map<String, ? extends
> Object>
> > context) {
> > + LocalDispatcher dispatcher = dctx.getDispatcher();
> > + Delegator delegator = dctx.getDelegator();
> > + Locale locale = (Locale) context.get("locale");
> > + GenericValue userLogin =
> (GenericValue)context.get("userLogin");
> > + String orderId = (String)context.get("orderId");
> > + String shipGroupSeqId = (String)context.get("shipGroupSeqId");
> > + String contactMechId = (String)context.get("contactMechId");
> > + String oldContactMechId =
> (String)context.get("oldContactMechId");
> > + String shipmentMethod = (String)context.get("shipmentMethod");
> > +
> > + //load cart from order to update new shipping method or address
> > + ShoppingCart shoppingCart = null;
> > + try {
> > + shoppingCart = loadCartForUpdate(dispatcher, delegator,
> > userLogin, orderId);
> > + } catch(GeneralException e) {
> > + Debug.logError(e, module);
> > + }
> > +
> > + String message = null;
> > + if (UtilValidate.isNotEmpty(shipGroupSeqId)) {
> > + OrderReadHelper orh = new OrderReadHelper(delegator,
> orderId);
> > + List<GenericValue> shippingMethods = null;
> > + String shipmentMethodTypeId = null;
> > + String carrierPartyId = null;
> > +
> > + // get shipment method from OrderItemShipGroup, if not
> > available in parameters
> > + if (UtilValidate.isNotEmpty(shipmentMethod)) {
> > + String[] arr = shipmentMethod.split( "@" );
> > + shipmentMethodTypeId = arr[0];
> > + carrierPartyId = arr[1];
> > + } else {
> > + GenericValue orderItemshipGroup =
> > orh.getOrderItemShipGroup(shipGroupSeqId);
> > + shipmentMethodTypeId =
> > orderItemshipGroup.getString("shipmentMethodTypeId");
> > + carrierPartyId =
> > orderItemshipGroup.getString("carrierPartyId");
> > + }
> > + int groupIdx =Integer.parseInt(shipGroupSeqId);
> > +
> > + /* check whether new selected contact address is same as old
> > contact.
> > + If contact address is different, get applicable ship
> > methods for changed contact */
> > + if (UtilValidate.isNotEmpty(oldContactMechId) &&
> > oldContactMechId.equals(contactMechId)) {
> > + shoppingCart.setShipmentMethodTypeId(groupIdx - 1,
> > shipmentMethodTypeId);
> > + shoppingCart.setCarrierPartyId(groupIdx - 1,
> > carrierPartyId);
> > + } else {
> > + Map<String, BigDecimal> shippableItemFeatures =
> > orh.getFeatureIdQtyMap(shipGroupSeqId);
> > + BigDecimal shippableTotal =
> > orh.getShippableTotal(shipGroupSeqId);
> > + BigDecimal shippableWeight =
> > orh.getShippableWeight(shipGroupSeqId);
> > + List<BigDecimal> shippableItemSizes =
> > orh.getShippableSizes(shipGroupSeqId);
> > +
> > + GenericValue shippingAddress = null;
> > + if(UtilValidate.isEmpty(shippingAddress)) {
> > + shippingAddress =
> > orh.getShippingAddress(shipGroupSeqId);
> > + }
> > +
> > + shippingMethods =
> > ProductStoreWorker.getAvailableStoreShippingMethods(delegator,
> > orh.getProductStoreId(),
> > + shippingAddress, shippableItemSizes,
> > shippableItemFeatures, shippableWeight, shippableTotal);
> > +
> > + boolean isShippingMethodAvailable = false;
> > + // search shipping method for ship group is applicable
> to
> > new address or not.
> > + for (GenericValue shippingMethod : shippingMethods) {
> > + isShippingMethodAvailable =
> > shippingMethod.getString("partyId").equals(carrierPartyId) &&
> >
> shippingMethod.getString("shipmentMethodTypeId").equals(shipmentMethodTypeId);
> > + if (isShippingMethodAvailable) {
> > + shoppingCart.setShipmentMethodTypeId(groupIdx -
> > 1, shipmentMethodTypeId);
> > + shoppingCart.setCarrierPartyId(groupIdx - 1,
> > carrierPartyId);
> > + break;
> > + }
> > + }
> > +
> > + // set first shipping method from list, if shipping
> > method for ship group is not applicable to new ship address.
> > + if(!isShippingMethodAvailable) {
> > + shoppingCart.setShipmentMethodTypeId(groupIdx - 1,
> > shippingMethods.get(0).getString("shipmentMethodTypeId"));
> > + shoppingCart.setCarrierPartyId(groupIdx - 1,
> > shippingMethods.get(0).getString("carrierPartyId"));
> > +
> > + String newShipMethTypeDesc =null;
> > + String shipMethTypeDesc=null;
> > + try {
> > + shipMethTypeDesc =
> > delegator.findOne("ShipmentMethodType",
> > UtilMisc.toMap("shipmentMethodTypeId", shipmentMethodTypeId),
> > false).getString("description");
> > + newShipMethTypeDesc =
> > delegator.findOne("ShipmentMethodType",
> > UtilMisc.toMap("shipmentMethodTypeId",
> > shippingMethods.get(0).getString("shipmentMethodTypeId")),
> > false).getString("description");
> > + } catch(GenericEntityException e) {
> > + Debug.logError(e, module);
> > + }
> > + // message to notify user for not applicability of
> > shipping method
> > + message= "Shipping Method "+carrierPartyId+"
> > "+shipMethTypeDesc+" is not applicable to shipping address.
> > "+shippingMethods.get(0).getString("carrierPartyId")+"
> > "+newShipMethTypeDesc+" has been set for shipping address.";
> > + }
> > + shoppingCart.setShippingContactMechId(groupIdx-1,
> > contactMechId);
> > + }
> > + }
> > +
> > + // save cart after updating shipping method and shipping
> address.
> > + Map<String, Object> changeMap = new HashMap<String, Object>();
> > + try {
> > + saveUpdatedCartToOrder(dispatcher, delegator, shoppingCart,
> > locale, userLogin, orderId, changeMap, true, false);
> > + } catch(GeneralException e) {
> > + Debug.logError(e, module);
> > + }
> > +
> > + if (UtilValidate.isNotEmpty(message)) {
> > + return ServiceUtil.returnSuccess(message);
> > + } else {
> > + return ServiceUtil.returnSuccess();
> > + }
> > + }
> > }
> >
> > 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=1686635&r1=1686634&r2=1686635&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
> > Sat Jun 20 14:58:45 2015
> > @@ -29,6 +29,7 @@ import org.ofbiz.order.order.*;
> > import org.ofbiz.party.contact.*;
> > import org.ofbiz.product.inventory.InventoryWorker;
> > import org.ofbiz.product.catalog.CatalogWorker;
> > +import org.ofbiz.product.store.ProductStoreWorker;
> > import org.ofbiz.accounting.payment.*;
> >
> > orderId = parameters.orderId;
> > @@ -420,8 +421,19 @@ if (orderHeader) {
> > context.shippingContactMechList = shippingContactMechList;
> >
> > // list to find all the shipmentMethods from the view named
> > "ProductStoreShipmentMethView".
> > - if (productStore) {
> > - context.productStoreShipmentMethList =
> > from("ProductStoreShipmentMethView").where("productStoreId",
> >
> productStore.productStoreId).orderBy("sequenceNumber").cache(true).queryList();
> > + shipGroupShippingMethods = [:];
> > + shipGroups.each { shipGroup ->
> > + shipGroupSeqId = shipGroup.shipGroupSeqId;
> > + shippableItemFeatures =
> > orderReadHelper.getFeatureIdQtyMap(shipGroupSeqId);
> > + shippableTotal =
> > orderReadHelper.getShippableTotal(shipGroupSeqId);
> > + shippableWeight =
> > orderReadHelper.getShippableWeight(shipGroupSeqId);
> > + shippableItemSizes =
> > orderReadHelper.getShippableSizes(shipGroupSeqId);
> > + shippingAddress =
> > orderReadHelper.getShippingAddress(shipGroupSeqId);
> > +
> > + List<GenericValue> productStoreShipmentMethList =
> > ProductStoreWorker.getAvailableStoreShippingMethods(delegator,
> > orderReadHelper.getProductStoreId(),
> > + shippingAddress, shippableItemSizes,
> > shippableItemFeatures, shippableWeight, shippableTotal);
> > + shipGroupShippingMethods.put(shipGroupSeqId,
> > productStoreShipmentMethList);
> > + context.shipGroupShippingMethods = shipGroupShippingMethods;
> > }
> >
> > // Get a map of returnable items
> >
> > Modified:
> > ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> > (original)
> > +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
> > Sat Jun 20 14:58:45 2015
> > @@ -1701,7 +1701,7 @@ under the License.
> > <request-map uri="addShippingAddress">
> > <security https="true" auth="true"/>
> > <event type="service" invoke="createUpdateShippingAddress"/>
> > - <response name="success" type="request"
> > value="updateOrderItemShipGroup"/>
> > + <response name="success" type="request"
> > value="updateShipGroupShipInfo"/>
> > <response name="error" type="view" value="orderview"/>
> > </request-map>
> > <request-map uri="getAssociatedStateList">
> > @@ -1888,6 +1888,13 @@ under the License.
> > <response name="success" type="view" value="splitship"/>
> > <response name="error" type="request" value="splitship"/>
> > </request-map>
> > +
> > + <request-map uri="updateShipGroupShipInfo">
> > + <security https="true" auth="true"/>
> > + <event type="service" invoke="updateShipGroupShipInfo"/>
> > + <response name="success" type="view" value="orderview"/>
> > + <response name="error" type="view" value="orderview"/>
> > + </request-map>
> >
> > <!--
> > These are just examples of reports developed using JasperReport
> > and not really
> >
> > Modified:
> >
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> > URL:
> >
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl?rev=1686635&r1=1686634&r2=1686635&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> > (original)
> > +++
> >
> ofbiz/trunk/applications/order/webapp/ordermgr/order/ordershippinginfo.ftl
> > Sat Jun 20 14:58:45 2015
> > @@ -353,7 +353,7 @@ under the License.
> > <br class="clear"/>
> > </div>
> > <div class="screenlet-body"
> > id="ShipGroupScreenletBody_${shipGroup.shipGroupSeqId}">
> > - <form name="updateOrderItemShipGroup" method="post"
> > action="<@o...@ofbizUrl>">
> > + <form name="updateOrderItemShipGroup" method="post"
> > action="<@o...@ofbizUrl>">
> > <input type="hidden" name="orderId" value="${orderId!}"/>
> > <input type="hidden" name="shipGroupSeqId"
> > value="${shipGroup.shipGroupSeqId!}"/>
> > <input type="hidden" name="contactMechPurposeTypeId"
> > value="SHIPPING_LOCATION"/>
> > @@ -404,7 +404,7 @@ under the License.
> > <#if
> > shipGroup.shipmentMethodTypeId?has_content>
> > <option
> > value="${shipGroup.shipmentMethodTypeId}@
> ${shipGroup.carrierPartyId!}@${shipGroup.carrierRoleTypeId!}"><#if
> > shipGroup.carrierPartyId?? && shipGroup.carrierPartyId !=
> >
> "_NA_">${shipGroup.carrierPartyId!}</#if> ${shipmentMethodType.get("description",locale)!}</option>
> > </#if>
> > - <#list productStoreShipmentMethList as
> > productStoreShipmentMethod>
> > + <#list
> > shipGroupShippingMethods[shipGroup.shipGroupSeqId] as
> > productStoreShipmentMethod>
> > <#assign shipmentMethodTypeAndParty
> =
> > productStoreShipmentMethod.shipmentMethodTypeId + "@" +
> > productStoreShipmentMethod.partyId + "@" +
> > productStoreShipmentMethod.roleTypeId>
> > <#if
> > productStoreShipmentMethod.partyId?has_content ||
> > productStoreShipmentMethod?has_content>
> > <option
> > value="${shipmentMethodTypeAndParty!}"><#if
> > productStoreShipmentMethod.partyId !=
> >
> "_NA_">${productStoreShipmentMethod.partyId!}</#if> ${productStoreShipmentMethod.get("description",locale)?default("")}</option>
> >
> >
> >
>
> --
> Thanks & Regards
> --
> Deepak Dixit
> www.hotwaxsystems.com
>