Overview
Below is a sample test class for Accounting Seed's Time Card feature. This class can be used to test whether your code is working as expected.
@IsTest
private class TimeCardExampleTest {
@IsTest
static void createTimeCard() {
// —— DATA PREPARATION ——
// insert 1 Accounting Period
AcctSeed__Accounting_Period__c acctPeriod = new AcctSeed__Accounting_Period__c(
Name = '1991-10',
AcctSeed__Start_Date__c = Date.newinstance(1991, 9, 30),
AcctSeed__End_Date__c = Date.newinstance(1991, 10, 31),
AcctSeed__Status__c = 'Open');
insert acctPeriod;
// insert 1 Time Card Period
AcctSeed__Time_Card_Period__c tcp = new AcctSeed__Time_Card_Period__c(
Name = '1991-10',
AcctSeed__Start_Date__c = date.newinstance(1991, 10, 1),
AcctSeed__End_Date__c = date.newinstance(1991, 10, 7),
AcctSeed__Status__c = 'Open'
);
insert tcp;
// 1 Cash GL-Account
AcctSeed__GL_Account__c cashGL = new AcctSeed__GL_Account__c(
Name = '1000-Cash',
AcctSeed__Active__c = true,
AcctSeed__Type__c = 'Balance Sheet',
AcctSeed__Bank__c = true,
AcctSeed__Sub_Type_1__c = 'Assets',
AcctSeed__Sub_Type_2__c = 'Cash');
insert CashGL;
// insert 4 billing formats
AcctSeed__Billing_Format__c[] billingFormats = new List<AcctSeed__Billing_Format__c>();
billingFormats.add(
new AcctSeed__Billing_Format__c(
Name = 'Default Billing Product',
AcctSeed__Visualforce_PDF_Page__c = 'BillingProductPDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__Type__c = 'Billing',
AcctSeed__Sort_Field__c = 'Name'
)
);
billingFormats.add(
new AcctSeed__Billing_Format__c(
Name = 'Default Billing Service',
AcctSeed__Visualforce_PDF_Page__c = 'BillingServicePDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__Type__c = 'Billing',
AcctSeed__Sort_Field__c = 'Name'
)
);
billingFormats.add(
new AcctSeed__Billing_Format__c (
Name = 'Billing Outstanding Statement',
AcctSeed__Visualforce_PDF_Page__c = 'BillingOutstandingStatementPDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__ReplyTo_Email__c = 'test3463464364646@gmail.com',
AcctSeed__Type__c = 'Outstanding Statement'
)
);
billingFormats.add(
new AcctSeed__Billing_Format__c (
Name = 'Billing Activity Statement',
AcctSeed__Visualforce_PDF_Page__c = 'BillingActivityStatementPDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__ReplyTo_Email__c = 'test3463464364646@gmail.com',
AcctSeed__Type__c = 'Activity Statement'
)
);
billingFormats.add(
new AcctSeed__Billing_Format__c(
Name = 'Default Purchase Order',
AcctSeed__Visualforce_PDF_Page__c = 'BillingServicePDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__Type__c = 'Purchase Order',
AcctSeed__Sort_Field__c = 'Name'
)
);
billingFormats.add(
new AcctSeed__Billing_Format__c(
Name = 'Default Packing Slip',
AcctSeed__Visualforce_PDF_Page__c = 'BillingServicePDF',
AcctSeed__Default_Email_Template__c = [Select Id, DeveloperName From EmailTemplate limit 1].DeveloperName,
AcctSeed__Type__c = 'Packing Slip',
AcctSeed__Sort_Field__c = 'Name'
)
);
insert billingFormats;
// insert 1 Ledger records
AcctSeed__Ledger__c ledger = new AcctSeed__Ledger__c(
Name = 'Actual',
AcctSeed__Type__c = 'Transactional',
AcctSeed__Default_Bank_Account__c = CashGL.id,
AcctSeed__Default_Billing_Format__c = billingFormats[0].Id,
AcctSeed__Billing_Outstanding_Statement_Format__c = billingFormats[2].Id,
AcctSeed__Billing_Activity_Statement_Format__c = billingFormats[3].Id,
AcctSeed__Default_Purchase_Order_Format__c = billingFormats[4].Id,
AcctSeed__Default_Packing_Slip_Format__c = billingFormats[5].Id);
insert ledger;
// --- START HERE ---
// Create Time Card Record
AcctSeed__Time_Card__c tc = new AcctSeed__Time_Card__c(
AcctSeed__Time_Card_Period__c = tcp.Id,
AcctSeed__Employee__c = UserInfo.getUserId(),
AcctSeed__Status__c = 'In Process',
AcctSeed__Ledger__c = ledger.Id
);
insert tc;
}
}
Comments
0 comments
Article is closed for comments.