createInvoices API is used to create Invoices automatically. It accepts a list of Account IDs and creates Invoices for each AccountID. 

API Signature
createInvoicesstatic void createInvoices(Set billToAccountIds, Datetime targetDateTime, Date invoiceDate)

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

targetDateTimeDatetimeYesProcess through Date
invoiceDateDate YesInvoice Creation Date


Code Sample

Set<ID> billToAccountIDs = new Set<ID>();
Date invoiceDate = Date.newInstance(2017, 1, 1);
Date myDate = Date.newInstance(2017, 1, 1);
Time myTime = Time.newInstance(3, 3, 3, 0);
DateTime targetDateTime = DateTime.newInstance(myDate, myTime);
Apttus_Billing.BillingService.createInvoices(billToAccountIDs, invoiceDate, targetDateTime);
CODE
APISignature
createInvoicesstatic void createInvoices(Set billToAccountIds, Apttus_Billing.InvoiceCreationOptions options)

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. the class contains options that influence the creation of an Invoice such as Invoice Date, Invoice Through Date and Auto Approve.


Request

Field

Type

Required?

Description

billToAccountIds

Set <Id>

Yes

Set of bill to Account IDs

optionsApttus_Billing.InvoiceCreationOptionsYesClass holding the Invoice Creation Options

DataObject - Billing.InvoiceCreationOptions

FieldTypeDescription
abortBooleanIf the process is aborted.
autoApproveBooleanMandatory Constructor. IfautoApprovefor Invoice is set to true.
autoApproveAmountDecimalMandatory Constructor. The amount provided for auto approval.
autoApproveCreditMemo

Boolean

Mandatory Constructor. If the autoApproveCreditMemo is set to true
autoApproveOperatorString

Mandatory Constructor. The selected

autoApproveOperator such as Greater than, Less than etc.

invoiceDateDateMandatory Constructor. The Invoice Date.
invoiceDateTypeStringThe 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.
numberAccountsProcessedIntegerThe number of accounts processed as part of the Invoice Runs.

numberCreditMemos

Genenerated

IntegerThe number of Credit Memos generated.
numberInvoicesGeneneratedIntegerThe number of Invoices generated.

numberOfAccountsThat

GeneratedCreditMemos

IntegerNumber of accounts for which Credit Memos are generated.

numberOfAccountsThat

GeneratedInvoices

IntegerNumber of accounts for which Invoices are generated.

numberOfAutoApprovedInvoices

IntegerNumber of Invoices that are auto-approved.

numberOfCreditMemos

AutoApproved

IntegerNumber of Credit Memos that are auto-approved.
numberOfSuppressedInvoicesIntegerNumber of Invoices that are suppressed.
processThruDateDateMandatory Constructor.The Process through date for invoice
splitInvoicesByOrderBooleanMandatory Constructor. If Split Invoices By Order is set to true.
suppressInvoicesAmountDecimal

Mandatory Constructor.The amount till

which you want to suppress invoices.

suppressInvoicesOperatorStringMandatory Constructor.

.The selected Suppress Invoices operator

such as Greater than, Less than etc.

taxCallbackStatusStringThe status of Tax Callback.

credtiMemoCreationOption

StringThe 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

StringName of the invoice template to override the default invoice template

CreditMemoOverrideTemplate

StringName of the credit memo template name to override the default credit memo template

Only the following values are currently supported for createInvoice API:

  • autoSendEmailforInvoice: false
  • autoSendEmailforCreditMemo: false
  • InvoiceOverrideTemplate: NULL
  • CreditMemoOverrideTemplate: NULL


Code Sample

Set<ID> billToAccountIDs = new Set<ID>();
Date invoiceDate = Date.newInstance(2017, 1, 1);
Date processThruDate = Date.newInstance(2017, 1, 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.BillingService.createInvoices(billToAccountIDs, options);
CODE

Code Sample

Use this code sample to provide credit memo creation options while generating invoices through the createInvoices API.

Set<ID> billToAccountIDs = new Set<ID>();
Date invoiceDate = Date.newInstance(2018,1,1); 
Date processThruDate = Date.newInstance(2018,9,9);
Boolean autoApprove = true;
Boolean splitInvoicesByOrder = false;
String autoApproveOperator = 'Greater than';
Decimal autoApproveAmount = 20.00 ; 
String suppressInvoicesOperator = 'Less than';
Decimal suppressInvoicesAmount = 2.00; 
Boolean autoApproveCreditMemo = true;
String credtiMemoCreationOption = 'Single Credit Memo for all Negative Schedules per Invoice';
Boolean autoSendEmailForInvoice = false;
Boolean autoSendEmailForCreditMemo = false;
String InvoiceOverrideTemplate = NULL;
String CreditMemoOverrideTemplate = NULL;
billToAccountIDs.add('0017F00000tPMvL');
InvoiceCreationOptions
options = new InvoiceCreationOptions( invoiceDate,
processThruDate,
autoApprove,
splitInvoicesByOrder,
autoApproveOperator,
autoApproveAmount,
suppressInvoicesOperator,
suppressInvoicesAmount,
autoApproveCreditMemo,
credtiMemoCreationOption,
autoSendEmailForInvoice,
autoSendEmailForCreditMemo,
InvoiceOverrideTemplate, 
CreditMemoOverrideTemplate);
BillingService.createInvoices(billToAccountIDs,options); 
CODE