Skip to content

Commit

Permalink
Merge pull request #7248 from SalesforceFoundation/feature/254__W-145…
Browse files Browse the repository at this point in the history
…39175-new-contact-changes-account-default-address-to-seasonal

W-14539175 -Adding new contact changes default address on Account
  • Loading branch information
lparrott authored Aug 12, 2024
2 parents c6b966a + 7dbde7b commit 3c48e20
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions force-app/main/domain/HouseholdMembers.cls
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ public inherited sharing class HouseholdMembers implements IHouseholdMembers {
}
if (!npspAddress.isEqualToIncludingAddressType(npspMatchingAddress, true)) {
npspMatchingAddress.copyFrom(npspAddress);
if (!npspContact.hasAddressOverride() && !npspMatchingAddress.isDefault()) {
if (!npspContact.hasAddressOverride() && !npspMatchingAddress.isDefault() && !isSeasonalAddress(npspMatchingAddress.getRecord())) {
npspMatchingAddress.setAsDefault();
}
addressUpdated = true;
}
// exact match. we aren't specifying override, so the address should become the new hh default address
else if (!npspContact.hasAddressOverride() && !npspMatchingAddress.isDefault()) {
else if (!npspContact.hasAddressOverride() && !npspMatchingAddress.isDefault() && !isSeasonalAddress(npspMatchingAddress.getRecord())) {
npspMatchingAddress.setAsDefault();
addressUpdated = true;
}
Expand All @@ -164,7 +164,9 @@ public inherited sharing class HouseholdMembers implements IHouseholdMembers {
}
} else {
// no match, not an override, make it a new default hh address
npspAddress.setAsDefault();
if (!isSeasonalAddress(npspAddress.getRecord())) {
npspAddress.setAsDefault();
}
npspAddress.setUndeliverable(npspContact.isUndeliverableMailingAddress());
addressesToInsert.add(npspAddress.getRecord());
}
Expand All @@ -181,6 +183,11 @@ public inherited sharing class HouseholdMembers implements IHouseholdMembers {
TDTM_TriggerHandler.processDML(dmlWrapper);
}

private Boolean isSeasonalAddress(Address__c address) {
return address.Seasonal_Start_Day__c != null && address.Seasonal_Start_Month__c != null &&
address.Seasonal_End_Day__c != null && address.Seasonal_End_Month__c != null;
}

private Boolean shouldUpdateAddressUndeliverableStatusFromContact(NPSP_Contact npspContact) {
return npspContact.isUndeliverableStatusChanged();
}
Expand Down

0 comments on commit 3c48e20

Please sign in to comment.