SalesforceFoundation/Recurring_Donations — pull request #13 by jamesmelville (2012-09-02 20:32:25+00:00)
Title: Multi currency bulk import fix

Hi Kevin,

Think this should resolve the second issue in #12. There were some describes inside a loop.

James

Move field describes out of loops and use
UserInfo.isMultiCurrencyOrganization() for proper detection of
multicurrency environments.

Also bulk test method attached below but not commited
```
static testMethod void multipleRDBulkInsert(){
//created to test github issue 12, second reported issue - bulk inserts

integer NB_Records = 200;

RecurringDonations_TEST.setRecurringDonationsSettingsForTest(
new Recurring_Donations_Settings__c(
Opportunity_Forecast_Months__c = 12,
Maximum_Donations__c = 50,
Open_Opportunity_Behavior__c =
RecurringDonations.RecurringDonationCloseOptions.Mark_Opportunities_Closed_Lost.name()

));

delete [select id from Custom_Field_Mapping__c];
Custom_Field_Mapping__c cfm1 = new Custom_Field_Mapping__c(
Recurring_Donation_Field__c = 'Name',
Opportunity_Field__c = 'Description',
Name = 'CFMName00001-Test'
);
insert cfm1;

Account a = new Account();
a.Name = 'test Individual';
insert a;

Contact c = new Contact();
c.FirstName = 'test';
c.LastName = 'contact';
c.AccountId = a.Id;
insert c;

list rdlist = new list();

for(integer i=0; i< NB_Records;i++)
{
Recurring_Donation__c r1 = new Recurring_Donation__c();
r1.Name = 'test';
r1.Installments__c = 2;
r1.Contact__c = c.Id;
r1.Amount__c = 100;
r1.Installment_Period__c =
System.Label.RecurringDonationInstallmentPeriodMonthly;
r1.Date_Established__c = system.today();//date.newinstance(1970,6,12);
r1.Schedule_Type__c = System.Label.RecurringDonationMultiplyValue;
r1.Open_Ended_Status__c = System.label.RecurringDonationOpenStatus;
r1.Next_Payment_Date__c = system.today();
rdlist.add(r1);
}

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

set rdIds = new set();
for(Recurring_Donation__c r : rdlist)
{
rdIds.add(r.Id);
}

map originalOpps = new map([select id,
Name,amount,accountid,CloseDate from Opportunity where
Recurring_Donation__r.id IN :rdIds]);
system.assertEquals(12*NB_Records, originalOpps.size());
}
```