You are here:
InsPolicyBillingService:generateDirectBillingStatements
Use this service to generate statements for accounts containing policies with direct billing whose due date is equal to today's date plus ten (10) days.
We don't recommend that you invoke this service directly. It was created to be invoked by the Generate Direct Billing Statements Vlocity Scheduled Job.
Method: generateDirectBillingStatements
How It Works
-
The service takes in a list of policies from a Vlocity Scheduled Job.
-
Groups policies by account and creates a statement for each account:
-
Sets
RecordTypetoBill. -
Sets
AccountId__cto the Id of the account. -
Sets
DueDate__cto theBillDueDate__cof the first policy in the group. -
Sets
StatementDate__cto theBillDueDate__cminus 10 days. -
Sets
StatementEndDate__cto theBillDueDate__cminus 10 days. -
Sets
StatementStartDate__cto the furthest date back, specified by theBillingFrequency__cvalues in the policies. -
Sets
BalanceDue__cas the sum of theAutomaticPaymentAmount__cvalues on the policies. -
Sets
PreviousBalance__cas the sum of thePastDue__cvalues on the policies
-
-
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.
Additional Information
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).
The StatementStartDate__c is determined by using the policy’s bill
due date and billing frequency to calculate the start date for each policy, then
choosing the start date that's furthest back in time.
For example, an account has two policies, both with bill due dates of
2018-03-31. Policy 1 has a monthly billing frequency. Policy 2 has a quarterly
billing frequency. Using the bill due date and billing frequency, the start date
of Policy 1 is 2018-02-28. The start date of Policy 2 is 2018-01-01. Because the
start date of Policy 2 is further back in time, the
StatementStartDate__c is set to 2018-01-01.
Input JSON
The service expects an input JSON to be generated from a Vlocity Scheduled Job. This scheduled job includes the following key and its value:
-
records: A list of policies selected by the scheduled job
{
"records": [{
"Id": "02i5A000005iF1zQAE",
"AccountId": "0015A000025MuenQAC",
"AutomaticPaymentAmount__c": 10,
"BillDueDate__c": "2018-03-31",
"BillingFrequency__c": "Monthly",
"PastDue__c": 10
},
{
"Id": "02i5A000005iF20QAE",
"AccountId": "0015A000025MuenQAC",
"AutomaticPaymentAmount__c": 30,
"BillDueDate__c": "2018-03-31",
"BillingFrequency__c": "Quarterly",
"PastDue__c": 30
}
]
}
