-
Notifications
You must be signed in to change notification settings - Fork 4
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
Changes from 6 commits
c6f25db
74778f5
2cdfb6e
249fcfc
3da7238
621bdff
f786aa3
c1e641b
1d84516
035ae7b
a463ea7
fdd7d0b
0b29547
f611edf
55b3be9
09dc8d8
5f5239d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
//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', | ||
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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about using |
||
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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's specify expected state in the assert statements. For example: |
||
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. | ||
*/ | ||
|
There was a problem hiding this comment.
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'));