Author: ashish
Date: Sat Sep 20 15:46:01 2014 New Revision: 1626462 URL: http://svn.apache.org/r1626462 Log: Applied bug fix from jira issue - OFBIZ-5261- Party contact expiration and its hidden problems. Thanks Mridul for providing the patch. Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java?rev=1626462&r1=1626461&r2=1626462&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceWorker.java Sat Sep 20 15:46:01 2014 @@ -299,16 +299,20 @@ public class InvoiceWorker { if (invoice.getString("invoiceTypeId").equals("PURCHASE_INVOICE")) destinationPartyId = invoice.getString("partyId"); try { - locations = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", destinationPartyId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false)); + locations = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", destinationPartyId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false); + locations = EntityUtil.filterByDate(locations, null, "contactFromDate", "contactThruDate", true); + locations = EntityUtil.filterByDate(locations, null, "purposeFromDate", "purposeThruDate", true); } catch (GenericEntityException e) { Debug.logError("Trouble getting contact party purpose list", module); } //if still not found get it from the general location if (UtilValidate.isEmpty(locations)) { try { - locations = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", destinationPartyId, "contactMechPurposeTypeId", "GENERAL_LOCATION"), null, false)); + locations = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", destinationPartyId, "contactMechPurposeTypeId", "GENERAL_LOCATION"), null, false); + locations = EntityUtil.filterByDate(locations, null, "contactFromDate", "contactThruDate", true); + locations = EntityUtil.filterByDate(locations, null, "purposeFromDate", "purposeThruDate", true); } catch (GenericEntityException e) { Debug.logError("Trouble getting contact party purpose list", module); } Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java?rev=1626462&r1=1626461&r2=1626462&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentMethodServices.java Sat Sep 20 15:46:01 2014 @@ -213,10 +213,11 @@ public class PaymentMethodServices { GenericValue tempVal = null; try { - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false), true); - - tempVal = EntityUtil.getFirst(allPCMPs); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -387,10 +388,12 @@ public class PaymentMethodServices { GenericValue tempVal = null; try { - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false), true); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - tempVal = EntityUtil.getFirst(allPCMPs); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -726,11 +729,12 @@ public class PaymentMethodServices { GenericValue tempVal = null; try { - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, - "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false), true); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - tempVal = EntityUtil.getFirst(allPCMPs); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -854,10 +858,11 @@ public class PaymentMethodServices { GenericValue tempVal = null; try { - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, - "contactMechPurposeTypeId",contactMechPurposeTypeId), null, false), true); - tempVal = EntityUtil.getFirst(allPCMPs); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java?rev=1626462&r1=1626461&r2=1626462&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/payment/PaymentWorker.java Sat Sep 20 15:46:01 2014 @@ -158,12 +158,13 @@ public class PaymentWorker { public static GenericValue getPaymentAddress(Delegator delegator, String partyId) { List<GenericValue> paymentAddresses = null; try { - paymentAddresses = delegator.findByAnd("PartyContactMechPurpose", - UtilMisc.toMap("partyId", partyId, "contactMechPurposeTypeId", "PAYMENT_LOCATION"), - UtilMisc.toList("-fromDate"), false); - paymentAddresses = EntityUtil.filterByDate(paymentAddresses); + paymentAddresses = delegator.findByAnd("PartyContactWithPurpose", + UtilMisc.toMap("partyId", partyId, "contactMechPurposeTypeId", "PAYMENT_LOCATION"), + UtilMisc.toList("-fromDate"), false); + paymentAddresses = EntityUtil.filterByDate(paymentAddresses, null, "contactFromDate", "contactThruDate", true); + paymentAddresses = EntityUtil.filterByDate(paymentAddresses, null, "purposeFromDate", "purposeThruDate", true); } catch (GenericEntityException e) { - Debug.logError(e, "Trouble getting PartyContactMechPurpose entity list", module); + Debug.logError(e, "Trouble getting PartyContactWithPurpose view entity list", module); } // get the address for the primary contact mech 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=1626462&r1=1626461&r2=1626462&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 Sat Sep 20 15:46:01 2014 @@ -143,11 +143,12 @@ if (partyGroup?.groupName) { context.companyName = companyName; // the address -addresses = delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, contactMechPurposeTypeId : "GENERAL_LOCATION"], null, false); -selAddresses = EntityUtil.filterByDate(addresses, nowTimestamp, "fromDate", "thruDate", true); +addresses = delegator.findByAnd("PartyContactWithPurpose", [partyId : partyId, contactMechPurposeTypeId : "GENERAL_LOCATION"], null, false); +addresses = EntityUtil.filterByDate(addresses, null, "contactFromDate", "contactThruDate", true); +addresses = EntityUtil.filterByDate(addresses, null, "purposeFromDate", "purposeThruDate", true); address = null; -if (selAddresses) { - address = delegator.findOne("PostalAddress", [contactMechId : selAddresses[0].contactMechId], false); +if (addresses) { + address = delegator.findOne("PostalAddress", [contactMechId : addresses[0].contactMechId], false); } if (address) { // get the country name and state/province abbreviation @@ -163,24 +164,27 @@ if (address) { context.postalAddress = address; //telephone -phones = delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_PHONE"], null, false); -selPhones = EntityUtil.filterByDate(phones, nowTimestamp, "fromDate", "thruDate", true); -if (selPhones) { - context.phone = delegator.findOne("TelecomNumber", [contactMechId : selPhones[0].contactMechId], false); +phones = delegator.findByAnd("PartyContactWithPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_PHONE"], null, false); +phones = EntityUtil.filterByDate(phones, null, "contactFromDate", "contactThruDate", true); +phones = EntityUtil.filterByDate(phones, null, "purposeFromDate", "purposeThruDate", true); +if (phones) { + context.phone = delegator.findOne("TelecomNumber", [contactMechId : phones[0].contactMechId], false); } // Fax -faxNumbers = delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, contactMechPurposeTypeId : "FAX_NUMBER"], null, false); -faxNumbers = EntityUtil.filterByDate(faxNumbers, nowTimestamp, null, null, true); +faxNumbers = delegator.findByAnd("PartyContactWithPurpose", [partyId : partyId, contactMechPurposeTypeId : "FAX_NUMBER"], null, false); +faxNumbers = EntityUtil.filterByDate(faxNumbers, null, "contactFromDate", "contactThruDate", true); +faxNumbers = EntityUtil.filterByDate(faxNumbers, null, "purposeFromDate", "purposeThruDate", true); if (faxNumbers) { context.fax = delegator.findOne("TelecomNumber", [contactMechId : faxNumbers[0].contactMechId], false); } -emails = delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_EMAIL"], null, false); -selEmails = EntityUtil.filterByDate(emails, nowTimestamp, "fromDate", "thruDate", true); -if (selEmails) { - context.email = delegator.findOne("ContactMech", [contactMechId : selEmails[0].contactMechId], false); +emails = delegator.findByAnd("PartyContactWithPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_EMAIL"], null, false); +emails = EntityUtil.filterByDate(emails, null, "contactFromDate", "contactThruDate", true); +emails = EntityUtil.filterByDate(emails, null, "purposeFromDate", "purposeThruDate", true); +if (emails) { + context.email = delegator.findOne("ContactMech", [contactMechId : emails[0].contactMechId], false); } else { //get email address from party contact mech contacts = delegator.findByAnd("PartyContactMech", [partyId : partyId], null, false); selContacts = EntityUtil.filterByDate(contacts, nowTimestamp, "fromDate", "thruDate", true); @@ -197,7 +201,9 @@ if (selEmails) { } // website -websiteUrls = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_WEB_URL"], null, false)); +websiteUrls = delegator.findByAnd("PartyContactWithPurpose", [partyId : partyId, contactMechPurposeTypeId : "PRIMARY_WEB_URLs"], null, false); +websiteUrls = EntityUtil.filterByDate(websiteUrls, null, "contactFromDate", "contactThruDate", true); +websiteUrls = EntityUtil.filterByDate(websiteUrls, null, "purposeFromDate", "purposeThruDate", true); if (websiteUrls) { websiteUrl = EntityUtil.getFirst(websiteUrls); context.website = delegator.findOne("ContactMech", [contactMechId : websiteUrl.contactMechId], false); Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java?rev=1626462&r1=1626461&r2=1626462&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Sat Sep 20 15:46:01 2014 @@ -809,9 +809,11 @@ public class ContactMechServices { try { Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap, null, false), true); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", pcmpFindMap, null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - tempVal = EntityUtil.getFirst(allPCMPs); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; @@ -870,9 +872,11 @@ public class ContactMechServices { try { Map<String, String> pcmpFindMap = UtilMisc.toMap("partyId", partyId, "contactMechId", contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId); //Debug.logInfo("pcmpFindMap = " + pcmpFindMap, module); - List<GenericValue> allPCMPs = EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", pcmpFindMap, null, false), true); + List<GenericValue> allPCWPs = delegator.findByAnd("PartyContactWithPurpose", pcmpFindMap, null, false); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "contactFromDate", "contactThruDate", true); + allPCWPs = EntityUtil.filterByDate(allPCWPs, null, "purposeFromDate", "purposeThruDate", true); - tempVal = EntityUtil.getFirst(allPCMPs); + tempVal = EntityUtil.getFirst(allPCWPs); } catch (GenericEntityException e) { Debug.logWarning(e.getMessage(), module); tempVal = null; |
Free forum by Nabble | Edit this page |