svn commit: r956402 - in /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order: CompanyHeader.groovy OrderView.groovy

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

svn commit: r956402 - in /ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order: CompanyHeader.groovy OrderView.groovy

jonesde
Author: jonesde
Date: Sun Jun 20 20:12:27 2010
New Revision: 956402

URL: http://svn.apache.org/viewvc?rev=956402&view=rev
Log:
Improved missing party handling for order view, especially purchase orders; also in the CompanyHeader improved getting bill to customer so it doesn't do the same thing over and over, and it could possibly be simplified more but should have a better fallback for future changes with the current two possible ways of getting it

Modified:
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy?rev=956402&r1=956401&r2=956402&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy Sun Jun 20 20:12:27 2010
@@ -59,15 +59,15 @@ if (quoteId) {
 }
 
 // defaults:
-logoImageUrl = null; // the default value, "/images/ofbiz_powered.gif", is set in the screen decorators
-partyId = null;
+def logoImageUrl = null; // the default value, "/images/ofbiz_powered.gif", is set in the screen decorators
+def partyId = null;
 
 // get the logo partyId from order or invoice - note that it is better to do comparisons this way in case the there are null values
 if (orderHeader) {
     orh = new OrderReadHelper(orderHeader);
     // for sales order, the logo party is the "BILL_FROM_VENDOR" of the order.  If that's not available, we'll use the OrderHeader's ProductStore's payToPartyId
     if ("SALES_ORDER".equals(orderHeader.orderTypeId)) {
-        if (orh.getBillToParty()) {
+        if (orh.getBillFromParty()) {
             partyId = orh.getBillFromParty().partyId;
         } else {
             productStore = orderHeader.getRelatedOne("ProductStore");
@@ -77,10 +77,14 @@ if (orderHeader) {
         }
     // purchase orders - use the BILL_TO_CUSTOMER of the order
     } else if ("PURCHASE_ORDER".equals(orderHeader.orderTypeId)) {
-        partyId = orh.getBillToParty().partyId;
-        billToCustomer = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", [roleTypeId : "BILL_TO_CUSTOMER"]));
-        if (billToCustomer) {
-            partyId = billToCustomer.partyId;
+        def billToParty = orh.getBillToParty();
+        if (billToParty) {
+            partyId = billToParty.partyId;
+        } else {
+            def billToCustomer = EntityUtil.getFirst(orderHeader.getRelatedByAnd("OrderRole", [roleTypeId : "BILL_TO_CUSTOMER"]));
+            if (billToCustomer) {
+                partyId = billToCustomer.partyId;
+            }
         }
     }
 } else if (invoice) {
@@ -120,7 +124,7 @@ if (partyGroup?.logoImageUrl) {
 context.logoImageUrl = logoImageUrl;
 
 // the company name
-companyName = "not found";
+companyName = "Default Company";
 if (partyGroup?.groupName) {
     companyName = partyGroup.groupName;
 }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy?rev=956402&r1=956401&r2=956402&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/OrderView.groovy Sun Jun 20 20:12:27 2010
@@ -50,7 +50,7 @@ context.assignRoleTypeId = assignRoleTyp
 context.fromDate = fromDate;
 context.delegate = delegate;
 context.todayDate = new java.sql.Date(System.currentTimeMillis()).toString();
-
+def partyId = null;
 
 orderHeader = null;
 orderItems = null;
@@ -286,22 +286,24 @@ if (orderHeader) {    
     // to the same contact mech of the ship group.
     if ("PURCHASE_ORDER".equals(orderType)) {
         facilitiesForShipGroup = [:];
-        ownerPartyId = orderReadHelper.getBillToParty().partyId;
-        Map ownedFacilities = FastMap.newInstance();
-        shipGroups.each { shipGroup ->
-            lookupMap = [ownerPartyId : ownerPartyId];
-            if (shipGroup.contactMechId) {
-                lookupMap.contactMechId = shipGroup.contactMechId;
-            }
-            facilities = delegator.findByAndCache("FacilityAndContactMech", lookupMap);
-            facilitiesForShipGroup[shipGroup.shipGroupSeqId] = facilities;
-            facilities.each { facility ->
-                ownedFacilities[facility.facilityId] = facility;
+        if (orderReadHelper.getBillToParty()) {
+            ownerPartyId = orderReadHelper.getBillToParty().partyId;
+            Map ownedFacilities = FastMap.newInstance();
+            shipGroups.each { shipGroup ->
+                lookupMap = [ownerPartyId : ownerPartyId];
+                if (shipGroup.contactMechId) {
+                    lookupMap.contactMechId = shipGroup.contactMechId;
+                }
+                facilities = delegator.findByAndCache("FacilityAndContactMech", lookupMap);
+                facilitiesForShipGroup[shipGroup.shipGroupSeqId] = facilities;
+                facilities.each { facility ->
+                    ownedFacilities[facility.facilityId] = facility;
+                }
             }
+            context.facilitiesForShipGroup = facilitiesForShipGroup;
+            // Now get the list of all the facilities owned by the bill-to-party
+            context.ownedFacilities = ownedFacilities.values();
         }
-        context.facilitiesForShipGroup = facilitiesForShipGroup;
-        // Now get the list of all the facilities owned by the bill-to-party
-        context.ownedFacilities = ownedFacilities.values();
     }
 
     // set the type of return based on type of order