Create Invoices
createInvoices API is used to create Invoices automatically. It accepts a list of Account IDs and creates Invoices for each AccountID.
|
API |
Signature |
|---|---|
|
createInvoices |
|
This API is used to create invoices for givens Account IDs. It accepts a Set of Account IDs, invoiceDate, and targetDateTime as input parameters. It creates invoices for all orders with billing schedules having status as pending billing and end date less than targetDateTime. All the new invoices are created with Invoice Date as the value mentioned in invoiceDate.
|
Request | |||
|---|---|---|---|
|
Field |
Type |
Required? |
Description |
|
billToAccountIds |
Set <Id> |
Yes |
Set of bill to Account IDs |
|
targetDateTime |
Datetime |
Yes |
Process through Date |
|
invoiceDate |
Date |
Yes |
Invoice Creation Date |
Set<ID> billToAccountIDs = new Set<ID>();
billToAccountIDs.add('001Dc00000umdOD');
Date invoiceDate = Date.newInstance(2026, 8, 1);
Date myDate = Date.newInstance(2026, 8, 1);
Time myTime = Time.newInstance(3, 3, 3, 0);
DateTime targetDateTime = DateTime.newInstance(myDate, myTime);
Apttus_Billing.InvoiceService.createInvoices(billToAccountIDs, targetDateTime, invoiceDate);
|
API |
Signature |
|---|---|
|
createInvoices |
|
This API is used to create invoices for given Account IDs. It accepts a set of Account IDs and a class containing invoice creation options. It leverages the InvoiceCreationOptions class to provide advanced control over how invoices are generated, approved, split, and suppressed.
|
Request | |||
|---|---|---|---|
|
Field |
Type |
Required? |
Description |
|
billToAccountIds |
Set <Id> |
Yes |
Set of bill to Account IDs |
|
options |
Apttus_Billing.InvoiceCreationOptions |
Yes |
Class holding the Invoice Creation Options |
|
DataObject - Billing.InvoiceCreationOptions | ||
|---|---|---|
|
Field |
Type |
Description |
|
abort |
Boolean |
If the process is aborted. |
|
autoApprove |
Boolean |
Mandatory Constructor. IfautoApprovefor Invoice is set to true. |
|
autoApproveAmount |
Decimal |
Mandatory Constructor. The amount provided for auto approval. |
|
autoApproveCreditMemo |
Boolean |
Mandatory Constructor. If the autoApproveCreditMemo is set to true |
|
autoApproveOperator |
String |
Mandatory Constructor. The selected autoApproveOperator such as Greater than, Less than etc. |
|
invoiceDate |
Date |
Mandatory Constructor. The Invoice Date. |
|
invoiceDateType |
String |
The Invoice Date Type such as month or year. |
|
invoiceRun |
Apttus_Billing __InvoiceRun__c |
The Invoice Run Object API Name. |
|
invoiceRunResult |
Apttus_Billing __InvoiceRunResult__c |
The Invoice Run Result Object API Name. |
|
numberAccountsProcessed |
Integer |
The number of accounts processed as part of the Invoice Runs. |
|
numberCreditMemos Genenerated |
Integer |
The number of Credit Memos generated. |
|
numberInvoicesGenenerated |
Integer |
The number of Invoices generated. |
|
numberOfAccountsThat GeneratedCreditMemos |
Integer |
Number of accounts for which Credit Memos are generated. |
|
numberOfAccountsThat GeneratedInvoices |
Integer |
Number of accounts for which Invoices are generated. |
|
numberOfAutoApprovedInvoices |
Integer |
Number of Invoices that are auto-approved. |
|
numberOfCreditMemos AutoApproved |
Integer |
Number of Credit Memos that are auto-approved. |
|
numberOfSuppressedInvoices |
Integer |
Number of Invoices that are suppressed. |
|
processThruDate |
Date |
Mandatory Constructor.The Process through date for invoice |
|
splitInvoicesByOrder |
Boolean |
Mandatory Constructor. If Split Invoices By Order is set to true. |
|
suppressInvoicesAmount |
Decimal |
Mandatory Constructor.The amount till which you want to suppress invoices. |
|
suppressInvoicesOperator |
String | Mandatory Constructor. .The selected Suppress Invoices operator such as Greater than, Less than etc. |
|
taxCallbackStatus |
String |
The status of Tax Callback. |
|
credtiMemoCreationOption |
String |
The credit memo creation option. For information on credit memo creation options, refer to Generating Credit Memos from Invoice Run. |
|
autoSendEmailforInvoice |
Boolean |
Set it to true to auto-send an email once the invoice is generated. |
|
autoSendEmailforCreditMemo |
Boolean |
Set it to true to auto-send an email once the credit memo is generated |
|
InvoiceOverrideTemplate |
String |
Name of the invoice template to override the default invoice template |
|
CreditMemoOverrideTemplate |
String |
Name of the credit memo template name to override the default credit memo template |
filterCriteria | String | Criteria to filter the billing schedule when creating invoice, it will be stored in InvoiceRun object for future reference |
- autoSendEmailforInvoice: false
- autoSendEmailforCreditMemo: false
- InvoiceOverrideTemplate: NULL
- CreditMemoOverrideTemplate: NULL
Set<ID> billToAccountIDs = new Set<ID>();
billToAccountIDs.add('001Dc00000umdOD');
Date invoiceDate = Date.newInstance(2026, 8, 1);
Date myDate = Date.newInstance(2026, 8, 1);
Time myTime = Time.newInstance(3, 3, 3, 0);
DateTime targetDateTime = DateTime.newInstance(myDate, myTime);
Apttus_Billing.InvoiceService.createInvoices(billToAccountIDs, targetDateTime, invoiceDate);
Code Sample
Set<ID> billToAccountIDs = new Set<ID>();
billToAccountIDs.add('001Dc00000zpVWG');
Date invoiceDate = Date.newInstance(2026, 8, 1);
Date processThruDate = Date.newInstance(2026, 8, 1);
Boolean autoApprove = true;
Boolean splitInvoicesByOrder = true;
String autoApproveOperator = 'Greater than';
Decimal autoApproveAmount = 5.00 ;
String suppressInvoicesOperator = 'Less than';
Decimal suppressInvoicesAmount = 2.00;
Boolean autoApproveCreditMemo = true;
Apttus_Billing.InvoiceCreationOptions options = new Apttus_Billing.InvoiceCreationOptions(
invoiceDate,
processThruDate,
autoApprove,
splitInvoicesByOrder,
autoApproveOperator,
autoApproveAmount,
suppressInvoicesOperator,
suppressInvoicesAmount,
autoApproveCreditMemo);
Apttus_Billing.InvoiceService.createInvoices(billToAccountIDs, options);
Code sample for Filter Criteria
Use this code sample to pass a filter criteria, via the InvoiceCreationOptions parameter. After including this filter criteria you can supply it directly to InvoiceCreationOptions, enabling on-demand invoice generation for selected Account, Account Location, Product, and Billing Schedules.
String filterCriteriaJson = '{' +
'"sObjectName": "Account",' +
'"sObjectLabel": "Account",' +
'"searchText": null,' +
'"queryExprStr": "",' +
'"filter": {' +
'"productFilter": {' +
'"relationFieldName": null,' +
'"predicates": [{' +
'"RowNum": 1,' +
'"FieldValue": "Sample Recurring product",' +
'"FieldType": "STRING",' +
'"FieldName": "Product2.Name",' +
'"FieldLabel": "Product Name",' +
'"CompOper": "equal to",' +
'"BoolOper": "AND"' +
'}],' +
'"condExpr": "1",' +
'"childSObjectName": "Product2",' +
'"childSObjectLabel": "Product"' +
'},' +
'"predicates": [{' +
'"RowNum": 1,' +
'"FieldValue": "Test_Account_01",' +
'"FieldType": "STRING",' +
'"FieldName": "Account.Name",' +
'"FieldLabel": "Account Name",' +
'"CompOper": "equal to",' +
'"BoolOper": "AND"' +
'}],' +
'"condExpr": "1",' +
'"childFilter": {' +
'"relationFieldName": null,' +
'"predicates": [{' +
'"RowNum": 1,' +
'"FieldValue": "Mumbai",' +
'"FieldType": "STRING",' +
'"FieldName": "Name",' +
'"FieldLabel": "Location Name",' +
'"CompOper": "not equal to",' +
'"BoolOper": "AND"' +
'}],' +
'"condExpr": "1",' +
'"childSObjectName": "Apttus_Config2__AccountLocation__c",' +
'"childSObjectLabel": "Account Location"' +
'},' +
'"billingScheduleFilter": {' +
'"relationFieldName": null,' +
'"predicates": [{' +
'"RowNum": 1,' +
'"FieldValue": "BS-00600223",' +
'"FieldType": "STRING",' +
'"FieldName": "Name",' +
'"FieldLabel": "Schedule Id",' +
'"CompOper": "greater than or equal to",' +
'"BoolOper": "AND"' +
'}, {' +
'"RowNum": 2,' +
'"FieldValue": "BS-00600226",' +
'"FieldType": "STRING",' +
'"FieldName": "Name",' +
'"FieldLabel": "Schedule Id",' +
'"CompOper": "less than or equal to",' +
'"BoolOper": null' +
'}],' +
'"condExpr": "1 AND 2",' +
'"childSObjectName": "BillingSchedule__c",' +
'"childSObjectLabel": "Billing Schedule"' +
'},' +
'"assetLineItemFilter": null' +
'},' +
'"fields": ["Account.Name", "Name", "Product2.Name"],' +
'"exprStr": "(((((Account.Account Name = Test_Account_01)) AND ((Account Location.Location Name != Mumbai))) AND ((Product.Product Name = Sample Recurring product))) AND ((Billing Schedule.Schedule Id >= BS-00600223) AND (Billing Schedule.Schedule Id <= BS-00600226)))"' +
'}';
Set<ID> billToAccountIDs = new Set<ID>();
billToAccountIDs.add('001Dc000011gXHV');
Date invoiceDate = Date.newInstance(2026, 7, 21);
Date processThruDate = Date.newInstance(2026, 7, 21);
Boolean autoApprove = true;
Boolean splitInvoicesByOrder = true;
String autoApproveOperator = '';
Decimal autoApproveAmount = null ;
String suppressInvoicesOperator = '';
Decimal suppressInvoicesAmount = null;
Boolean autoApproveCreditMemo = false;
String creditMemoCreationOption='';
Boolean autoSendEmailForInvoice=false;
Boolean autoSendEmailForCreditMemo=false;
String InvoiceOverrideTemplate='';
String CreditMemoOverrideTemplate='';
String filterCriteria = filterCriteriaJson;
Apttus_Billing.InvoiceCreationOptions options = new Apttus_Billing.InvoiceCreationOptions(
invoiceDate, processThruDate, autoApprove, splitInvoicesByOrder, autoApproveOperator,
autoApproveAmount, suppressInvoicesOperator,
suppressInvoicesAmount, autoApproveCreditMemo,
creditMemoCreationOption, autoSendEmailForInvoice,
autoSendEmailForCreditMemo, InvoiceOverrideTemplate,
CreditMemoOverrideTemplate, filterCriteria);
Apttus_Billing.InvoiceService.createInvoices(billToAccountIDs, options);