svn commit: r1064662 - in /ofbiz/branches/release10.04/specialpurpose/ebay: src/org/ofbiz/ebay/ widget/

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

svn commit: r1064662 - in /ofbiz/branches/release10.04/specialpurpose/ebay: src/org/ofbiz/ebay/ widget/

jleroux@apache.org
Author: jleroux
Date: Fri Jan 28 13:27:13 2011
New Revision: 1064662

URL: http://svn.apache.org/viewvc?rev=1064662&view=rev
Log:
A patch from Arun Patidar "Some misc issues in ebayStore component." (https://issues.apache.org/jira/browse/OFBIZ-4118) - OFBIZ-4118

A patch for bug fixes in 10.04, which are already fixed in trunk at r1063265. This patch does not include any new/missing functionality.

Modified:
    ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
    ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
    ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
    ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
    ofbiz/branches/release10.04/specialpurpose/ebay/widget/CommonScreens.xml

Modified: ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java?rev=1064662&r1=1064661&r2=1064662&view=diff
==============================================================================
--- ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java (original)
+++ ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayHelper.java Fri Jan 28 13:27:13 2011
@@ -192,7 +192,7 @@ public class EbayHelper {
     }
 
     public static boolean createPaymentFromPaymentPreferences(Delegator delegator, LocalDispatcher dispatcher, GenericValue userLogin,
-            String orderId, String externalId, Timestamp orderDate, String partyIdFrom) {
+        String orderId, String externalId, Timestamp orderDate, BigDecimal amount, String partyIdFrom) {
         List<GenericValue> paymentPreferences = null;
         try {
             Map<String, String> paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_RECEIVED",
@@ -207,7 +207,25 @@ public class EbayHelper {
                     if (!okay)
                         return false;
                 }
-            }
+            } else {
+                paymentFields = UtilMisc.toMap("orderId", orderId, "statusId", "PAYMENT_NOT_RECEIVED",
+                    "paymentMethodTypeId", "EXT_EBAY");
+                paymentPreferences = delegator.findByAnd("OrderPaymentPreference", paymentFields);
+                if (UtilValidate.isNotEmpty(paymentPreferences)) {
+                    Iterator<GenericValue> i = paymentPreferences.iterator();
+                    while (i.hasNext()) {
+                        GenericValue pref = (GenericValue) i.next();
+                        if (UtilValidate.isNotEmpty(amount)) {
+                            pref.set("statusId", "PAYMENT_RECEIVED");
+                            pref.set("maxAmount", amount);
+                            pref.store();
+                        }
+                        boolean okay = createPayment(dispatcher, userLogin, pref, orderId, externalId, orderDate, partyIdFrom);
+                        if (!okay)
+                            return false;
+                    }
+                }
+            }
         } catch (Exception e) {
             Debug.logError(e, "Cannot get payment preferences for order #" + orderId, module);
             return false;

Modified: ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java?rev=1064662&r1=1064661&r2=1064662&view=diff
==============================================================================
--- ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java (original)
+++ ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/EbayOrderServices.java Fri Jan 28 13:27:13 2011
@@ -998,12 +998,14 @@ public class EbayOrderServices {
 
             // set the external id with the eBay Item Id
             String externalId = (String) context.get("externalId");
+            String transactionId = (String) context.get("transactionId");
 
             if (UtilValidate.isNotEmpty(externalId)) {
                 if (externalOrderExists(delegator, externalId) != null && create) {
                     return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.externalIdAlreadyExist", locale));
                 }
                 cart.setExternalId(externalId);
+                cart.setTransactionId(transactionId);
             } else {
                 return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.externalIdNotAvailable", locale));
             }
@@ -1214,7 +1216,7 @@ public class EbayOrderServices {
                     // create the payment from the preference
                     if (approved) {
                         Debug.logInfo("Creating payment for approved order.", module);
-                        EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId);
+                        EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId);
                         Debug.logInfo("Payment created.", module);
                     }
                 }
@@ -1255,20 +1257,37 @@ public class EbayOrderServices {
         HashMap<Object, Object> attrs = new HashMap<Object, Object>();
         attrs.put("shipGroup", groupIdx);
 
-        int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
-        ShoppingCartItem cartItem = cart.findCartItem(idx);
-        cartItem.setQuantity(qty, dispatcher, cart, true, false);
-        // locate the price verify it matches the expected price
-        BigDecimal cartPrice = cartItem.getBasePrice();
-        cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding);
-        if (price.doubleValue() != cartPrice.doubleValue()) {
-            // does not match; honor the price but hold the order for manual review
-            cartItem.setIsModifiedPrice(true);
-            cartItem.setBasePrice(price);
-            cart.setHoldOrder(true);
-            cart.addInternalOrderNote("Price received [" + price + "] (for item # " + productId + ") from eBay Checkout does not match the price in the database [" + cartPrice + "]. Order is held for manual review.");
+        // Checking if previously added same product exists in the cart
+        ShoppingCartItem previouslyAddedItemInCart = null;
+        if (cart.size() != 0) {
+            Iterator cartiter = cart.iterator();
+            while (cartiter != null && cartiter.hasNext()) {
+                ShoppingCartItem cartItem = (ShoppingCartItem) cartiter.next();
+                if (cartItem.getProductId().equals(productId)) {
+                    previouslyAddedItemInCart = cartItem;
+                }
+            }
         }
-        // assign the item to its ship group
-        cart.setItemShipGroupQty(cartItem, qty, groupIdx);
-    }
+        if (previouslyAddedItemInCart != null) {
+            BigDecimal newQuantity = previouslyAddedItemInCart.getQuantity().add(qty);
+            previouslyAddedItemInCart.setQuantity(newQuantity, dispatcher, cart);
+        } else {
+            int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
+            ShoppingCartItem cartItem = cart.findCartItem(idx);
+            cartItem.setQuantity(qty, dispatcher, cart, true, false);
+            // locate the price verify it matches the expected price
+            BigDecimal cartPrice = cartItem.getBasePrice();
+            cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding);
+            if (price.doubleValue() != cartPrice.doubleValue()) {
+                // does not match; honor the price but hold the order for manual review
+                cartItem.setIsModifiedPrice(true);
+                cartItem.setBasePrice(price);
+                cart.setHoldOrder(true);
+                cart.addInternalOrderNote("Price received [" + price + "] (for item # " + productId + ") from eBay Checkout does not match the price in the database [" + cartPrice + "]. Order is held for manual review.");
+            }
+            // assign the item to its ship group
+            cart.setItemShipGroupQty(cartItem, qty, groupIdx);
+        }
+    }
+
 }

Modified: ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java?rev=1064662&r1=1064661&r2=1064662&view=diff
==============================================================================
--- ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java (original)
+++ ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ImportOrdersFromEbay.java Fri Jan 28 13:27:13 2011
@@ -270,6 +270,7 @@ public class ImportOrdersFromEbay {
             // default shipped = Y (call from eca during order completed)
             if (paid == null && shipped == null) {
                 shipped = "Y";
+                paid = "Y";
             }
 
             // Set item id to paid or not paid
@@ -796,7 +797,7 @@ public class ImportOrdersFromEbay {
                     // create the payment from the preference
                     if (approved) {
                         Debug.logInfo("Creating payment for approved order.", module);
-                        EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), partyId);
+                        EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId);
                         Debug.logInfo("Payment created.", module);
                     }
                 }

Modified: ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java?rev=1064662&r1=1064661&r2=1064662&view=diff
==============================================================================
--- ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original)
+++ ofbiz/branches/release10.04/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Fri Jan 28 13:27:13 2011
@@ -316,6 +316,11 @@ public class ProductsExportToEbay {
 
                 Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument);
                 UtilXml.addChildElementValue(primaryCatElem, "CategoryID", primaryCategoryId, itemDocument);
+                UtilXml.addChildElementValue(itemElem, "ConditionID", "1000", itemDocument);
+                Element itemSpecificsElem = UtilXml.addChildElement(itemElem, "ItemSpecifics", itemDocument);
+                Element nameValueListElem = UtilXml.addChildElement(itemSpecificsElem, "NameValueList", itemDocument);
+                UtilXml.addChildElementValue(nameValueListElem, "Name", "Condition", itemDocument);
+                UtilXml.addChildElementValue(nameValueListElem, "Value", "New: With Tags", itemDocument);
 
                 //Debug.logInfo("The generated string is ======= " + UtilXml.writeXmlDocument(itemDocument), module);
                 dataItemsXml.append(UtilXml.writeXmlDocument(itemDocument));

Modified: ofbiz/branches/release10.04/specialpurpose/ebay/widget/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release10.04/specialpurpose/ebay/widget/CommonScreens.xml?rev=1064662&r1=1064661&r2=1064662&view=diff
==============================================================================
--- ofbiz/branches/release10.04/specialpurpose/ebay/widget/CommonScreens.xml (original)
+++ ofbiz/branches/release10.04/specialpurpose/ebay/widget/CommonScreens.xml Fri Jan 28 13:27:13 2011
@@ -28,6 +28,7 @@ under the License.
                 <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                 <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
                 <property-map resource="WorkEffortUiLabels" map-name="uiLabelMap" global="true"/>
+                <property-map resource="GoogleBaseUiLabels" map-name="uiLabelMap" global="true"/>
                 <set field="activeApp" value="ebay" global="true"/>
                 <set field="layoutSettings.companyName" from-field="uiLabelMap.EbayCompanyName" global="true"/>
                 <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.EbayApplication" global="true"/>