You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/07/15 07:53:43 UTC

svn commit: r556364 - in /ofbiz/trunk: applications/accounting/src/org/ofbiz/accounting/tax/ applications/ecommerce/data/ applications/party/src/org/ofbiz/party/contact/ framework/common/data/

Author: jonesde
Date: Sat Jul 14 22:53:41 2007
New Revision: 556364

URL: http://svn.apache.org/viewvc?view=rev&rev=556364
Log:
Implemented feature to lookup city or county or other tax jurisdiction by postal code; includes some demo/test data for it that will work with DemoCustomer; there are some new patterns established like a convention for postal code ID within a country

Modified:
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
    ofbiz/trunk/applications/ecommerce/data/DemoTaxAuthority.xml
    ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java
    ofbiz/trunk/framework/common/data/GeoData_US.xml

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java?view=diff&rev=556364&r1=556363&r2=556364
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/tax/TaxAuthorityServices.java Sat Jul 14 22:53:41 2007
@@ -43,6 +43,7 @@
 import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
+import org.ofbiz.party.contact.ContactMechWorker;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.ServiceUtil;
 
@@ -144,8 +145,8 @@
         BigDecimal orderShippingAmount = (BigDecimal) context.get("orderShippingAmount");
         GenericValue shippingAddress = (GenericValue) context.get("shippingAddress");
 
-        if (shippingAddress == null || (shippingAddress.get("countryGeoId") == null && shippingAddress.get("stateProvinceGeoId") == null)) {
-            return ServiceUtil.returnError("The address(es) used for tax calculation did not have State/Province or Country values set, so we cannot determine the taxes to charge.");
+        if (shippingAddress == null || (shippingAddress.get("countryGeoId") == null && shippingAddress.get("stateProvinceGeoId") == null && shippingAddress.get("postalCodeGeoId") == null)) {
+            return ServiceUtil.returnError("The address(es) used for tax calculation did not have State/Province or Country or other tax jurisdiction values set, so we cannot determine the taxes to charge.");
         }
         // without knowing the TaxAuthority parties, just find all TaxAuthories for the set of IDs...
         Set taxAuthoritySet = FastSet.newInstance();
@@ -197,21 +198,29 @@
     private static void getTaxAuthorities(GenericDelegator delegator, GenericValue shippingAddress, Set taxAuthoritySet) throws GenericEntityException {
         Set geoIdSet = FastSet.newInstance();
         if (shippingAddress != null) {
-            if (shippingAddress.getString("countryGeoId") != null) {
+            if (UtilValidate.isNotEmpty(shippingAddress.getString("countryGeoId"))) {
                 geoIdSet.add(shippingAddress.getString("countryGeoId"));
             }
-            if (shippingAddress.getString("stateProvinceGeoId") != null) {
+            if (UtilValidate.isNotEmpty(shippingAddress.getString("stateProvinceGeoId"))) {
                 geoIdSet.add(shippingAddress.getString("stateProvinceGeoId"));
             }
-            if (shippingAddress.getString("countyGeoId") != null) {
+            if (UtilValidate.isNotEmpty(shippingAddress.getString("countyGeoId"))) {
                 geoIdSet.add(shippingAddress.getString("countyGeoId"));
             }
+            String postalCodeGeoId = ContactMechWorker.getPostalAddressPostalCodeGeoId(shippingAddress, delegator);
+            if (UtilValidate.isNotEmpty(postalCodeGeoId)) {
+            	geoIdSet.add(postalCodeGeoId);
+            }
         }
+        
+        // Debug.logInfo("Tax calc geoIdSet before expand:" + geoIdSet, module);
         // get the most granular, or all available, geoIds and then find parents by GeoAssoc with geoAssocTypeId="REGIONS" and geoIdTo=<granular geoId> and find the GeoAssoc.geoId
         geoIdSet = GeoWorker.expandGeoRegionDeep(geoIdSet, delegator);
+        // Debug.logInfo("Tax calc geoIdSet after expand:" + geoIdSet, module);
 
         List taxAuthorityRawList = delegator.findByConditionCache("TaxAuthority", new EntityExpr("taxAuthGeoId", EntityOperator.IN, geoIdSet), null, null);
         taxAuthoritySet.addAll(taxAuthorityRawList);
+        // Debug.logInfo("Tax calc taxAuthoritySet after expand:" + taxAuthoritySet, module);
     }
 
     private static List getTaxAdjustments(GenericDelegator delegator, GenericValue product, GenericValue productStore, String payToPartyId, String billToPartyId, Set taxAuthoritySet, BigDecimal itemPrice, BigDecimal itemAmount, BigDecimal shippingAmount) {
@@ -347,7 +356,7 @@
 
                 // check to see if this party has a tax ID for this, and if the party is tax exempt in the primary (most-local) jurisdiction
                 if (UtilValidate.isNotEmpty(billToPartyId) && taxAuthGeoId != null) {
-                    // see if partyId is a member of any groups , if so honor their tax exemptions
+                    // see if partyId is a member of any groups, if so honor their tax exemptions
                     // look for PartyRelationship with partyRelationshipTypeId=GROUP_ROLLUP, the partyIdTo is the group member, so the partyIdFrom is the groupPartyId
                     Set billToPartyIdSet = FastSet.newInstance();
                     billToPartyIdSet.add(billToPartyId);
@@ -374,7 +383,7 @@
     }
     
     private static void handlePartyTaxExempt(GenericValue adjValue, Set billToPartyIdSet, String taxAuthGeoId, String taxAuthPartyId, BigDecimal taxAmount, Timestamp nowTimestamp, GenericDelegator delegator) throws GenericEntityException {
-        Debug.log("Checking for tax exemption : " + taxAuthGeoId + " / " + taxAuthPartyId, module);
+        Debug.logInfo("Checking for tax exemption : " + taxAuthGeoId + " / " + taxAuthPartyId, module);
         List ptiConditionList = UtilMisc.toList(
                 new EntityExpr("partyId", EntityOperator.IN, billToPartyIdSet),
                 new EntityExpr("taxAuthGeoId", EntityOperator.EQUALS, taxAuthGeoId),
@@ -404,7 +413,7 @@
                     UtilMisc.toList("-fromDate"));
             taxAuthorityAssocList = EntityUtil.filterByDate(taxAuthorityAssocList, true);
             GenericValue taxAuthorityAssoc = EntityUtil.getFirst(taxAuthorityAssocList);
-            Debug.log("Parent assoc to " + taxAuthGeoId + " : " + taxAuthorityAssoc, module);
+            // Debug.log("Parent assoc to " + taxAuthGeoId + " : " + taxAuthorityAssoc, module);
             if (taxAuthorityAssoc != null) {
                 handlePartyTaxExempt(adjValue, billToPartyIdSet, taxAuthorityAssoc.getString("taxAuthGeoId"), taxAuthorityAssoc.getString("taxAuthPartyId"), taxAmount, nowTimestamp, delegator);
             }

Modified: ofbiz/trunk/applications/ecommerce/data/DemoTaxAuthority.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/data/DemoTaxAuthority.xml?view=diff&rev=556364&r1=556363&r2=556364
==============================================================================
--- ofbiz/trunk/applications/ecommerce/data/DemoTaxAuthority.xml (original)
+++ ofbiz/trunk/applications/ecommerce/data/DemoTaxAuthority.xml Sat Jul 14 22:53:41 2007
@@ -48,6 +48,9 @@
     <Party partyId="UT_TAXMAN" partyTypeId="PARTY_GROUP"/>
     <PartyGroup partyId="UT_TAXMAN" groupName="Utah Sales Tax Authority"/>
     <PartyRole partyId="UT_TAXMAN" roleTypeId="TAX_AUTHORITY"/>  
+    <Party partyId="UT_UTAH_TAXMAN" partyTypeId="PARTY_GROUP"/>
+    <PartyGroup partyId="UT_UTAH_TAXMAN" groupName="Utah County, Utah Sales Tax Authority"/>
+    <PartyRole partyId="UT_UTAH_TAXMAN" roleTypeId="TAX_AUTHORITY"/>  
     
     <Party partyId="CAN_TAXMAN" partyTypeId="PARTY_GROUP"/>
     <PartyGroup partyId="CAN_TAXMAN" groupName="Canada Tax Authority"/>
@@ -96,6 +99,14 @@
     <TaxAuthorityRateProduct taxAuthorityRateSeqId="9004" taxAuthGeoId="UT" taxAuthPartyId="UT_TAXMAN" taxAuthorityRateTypeId="SALES_TAX" productStoreId="9000"
         productCategoryId="" titleTransferEnumId="" minItemPrice="0.00" minPurchase="0.00" taxShipping="N" taxPercentage="4.75" 
         fromDate="2001-05-13 00:00:00.001" thruDate="" description="Utah State Sales Tax"/>
+    <!-- An example county; there is some zip code data for testing this; note this is ONLY test data, there isn't really extra sales tax for this county -->
+    <TaxAuthority taxAuthGeoId="UT-UTAH" taxAuthPartyId="UT_UTAH_TAXMAN" includeTaxInPrice="N"/>
+    <!-- NOTE: using the state's sales tax GL Account -->
+    <TaxAuthorityGlAccount taxAuthGeoId="UT-UTAH" taxAuthPartyId="UT_UTAH_TAXMAN" organizationPartyId="Company" glAccountId="224153"/>
+    <TaxAuthorityAssoc taxAuthGeoId="UT" taxAuthPartyId="UT_TAXMAN" toTaxAuthGeoId="UT-UTAH" toTaxAuthPartyId="UT_UTAH_TAXMAN" taxAuthorityAssocTypeId="EXEMPT_INHER" fromDate="2001-05-13 00:00:00.001" thruDate=""/>
+    <TaxAuthorityRateProduct taxAuthorityRateSeqId="9005" taxAuthGeoId="UT-UTAH" taxAuthPartyId="UT_UTAH_TAXMAN" taxAuthorityRateTypeId="SALES_TAX" productStoreId="9000"
+        productCategoryId="" titleTransferEnumId="" minItemPrice="0.00" minPurchase="0.00" taxShipping="N" taxPercentage="0.1" 
+        fromDate="2001-05-13 00:00:00.001" thruDate="" description="Utah County, Utah Sales Tax"/>
     
     <!-- Canada TaxAuthority defs -->        
     <TaxAuthority taxAuthGeoId="CAN" taxAuthPartyId="CAN_TAXMAN" includeTaxInPrice="N"/>
@@ -110,6 +121,7 @@
     <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="NY" taxAuthPartyId="NY_DTF" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="" isExempt="" isNexus="Y"/>
     <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="TX" taxAuthPartyId="TX_TAXMAN" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="" isExempt="" isNexus="N"/> <!-- this one is not a nexus to test that feature -->
     <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="UT" taxAuthPartyId="UT_TAXMAN" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="" isExempt="" isNexus="Y"/>
+    <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="UT-UTAH" taxAuthPartyId="UT_UTAH_TAXMAN" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="" isExempt="" isNexus="Y"/>
     <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="CAN" taxAuthPartyId="CAN_TAXMAN" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="87654321" isExempt="N" isNexus="Y"/>
     <PartyTaxAuthInfo partyId="Company" taxAuthGeoId="ON" taxAuthPartyId="ON_TAXMAN" fromDate="2001-05-13 00:00:00.001" thruDate="" partyTaxId="" isExempt="" isNexus="Y"/>
     

Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?view=diff&rev=556364&r1=556363&r2=556364
==============================================================================
--- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original)
+++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Sat Jul 14 22:53:41 2007
@@ -314,180 +314,6 @@
         return workEffortContactMechValueMaps.size() > 0 ? workEffortContactMechValueMaps : null;
     }
     
-    /** TO BE REMOVED (DEJ 20030221): This method was for use in a JSP and when they are removed this can be removed as well rather than being maintained, should be removed when eCommerce and party mgr and possible other places are converted to FTL */
-    public static void getContactMechAndRelated(PageContext pageContext, String partyId, String contactMechAttr, String contactMechIdAttr,
-        String partyContactMechAttr, String partyContactMechPurposesAttr, String contactMechTypeIdAttr, String contactMechTypeAttr, String purposeTypesAttr,
-        String postalAddressAttr, String telecomNumberAttr, String requestNameAttr, String donePageAttr, String tryEntityAttr, String contactMechTypesAttr) {
-
-        ServletRequest request = pageContext.getRequest();
-        GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
-
-        boolean tryEntity = true;
-
-        if (request.getAttribute("_ERROR_MESSAGE_") != null) tryEntity = false;
-        if ("true".equals(request.getParameter("tryEntity"))) tryEntity = true;
-
-        String donePage = request.getParameter("DONE_PAGE");
-
-        if (donePage == null) donePage = (String) request.getAttribute("DONE_PAGE");
-        if (donePage == null || donePage.length() <= 0) donePage = "viewprofile";
-        pageContext.setAttribute(donePageAttr, donePage);
-
-        String contactMechTypeId = request.getParameter("preContactMechTypeId");
-
-        if (contactMechTypeId == null) contactMechTypeId = (String) request.getAttribute("preContactMechTypeId");
-        if (contactMechTypeId != null)
-            tryEntity = false;
-
-        String contactMechId = request.getParameter("contactMechId");
-
-        if (request.getAttribute("contactMechId") != null)
-            contactMechId = (String) request.getAttribute("contactMechId");
-
-        GenericValue contactMech = null;
-
-        if (contactMechId != null) {
-            pageContext.setAttribute(contactMechIdAttr, contactMechId);
-
-            // try to find a PartyContactMech with a valid date range
-            List partyContactMechs = null;
-
-            try {
-                partyContactMechs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId)), true);
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-
-            GenericValue partyContactMech = EntityUtil.getFirst(partyContactMechs);
-
-            if (partyContactMech != null) {
-                pageContext.setAttribute(partyContactMechAttr, partyContactMech);
-
-                Collection partyContactMechPurposes = null;
-
-                try {
-                    partyContactMechPurposes = EntityUtil.filterByDate(partyContactMech.getRelated("PartyContactMechPurpose"), true);
-                } catch (GenericEntityException e) {
-                    Debug.logWarning(e, module);
-                }
-                if (partyContactMechPurposes != null && partyContactMechPurposes.size() > 0)
-                    pageContext.setAttribute(partyContactMechPurposesAttr, partyContactMechPurposes);
-            }
-
-            try {
-                contactMech = delegator.findByPrimaryKey("ContactMech", UtilMisc.toMap("contactMechId", contactMechId));
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-
-            if (contactMech != null) {
-                pageContext.setAttribute(contactMechAttr, contactMech);
-                contactMechTypeId = contactMech.getString("contactMechTypeId");
-            }
-        }
-
-        if (contactMechTypeId != null) {
-            pageContext.setAttribute(contactMechTypeIdAttr, contactMechTypeId);
-
-            try {
-                GenericValue contactMechType = delegator.findByPrimaryKey("ContactMechType", UtilMisc.toMap("contactMechTypeId", contactMechTypeId));
-
-                if (contactMechType != null)
-                    pageContext.setAttribute(contactMechTypeAttr, contactMechType);
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-
-            Collection purposeTypes = new LinkedList();
-            Iterator typePurposes = null;
-
-            try {
-                typePurposes = UtilMisc.toIterator(delegator.findByAnd("ContactMechTypePurpose", UtilMisc.toMap("contactMechTypeId", contactMechTypeId)));
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-            while (typePurposes != null && typePurposes.hasNext()) {
-                GenericValue contactMechTypePurpose = (GenericValue) typePurposes.next();
-                GenericValue contactMechPurposeType = null;
-
-                try {
-                    contactMechPurposeType = contactMechTypePurpose.getRelatedOne("ContactMechPurposeType");
-                } catch (GenericEntityException e) {
-                    Debug.logWarning(e, module);
-                }
-                if (contactMechPurposeType != null) {
-                    purposeTypes.add(contactMechPurposeType);
-                }
-            }
-            if (purposeTypes.size() > 0)
-                pageContext.setAttribute(purposeTypesAttr, purposeTypes);
-        }
-
-        String requestName;
-
-        if (contactMech == null) {
-            // create
-            if ("POSTAL_ADDRESS".equals(contactMechTypeId)) {
-                if (request.getParameter("contactMechPurposeTypeId") != null || request.getAttribute("contactMechPurposeTypeId") != null) {
-                    requestName = "createPostalAddressAndPurpose";
-                } else {
-                    requestName = "createPostalAddress";
-                }
-            } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) {
-                requestName = "createTelecomNumber";
-            } else if ("EMAIL_ADDRESS".equals(contactMechTypeId)) {
-                requestName = "createEmailAddress";
-            } else {
-                requestName = "createContactMech";
-            }
-        } else {
-            // update
-            if ("POSTAL_ADDRESS".equals(contactMechTypeId)) {
-                requestName = "updatePostalAddress";
-            } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) {
-                requestName = "updateTelecomNumber";
-            } else if ("EMAIL_ADDRESS".equals(contactMechTypeId)) {
-                requestName = "updateEmailAddress";
-            } else {
-                requestName = "updateContactMech";
-            }
-        }
-        pageContext.setAttribute(requestNameAttr, requestName);
-
-        if ("POSTAL_ADDRESS".equals(contactMechTypeId)) {
-            GenericValue postalAddress = null;
-
-            try {
-                if (contactMech != null) postalAddress = contactMech.getRelatedOne("PostalAddress");
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-            if (postalAddress != null) pageContext.setAttribute(postalAddressAttr, postalAddress);
-        } else if ("TELECOM_NUMBER".equals(contactMechTypeId)) {
-            GenericValue telecomNumber = null;
-
-            try {
-                if (contactMech != null) telecomNumber = contactMech.getRelatedOne("TelecomNumber");
-            } catch (GenericEntityException e) {
-                Debug.logWarning(e, module);
-            }
-            if (telecomNumber != null) pageContext.setAttribute(telecomNumberAttr, telecomNumber);
-        }
-
-        if ("true".equals(request.getParameter("useValues"))) tryEntity = true;
-        pageContext.setAttribute(tryEntityAttr, new Boolean(tryEntity));
-
-        try {
-            Collection contactMechTypes = delegator.findAllCache("ContactMechType", null);
-
-            if (contactMechTypes != null) {
-                pageContext.setAttribute(contactMechTypesAttr, contactMechTypes);
-            }
-        } catch (GenericEntityException e) {
-            Debug.logWarning(e, module);
-        }
-    }
-
     public static void getContactMechAndRelated(ServletRequest request, String partyId, Map target) {
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
 
@@ -877,16 +703,6 @@
         return postalAddressInfos;
     }
 
-    /** TO BE REMOVED (DEJ 20030221): This method was for use in a JSP and when they are removed this can be removed as well rather than being maintained, should be removed when eCommerce and party mgr and possible other places are converted to FTL */
-    public static void getCurrentPostalAddress(PageContext pageContext, String partyId, String curContactMechId,
-            String curPartyContactMechAttr, String curContactMechAttr, String curPostalAddressAttr, String curPartyContactMechPurposesAttr) {
-        ServletRequest request = pageContext.getRequest();
-        Map results = getCurrentPostalAddress(request, partyId, curContactMechId);
-        if (results.get("curPartyContactMech") != null) pageContext.setAttribute(curPartyContactMechAttr, results.get("curPartyContactMech"));
-        if (results.get("curContactMech") != null) pageContext.setAttribute(curContactMechAttr, results.get("curContactMech"));
-        if (results.get("curPostalAddress") != null) pageContext.setAttribute(curPostalAddressAttr, results.get("curPostalAddress"));
-        if (results.get("curPartyContactMechPurposes") != null) pageContext.setAttribute(curPartyContactMechPurposesAttr, results.get("curPartyContactMechPurposes"));
-    }
     public static Map getCurrentPostalAddress(ServletRequest request, String partyId, String curContactMechId) {
         GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         Map results = new HashMap();
@@ -1058,5 +874,40 @@
         } else {
             return attr.getString("attrValue");
         }
+    }
+    
+    public static String getPostalAddressPostalCodeGeoId(GenericValue postalAddress, GenericDelegator delegator) throws GenericEntityException {
+    	// if postalCodeGeoId not empty use that
+    	if (UtilValidate.isNotEmpty(postalAddress.getString("postalCodeGeoId"))) {
+    		return postalAddress.getString("postalCodeGeoId");
+    	}
+    	
+    	// no postalCodeGeoId, see if there is a Geo record matching the countryGeoId and postalCode fields
+    	if (UtilValidate.isNotEmpty(postalAddress.getString("countryGeoId")) && UtilValidate.isNotEmpty(postalAddress.getString("postalCode"))) {
+    		// first try the shortcut with the geoId convention for "{countryGeoId}-{postalCode}"
+    		GenericValue geo = delegator.findByPrimaryKeyCache("Geo", UtilMisc.toMap("geoId", postalAddress.getString("countryGeoId") + "-" + postalAddress.getString("postalCode")));
+    		if (geo != null) {
+    			// save the value to the database for quicker future reference
+    			postalAddress.set("postalCodeGeoId", geo.getString("geoId"));
+    			postalAddress.store();
+    			
+    			return geo.getString("geoId");
+    		}
+
+    		// no shortcut, try the longcut to see if there is something with a geoCode associated to the countryGeoId
+			List geoAssocAndGeoToList = delegator.findByAndCache("GeoAssocAndGeoTo", 
+					UtilMisc.toMap("geoIdFrom", postalAddress.getString("countryGeoId"), "geoCode", postalAddress.getString("postalCode"), "geoAssocTypeId", "REGIONS"));
+			GenericValue geoAssocAndGeoTo = EntityUtil.getFirst(geoAssocAndGeoToList);
+			if (geoAssocAndGeoTo != null) {
+    			// save the value to the database for quicker future reference
+    			postalAddress.set("postalCodeGeoId", geoAssocAndGeoTo.getString("geoId"));
+    			postalAddress.store();
+    			
+				return geoAssocAndGeoTo.getString("geoId");
+			}
+    	}
+    	
+    	// nothing found, return null
+    	return null;
     }
 }

Modified: ofbiz/trunk/framework/common/data/GeoData_US.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/GeoData_US.xml?view=diff&rev=556364&r1=556363&r2=556364
==============================================================================
--- ofbiz/trunk/framework/common/data/GeoData_US.xml (original)
+++ ofbiz/trunk/framework/common/data/GeoData_US.xml Sat Jul 14 22:53:41 2007
@@ -269,9 +269,12 @@
     <GeoAssoc geoId="CAN" geoIdTo="USMEXCAN" geoAssocTypeId="GROUP_MEMBER"/>
     
     <!-- Some county info for testing -->
-    <Geo abbreviation="UTAH" geoCode="UTAH" geoId="UT-UTAH" geoName="Utah" geoTypeId="COUNTY"/>
+    <Geo abbreviation="UTAH" geoCode="UTAH" geoId="UT-UTAH" geoName="Utah County" geoTypeId="COUNTY"/>
     <GeoAssoc geoId="UT" geoIdTo="UT-UTAH" geoAssocTypeId="REGIONS"/>
     <Geo abbreviation="SANPETE" geoCode="SANPETE" geoId="UT-SANPETE" geoName="Sanpete" geoTypeId="COUNTY"/>
     <GeoAssoc geoId="UT" geoIdTo="UT-SANPETE" geoAssocTypeId="REGIONS"/>
+    <Geo abbreviation="84057" geoCode="84057" geoId="USA-84057" geoName="84057" geoTypeId="POSTAL_CODE"/>
+    <GeoAssoc geoId="UT-UTAH" geoIdTo="USA-84057" geoAssocTypeId="REGIONS"/><!-- the postal code is in this county for tax lookup purposes to find the county by zip code -->
+    <GeoAssoc geoId="USA" geoIdTo="USA-84057" geoAssocTypeId="REGIONS"/><!-- the postal code is in this country which is necessary to lookup the postalCodeGeoId by countryGeoId and postalCode string; this isn't necessary as there is a convention for postal code geoIds of "{countryGeoId}-{postalCode}" that the code looks for -->
 </entity-engine-xml>