Prerequisites
Prior to reading this article, we recommend that you become familiar with the Salesforce Flow by completing the Flow Builder module in Salesforce Trailhead.
Note: If you have already completed this module, continue with reading this article.
Overview
Amortizing revenue and expenses has never been easier with the new declarative features built into the Accounting Seed Financial Suite. You can now declaratively leverage the same Amortization options that are accessible via our standard Amortization component using the Salesforce Flow. A custom flow action is now available to add to any user defined flows to perform Amortization for selected source document records (currently available for Billings and Payables).
Do you want to:
Amortization Flow Considerations
Amortization Methods
Amortization methods available via the standard Accounting Seed component or declaratively via Flow are stored as records of the Custom Metadata Type, AcctSeed__Bindings__mdt. The standard methods available are Daily Amortization and Monthly Amortization. These methods can be overridden and/or new Apex amortization methods can be created to meet your specific needs. To view these options navigate to Setup | Custom Metadata Types | Bindings | Manage Bindings.
Note: Click here to view the above image in full screen.
Default Debit and Credit GL Accounts
In order to insert Amortization records, General Ledger Debit and Credit Accounts need to be defined, which will be applied to the records created. Default Accounts are configured in Accounting Settings (AcctSeed__Default_Credit_GL_Account_Expense__c, AcctSeed__Default_Credit_GL_Account_Revenue__c, AcctSeed__Default_Debit_GL_Account_Expense__c, AcctSeed__Default_Debit_GL_Account_Revenue__c).
These defaults are used in the following example.
Amortization Flow Example | |
The Accounting Seed custom flow action (Apex action) can be utilized on Auto-Launched, Schedule-Triggered, and Record-Triggered flows. The entry point into the Flow can be customized to meet your business needs. In the Auto-Launched Flow example shown, a Get Records Flow component is being used to query Billing records to perform Amortization on. The following steps of this Flow example will be described in detail.
|
Return to top
Create an Amortization Flow
- To create a new Flow, click the Gear icon and select Setup.
- Enter Flow in the search textbox, and click Flows.
- Click New Flow.
Note: Click here to view the above image in full screen. - Select your Flow of choice and click Create.
Your new Flow is now created, and you can begin to add actions.
Note: The example is utilizing an Auto-Launched Flow. The same Flow logic can be created on a Record-Triggered or Schedule-Triggered Flow. - To add an Element, click the + (plus sign).
-
Get Records to Amortize.
-
Select the + icon to add an element, and then select Get Records.
- From the Get Records screen, in the Label field, define the logic (Get Records to Amortize) to query the records that you want to Amortize. In the sample screen below, specific Billing records are being selected to Amortize. Notice that the sample screen has no filter criteria. Therefore, it will Amortize all Billings.
Note: After entering the Label, press Enter to automatically populate the API Name. - From the Condition Requirements drop-down list, select None-Get All Billing Records.
-
From How Many Records to Store, click the All records radio button.
Important: Be sure to define filter criteria in order for the Flow to work on specific records.
-
Click Done.
-
Select the + icon to add an element, and then select Get Records.
-
Get Amortization Methods defined in Custom Metadata.
-
Select the + icon to add an element, and then select Get Records.
- From the Get Records screen, enter value in the Label field. In the sample screen below, “Get Amortization Methods” was entered.
- Select the Binding custom metadata object and filter to records with AcctSeed__Type__c = AbstractAmortization.
-
Click Add Condition to add the MasterLabel = Straight Line - Full Month. You can select any Amortization that exists in AcctSeed__Bindings__mdt records.
For the sample screen below, Straight Line - Full Month Amortization was selected.
Important: If you need assistance with locating the values for the AcctSeed__Type__c and MasterLabel, click the Gear icon and select Setup. Enter Custom Metadata in the search textbox. Then select Custom Metadata Types.
Return to top
Select Manage Records (Binding)
Note: Click here to view the above image in full screen.
From the Label column, click the appropriate Amortization Method. Using this example, Straight Line – Full Month was selected. Copy the Type for the AcctSeed__Type__c value.
Note: Click here to view the above image in full screen.
- From the Flow | Edit Get Records screen, click Done.
- Save your flow.
-
Select the + icon to add an element, and then select Get Records.
-
Get GL Account Defaults defined on the Default GL Accounts page.
- Click the Gear icon and select Developer Console.
- Select the Query Editor tab.
- Copy/paste the below script into the query textbox. Then, click Execute.
SELECT Id, AcctSeed__Default_Credit_GL_Account_Expense__c, AcctSeed__Default_Credit_GL_Account_Revenue__c, AcctSeed__Default_Debit_GL_Account_Expense__c, AcctSeed__Default_Debit_GL_Account_Revenue__c FROM AcctSeed__Accounting_Settings__c
- A row with listed columns will display. If the columns are empty, enter the IDs of the GL Accounts that you want to use. Then, click Save Rows.
- Return to the flow that you saved.
- Select the + icon to add an element, and then select Get Records.
- From the Get Records screen, in the Label field, enter Get GL Account Defaults.
- From the Object drop-down list, select Accounting Settings.
- From the Condition Requirements drop-down list, select None-Get All Accounting Settings Records.
Note: This step is selecting the default GL Expense and Revenue Accounts from Accounting Settings. If you choose not to use the defaults, you can select any applicable GL Account using a Get Records element and skip this step. -
Click Done.
- Loop over records to Amortize.
-
Select the + icon to add an element, and then select Loop.
- From the New Loop screen, enter a value in the Label field. In the sample screen below, Amortization Loop was entered.
-
On the New Loop screen for the Collection Variable, set it to the results of step 3, Get_Records_To_Amortize and leave the default direction.
-
Click Done.
-
Select the + icon to add an element, and then select Loop.
-
Utilize Accounting Seed custom Flow Action component to calculate Amortization schedule.
-
Select the + icon to add an element, and then select Action.
- Select Uncategorized from the Filter By drop-down list.
- From the Action search textbox on the right, search for and select Amortize Records.
- Enter a Label (i.e. Create Amortization Records).
Note: Press Enter to automatically generate the API Name.
- Enter the corresponding input variable values (refer to the screen capture below). Required fields display with a red asterisk (*) and include the following based upon the selected Amortization Method:
- Amortization Method = {!Get_Amortization_Methods.Label}
- Accrual and/or Cash = Accrual, Cash, or Accrual and Cash
- Amount = {!Loop_over_records_to_Amortize.AcctSeed__Value__c}
- End Date, Record To Amortize Id = {!Loop_over_records_to_Amortize.Id}
- Start Date = {!Loop_over_records_to_Amortize.CreatedDate}
- Credit GL Account Id = {!Get_GL_Account_Defaults.AcctSeed__Default_Credit_GL_Account_Expense__c}
- Debit GL Account Id = {!Get_GL_Account_Defaults.AcctSeed__Default_Debit_GL_Account_Revenue__c}
-
Number of Periods (Straight Line – Prorated Monthly and Straight Line – Full Month requires that the Number of Periods be entered)
- Click Done.
-
Select the + icon to add an element, and then select Action.
Return to top
Notes:
The Amortize Records action does not insert the records. It creates them for insertion in a subsequent Flow action, which allows for any type of pre-insertion processing that you might choose.
The Credit and Debit GL Account Inputs are not required to create the Amortization Entry records but they are required for insertion into the database in a subsequent step.
The AcctSeed__Amortization.cls Apex class contains an @InvocableMethod, which enables our Amortization code to be called declaratively via a Salesforce Flow action. This method has defined input variables, which is what is seen on the Amortize Records action screen.
-
Add Amortization (Scheduled Revenue/Expense) records to collection.
-
Create a Flow variable to store all Amortization Entries for insertion.
- From the Flow Toolbox, click New Resource.
- Enter Variable for Resource Type.
- Enter an API Name (i.e. AmortizationRecordsToInsert).
- From the Data Type drop-down list, select Record and select the Allow Multiple checkbox.
-
In the Object field, enter Amortization Entry.
-
Click Done.
-
Create a Flow variable to store all Amortization Entries for insertion.
-
Assign the output from the Accounting Seed custom flow action to the newly created variable.
- Select the + icon to add an element, and then search for and select Assignment.
- Enter a Label (i.e. Collect Amortization Records). In the example below Label = Collect Amortization Records.
Note: The API Name is automatically generated. - Variable = Set the Variable to the previously created Flow variable: AmortizationRecordsToInsert.
- From the Operator drop-down list, select Add.
-
Value = Select the Outputs from the Accounting Seed custom flow action that were previously created: Create_Amortization_Records.amortizationEntries.
-
Click Done.
- Select the + icon to add an element, and then search for and select Assignment.
- Insert Amortization records.
-
Select the + icon to add an element, then select Create Records.
-
Enter a Label (i.e. Insert Amortization Records).
Note: The API Name is automatically generated.
- Click the Multiple radio button.
- Set the Record Collection to the variable created in the previous step: AmortizationRecordsToInsert.
-
Click Done.
The Flow is now ready for Debugging, Running, and Activation.
Important: When running Flows, be extremely careful because they will impact data in the org (organization) that you are using. If you are not familiar with these processes, please complete the Flow Builder module in Salesforce Trailhead, which was mentioned at the beginning of this article as a prerequisite.
-
Select the + icon to add an element, then select Create Records.
- Click Save As to save your version of the flow.
- Activate the flow. Then, run the flow.
Important: Before you run the flow, make sure that records have been created. In the sample screen below, six Amortized Revenue records have been created.
Note: Click here to view the above image in full screen.
Comments
0 comments
Please sign in to leave a comment.