svn commit: r1051783 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java widget/ordermgr/RequirementForms.xml

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

svn commit: r1051783 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java widget/ordermgr/RequirementForms.xml

hansbak-2
Author: hansbak
Date: Wed Dec 22 08:00:12 2010
New Revision: 1051783

URL: http://svn.apache.org/viewvc?rev=1051783&view=rev
Log:
when creating a purchase order from requirments, use when supplied, the preferred currency of the supplier, further show these preferences on the related screens.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/applications/order/widget/ordermgr/RequirementForms.xml

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1051783&r1=1051782&r2=1051783&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Wed Dec 22 08:00:12 2010
@@ -643,11 +643,23 @@ public class ShoppingCartEvents {
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         HttpSession session = request.getSession();
         Locale locale = UtilHttp.getLocale(request);
-
-        ShoppingCart cart = new WebShoppingCart(request);
+        String supplierPartyId = request.getParameter("supplierPartyId_o_0");
+        
+        // check the preferred currency of the supplier, if set, use that for the cart, otherwise use system defaults.
+        ShoppingCart cart = null;
+        try {
+         GenericValue supplierParty = delegator.findOne("Party", UtilMisc.toMap("partyId", supplierPartyId), false);
+            if (UtilValidate.isNotEmpty(supplierParty.getString("preferredCurrencyUomId"))) {
+                cart = new WebShoppingCart(request, locale, supplierParty.getString("preferredCurrencyUomId"));
+            } else {
+                cart = new WebShoppingCart(request);
+            }
+        } catch (GenericEntityException e) {
+            Debug.logError(e.getMessage(), module);
+        }
+        
         // TODO: the code below here needs some cleanups
         String billToCustomerPartyId = request.getParameter("billToCustomerPartyId_o_0");
-        String supplierPartyId = request.getParameter("supplierPartyId_o_0");
         if (UtilValidate.isEmpty(billToCustomerPartyId) && UtilValidate.isEmpty(supplierPartyId)) {
             request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderCouldNotInitPurchaseOrder", locale));
             return "error";

Modified: ofbiz/trunk/applications/order/widget/ordermgr/RequirementForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/RequirementForms.xml?rev=1051783&r1=1051782&r2=1051783&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/widget/ordermgr/RequirementForms.xml (original)
+++ ofbiz/trunk/applications/order/widget/ordermgr/RequirementForms.xml Wed Dec 22 08:00:12 2010
@@ -266,7 +266,7 @@ under the License.
                 </entity-options>
             </drop-down>
         </field>
-        <field name="partyId" title="${uiLabelMap.ProductSupplier}">
+        <field name="partyId" title="${uiLabelMap.ProductSupplier}" position="1">
             <drop-down allow-empty="true">
                 <entity-options entity-name="PartyRoleAndPartyDetail" key-field-name="partyId" description="${groupName} [${partyId}]">
                     <entity-constraint name="roleTypeId"  value="SUPPLIER" operator="equals"/>
@@ -274,6 +274,7 @@ under the License.
                 </entity-options>
             </drop-down>
         </field>
+        <field name="supplierCurrencyUomId" entry-name="parameters.supplierCurrencyUomId" position="2"><display/></field>
         <field name="unassignedRequirements"><check/></field>
         <field name="facilityId">
             <drop-down allow-empty="true">
@@ -343,8 +344,9 @@ under the License.
             <display-entity entity-name="Product" key-field-name="productId" description="${internalName}"/>
         </field>
         <field name="partyId" title="${uiLabelMap.ProductSupplier}">
-            <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
+            <display-entity entity-name="PartyNameView" description="${lastName} ${firstName} ${groupName}"/>
         </field>
+        <field name="supplierCurrencyUomId" entry-name="parameters.supplierCurrencyUomId"><display/></field>
         <field name="supplierProductId" title="${uiLabelMap.ProductSupplierProductId}"><display/></field>
         <field name="idValue" title="${uiLabelMap.ProductUPCA}"><display/></field>
         <field name="minimumOrderQuantity" title="${uiLabelMap.FormFieldTitle_minimumOrderQuantity}" widget-area-style="align-text"><display/></field>
@@ -372,9 +374,16 @@ under the License.
     </form>
     <form name="ApprovedProductRequirementsByVendor" type="list" use-row-submit="true" list-name="requirements" target="ApprovedProductRequirements" separate-columns="true"
         paginate-target="ApprovedProductRequirementsByVendor" odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
+        <row-actions>
+            <entity-one entity-name="Party" value-field="supplierParty">
+                <field-map field-name="partyId" from-field="partyId"/>
+            </entity-one>
+            <set field="supplierCurrencyUomId" from-field="supplierParty.preferredCurrencyUomId"/>
+        </row-actions>
         <field name="partyId">
             <display description="${bsh: org.ofbiz.party.party.PartyHelper.getPartyName(delegator, partyId, false);}"/>
         </field>
+        <field name="supplierCurrencyUomId"><display/></field>
         <field name="productId" title="${uiLabelMap.OrderVendorRequirementCount}" widget-area-style="align-text"><display also-hidden="false"/></field>
         <field name="billToCustomerPartyId">
             <drop-down allow-empty="false">