Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Split Invoices

The createSplitInvoices API is used to split a single or multiple invoice(s) into multiple invoices . You have an option to choose between split by amount or split by percentage methods.

Note:

The API can handle the splitting of 10 invoices with 12 line items each during a single execution.

API

Signature

createSplitInvoices

static List createSplitInvoices(List splitInvoiceRequests)

The API accepts source invoice ID, split by amount or percentage, number of splits, as the required input parameters. For each SplitInvoiceRequest, a set of split invoices is generated in Draft status. You can auto-approve the split invoices by setting the Auto Approve Split Invoices to True.

Request - SplitInvoiceRequestInput

Field

Type

Required

Description

Source Invoice ID

ID

Yes

The ID of the approved Invoice to be split.

  • Split by Amount
  • Split by Percentage
  • Split by Line Item Parameter (Parameter Name)

Decimal (for Split by Amount or Split by Percentage)

String (for Split by Line Item Parameter)

Yes

The split method to be used for splitting the invoice.

  • Split by Percent: Enter “Percent” if you want to split the invoice based on the percentage for each split invoice. For example, the total invoice amount of the source invoice is $100 and you want to split it into two invoices based on percentages of 60% and 40% respectively. The system supports a decimal precision of up to 8 digits.
  • Split by Amount: Enter “Amount“ if you want to split the invoice based on the amount for each split invoice. For example, the total invoice amount of the source invoice is $100 and you want to split it into two invoices based on amounts of $75 and $25 respectively.
  • Split by Line Item Parameter (Parameter Name):

    Enter a valid parameter name (field available on the Invoice Line Item Object) such as Period Start Date, Product Name, Service Location, etc., which can either be a standard or a custom field.

    The supported field data types are:

    • Lookup
    • Date
    • Picklist
    • Checkbox

    For invoice splitting to occur, an invoice must contain more than one eligible line item. Bundles and their associated components are treated as a single unit and cannot be split across multiple invoices. When a bundle is selected for splitting, all its components are included with it; however, components cannot be split independently of their parent bundle.

    This functionality works only when the invoice line items have valid data in the field that will be used as the split parameter.

Number of Splits

Decimal (Not applicable for Split by Line Item Parameter)

Yes

The number of splits you want for the source invoice.

Auto Approve Split Invoices

Boolean

No

If True, the split invoice is transitioned to Approved status otherwise it is created in a Draft status.

Generate Invoice Line Summary

Boolean

No

If True, the split invoices have a line summary generated for them; otherwise, they are created without any line summary.

Split Details Info

List (Not applicable for Split by Line Item Parameter)

Yes

Information pertaining to splitting the invoices.

Request - SplitInvoiceLineItemInput
Note: This section is not applicable for Split by Line Item Parameter functionality.

Field

Type

Required

Description

Split By Value

Decimal

Yes

The fee amount of the split invoice

Date of Split

Date

Yes

Date of split

Payment Term ID

ID

No

Payment term ID to be associated with the split invoice

Bill To ID

ID

No

The bill to ID for the split invoice.

Account Location ID

ID

No

The account location ID for the split invoice.

Response

Field

Type

Description

CustomClass.SplitInvoiceResponse

List

A result parameter is returned for each request parameter.

When you split an invoice, the status of the source invoice changes to Distributed status. The split invoices are created based on the values provided by the user. Split invoices are created with the same number of invoice line items as that of the source invoice. The amount for the split invoice is distributed based on the split percentage or split amount. Taxes are recalculated based on the split invoices and Destination Related A/R Transactions are created for each split invoice.

The API returns an error message in the following scenarios:

  • Common scenarios for all split types:
    • The source invoice ID is not valid.
    • The source invoice ID is valid but the invoice has a credit memo associated with it.
    • The source invoice ID is valid but the invoice is not approved.
    • The source invoice ID is valid but the invoice is already split.
    • The source invoice ID is valid but the invoice is paid from a wallet.
  • Scenarios exclusive for Split by Amount or Split by Percentage:
    • The number of splits is an invalid value.
    • The "Split by" is null or has an unrecognized value.
    • The number of supplied values for "Split by value" does not match the "Number of splits" mentioned.
    • The sum of the percent values of all the splits is not equal to 100.
    • The sum of the split amounts mentioned in the split lines does not equal the total value on the original invoice.
    • "Auto approve the split invoices" or "Generate Invoice Lines Summary" does not have a valid value.
    • Details like Bill To, Location, Payment Term, or Invoice Date are supplied for a few of the splits.
  • Scenarios exclusive for Split by Line Item Parameter (Parameter Name):
    • There is only one line item on the source invoice.
    • The split parameter has same value across all lines.
    • Parameter is not recognized or there are duplicate parameter fields.
    • The parameter value is NULL or has has no corresponding data across all the line items.
Code Sample to Split Single Invoice
//===============================
Apttus_Billing.CustomClass.SplitInvoiceDetails details1 = new Apttus_Billing.CustomClass.SplitInvoiceDetails
(
40, // Split By value
DateTime.now(), // Date Of Split
null, // Payment Term ID
null, // Bill To ID
null // Account Location ID
);
Apttus_Billing.CustomClass.SplitInvoiceDetails details2 = new Apttus_Billing.CustomClass.SplitInvoiceDetails
(40,DateTime.now(),null,null,null);
Apttus_Billing.CustomClass.SplitInvoiceDetails details3 = new Apttus_Billing.CustomClass.SplitInvoiceDetails
(20,DateTime.now(),null,null,null);
  
List<Apttus_Billing.CustomClass.SplitInvoiceDetails> splitDetails = new List<Apttus_Billing.CustomClass.SplitInvoiceDetails>();
splitDetails.add(details1);
splitDetails.add(details2);
splitDetails.add(details3);
system.debug('---'+splitDetails);
  
Apttus_Billing.CustomClass.SplitMethod percentage = Apttus_Billing.CustomClass.SplitMethod.SPLIT_BY_PERCENTAGE;
//Apttus_Billing.CustomClass.SplitMethod amount = Apttus_Billing.CustomClass.SplitMethod.SPLIT_BY_AMOUNT;
Apttus_Billing.CustomClass.SplitInvoiceRequest input1 = new Apttus_Billing.CustomClass.SplitInvoiceRequest
(
'a5TDc00000161lG', //Source Invoice ID.
percentage, //Split By. amount or percentage.
3, //No Of Splits.
true, //Auto Approve split invoices.
true, //Generate Invoice Line Summary.
splitDetails //Split Details Info.
);
List<Apttus_Billing.CustomClass.SplitInvoiceRequest> splitInvoice = new List<Apttus_Billing.CustomClass.SplitInvoiceRequest>();
splitInvoice.add(input1);
  
List<Apttus_Billing.CustomClass.SplitInvoiceResponse> splitResp = new List<Apttus_Billing.CustomClass.SplitInvoiceResponse>();
splitResp = Apttus_Billing.InvoiceService.createSplitInvoices(splitInvoice);
  
system.debug('Response!!!!'+splitResp);
Code Sample to Split Multiple Invoices
//=================================

Apttus_Billing.CustomClass.SplitInvoiceDetails details1 =  new Apttus_Billing.CustomClass.SplitInvoiceDetails(40,DateTime.now(),null,null,null);
Apttus_Billing.CustomClass.SplitInvoiceDetails details2 =  new Apttus_Billing.CustomClass.SplitInvoiceDetails(40,DateTime.now(),null,null,null);
Apttus_Billing.CustomClass.SplitInvoiceDetails details3 =  new Apttus_Billing.CustomClass.SplitInvoiceDetails(20,DateTime.now(),null,null,null);

List<Apttus_Billing.CustomClass.SplitInvoiceDetails> splitDetails1 = new List<Apttus_Billing.CustomClass.SplitInvoiceDetails>();
splitDetails1.add(details1);
splitDetails1.add(details2);
splitDetails1.add(details3);

//Apttus_Billing.CustomClass.SplitMethod percentage = Apttus_Billing.CustomClass.SplitMethod.SPLIT_BY_PERCENTAGE;
Apttus_Billing.CustomClass.SplitMethod amount = Apttus_Billing.CustomClass.SplitMethod.SPLIT_BY_AMOUNT;

//a5T040000001ANF - invalid id. 
Apttus_Billing.CustomClass.SplitInvoiceRequest input1 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lM',amount,3,false,true,splitDetails1);
//a5T040000001ANK - in draft mode.
Apttus_Billing.CustomClass.SplitInvoiceRequest input2 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lN',amount,3,false,true,splitDetails1);
//a5T040000001ANP- with Distributed status
Apttus_Billing.CustomClass.SplitInvoiceRequest input3 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lO',amount,3,false,true,splitDetails1);
//Auto Approve option is set to null.
Apttus_Billing.CustomClass.SplitInvoiceRequest input4 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lP',amount,3,null,true,splitDetails1);
//Number of split details =12, but provided value=10.
Apttus_Billing.CustomClass.SplitInvoiceRequest input5 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lQ',amount,3,false,true,splitDetails1);
//split by is not valid
Apttus_Billing.CustomClass.SplitInvoiceRequest input6 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lR',amount,3,false,true,splitDetails1);
Apttus_Billing.CustomClass.SplitInvoiceRequest input7 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a5TDc00000161lG',amount,2,false,true,splitDetails1);

List<Apttus_Billing.CustomClass.SplitInvoiceRequest> splitInvoice = new List<Apttus_Billing.CustomClass.SplitInvoiceRequest>();
splitInvoice.add(input1);
splitInvoice.add(input2);
splitInvoice.add(input3);
splitInvoice.add(input4);
splitInvoice.add(input5);
splitInvoice.add(input6);
splitInvoice.add(input7);

//=======================================================================
 
List<Apttus_Billing.CustomClass.SplitInvoiceResponse>  splitResp = new List<Apttus_Billing.CustomClass.SplitInvoiceResponse>();
splitResp = Apttus_Billing.InvoiceService.createSplitInvoices(splitInvoice);
system.debug('Response!!!!'+splitResp);

Code sample to Split by Line Item Parameter

Apttus_Billing.CustomClass.SplitMethod splitByCriteria = Apttus_Billing.CustomClass.SplitMethod.SPLIT_BY_CRITERIA;
String criteria = 'LocationId__c';
Boolean autoApproveSplitInvoice = false;
Boolean generateInvoiceLinesSummary = false;
Apttus_Billing.CustomClass.SplitInvoiceRequest input1 = new Apttus_Billing.CustomClass.SplitInvoiceRequest('a2Vg80000038Y4PEAU', splitByCriteria, criteria, autoApproveSplitInvoice , generateInvoiceLinesSummary );
 
List<Apttus_Billing.CustomClass.SplitInvoiceRequest> splitInvoice = new List<Apttus_Billing.CustomClass.SplitInvoiceRequest>();
splitInvoice.add(input1);  

// Users can add multiple splitInvoice.add(input2); splitInvoice.add(input3);

List<Apttus_Billing.CustomClass.SplitInvoiceResponse> response = new List<Apttus_Billing.CustomClass.SplitInvoiceResponse>();
response = InvoiceService.createSplitInvoices(splitInvoice);
System.debug('Response!!'+response);

For example, you have the following invoice (Invoice - 002300) and you want to split it based on service location.

Invoice Line Item IDProduct NameQuantityPeriod Start DatePeriod End DateFee AmountPrice TypeCharge TypeService Location
ILI-001Machine Usage1.001-Jun-2631-Aug-26$25,000.00UsageUsageSan Mateo, CA
ILI-002Machine Usage1.001-Jun-2631-Aug-26$25,000.00UsageUsagePleasanton, CA
ILI-003Installation1.001-Jun-2630-Jun-26$10,000.00One-TimeService
ILI-005Maintenance2.001-Jun-2630-Jun-26$100,000.00RecurringServicePleasanton, CA

You called the Split invoices API and set the Spit by Criteria as LocationId; CustomClass.SplitMethod splitByCriteria = CustomClass.SplitMethod.SPLIT_BY_CRITERIA; String criteria = 'LocationId__c';.

The invoice is split into three child invoices (Invoices - 002302, 002303, and 002304) based on the service locations (San Mateo, CA, Pleasanton, CA, and blank field - service location not specified) as follows:

Invoice - 002302

Invoice Line Item IDProduct NameQuantityPeriod Start DatePeriod End DateFee AmountPrice TypeCharge TypeService Location
ILI-001Machine Usage1.001-Jun-2631-Aug-26$25,000.00UsageUsageSan Mateo, CA

Invoice - 002303

Invoice Line Item IDProduct NameQuantityPeriod Start DatePeriod End DateFee AmountPrice TypeCharge TypeService Location
ILI-002Machine Usage1.001-Jun-2631-Aug-26$25,000.00UsageUsagePleasanton, CA
ILI-005Maintenance2.001-Jun-2630-Jun-26$100,000.00RecurringServicePleasanton, CA

Invoice - 002304

Invoice Line Item IDProduct NameQuantityPeriod Start DatePeriod End DateFee AmountPrice TypeCharge TypeService Location
ILI-003Installation1.001-Jun-2630-Jun-26$10,000.00One-TimeService