Fee Billing Engine Overview
In this article, we are going to look deeper into the new features added to Maica in the latest release. These are specifically around our billing engine and our fee invoicing automation that handles the generation of invoice line items for fees that have been configured on a Service Agreement.
Some concepts around the setting up of a Budget within a Service Agreement and the output of Invoice Line Items. Please see our other articles for more details.
Now, we will look deeper into three Maica templated flows. These leverage Salesforce flow technology to build out automation pieces and these have been created as templated flows. That allows you to customise, extend and create your own versions of these pieces of automation to suit your requirements.
In Maica, we have three separate flows that complement each other in order to achieve the outcome of daily automated billing cycles for your active Home Care Packages.
Now, each of these flows will be discussed in more detail.
Fee Invoicing Initialisation
This is a scheduled Salesforce which runs of a daily schedule. Its role is quite simple - it is going to pass Service Agreements, either active or on leave, with the funding type of Home Care Package because we only want to pick up Service Agreements with the Home Care Package type.
These Service Agreements will be marked as initialised in order to commence the next piece of our automation. The field maica_Invoicing_Flow_Status__c
will be defined as Initialised.
Fee Invoicing Trigger
Fee Invoicing Trigger is the second part of our automation piece. This is looking for some specific changes to a Service Agreement, specifically that the invoicing flow status has changed and has been updated to an initialised status. It also ensures that the funding type is a Home Care Package.
The primary purpose of this flow is to act as a trigger for our Auto Launch flow, which is where all of our billing logic is contained for our billing engine, and that is in our Fee Invoice Generation flow.
Error Handling Capabilities
This flow does have some error handling capabilities programmed into it. So, when the Fee Invoicing flow where all the logic lives completes, this flow is going to check if there were any errors. If there were errors, it will create a log record that contains the details of that error and also the runtime and the ID of the Service Agreement that initially launched the flow.
If the flow fails, use this log to investigate and determine why.
The final action of the flow is to either set the flow status to failed or complete. If it fails, you can run a report or set up a list view if you are looking for Service Agreements where billing has failed.
Our fee invoicing automation runs on a daily basis, so it can catch any changes to a Service Agreement.
Fee Invoicing Generation
This is the final (and most complex) piece of the automation in our billing engine, and it must be called from either another flow or from Apex. This contains all of our billing logic within it, as well as our error handling.
The flow is going to retrieve the details of a Service Agreement that has been passed in. It will get any related plan, where we can pull up all of the relevant budget information. For more information about Plans and Budgets, please see the following article. From these, we can determine what fees should be billed within our billing engine.
The first decision in the flow is to determine whether the Service Agreement has been placed on leave. There are some specific billing requirements for Home Care Packages from the government when they are on leave - certain fees cannot be charged. This is all programmed into the flow.
If the Service Agreement is not on leave, then the process is quite simple. We simply retrieve all of the billable plan budgets, then the claimable plan budgets.
Billable Plan Budgets are fees that can be charged directly to the client as a co-payment and Claimable Plan Budgets are ones that we will put into the claim file and claim from the government.
If the Service Agreement is on leave, then we need to make some decisions around consecutive leave. If there has been greater than 28 days of consecutive leave, then the flow will automatically recalculate the appropriate rate for any income tested fee and assign that accordingly.
Then, it determines what type of leave we have been placed on because the type of leave dictates whether or not we can charge a basic daily fee.
Ultimately, this all determines what plan budget lines from the Service Agreements budget we can include in our billing run for the day for this Service Agreement. So finally, we are just validating that we actually do have some planned budgets we can bill. If so, our flow is first going to try and locate an open co-payment invoice. Billable planned budgets get played in a co-payment invoice that goes directly to the customer. If no invoice exists, it will create an invoice and give us the details of this invoice.
Once it has iterated through all of the planned budgets, it will build up a collection of invoice line items that we need to create at the end of the flow. It is also going to do the same thing for our Claimable Plan Budgets, which are the ones that we are going to put into a Claim Invoice.
The ultimate output of this is Invoice Line Items - the flow will generate Invoices and Invoice Line Items. We will do things like set the support category and the product, the unit price per line item and the quantity - which is usually going to be a quantity that we bill on a daily basis. So, we generate a single line item for the fees that were charged for that package for that day.
The government requires you to be able to let a participant know on any particular day or date exactly what fees you charge them and what the rate was for those fees.
The architecture that you have just learnt about works out of the box. You simply have to ensure that you configure your products accordingly so that they are picked up as either claimable plan budgets or billable plan budgets.
Last updated