You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2009/01/07 16:37:09 UTC
Re: loadCartFromOrder setting shipGroups
Is an issue created ?
Jacques
From: "Stephen Rufle" <sr...@salmonllc.com>
>I think the attached patch fixes the issue I am having.
>
> For each OrderItemShipGroup get the shipGroupSeqId value and use that as
> the index. I also had to modify the call to
>
> 564: newItem.setQuantity(..., false, ...);
> in
> 398: org.ofbiz.order.shoppingcart.ShoppingCartItem.makeItem(...)
>
> so that when a second item gets added to the cart with a shipGroupSeqId
> less then the first the shipInfo member in cart does not get touched.
>
> I will create a JIRA issue, if no one finds any issues.
>
> Stephen Rufle wrote:
>> In ShoppingCartServices.loadCartFromOrder(dctx, context) there is a call
>> to get a list of shipGroups
>> *
>> 455: List<GenericValue>shipGroups = orh.getOrderItemShipGroupAssocs(item);*
>>
>> This then loops through setting information on the cart creating new
>> CartShipInfo objects if one can not be found. My issue is that when I
>> get to the second item in the loop the shipGroups are gotten for that
>> item and the
>>
>> *470: cart.setShipAfterDate(g, sg.getTimestamp("shipAfterDate"));*
>>
>> index (g) starts over and overwrites the previous value in the cart. I
>> am not sure how else to set the shipGroups on the cart though so any
>> advice would be great.
>>
>> My data for the above scenario is as follows
>> OrderItem orderItemSeqId="00001" productId="ABC"
>> OrderItemShipGroupAssoc orderItemSeqId="00001" shipGroupSeqId="00001"
>> OrderItemShipGroup shipGroupSeqId="00001" facilityId="AAA"
>>
>> OrderItem orderItemSeqId="00002" productId="ABC"
>> OrderItemShipGroupAssoc orderItemSeqId="00002" shipGroupSeqId="00002"
>> OrderItemShipGroup shipGroupSeqId="00002" facilityId="BBB"
>>
>>
>>
>>
>>
>
> --
> Stephen P Rufle
> srufle@salmonllc.com
> H1:480-626-8022
> H2:480-802-7173
> Yahoo IM: stephen_rufle
> AOL IM: stephen1rufle
>
>
--------------------------------------------------------------------------------
> ### Eclipse Workspace Patch 1.0
> #P ofbiz
> Index: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
> ===================================================================
> --- applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (revision 730447)
> +++ applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (working copy)
> @@ -561,7 +561,7 @@
> }
>
> try {
> - newItem.setQuantity((int)quantity, dispatcher, cart, triggerExternalOps, true, triggerPriceRules,
> skipInventoryChecks.booleanValue());
> + newItem.setQuantity((int)quantity, dispatcher, cart, triggerExternalOps, false, triggerPriceRules,
> skipInventoryChecks.booleanValue());
> } catch (CartItemModifyException e) {
> Debug.logWarning(e.getMessage(), module);
> cart.removeCartItem(cart.getItemIndex(newItem), dispatcher);
> Index: applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
> ===================================================================
> --- applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (revision 730447)
> +++ applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (working copy)
> @@ -28,6 +28,7 @@
> import javolution.util.FastList;
> import javolution.util.FastMap;
>
> +import org.apache.commons.lang.math.NumberUtils;
> import org.ofbiz.base.util.Debug;
> import org.ofbiz.base.util.GeneralException;
> import org.ofbiz.base.util.UtilFormatOut;
> @@ -467,19 +468,34 @@
> Debug.logError(e, module);
> return ServiceUtil.returnError(e.getMessage());
> }
> - cart.setShipAfterDate(g, sg.getTimestamp("shipAfterDate"));
> - cart.setShipBeforeDate(g, sg.getTimestamp("shipByDate"));
> - cart.setShipmentMethodTypeId(g, sg.getString("shipmentMethodTypeId"));
> - cart.setCarrierPartyId(g, sg.getString("carrierPartyId"));
> - cart.setSupplierPartyId(g, sg.getString("supplierPartyId"));
> - cart.setMaySplit(g, sg.getBoolean("maySplit"));
> - cart.setGiftMessage(g, sg.getString("giftMessage"));
> - cart.setShippingContactMechId(g, sg.getString("contactMechId"));
> - cart.setShippingInstructions(g, sg.getString("shippingInstructions"));
> - cart.setShipGroupFacilityId(g, sg.getString("facilityId"));
> - cart.setShipGroupVendorPartyId(g, sg.getString("vendorPartyId"));
> - cart.setShipGroupSeqId(g, sg.getString("shipGroupSeqId"));
> - cart.setItemShipGroupQty(itemIndex, shipGroupQty.doubleValue(), g);
> + String cartShipGroupIndexStr = sg.getString("shipGroupSeqId");
> + int cartShipGroupIndex = NumberUtils.toInt(cartShipGroupIndexStr);
> +
> + if (cart.getShipGroupSize() < cartShipGroupIndex) {
> + int groupDiff = cartShipGroupIndex - cart.getShipGroupSize();
> + for (int i = 0; i < groupDiff; i++) {
> + cart.addShipInfo();
> + }
> + }
> +
> + cartShipGroupIndex = cartShipGroupIndex - 1;
> + if (cartShipGroupIndex > 0) {
> + cart.positionItemToGroup(itemIndex, shipGroupQty.doubleValue(), 0, cartShipGroupIndex, false);
> + }
> +
> + cart.setShipAfterDate(cartShipGroupIndex, sg.getTimestamp("shipAfterDate"));
> + cart.setShipBeforeDate(cartShipGroupIndex, sg.getTimestamp("shipByDate"));
> + cart.setShipmentMethodTypeId(cartShipGroupIndex, sg.getString("shipmentMethodTypeId"));
> + cart.setCarrierPartyId(cartShipGroupIndex, sg.getString("carrierPartyId"));
> + cart.setSupplierPartyId(cartShipGroupIndex, sg.getString("supplierPartyId"));
> + cart.setMaySplit(cartShipGroupIndex, sg.getBoolean("maySplit"));
> + cart.setGiftMessage(cartShipGroupIndex, sg.getString("giftMessage"));
> + cart.setShippingContactMechId(cartShipGroupIndex, sg.getString("contactMechId"));
> + cart.setShippingInstructions(cartShipGroupIndex, sg.getString("shippingInstructions"));
> + cart.setShipGroupFacilityId(cartShipGroupIndex, sg.getString("facilityId"));
> + cart.setShipGroupVendorPartyId(cartShipGroupIndex, sg.getString("vendorPartyId"));
> + cart.setShipGroupSeqId(cartShipGroupIndex, sg.getString("shipGroupSeqId"));
> + cart.setItemShipGroupQty(itemIndex, shipGroupQty.doubleValue(), cartShipGroupIndex);
> }
> }
>
>
Re: loadCartFromOrder setting shipGroups
Posted by Stephen Rufle <sr...@salmonllc.com>.
I think the patch from OFBIZ-2109 should fix.
https://issues.apache.org/jira/browse/OFBIZ-2109?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Jacques Le Roux wrote:
> Is an issue created ?
>
> Jacques
>
> From: "Stephen Rufle" <sr...@salmonllc.com>
>> I think the attached patch fixes the issue I am having.
>>
>> For each OrderItemShipGroup get the shipGroupSeqId value and use that as
>> the index. I also had to modify the call to
>>
>> 564: newItem.setQuantity(..., false, ...);
>> in
>> 398: org.ofbiz.order.shoppingcart.ShoppingCartItem.makeItem(...)
>>
>> so that when a second item gets added to the cart with a shipGroupSeqId
>> less then the first the shipInfo member in cart does not get touched.
>>
>> I will create a JIRA issue, if no one finds any issues.
>>
>> Stephen Rufle wrote:
>>> In ShoppingCartServices.loadCartFromOrder(dctx, context) there is a
>>> call
>>> to get a list of shipGroups
>>> *
>>> 455: List<GenericValue>shipGroups =
>>> orh.getOrderItemShipGroupAssocs(item);*
>>>
>>> This then loops through setting information on the cart creating new
>>> CartShipInfo objects if one can not be found. My issue is that when I
>>> get to the second item in the loop the shipGroups are gotten for that
>>> item and the
>>>
>>> *470: cart.setShipAfterDate(g, sg.getTimestamp("shipAfterDate"));*
>>>
>>> index (g) starts over and overwrites the previous value in the cart. I
>>> am not sure how else to set the shipGroups on the cart though so any
>>> advice would be great.
>>>
>>> My data for the above scenario is as follows
>>> OrderItem orderItemSeqId="00001" productId="ABC"
>>> OrderItemShipGroupAssoc orderItemSeqId="00001" shipGroupSeqId="00001"
>>> OrderItemShipGroup shipGroupSeqId="00001" facilityId="AAA"
>>>
>>> OrderItem orderItemSeqId="00002" productId="ABC"
>>> OrderItemShipGroupAssoc orderItemSeqId="00002" shipGroupSeqId="00002"
>>> OrderItemShipGroup shipGroupSeqId="00002" facilityId="BBB"
>>>
>>>
>>>
>>>
>>>
>>
>> --
>> Stephen P Rufle
>> srufle@salmonllc.com
>> H1:480-626-8022
>> H2:480-802-7173
>> Yahoo IM: stephen_rufle
>> AOL IM: stephen1rufle
>>
>>
>
>
> --------------------------------------------------------------------------------
>
>
>
>> ### Eclipse Workspace Patch 1.0
>> #P ofbiz
>> Index:
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
>>
>> ===================================================================
>> ---
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
>> (revision 730447)
>> +++
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
>> (working copy)
>> @@ -561,7 +561,7 @@
>> }
>>
>> try {
>> - newItem.setQuantity((int)quantity, dispatcher, cart,
>> triggerExternalOps, true, triggerPriceRules,
>> skipInventoryChecks.booleanValue());
>> + newItem.setQuantity((int)quantity, dispatcher, cart,
>> triggerExternalOps, false, triggerPriceRules,
>> skipInventoryChecks.booleanValue());
>> } catch (CartItemModifyException e) {
>> Debug.logWarning(e.getMessage(), module);
>> cart.removeCartItem(cart.getItemIndex(newItem), dispatcher);
>> Index:
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
>>
>> ===================================================================
>> ---
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
>> (revision 730447)
>> +++
>> applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
>> (working copy)
>> @@ -28,6 +28,7 @@
>> import javolution.util.FastList;
>> import javolution.util.FastMap;
>>
>> +import org.apache.commons.lang.math.NumberUtils;
>> import org.ofbiz.base.util.Debug;
>> import org.ofbiz.base.util.GeneralException;
>> import org.ofbiz.base.util.UtilFormatOut;
>> @@ -467,19 +468,34 @@
>> Debug.logError(e, module);
>> return ServiceUtil.returnError(e.getMessage());
>> }
>> - cart.setShipAfterDate(g,
>> sg.getTimestamp("shipAfterDate"));
>> - cart.setShipBeforeDate(g,
>> sg.getTimestamp("shipByDate"));
>> - cart.setShipmentMethodTypeId(g,
>> sg.getString("shipmentMethodTypeId"));
>> - cart.setCarrierPartyId(g,
>> sg.getString("carrierPartyId"));
>> - cart.setSupplierPartyId(g,
>> sg.getString("supplierPartyId"));
>> - cart.setMaySplit(g, sg.getBoolean("maySplit"));
>> - cart.setGiftMessage(g,
>> sg.getString("giftMessage"));
>> - cart.setShippingContactMechId(g,
>> sg.getString("contactMechId"));
>> - cart.setShippingInstructions(g,
>> sg.getString("shippingInstructions"));
>> - cart.setShipGroupFacilityId(g,
>> sg.getString("facilityId"));
>> - cart.setShipGroupVendorPartyId(g,
>> sg.getString("vendorPartyId"));
>> - cart.setShipGroupSeqId(g,
>> sg.getString("shipGroupSeqId"));
>> - cart.setItemShipGroupQty(itemIndex,
>> shipGroupQty.doubleValue(), g);
>> + String cartShipGroupIndexStr =
>> sg.getString("shipGroupSeqId");
>> + int cartShipGroupIndex =
>> NumberUtils.toInt(cartShipGroupIndexStr);
>> +
>> + if (cart.getShipGroupSize() < cartShipGroupIndex) {
>> + int groupDiff = cartShipGroupIndex -
>> cart.getShipGroupSize();
>> + for (int i = 0; i < groupDiff; i++) {
>> + cart.addShipInfo();
>> + }
>> + }
>> +
>> + cartShipGroupIndex = cartShipGroupIndex - 1;
>> + if (cartShipGroupIndex > 0) {
>> + cart.positionItemToGroup(itemIndex,
>> shipGroupQty.doubleValue(), 0, cartShipGroupIndex, false);
>> + }
>> +
>> + cart.setShipAfterDate(cartShipGroupIndex,
>> sg.getTimestamp("shipAfterDate"));
>> + cart.setShipBeforeDate(cartShipGroupIndex,
>> sg.getTimestamp("shipByDate"));
>> + cart.setShipmentMethodTypeId(cartShipGroupIndex,
>> sg.getString("shipmentMethodTypeId"));
>> + cart.setCarrierPartyId(cartShipGroupIndex,
>> sg.getString("carrierPartyId"));
>> + cart.setSupplierPartyId(cartShipGroupIndex,
>> sg.getString("supplierPartyId"));
>> + cart.setMaySplit(cartShipGroupIndex,
>> sg.getBoolean("maySplit"));
>> + cart.setGiftMessage(cartShipGroupIndex,
>> sg.getString("giftMessage"));
>> +
>> cart.setShippingContactMechId(cartShipGroupIndex,
>> sg.getString("contactMechId"));
>> + cart.setShippingInstructions(cartShipGroupIndex,
>> sg.getString("shippingInstructions"));
>> + cart.setShipGroupFacilityId(cartShipGroupIndex,
>> sg.getString("facilityId"));
>> +
>> cart.setShipGroupVendorPartyId(cartShipGroupIndex,
>> sg.getString("vendorPartyId"));
>> + cart.setShipGroupSeqId(cartShipGroupIndex,
>> sg.getString("shipGroupSeqId"));
>> + cart.setItemShipGroupQty(itemIndex,
>> shipGroupQty.doubleValue(), cartShipGroupIndex);
>> }
>> }
>>
>>
>
>
>
--
Stephen P Rufle
srufle@salmonllc.com
H1:480-626-8022
H2:480-802-7173
Yahoo IM: stephen_rufle
AOL IM: stephen1rufle