Skip to content

Commit

Permalink
Merge a8a24c7 into feature/ErrRelease252
Browse files Browse the repository at this point in the history
  • Loading branch information
salesforce-org-metaci[bot] authored Dec 16, 2024
2 parents b2b9896 + a8a24c7 commit ee969cd
Show file tree
Hide file tree
Showing 31 changed files with 751 additions and 151 deletions.
5 changes: 4 additions & 1 deletion .forceignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@

# LWC Jest
**/__tests__/**
**/__mocks__/**
**/__mocks__/**
**/tsconfig.json

**/*.ts
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Comment line immediately above ownership line is reserved for related other information. Please be careful while editing.
#ECCN:Open Source
105 changes: 105 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Salesforce Open Source Community Code of Conduct

## About the Code of Conduct

Equality is a core value at Salesforce. We believe a diverse and inclusive
community fosters innovation and creativity, and are committed to building a
culture where everyone feels included.

Salesforce open-source projects are committed to providing a friendly, safe, and
welcoming environment for all, regardless of gender identity and expression,
sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
race, age, religion, level of experience, education, socioeconomic status, or
other similar personal characteristics.

The goal of this code of conduct is to specify a baseline standard of behavior so
that people with different social values and communication styles can work
together effectively, productively, and respectfully in our open source community.
It also establishes a mechanism for reporting issues and resolving conflicts.

All questions and reports of abusive, harassing, or otherwise unacceptable behavior
in a Salesforce open-source project may be reported by contacting the Salesforce
Open Source Conduct Committee at [email protected].

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of gender
identity and expression, sexual orientation, disability, physical appearance,
body size, ethnicity, nationality, race, age, religion, level of experience, education,
socioeconomic status, or other similar personal characteristics.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy toward other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Personal attacks, insulting/derogatory comments, or trolling
* Public or private harassment
* Publishing, or threatening to publish, others' private information—such as
a physical or electronic address—without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Advocating for or encouraging any of the above behaviors

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned with this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project email
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the Salesforce Open Source Conduct Committee
at [email protected]. All complaints will be reviewed and investigated
and will result in a response that is deemed necessary and appropriate to the
circumstances. The committee is obligated to maintain confidentiality with
regard to the reporter of an incident. Further details of specific enforcement
policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership and the Salesforce Open Source Conduct
Committee.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant-home],
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
[CNCF Code of Conduct][cncf-coc], and [Microsoft Open Source Code of Conduct][microsoft-coc].

This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].

[contributor-covenant-home]: https://www.contributor-covenant.org (https://www.contributor-covenant.org/)
[golang-coc]: https://golang.org/conduct
[cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
[microsoft-coc]: https://opensource.microsoft.com/codeofconduct/
[cc-by-3-us]: https://creativecommons.org/licenses/by/3.0/us/
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing Guide For NPSP

This page lists the operational governance model of this project, as well as the recommendations and requirements for how to best contribute to NPSP. We strive to obey these as best as possible. As always, thanks for contributing – we hope these guidelines make it easier and shed some light on our approach and processes.

# Governance Model

## Salesforce Sponsored

The intent and goal of open sourcing this project is to increase the contributor and user base. However, only Salesforce employees will be given `admin` rights and will be the final arbitrars of what contributions are accepted or not.

# Issues, requests & ideas

The Nonprofit Success Pack team does not review or respond to support requests or questions posted in this repository.

Instead, please post all questions and issues directly in the Nonprofit Hub of the Trailblazer Community: http://sfdc.co/npchub

# Code of Conduct
Please follow our [Code of Conduct](CODE_OF_CONDUCT.md).

# License
By contributing your code, you agree to license your contribution under the terms of our project [LICENSE](LICENSE) and to sign the [Salesforce CLA](https://cla.salesforce.com/sign-cla)
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Security

Please report any security issue to [[email protected]](mailto:[email protected])
as soon as it is discovered. This library limits its runtime dependencies in
order to reduce the total cost of ownership as much as can be, but all consumers
should remain vigilant and have their security stakeholders review all third-party
products (3PP) like this one and their dependencies.
48 changes: 41 additions & 7 deletions force-app/main/adapter/in/sobjects/contact/ContactAdapter.cls
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public inherited sharing class ContactAdapter extends fflib_SObjects2 {
// mark the new address as default
// put it on dmlWrapper
//

// Map to hold the contact-to-address mapping
Map<Contact, Address__c> contactAddressesByContact = getContactAddressesByContact(contacts);

// look for duplicates for our proposed new addresses
Expand All @@ -665,22 +665,56 @@ public inherited sharing class ContactAdapter extends fflib_SObjects2 {
Address__c newAddressFromContact = contactAddressesByContact.get(contact);
Address__c existingAddressFromContact = existingAddressesByAddress.get(newAddressFromContact);

// if found a match
if (contactAddressHasAddressMatch(existingAddressFromContact)) {
// Check if the contact's address fields are intentionally set to null
Boolean isAddressFieldsNull = String.isBlank(contact.MailingStreet) &&
String.isBlank(contact.MailingCity) &&
String.isBlank(contact.MailingPostalCode) &&
String.isBlank(contact.MailingState) &&
String.isBlank(contact.MailingCountry);

// If all address fields are null, clear the Current_Address__c field and continue
if (isAddressFieldsNull) {
contact.Current_Address__c = null;
continue; // Skip address creation for this contact
}

// Check if the contact has Address Override enabled
if (contact.Is_Address_Override__c == true) {
// Create a new address record specific to this contact
Address__c newAddress = new Address__c();
newAddress.Household_Account__c = contact.AccountId; // Link to household/account
newAddress.MailingStreet__c = contact.MailingStreet;
newAddress.MailingCity__c = contact.MailingCity;
newAddress.MailingState__c = contact.MailingState;
newAddress.MailingPostalCode__c = contact.MailingPostalCode;
newAddress.MailingCountry__c = contact.MailingCountry;
newAddress.Default_Address__c = false; // It's not a default address

// Add the new address to be inserted
contactAddressesToInsertByContact.put(contact, newAddress);

}
else if (contactAddressHasAddressMatch(existingAddressFromContact)) {
updateContactAddressFromExistingAddress(contact, existingAddressFromContact);

// Prevent an address that was just inserted by the BeforeInsert trigger from being udpated
// a second time by the AfterInsert trigger.
}

// no match found, and its an override just for this contact
else if (contact.is_Address_Override__c) {
else {
// put it on the list of addresss to create now
contactAddressesToInsertByContact.put(contact, newAddressFromContact);
}
}

// Insert the new addresses created for contacts with Address Override
insertContactAddresses(contactAddressesToInsertByContact);

// Update the Current_Address__c field for each contact after the address insertion
for (Contact contact : contactAddressesToInsertByContact.keySet()) {
Address__c insertedAddress = contactAddressesToInsertByContact.get(contact);
if (insertedAddress != null && insertedAddress.Id != null) {
contact.Current_Address__c = insertedAddress.Id; // Set the address ID after insertion
}
}
}

private Set<Contact> getAddressCreationQueueBeforeUpdate() {
Expand Down
4 changes: 2 additions & 2 deletions force-app/main/default/classes/BDI_ContactService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public with sharing class BDI_ContactService {
/*******************************************************************************************************
* @description cached map to get Contact1 for a DI
*/
private Map<Id, Contact> mapDIIdToC1;
@TestVisible private Map<Id, Contact> mapDIIdToC1;

/*******************************************************************************************************
* @description cached map to get Contact2 for a DI
*/
private Map<Id, Contact> mapDIIdToC2;
@TestVisible private Map<Id, Contact> mapDIIdToC2;

/*******************************************************************************************************
* @description map that holds multiple DIKeys for each Contact
Expand Down
77 changes: 69 additions & 8 deletions force-app/main/default/classes/BDI_DataImportService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ global with sharing class BDI_DataImportService {
/*******************************************************************************************************
* @description holds the Contact Service class for use during processing
*/
private BDI_ContactService contactService { get; private set; }
@TestVisible private BDI_ContactService contactService { get; private set; }

/*******************************************************************************************************
* @description holds the Additional Object Service class for use during processing
Expand Down Expand Up @@ -1260,6 +1260,7 @@ global with sharing class BDI_DataImportService {
* @description importing or updating Account1 and Account2, and setting the contacts' Primary Affiliation.
* @return void
*/
@TestVisible
private void importAccounts() {

// first, try to match our existing Accounts
Expand Down Expand Up @@ -1333,18 +1334,39 @@ global with sharing class BDI_DataImportService {
dataImport.Account1Imported__c = acc.Id;
}
}
// set c1's primary affilation
// Set C1's fields first
if (dataImport.Account1Imported__c != null) {
Contact c1 = ContactFromDi(dataImport, 1);
if (c1 != null && c1.Primary_Affiliation__c != dataImport.Account1Imported__c) {
c1.Primary_Affiliation__c = dataImport.Account1Imported__c;
if (c1 != null) {
updateContactFieldsForImport(c1, dataImport, 'Contact1_');
if (mapConIdToConUpdate.get(c1.Id) == null) {
mapConIdToConUpdate.put(c1.Id, c1);
}
}
}
}

// Update contacts to ensure all relevant fields are updated
if (mapConIdToConUpdate.size() > 0) {
UTIL_DMLService.updateRecords(mapConIdToConUpdate.values());
}

// Set C1's primary affiliation separately to avoid conflicts
for (DataImport__c dataImport : listDI) {
if (dataImport.Account1Imported__c != null) {
Contact c1 = ContactFromDi(dataImport, 1);
if (c1 != null && c1.Primary_Affiliation__c != dataImport.Account1Imported__c) {
c1.Primary_Affiliation__c = dataImport.Account1Imported__c;
mapConIdToConUpdate.put(c1.Id, c1);
}
}
}

// Now update the Contacts again to set their Affiliations
if (mapConIdToConUpdate.size() > 0) {
UTIL_DMLService.updateRecords(mapConIdToConUpdate.values());
}

// create/update our A2's
listAccUpsert.clear();
listDIUpsert.clear();
Expand Down Expand Up @@ -1403,24 +1425,63 @@ global with sharing class BDI_DataImportService {
dataImport.Account2Imported__c = acc.Id;
}
}
// set c2's primary affilation
// Set C2's fields first
if (dataImport.Account2Imported__c != null) {
Contact c2 = ContactFromDi(dataImport, 2);
if (c2 != null && c2.Primary_Affiliation__c != dataImport.Account2Imported__c) {
c2.Primary_Affiliation__c = dataImport.Account2Imported__c;
if (c2 != null) {
updateContactFieldsForImport(c2, dataImport, 'Contact2_');
if (mapConIdToConUpdate.get(c2.Id) == null) {
mapConIdToConUpdate.put(c2.Id, c2);
}
}
}
}

// now update the Contacts to create their Affiliations
// Update contacts to ensure all relevant fields are updated
if (mapConIdToConUpdate.size() > 0) {
UTIL_DMLService.updateRecords(mapConIdToConUpdate.values());
}

// Set C2's primary affiliation separately to avoid conflicts
for (DataImport__c dataImport : listDI) {
if (dataImport.Account2Imported__c != null) {
Contact c2 = ContactFromDi(dataImport, 2);
if (c2 != null && c2.Primary_Affiliation__c != dataImport.Account2Imported__c) {
c2.Primary_Affiliation__c = dataImport.Account2Imported__c;
mapConIdToConUpdate.put(c2.Id, c2);
}
}
}
// now update the Contacts again to set their Affiliations
if (mapConIdToConUpdate.size() > 0) {
UTIL_DMLService.updateRecords(mapConIdToConUpdate.values());
}
}

private void updateContactFieldsForImport(Contact contact, DataImport__c dataImport, String contactPrefix) {
if (dataImport.get(contactPrefix + 'Home_Phone__c') != null) {
contact.HomePhone = (String) dataImport.get(contactPrefix + 'Home_Phone__c');
}
if (dataImport.get(contactPrefix + 'Work_Phone__c') != null) {
contact.Phone = (String) dataImport.get(contactPrefix + 'Work_Phone__c');
}
if (dataImport.get(contactPrefix + 'Mobile_Phone__c') != null) {
contact.MobilePhone = (String) dataImport.get(contactPrefix + 'Mobile_Phone__c');
}
if (dataImport.get(contactPrefix + 'Other_Phone__c') != null) {
contact.OtherPhone = (String) dataImport.get(contactPrefix + 'Other_Phone__c');
}
if (dataImport.get(contactPrefix + 'Personal_Email__c') != null) {
contact.Email = (String) dataImport.get(contactPrefix + 'Personal_Email__c');
}
if (dataImport.get(contactPrefix + 'Work_Email__c') != null) {
contact.npe01__WorkEmail__c = (String) dataImport.get(contactPrefix + 'Work_Email__c');
}
if (dataImport.get(contactPrefix + 'Alternate_Email__c') != null) {
contact.npe01__AlternateEmail__c = (String) dataImport.get(contactPrefix + 'Alternate_Email__c');
}
}

/*******************************************************************************************************
* @description returns the field name of the Account CustomID field for Account1 or Account2 in the
* Data Import object.
Expand Down
Loading

0 comments on commit ee969cd

Please sign in to comment.