Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy currency code to new account #4141

Merged
merged 17 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c6f25db
copy currency code to new account
Mar 22, 2019
74778f5
Merge 204df5d3b36b16a3b3ec9695bc373c3038c152e1 into feature/pyan/popu…
mrbelvedere Mar 22, 2019
2cdfb6e
Merge 5edc592f5c7ee16d3cf50135df043eaaa7efda57 into feature/pyan/popu…
mrbelvedere Mar 25, 2019
249fcfc
fix case
Mar 25, 2019
3da7238
Merge branch 'feature/pyan/populate-currency-field-on-create' of gith…
Mar 25, 2019
621bdff
Merge 0f49ae81d0dd41333add6aa0b53e4ea206ac230c into feature/pyan/popu…
mrbelvedere Mar 25, 2019
f786aa3
fix changes from review
Mar 25, 2019
c1e641b
Merge branch 'feature/pyan/populate-currency-field-on-create' of gith…
Mar 25, 2019
1d84516
Merge bdaf6eaa9f21591303211ab0d883bd39f0c1f3dc into feature/pyan/popu…
mrbelvedere Mar 26, 2019
035ae7b
Merge 8c940e6c9021b95511a74788c87f3621cb8e81b4 into feature/pyan/popu…
mrbelvedere Mar 27, 2019
a463ea7
Merge 1e916d1a5521e91c4fa3c682aad296f0f39121ac into feature/pyan/popu…
mrbelvedere Mar 28, 2019
fdd7d0b
Merge 0a6450c677c53f580c70ba07e63824feebd5cebd into feature/pyan/popu…
mrbelvedere Mar 28, 2019
0b29547
Merge 71c98d1fb3f5f26060670955fb2d8f793c9028f5 into feature/pyan/popu…
mrbelvedere Mar 28, 2019
f611edf
Merge b421aed5dd243f6914ce150edbdaf4907e707eed into feature/pyan/popu…
mrbelvedere Apr 2, 2019
55b3be9
Merge 30eeb7dea3a1540825684b07d6432c683097991b into feature/pyan/popu…
mrbelvedere Apr 2, 2019
09dc8d8
Merge branch 'master' into feature/pyan/populate-currency-field-on-cr…
rponti-sforg Apr 2, 2019
5f5239d
merge master
Apr 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/classes/ACCT_IndividualAccounts_TDTM.cls
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ public class ACCT_IndividualAccounts_TDTM extends TDTM_Runnable {
a.Phone = c.Phone;
a.Fax = c.Fax;
a.OwnerId = c.OwnerId;

if (UserInfo.isMultiCurrencyOrganization()) {
a.put('CurrencyIsoCode', String.valueOf(c.get('CurrencyIsoCode')));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's cast into String, ie a.put('CurrencyIsoCode', (String) c.get('CurrencyIsoCode'));

}

// only set account's billing address if address management is off.
// otherwise, we'll let ADDR_Contact_TDTM push the new address into the account.
if (!CAO_Constants.isHHAccountModel() || UTIL_CustomSettingsFacade.getContactsSettings().Household_Account_Addresses_Disabled__c) {
Expand All @@ -568,9 +573,9 @@ public class ACCT_IndividualAccounts_TDTM extends TDTM_Runnable {
ADDR_Addresses_TDTM.copyAddressStdSObj(c, 'Other', a, 'Shipping');

a.npe01__SYSTEM_AccountType__c = CAO_Constants.isHHAccountModel() ? CAO_Constants.HH_ACCOUNT_TYPE : CAO_Constants.ONE_TO_ONE_ORGANIZATION_TYPE;
if (rtIdAcccount != null) {
if (rtIdAcccount != null) {
a.put('RecordTypeID', rtIdAcccount);
}
}
a.Type = CAO_Constants.isHHAccountModel() ? CAO_Constants.HH_TYPE : '';
a.npe01__SYSTEMISINDIVIDUAL__c = true;
accountInserts.add(a);
Expand Down
45 changes: 45 additions & 0 deletions src/classes/ACCT_IndividualAccounts_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,51 @@ private class ACCT_IndividualAccounts_TEST {
system.assertEquals(null,insertedContacts[0].AccountId);
}

/*********************************************************************************************************
* @description Accounts created from the trigger should populate the currency code with the contact
*/
@IsTest
private static void accountCreatedWithCorrectCurrencyCodes() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldPopulateNewAccountCurrencyWithContactCurrency()?

//Skip the test if Advancement is installed
if (ADV_PackageInfo_SVC.useAdv()) return;

Boolean isMultiCurrencyEnabled = UserInfo.isMultiCurrencyOrganization();
String defaultCurrency = UserInfo.getDefaultCurrency();

Contact newContact = new Contact(
lastname = 'CurrencyTest',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use CamelCase for fields API names, ie LastName and FirstName.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RadSFDeveloper Thanks. I've updated the names

firstname = 'Test'
);

String currencyField = '';
if (isMultiCurrencyEnabled) {

// Set currency to be something different than the default one if possible
List<SObject> currencies = Database.query('SELECT IsoCode FROM CurrencyType WHERE IsActive = True');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using UTIL_UnitTestData_TEST.nonDefaultCurrencyType for this test? See similar tests in PMT_Payment_TEST.

for (SObject curr : currencies) {
if (String.valueOf(curr.get('IsoCode')) != defaultCurrency) {
defaultCurrency = String.valueOf(curr.get('IsoCode'));
break;
}
}

newContact.put('CurrencyIsoCode', defaultCurrency);
currencyField = ', CurrencyIsoCode ';
}

Test.startTest();
insert newContact;
Test.stopTest();

String qryString = 'SELECT Id, Name' + currencyField + ' FROM Account LIMIT 1';
Account newAccount = Database.query(qryString);
System.assertNotEquals(null, newAccount, 'New Account was not created');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's specify expected state in the assert statements. For example: New Account should be created or Account Currency should be populated.

if (isMultiCurrencyEnabled) {
System.assertEquals(defaultCurrency, String.valueOf(newAccount.get('CurrencyIsoCode')), 'Correct Currency Code was not populated');
}

}

/*********************************************************************************************************
* @description Test changing the account model from one-to-one account to household account.
*/
Expand Down