Skip to content

Instantly share code, notes, and snippets.

@laurens-findock
Last active October 25, 2024 14:55
Show Gist options
  • Save laurens-findock/fb7a88dac32f13cb8aab35716ef94721 to your computer and use it in GitHub Desktop.
Save laurens-findock/fb7a88dac32f13cb8aab35716ef94721 to your computer and use it in GitHub Desktop.
Random Installment data
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