createInvoicesforOrder API is used to create invoices for given orders. It accepts a List of order IDs as input and produces invoices for each order ID.

API Signature
createInvoicesForOrderstatic List createInvoicesForOrder(Id orderId, Datetime targetDateTime, Date invoiceDate)

This API is used to create invoices for given order ID. It accepts the order ID, targetDateTime and invoiceDate as input parameters. It creates invoices for the billing schedules that have 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

orderId

ID

Yes

Order Id

targetDateTimeDatetimeYesInvoice Process Through Date
invoiceDateDate YesInvoice Creation Date

Response

Field

Type

Description

Apttus_Config2__Invoice_c

List of Invoice objectsInvoices created for each order ID

Code Sample

ID orderID = new 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);
List <Invoice_c> invoices =  Apttus_Billing.BillingService.createInvoicesForOrder(orderID, targetDateTime, invoiceDate);
CODE
API Signature
createInvoicesForOrderstatic List createInvoicesForOrder(Id orderId, Apttus_Billing.InvoiceCreationOptions options)


This API is used to create invoices for the given order ID. It accepts the order 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. It returns a list of invoices. 


Request

Field

Type

Required?

Description

orderId

ID

Yes

Order Id

optionsApttus_Billing.InvoiceCreationOptionsYesClass holding the Invoice Creation Options


 

Response

Field

Type

Description

Apttus_Config2__Invoice_c

List of Invoice objectsInvoices created for each order ID



DataObject - Billing.InvoiceCreationOptions
FieldTypeOption TypeDescription
abortBoolean

Output 

If the process is aborted.
autoApproveBooleanInputMandatory Constructor. If autoApprove for Invoice is set to true.
autoApproveAmountDecimalInputMandatory Constructor. The amount provided for auto approval.
autoApproveCreditMemo

Boolean

InputMandatory Constructor. If autoApproveCreditMemo is set to true
autoApproveOperatorStringInput

Mandatory Constructor. The selected

autoApproveOperator such as Greater than, Less than etc.

invoiceDateDateInputMandatory Constructor. The Invoice Date.
invoiceDateTypeStringInputThe Invoice Date Type such as month or year.
invoiceRun

Apttus_Billing__

InvoiceRun__c

InputThe Invoice Run Object API Name.
invoiceRunResult

Apttus_Billing__

InvoiceRun

Result__c

Input/OutputThe Invoice Run Result Object API Name.
numberAccountsProcessedIntegerOutputThe number of accounts processed as part of the Invoice Runs.

numberCreditMemos

Genenerated

IntegerOutputThe number of Credit Memos generated.
numberInvoicesGeneneratedIntegerOutputThe number of Invoices generated.

numberOfAccountsThat

GeneratedCreditMemos

IntegerOutputNumber of accounts for which Credit Memos are generated.

numberOfAccountsThat

GeneratedInvoices

IntegerOutputNumber of accounts for which Invoices are generated.

numberOfAutoApprovedInvoices

IntegerOutputNumber of Invoices that are auto-approved.

numberOfCreditMemos

AutoApproved

IntegerOutputNumber of Credit Memos that are auto-approved.

numberOfSuppressedInvoices

IntegerOutputNumber of Invoices that are suppressed.
processThruDateDateInputMandatory Constructor. The Process through date for invoice
splitInvoicesByOrderBooleanInputMandatory Constructor. If Split Invoices By Order is set to true.
suppressInvoicesAmountDecimalInputMandatory Constructor. The amount till which you want to suppress invoices.
suppressInvoicesOperatorStringInput

Mandatory Constructor.The selected Suppress Invoices operator

such as Greater than, Less than etc.

taxCallbackStatusStringOutputThe status of Tax Callback.


Code Sample

ID orderID = new 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.createInvoicesForOrder(orderID, options);
CODE