|
|
Overview
This rolls up certain membership-related statistics from Opps to Contacts or Accounts. Stats include:
- member expire date
- member join date
- current member level
- last membership origin (new vs renewal etc)
from these, other fields like Member Status are calculated via formula
Basic Approach
A trigger on Opportunity fires whenever a Won membership-type opp is created or modified in certain ways. When this happens, the code looks at all Won member Opps related to that contact/HH or account, not just the opp that caused the trigger.
The stats listed above are figured based on the most recent or first membership opp for the HH/account, based on the MemberStartDate of each opp. (Stats pull from most recent membership, except for Join Date which pulls from first)
Individual opps roll up to all contacts in the HH of the primary contact role, regardless of other contact roles on the opp(s). Account opps roll up to account only.
(An account opp is defined as an opp related an account other than the default Individual acct, regardless of contact roles.)
(A membership type opp is determined by list of record types stored in Constants class.)
Limitations
Since we currently cannot trigger on Contact Roles, stats may get out of sync if a user changes contact roles on an individual opp after insert. Will need to provide a web service method to recalculate stats (single HH/acct and db-wide?)
Future Enhancements
definite:
- WebService method to run rollup (see above)
possible:
- validation to prevent overlapping membership periods (currently can cause problems if one mbr period starts before and also ends after another period)
- rollup of member "chain" stats for sake of analysis (mainly change in member amt/level from year-to-year)
- intelligent defaulting of membership fields (start/end dates, new vs. renewal, etc.) (prob. will have to be done w/ scontrol)
Triggers
MembershipStatusRollup (Opportunity)
fires when:
- membership-type opp inserted or deleted & IsWon
- membership-type opp updated any of the following:
- Account
- stage (not IsWon to IsWon or viceversa)
- Amount
- membership dates
- member origin or level
in UI use, correct behavior may also depend on:
- CreateContactRoles
Classes
- Membership Rollup (not instantiated, method calls only)
- HouseholdOppHistory (instantiated by the above, may be renamed)
- DefaultAccount
- RecordTypes
- Constants
Schema
- Opp
- Membership_Start_Date__c
- Membership_End_Date__c
- Membership_Origin__c,
- Member_Level__c
- (more to come, see Future Enhancements above)
- Contact
- Membership_End_Date__c
- Membership_Status__c (Formula based on end date)
- Membership_Join_Date__c
- Membership_Origin__c,
- Member_Level__c
- Membership_Span__c (formula)
- (more to come)
- Account
- same as Contact
Tests
- TestMemberStatus
relies on:
- UnitTestData
- Household triggers
- ContactRole trigger
Sign in to add a comment
