From 2eb59c1b19d6447d6b809dd6badd3a97f2e60dc9 Mon Sep 17 00:00:00 2001
From: Lucas Carvalho <lucas@nexedi.com>
Date: Fri, 7 Aug 2009 17:39:10 +0000
Subject: [PATCH] * fixed payment_mode bug * fixed currency

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28314 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_commerce/Resource_addToShoppingCart.xml          | 2 +-
 .../erp5_commerce/SaleOrder_getShoppingCart.xml           | 2 +-
 .../SaleOrder_getShoppingCartDefaultCurrency.xml          | 2 +-
 .../erp5_commerce/SaleOrder_paymentRedirect.xml           | 2 +-
 .../erp5_commerce/WebSite_getNewPaypalToken.xml           | 8 ++------
 .../erp5_commerce/WebSite_getPaypalOrderParameterDict.xml | 7 -------
 bt5/erp5_commerce/bt/revision                             | 2 +-
 7 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/Resource_addToShoppingCart.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/Resource_addToShoppingCart.xml
index 794e6865eb..597a1481c6 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/Resource_addToShoppingCart.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/Resource_addToShoppingCart.xml
@@ -92,7 +92,7 @@ line_found=False\n
 for order_line in shopping_cart_items:\n
   if order_line.getResource() == resource.getRelativeUrl():\n
     new_quantity = int(order_line.getQuantity()) + quantity\n
-    if new_quantity<=0:\n
+    if new_quantity <= 0:\n
       ## remove items with zero quantity\n
       shopping_cart.manage_delObjects(order_line)\n
     else:\n
diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
index fe1089ef54..e91a077686 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCart.xml
@@ -79,7 +79,7 @@ else:\n
   if not shopping_cart_id in session.keys():\n
     from Products.ERP5Type.Document import newTempOrder\n
     shopping_cart = newTempOrder(portal_sessions, shopping_cart_id)\n
-    shopping_cart.setPriceCurrency(\'currency_module/1\')\n
+    shopping_cart.setPriceCurrency(\'currency_module/EUR\')\n
     session[shopping_cart_id] = shopping_cart\n
 \n
   ## return just a part of session for shopping cart\n
diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCartDefaultCurrency.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCartDefaultCurrency.xml
index 515016b2bd..477d5c6b55 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCartDefaultCurrency.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_getShoppingCartDefaultCurrency.xml
@@ -58,7 +58,7 @@
   Please update accordingly relative path. \n
   XXX: there must be an way to do this better?\n
 """\n
-return context.getPortalObject().restrictedTraverse(\'currency_module/1\')\n
+return context.getPortalObject().restrictedTraverse(\'currency_module/EUR\')\n
 </string> </value>
         </item>
         <item>
diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_paymentRedirect.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_paymentRedirect.xml
index ab7940f69e..8a7cd1468e 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_paymentRedirect.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/SaleOrder_paymentRedirect.xml
@@ -60,7 +60,7 @@ if field_my_payment_mode is None:\n
 \n
 if field_my_payment_mode == \'Credit Card\':\n
   return context.getWebSectionValue().SaleOrder_viewAsWebConfirmCreditCardPayment()\n
-elif field_my_payment_mode == \'PayPal\':\n
+elif field_my_payment_mode.lower() == \'paypal\':\n
   return context.getWebSectionValue().SaleOrder_viewAsWebConfirmPayPalPayment()\n
 else:\n
   return "This method is actually not activated, sorry : %s" % field_my_payment_mode\n
diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getNewPaypalToken.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getNewPaypalToken.xml
index ad944cb46d..5bf6799b88 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getNewPaypalToken.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getNewPaypalToken.xml
@@ -53,10 +53,7 @@
         </item>
         <item>
             <key> <string>_body</string> </key>
-            <value> <string>parameter_dict = context.WebSite_getPaypalOrderParameterDict()\n
-if parameter_dict is None:\n
-  return None\n
-response_parameter_dict = context.ERP5Base_submitPaypalNVPRequest(parameter_dict=parameter_dict,\n
+            <value> <string>response_parameter_dict = context.ERP5Base_submitPaypalNVPRequest(parameter_dict=context.WebSite_getPaypalOrderParameterDict(),\n
                                                                   nvp_url=context.WebSite_getPaypalUrl(api=\'nvp\', alternative_url=alternative_url))\n
 \n
 if response_parameter_dict is None:\n
@@ -104,9 +101,8 @@ return \'\'\n
                             <string>alternative_url</string>
                             <string>_getattr_</string>
                             <string>context</string>
-                            <string>parameter_dict</string>
-                            <string>None</string>
                             <string>response_parameter_dict</string>
+                            <string>None</string>
                             <string>_getitem_</string>
                           </tuple>
                         </value>
diff --git a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getPaypalOrderParameterDict.xml b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getPaypalOrderParameterDict.xml
index a284b5a4de..031f66c01c 100644
--- a/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getPaypalOrderParameterDict.xml
+++ b/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce/WebSite_getPaypalOrderParameterDict.xml
@@ -59,17 +59,11 @@ if order_parameter_dict is None:\n
 \n
 shopping_cart = context.SaleOrder_getShoppingCart()\n
 shopping_cart_product_list = shopping_cart.SaleOrder_getShoppingCartItemList()\n
-\n
-if len(shopping_cart_product_list) == 0:\n
-  return None \n
-\n
 shopping_cart_price = float(shopping_cart.SaleOrder_getShoppingCartTotalPrice())\n
 taxes_amount = float(shopping_cart.SaleOrder_getShoppingCartTotalPrice(include_taxes=True, include_shipping=True)) - \\\n
                float(shopping_cart.SaleOrder_getShoppingCartTotalPrice(include_shipping=True));\n
 shipping = context.SaleOrder_getSelectedShippingResource()\n
 shipping_price = context.restrictedTraverse(shipping).getPrice()\n
-if shipping_price is None:\n
-  shipping_price = 0\n
 customer = context.SaleOrder_getShoppingCartCustomer()\n
 site_url = context.getWebSiteValue().absolute_url()\n
 \n
@@ -140,7 +134,6 @@ return order_parameter_dict\n
                             <string>None</string>
                             <string>shopping_cart</string>
                             <string>shopping_cart_product_list</string>
-                            <string>len</string>
                             <string>float</string>
                             <string>shopping_cart_price</string>
                             <string>True</string>
diff --git a/bt5/erp5_commerce/bt/revision b/bt5/erp5_commerce/bt/revision
index bc768da71a..5d1277e790 100644
--- a/bt5/erp5_commerce/bt/revision
+++ b/bt5/erp5_commerce/bt/revision
@@ -1 +1 @@
-146
\ No newline at end of file
+147
\ No newline at end of file
-- 
2.30.9