In Salesforce CPQ, you can create invoice for the customer, based on the usage of products.
We are going to see an example of Usage products and creating invoices based on the units/quantity consumed by the customer. This example will show how the Invoice total is calculated based on the number of units/quantities consumed by the customer.
Create a quote from an Opportunity.
Add a quote line for the test usage-based product.
Create an Order from the Quote, by checking ordered checkbox.
Open Order Product and look at Related List. You can see the twelve usage summary records created.
You can load usage records for usage summary records.
Following is the code snippet that I used to insert usage records. Matching Id is Id of Order product.
blng__Usage__c u = new blng__Usage__c();
u.blng__Account__c = ‘0015g00000tdCbBAAU’;
u.blng__Order__c = ‘8015g0000009XBmAAM’;
u.blng__OrderProduct__c = ‘8025g000000NQ4AAAW’;
u.blng__UsageSummary__c = ‘a2K5g000000HqggEAC’;
u.blng__MatchingId__c = ‘8025g000000NQ4AAAW’;
u.blng__Status__c = ‘New’;
u.blng__StartDateTime__c = DateTime.Now();
u.blng__EndDateTime__c = DateTime.Now() + 2;
u.blng__Quantity__c = 10;
insert u;
Following is the usage record created and associated to Usage Summary.
Manually create invoices, by checking the [Bill Now] checkbox in Order. Make sure the Order is activated before creating invoices.
You can see the invoice created for the usage of product, and it is related to Order Record. Following is the example screenshot.
Reference:
https://help.salesforce.com/s/articleView?id=sf.cpq_usage_products_parent.htm&type=5
https://help.salesforce.com/s/articleView?id=sf.blng_usage_fields.htm&type=5