You are here:
InsPolicyBillingService:generateBillingAccountStatements
Use this service to generate statements for accounts that contain policies with billing accounts that have Due Date = today.
We don't recommend that you invoke this service directly. It was created to be invoked by the Generate Billing Account Statements Vlocity Scheduled Job.
Method: generateBillingAccountStatements
How It Works
-
The service takes in a list of billing accounts from a Vlocity Scheduled Job.
-
Groups billing accounts by accounts.
-
Retrieves policies associated with the Billing Accounts.
-
Creates a statement for each account:
-
Sets
RecordType__ctoStatement. -
Sets
AccountId__cto the Id of the account. -
Sets
DueDate__cto the value ofBillDueDate__cof the first billing account in the group. -
Sets
StatementDate__cto the value ofBillDueDate__c. -
Sets
StatementEndDate__cto the value ofBillDueDate__c. -
Sets
StatementStartDate__cto the furthest date back specified by theBillingFrequency__cvalues in the billing accounts. -
Sets
BalanceDue__cto the sum of theAutomaticPaymentAmounts__cvalues on the policies associated with the billing accounts. -
Sets
PreviousBalance__cto the sum of the PastDue__c values on the policies associated with the billing accounts.
-
-
For all policies associated with a specific statement, retrieves all transactions associated with the specified policies that have a
TransactionDate__cwithin the statement period start and end date.If the transaction does not have a value for the
StatementId__c, set theStatementId__cto the Id of the specified Statement. -
For each billing account:
-
Sets
AutomaticPaymentAmount__cto the sum of theNextPaymentAmountDue__cvalues on the policies associated with the billing account. -
Sets the new
BillDueDate__cbased on the currentBillDueDate__candBillingFrequency__c.
-
-
For each policy associated with a specific billing account:
-
Sets the
AutomaticPaymentAmountDue__cto theNextPaymentAmountDue__c. -
Sets
BillDueDate__cto the billing account’s updatedBillDueDate__c.
-
Calculating StatementStartDate__c
An account can have multiple policies with direct billing. Each policy may
have a different billing frequency (annual, quarterly, monthly, or semi-monthly).
StatementStartDate__c is determined using the policy’s bill due
date and billing frequency to calculate the start date for each policy. then
choosing the start date that' furthest back in time.
For example, if an Account has two policies, both with a bill due date of ‘2018-03-31’. Policy 1 has a billing frequency of ‘Monthly’ and Policy 2 has a billing frequency of ‘Quarterly’. Using the bill due date and billing frequency, the start date of Policy 1 would be ‘2018-02-28’ and the start date of Policy 2 would be ‘2018-01-01’. Since the start date of Policy 2 is further back in time, the StatementStartDate__c is set to ‘2018-01-01’.
Calculating the new BillDueDate__c
A new BillDueDate__c is calculated based on the current BillDueDate__c and the BillingFrequency__c. Here are the billing frequencies and calculations for the new BillDueDate__c:
-
Annually
Current
BillDueDate__cplus 1 year -
Quarterly
BillDueDate__ccan only be 1 of 4 dates: March 31st, June 30th, September 30th, or December 31st. SetBillDueDate__cto the next date in the sequence. For example, if it is currently set to currently March 31st, set it to June 30th. -
Monthly
Current
BillDueDate__cplus 1 month -
Semi-Monthly
-
If current
BillDueDate__cis the end of the month, set it to the middle of the next month (14th if February, 15th if any other month) -
If current
BillDueDate__cis the middle of the month, set it to the end of the month
-
Input JSON
This service expects an input JSON generated by a Vlocity Scheduled Job. This scheduled job will include the following key and their values:
-
records: A list of billing accounts selected by the scheduled job
{
"records": [{
"Id": "a3h5A000000Xz7l",
"AccountId": "0015A000025MuenQAC",
"BillDueDate__c": "2018-03-31",
"BillingFrequency__c": "Monthly"
},
{
"Id": "a3h5A000000Xz7m",
"AccountId": "0015A000025MuenQAC"
"BillDueDate__c": "2018-03-31",
"BillingFrequency__c": "Quarterly"
}
]
}
