TestService Class

Contains methods for configuring and determining current configuration of Accounting Seed in a testing context. The purpose of this class is to facilitate writing unit tests for integrations to Accounting Seed.

Note: This class and methods can only be used in a test context.

TestService Methods

The following are methods for TestService. All methods are static.


disableAutoPostSourceDocuments()

Disables auto posting for certain source documents in testing context. The Cash Receipt, Billing Cash Receipt, AP Disbursement, and Amortization Entry Accounting Seed objects can be configured to auto post when created.
If Orders and Inventory is installed the Sales Order Inventory Movement, Purchase Order Inventory Movement, Manufacturing Inventory Movement, Inbound Inventory Movement and the Outbound Inventory Movement custom objects auto post when created. Auto posting is enabled by default.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.disableAutoPostSourceDocuments();



enableAutoPostSourceDocuments()

Enables auto posting for certain source documents in a testing context. The Cash Receipt, Billing Cash Receipt, AP Disbursement, and Amortization Entry Accounting Seed objects can be configured to auto post when created.
If Orders and Inventory is installed the Sales Order Inventory Movement, Purchase Order Inventory Movement, Manufacturing Inventory Movement, Inbound Inventory Movement and the Outbound Inventory Movement custom objects auto post when created. Auto posting is enabled by default.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.enableAutoPostSourceDocuments();



enableAvalaraVATReporting()

Enables functionality associated with the Accounting Seed Avalara VAT Reporting integration extension package in a testing context. This method should only be used if the Accounting Seed Avalara VAT Reporting integration extension package is installed.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.enableAvalaraVATReporting();



enableMultiCurrency()

Enables Accounting Seed multicurrency functionality in a testing context. The org must have Salesforce advanced multicurrency enabled and configured to use this method.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.enableMultiCurrency();



getInventoryValuation()

Returns the inventory valuation method used by Accounting Seed to calculate cost of goods sold in a testing context. The supported inventory valuation methods are standard cost and average cost.
Inventory valuation is supported only if the Accounting Seed Orders and Inventory extension package is installed.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.getInventoryValuation();



getLedgerLimit()

Returns the number of allowed transactional ledgers in a testing context.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.getLedgerLimit();



isAvalaraVATReportingEnabled()

Returns whether Accounting Seed Avalara VAT Reporting has been enabled in a testing context.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.isAvalaraVATReportingEnabled();



setLedgerLimit(Integer newLedgerLimit)

Sets the number of transactional ledgers allowed in the application in a testing context.

Parameters

ledgerId
Type: Integer
The number of transactional ledgers allowable in the application.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.setLedgerLimit(10);



getOrgDefaultLedgerId()

Returns the default organization ledger Id in a testing context. The default organization ledger is the ledger used when users create source document records i.e. Billing, Payable, Journal Entry, etc. The default ledger can be set on a user by user basis by setting a user active ledger using the setUserActiveLedgerId(Id ledgerId) method.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.getOrgDefaultLedgerId();



setOrgDefaultLedgerId(Id ledgerId)

Sets the default organization ledger Id in a testing context. The default organization ledger is the ledger used when users create source document records i.e. Billing, Payable, Journal Entry, etc. The default ledger can be set on a user by user basis by setting a user active ledger using the setUserActiveLedgerId(Id ledgerId) method.

Parameters

ledgerId
Type: Id
The Id of the ledger to set as the default organization ledger.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.setOrgDefaultLedgerId();



setupTestData()

Configures setup data in a testing context. This includes Accounting Period, GL Account, Accounting Settings, and Ledger records. This is the base data needed to facilitate implementing unit tests in Accounting Seed.

Return Value
Type: ServiceResult

data property of the ServiceResult instance will contain serialized test data collections mapped by the following keys:

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.setupTestData();

//Deserialize test data
Map<String, List<SObject>> testData = 
    (Map<String, List<SObject>>) JSON.deserializeStrict(sr.data, Map<String, List<SObject>>.class);

//Get Accounting Periods
List<AcctSeed__Accounting_Period__c> accountingPeriods = (List<AcctSeed__Accounting_Period__c>) testData.get('accountingPeriods');
//Get GL Accounts
List<AcctSeed__GL_Account__c> glAccounts = (List<AcctSeed__GL_Account__c>) testData.get('glAccounts');
//Get Billing Formats (PDF Formats)
List<AcctSeed__Billing_Format__c> billingFormats = (List<AcctSeed__Billing_Format__c>) testData.get('billingFormats');
//Get Ledgers
List<AcctSeed__Ledger__c> ledgers = (List<AcctSeed__Ledger__c>) testData.get('ledgers');
//Get Accounting Settings
List<AcctSeed__Accounting_Settings__c> = (List<AcctSeed__Accounting_Settings__c>) testData.get('accountingSettings');



setupTestData(Boolean isBaseInitNeeded, Boolean createStandardObjectData, Boolean includeStandardFieldPerms)

Parameters

isBaseInitNeeded

Type: Boolean - true - the base test data will be created - false - the base test data creation will be skipped if the test data exists already

createStandardObjectData

Type: Boolean

includeStandardFieldPerms

Type: Boolean

Configures setup data in a testing context. This includes Accounting Period, GL Account, Accounting Settings, and Ledger records. This is the base data needed to facilitate implementing unit tests in Accounting Seed.

Return Value
Type: ServiceResult

data property of the ServiceResult instance will contain serialized test data collections mapped by the following keys:

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.setupTestData(true, true, true);

//Deserialize test data
Map<String, List<SObject>> testData = 
    (Map<String, List<SObject>>) JSON.deserializeStrict(sr.data, Map<String, List<SObject>>.class);

//Get Accounting Periods
List<AcctSeed__Accounting_Period__c> accountingPeriods = (List<AcctSeed__Accounting_Period__c>) testData.get('accountingPeriods');
//Get GL Accounts
List<AcctSeed__GL_Account__c> glAccounts = (List<AcctSeed__GL_Account__c>) testData.get('glAccounts');
//Get Billing Formats (PDF Formats)
List<AcctSeed__Billing_Format__c> billingFormats = (List<AcctSeed__Billing_Format__c>) testData.get('billingFormats');
//Get Ledgers
List<AcctSeed__Ledger__c> ledgers = (List<AcctSeed__Ledger__c>) testData.get('ledgers');
//Get Accounting Settings
List<AcctSeed__Accounting_Settings__c> = (List<AcctSeed__Accounting_Settings__c>) testData.get('accountingSettings');
//Get Accounts, Contacts and Opportunities
List<Account> accounts = (List<Account>) testData.get('accounts);
List<Contact> contacts = (List<Contact) testData.get('contacts);
List<Opportunity> opportunities = (List<Opportunity>) testData.get('opportunities');



getUserActiveLedgerId()

Get the active ledger for the current user in a testing context. The active ledger is the default ledger used when users create source document records i.e. Billing, Payable, Journal Entry, etc.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.getUserActiveLedgerId();



setUserActiveLedgerId(Id ledgerId)

Set the active ledger for the current user in a testing context. The active ledger is the default ledger used when users create source document records i.e. Billing, Payable, Journal Entry, etc.

Parameters

ledgerId
Type: Id
The Id of the ledger to set as the default for the active user.

Return Value
Type: ServiceResult

Usage

Id ledgerId = [SELECT Id FROM AcctSeed__Ledger__c WHERE Name = 'Actual' LIMIT 1].Id;
AcctSeed.ServiceResult sr = AcctSeed.TestService.setUserActiveLedgerId(ledgerId);



getUserActiveLedgerId()

Get the active ledger for the current user in a testing context. The active ledger is the default ledger used when users create source document records i.e. Billing, Payable, Journal Entry, etc.

Return Value
Type: ServiceResult

Usage

AcctSeed.ServiceResult sr = AcctSeed.TestService.getUserActiveLedgerId();