[ https://issues.apache.org/jira/browse/OFBIZ-5261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14245300#comment-14245300 ]
Jacques Le Roux commented on OFBIZ-5261: ---------------------------------------- Finally I give up on backporting in R12.04, too much issues in Groovy files. This is where a strongly typed language misses... > Party contact expiration and its hidden problems > ------------------------------------------------ > > Key: OFBIZ-5261 > URL: https://issues.apache.org/jira/browse/OFBIZ-5261 > Project: OFBiz > Issue Type: Bug > Components: accounting, order, party > Affects Versions: Release 09.04, Release 09.04.01, Release 10.04, Release > Branch 11.04, Trunk > Reporter: Sergei Biletnikov > Assignee: Ashish Vijaywargiya > Fix For: Release Branch 11.04, Upcoming Branch, 13.07.02 > > Attachments: OFBIZ-5261.patch > > > I found a problem which can appear when you add new contact like postal > address and expiry old one, the old contact is still used by some code. > The cause of the problem is easy and clear. > To make it more clear, let me remind you that OFBiz has a smart contacts data > model, where each contact represents the contact data like address, phone > number and etc and contact purposes, which is responsible for the how to > apply the contact. > Regarding parties, the main entities here: > PartyContactMech (contact) > and > PartyContactMechPurpose (purpose) > All looks good. > However, both PartyContactMech and PartyContactMechPurpose have from and thru > date creterias,i.e. can be expired! > If you add a purpose to the contanct and after that you remove it, the > purpose will be expired (not deleted), that is ok for auditing. > RE: PartyContactMech, if you expire the contact,it means this contact > mechanism must be out from the game and not be visisble on the profile page. > The state of its purposes do not matter anymore, it must be not used. > But there is a problem here, some code takes into account > PartyContactMechPurpose and use date filter but ignores PartyContactMech > expiration state. This follows to the error: the contact is expired, the > purposes not, but the contact is still used!!! > Example: > \applications\order\webapp\ordermgr\WEB-INF\actions\order\CompanyHeader.groovy > addresses = delegator.findByAnd("PartyContactMechPurpose", [partyId : > partyId, contactMechPurposeTypeId : "GENERAL_LOCATION"]); > selAddresses = EntityUtil.filterByDate(addresses, nowTimestamp, "fromDate", > "thruDate", true); > ........ > phones = delegator.findByAnd("PartyContactMechPurpose", [partyId : partyId, > contactMechPurposeTypeId : "PRIMARY_PHONE"]); > ........... > only PartyContactMechPurpose ??? and it ignores that PartyContactMech is > already expired! The result : I see the expired contact on the order page. > \applications\accounting\src\org\ofbiz\accounting\payment\PaymentMethodServices.java > try { > List<GenericValue> allPCMPs = > EntityUtil.filterByDate(delegator.findByAnd("PartyContactMechPurpose", > UtilMisc.toMap("partyId", partyId, "contactMechId", > contactMechId, "contactMechPurposeTypeId", contactMechPurposeTypeId), null), > true); > tempVal = EntityUtil.getFirst(allPCMPs); > } catch (GenericEntityException e) { > Debug.logWarning(e.getMessage(), module); > tempVal = null; > } > ..... > and again, we are interested only in PartyContactMechPurpose. The potential > problem is here. > I did not check the all code of OFBiz, it is just my fast search attempts. > How to solve the problem??? > In my opinion, the data model looks ok, and it is ok when PartyContactMech is > expired, but its purposes are not. It does not break a sense and good for > auditing. > The good solution is to correct code and rely on both parties to find the > necessary contact/purpose, for example the PartyContactWithPurpose can be > used with contactFromDate, contactThruDate, purposeFromDate, purposeThruDate > accordingly. However, I do not know how is big the effort to do that in the > existing code. > The fast and easy solution is expiring all purposes for the expired contact > mechanisms, in this case we can rely only on PartyContactMechPurpose. -- This message was sent by Atlassian JIRA (v6.3.4#6332)