svn commit: r577215 - in /ofbiz/trunk/applications/order: config/OrderUiLabels.properties servicedef/services.xml src/org/ofbiz/order/order/ImportOrdersFromEbay.java webapp/ordermgr/order/OrderForms.xml

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

svn commit: r577215 - in /ofbiz/trunk/applications/order: config/OrderUiLabels.properties servicedef/services.xml src/org/ofbiz/order/order/ImportOrdersFromEbay.java webapp/ordermgr/order/OrderForms.xml

jacopoc
Author: jacopoc
Date: Wed Sep 19 02:34:30 2007
New Revision: 577215

URL: http://svn.apache.org/viewvc?rev=577215&view=rev
Log:
Misc improvements by Marco Risaliti to the eBay import service: added support for sales taxes and address2 field.

Modified:
    ofbiz/trunk/applications/order/config/OrderUiLabels.properties
    ofbiz/trunk/applications/order/servicedef/services.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
    ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml

Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?rev=577215&r1=577214&r2=577215&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.properties Wed Sep 19 02:34:30 2007
@@ -402,6 +402,7 @@
 FormFieldTitle_visitId=Visit Id
 FormFieldTitle_visitorId=Visitor Id
 FormFieldTitle_webSiteId=Web Site Id
+FormFieldTitle_salesTaxAmount=Sales Tax Amount
 OrderAddCode=Add Code
 OrderAddNote=Add Note
 OrderAddOrderToShoppingList=Add Order Items to Shopping List

Modified: ofbiz/trunk/applications/order/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/servicedef/services.xml?rev=577215&r1=577214&r2=577215&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/order/servicedef/services.xml Wed Sep 19 02:34:30 2007
@@ -807,13 +807,17 @@
         <attribute type="String" mode="IN" name="shippingService" optional="true"/>
         <attribute type="String" mode="IN" name="shippingServiceCost" optional="true"/>
         <attribute type="String" mode="IN" name="shippingTotalAdditionalCost" optional="true"/>
+        <attribute type="String" mode="IN" name="salesTaxAmount" optional="true"/>
+        <attribute type="String" mode="IN" name="salesTaxPercent" optional="true"/>
         <attribute type="String" mode="IN" name="amountPaid" optional="true"/>
         <attribute type="String" mode="IN" name="paidTime" optional="true"/>
         <attribute type="String" mode="IN" name="shippedTime" optional="true"/>
         <attribute type="String" mode="IN" name="buyerName" optional="true"/>
         <attribute type="String" mode="IN" name="emailBuyer" optional="true"/>
         <attribute type="String" mode="IN" name="shippingAddressPhone" optional="true"/>
+        <attribute type="String" mode="IN" name="shippingAddressStreet" optional="true"/>
         <attribute type="String" mode="IN" name="shippingAddressStreet1" optional="true"/>
+        <attribute type="String" mode="IN" name="shippingAddressStreet2" optional="true"/>
         <attribute type="String" mode="IN" name="shippingAddressPostalCode" optional="true"/>
         <attribute type="String" mode="IN" name="shippingAddressCountry" optional="true"/>
         <attribute type="String" mode="IN" name="shippingAddressStateOrProvince" optional="true"/>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java?rev=577215&r1=577214&r2=577215&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java Wed Sep 19 02:34:30 2007
@@ -93,18 +93,13 @@
             // get the xmlGatewayUri
             String xmlGatewayUri = UtilProperties.getPropertyValue(configString, "productsExport.eBay.xmlGatewayUri");
             
-            StringBuffer ebayDetailsItemsXml = new StringBuffer();
             StringBuffer sellerTransactionsItemsXml = new StringBuffer();
             
-            if (!ServiceUtil.isFailure(buildGetEbayDetailsRequest(context, ebayDetailsItemsXml, token))) {
-                postItem(xmlGatewayUri, ebayDetailsItemsXml, devID, appID, certID, "GeteBayDetails", compatibilityLevel, siteID);
-                
-                if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, token))) {
-                    result = postItem(xmlGatewayUri, sellerTransactionsItemsXml, devID, appID, certID, "GetSellerTransactions", compatibilityLevel, siteID);
-                    String success = (String)result.get(ModelService.SUCCESS_MESSAGE);
-                    if (success != null) {
-                        result = checkOrders(delegator, dispatcher, locale, context, success);
-                    }
+            if (!ServiceUtil.isFailure(buildGetSellerTransactionsRequest(context, sellerTransactionsItemsXml, token))) {
+                result = postItem(xmlGatewayUri, sellerTransactionsItemsXml, devID, appID, certID, "GetSellerTransactions", compatibilityLevel, siteID);
+                String success = (String)result.get(ModelService.SUCCESS_MESSAGE);
+                if (success != null) {
+                    result = checkOrders(delegator, dispatcher, locale, context, success);
                 }
             }
         } catch (Exception e) {        
@@ -133,6 +128,8 @@
             order.put("shippingService", (String) context.get("shippingService"));
             order.put("shippingServiceCost", (String) context.get("shippingServiceCost"));
             order.put("shippingTotalAdditionalCost", (String) context.get("shippingTotalAdditionalCost"));
+            order.put("salesTaxAmount", (String) context.get("salesTaxAmount"));
+            order.put("salesTaxPercent", (String) context.get("salesTaxPercent"));
             order.put("amountPaid", (String) context.get("amountPaid"));
             order.put("paidTime", (String) context.get("paidTime"));
             order.put("shippedTime", (String) context.get("shippedTime"));
@@ -140,7 +137,9 @@
             order.put("buyerName", (String) context.get("buyerName"));
             order.put("emailBuyer", (String) context.get("emailBuyer"));
             order.put("shippingAddressPhone", (String) context.get("shippingAddressPhone"));
+            order.put("shippingAddressStreet", (String) context.get("shippingAddressStreet"));
             order.put("shippingAddressStreet1", (String) context.get("shippingAddressStreet1"));
+            order.put("shippingAddressStreet2", (String) context.get("shippingAddressStreet2"));
             order.put("shippingAddressPostalCode", (String) context.get("shippingAddressPostalCode"));
             order.put("shippingAddressCountry", (String) context.get("shippingAddressCountry"));
             order.put("shippingAddressStateOrProvince", (String) context.get("shippingAddressStateOrProvince"));
@@ -505,7 +504,9 @@
                                     while (shippingAddressElemIter.hasNext()) {
                                         Element shippingAddressElement = (Element)shippingAddressElemIter.next();
                                         order.put("buyerName", UtilXml.childElementValue(shippingAddressElement, "Name", ""));
+                                        order.put("shippingAddressStreet", UtilXml.childElementValue(shippingAddressElement, "Street", ""));
                                         order.put("shippingAddressStreet1", UtilXml.childElementValue(shippingAddressElement, "Street1", ""));
+                                        order.put("shippingAddressStreet2", UtilXml.childElementValue(shippingAddressElement, "Street2", ""));
                                         order.put("shippingAddressCityName", UtilXml.childElementValue(shippingAddressElement, "CityName", ""));
                                         order.put("shippingAddressStateOrProvince", UtilXml.childElementValue(shippingAddressElement, "StateOrProvince", ""));
                                         order.put("shippingAddressCountry", UtilXml.childElementValue(shippingAddressElement, "Country", ""));
@@ -787,7 +788,7 @@
             if (UtilValidate.isNotEmpty(shippingCost)) {
                 double shippingAmount = new Double(shippingCost).doubleValue();
                 if (shippingAmount > 0) {
-                    GenericValue shippingAdjustment = makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount);      
+                    GenericValue shippingAdjustment = makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount, 0.0);      
                     if (shippingAdjustment != null) {
                         cart.addAdjustment(shippingAdjustment);
                     }
@@ -799,13 +800,30 @@
             if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) {
                 double shippingAdditionalCost = new Double(shippingTotalAdditionalCost).doubleValue();
                 if (shippingAdditionalCost > 0) {
-                    GenericValue shippingAdjustment = makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost);      
+                    GenericValue shippingAdjustment = makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0);      
                     if (shippingAdjustment != null) {
                         cart.addAdjustment(shippingAdjustment);
                     }
                 }
             }
             
+            // Apply sales tax as order adjustment
+            String salesTaxAmount = (String) parameters.get("salesTaxAmount");
+            String salesTaxPercent = (String) parameters.get("salesTaxPercent");
+            if (UtilValidate.isNotEmpty(salesTaxAmount)) {
+                double salesTaxAmountTotal = new Double(salesTaxAmount).doubleValue();
+                if (salesTaxAmountTotal > 0) {
+                    double salesPercent = 0.0;
+                    if (UtilValidate.isNotEmpty(salesTaxPercent)) {
+                        salesPercent = new Double(salesTaxPercent).doubleValue();
+                    }
+                    GenericValue salesTaxAdjustment = makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent);
+                    if (salesTaxAdjustment != null) {
+                        cart.addAdjustment(salesTaxAdjustment);
+                    }
+                }
+            }
+            
             // order has to be created ?
             if (create) {
                 Debug.logInfo("Importing new order from eBay", module);
@@ -966,7 +984,8 @@
         }
     }
     
-    private static GenericValue makeOrderAdjustment(GenericDelegator delegator, String orderAdjustmentTypeId, String orderId, String orderItemSeqId, String shipGroupSeqId, double amount) {
+    private static GenericValue makeOrderAdjustment(GenericDelegator delegator, String orderAdjustmentTypeId, String orderId,
+                                                    String orderItemSeqId, String shipGroupSeqId, double amount, double sourcePercentage) {
         GenericValue orderAdjustment  = null;
         
         try {
@@ -979,6 +998,9 @@
       
             Map inputMap = UtilMisc.toMap("orderAdjustmentTypeId", orderAdjustmentTypeId,  "orderId", orderId, "orderItemSeqId", orderItemSeqId,
                                           "shipGroupSeqId", shipGroupSeqId, "amount", new Double(amount));
+            if (sourcePercentage != 0) {
+                inputMap.put("sourcePercentage", new Double(sourcePercentage));
+            }
             orderAdjustment = delegator.makeValue("OrderAdjustment", inputMap);
         } catch (Exception e) {
             Debug.logError(e, "Failed to made order adjustment for order " + orderId, module);
@@ -1024,6 +1046,7 @@
             Map context = FastMap.newInstance();
             context.put("partyId", partyId);
             context.put("address1", (String)address.get("shippingAddressStreet1"));
+            context.put("address2", (String)address.get("shippingAddressStreet2"));
             context.put("postalCode", (String)address.get("shippingAddressPostalCode"));
             context.put("userLogin", userLogin);
             context.put("contactMechPurposeTypeId", contactMechPurposeTypeId);      
@@ -1270,6 +1293,7 @@
                 //
                 // now compare values.  If all fields match, that's our shipping address.  Return the related contact mech id.
                 if (    parameters.get("shippingAddressStreet1").toString().equals((postalAddress.get("address1").toString())) &&
+                        parameters.get("shippingAddressStreet2").toString().equals((postalAddress.get("address2").toString())) &&
                         parameters.get("city").toString().equals((postalAddress.get("city").toString())) &&
                         parameters.get("stateProvinceGeoId").toString().equals((postalAddress.get("stateProvinceGeoId").toString())) &&
                         parameters.get("countryGeoId").toString().equals((postalAddress.get("countryGeoId").toString())) &&

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml?rev=577215&r1=577214&r2=577215&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/order/OrderForms.xml Wed Sep 19 02:34:30 2007
@@ -133,17 +133,24 @@
     <form name="ListOrdersFromEbay" type="multi" use-row-submit="true" list-name="orderList" target="ImportOrderFromEbay">
         <row-actions>
             <set field="canImportOrder" value="${bsh: org.ofbiz.base.util.UtilValidate.isEmpty(orderId) &amp;&amp; org.ofbiz.base.util.UtilValidate.isEmpty(errorMessage)}" type="Boolean"/>
+            <set field="allowProductIdChange" value="${bsh: org.ofbiz.base.util.UtilValidate.isEmpty(orderId) &amp;&amp; org.ofbiz.base.util.UtilValidate.isNotEmpty(errorMessage)}" type="Boolean"/>
         </row-actions>
         <field name="productStoreId"><hidden/></field>
         <field name="externalId" title="${uiLabelMap.OrderImportEbayItem}"><display/></field>
         <field name="transactionId"><display/></field>
         <field name="orderId"><hyperlink target="orderview?orderId=${orderId}" description="${orderId}"/></field>
         <field name="createdDate"><display/></field>
+        <!--
+        <field name="productId" use-when="!${allowProductIdChange}"><display/></field>
+        <field name="productId" use-when="${allowProductIdChange}"><lookup target-form-name="LookupProduct"/></field>
+        -->
         <field name="productId"><display/></field>
         <field name="productName" entry-name="productId"><display-entity entity-name="Product" key-field-name="productId" description="${internalName}"/></field>
         <field name="title"><display/></field>
         <field name="quantityPurchased" title="${uiLabelMap.OrderQuantitySold}"><display/></field>
         <field name="transactionPrice" title="${uiLabelMap.OrderUnitPrice}"><display/></field>
+        <field name="salesTaxAmount"><display/></field>
+        <field name="salesTaxPercent"><hidden/></field>
         <field name="shippingServiceCost"><display/></field>
         <field name="shippingTotalAdditionalCost"><display/></field>
         <field name="amountPaid"><display/></field>
@@ -156,7 +163,9 @@
         <field name="checkoutStatus"><display/></field>
         <field name="completeStatus"><display/></field>
         <field name="buyerName"><display/></field>
+        <field name="shippingAddressStreet"><hidden/></field>
         <field name="emailBuyer"><display/></field>
+        <field name="shippingAddressStreet2"><hidden/></field>
         <field name="shippingAddressPhone"><hidden/></field>
         <field name="shippingAddressStreet1"><hidden/></field>
         <field name="shippingAddressPostalCode"><hidden/></field>