Last active
October 25, 2024 14:55
Random Installment data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Integer COUNT = 400; | |
List<String> SEPAMethods = new List<String>{'Direct Debit', 'Manual'}; | |
List<String> StripeMethods = new List<String>{'CreditCard', 'Blik24', 'Sepa Direct Debit', 'Ideal'}; | |
List<String> Statusses = new List<String>{'New', 'Failed', 'Collected'}; | |
List<Contact> contactList = new List<Contact>(); | |
for(Integer i = 0; i < COUNT; i++) { | |
contactList.add(new Contact(LastName = 'lastName' + i)); | |
} | |
insert contactList; | |
List<cpm__Installment__c> installmentList = new List<cpm__Installment__c>(); | |
for(Contact c : contactList) { | |
String processor; | |
if(Math.random() > 0.5) { | |
processor = 'SEPA'; | |
} else { | |
processor = 'Stripe'; | |
} | |
String paymentMethod; | |
if(processor == 'SEPA') { | |
paymentMethod = SEPAMethods[Integer.valueOf(math.Random()*SEPAMethods.size())]; | |
} | |
if(processor == 'Stripe') { | |
paymentMethod = StripeMethods[Integer.valueOf(math.Random()*StripeMethods.size())]; | |
} | |
String status = Statusses[Integer.valueOf(Math.Random()*Statusses.size())]; | |
cpm__Installment__c inst = new cpm__Installment__c( | |
cpm__Contact__c = c.Id, | |
cpm__Amount__c = Integer.valueof((Math.random() * 100)), | |
cpm__Payment_Processor__c = processor, | |
cpm__Payment_Method__c = paymentMethod, | |
cpm__Status__c = status | |
); | |
installmentList.add(inst); | |
} | |
insert installmentList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment