You can split an invoice into multiple invoices by calling the Apttus_Billing.BillingService.createSplitInvoices API. You have an option to choose between split by amount or split by percentage methods.

This API can split a single-source invoice into multiple invoices. To split more than one single-source invoice, you must exclusively call the API each time to individually split the invoices.


API

Signature

Apttus_Billing.BillingService.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 or Percentage.

Decimal

Yes

The split method to be used for splitting the invoice.

  • 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.

  • 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.

Number of Splits

Decimal

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

String

Yes

Information pertaining to splitting the invoices.

Request - SplitInvoiceLineItemInput

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 if:

  • The source invoice ID is not valid.

  • The source invoice ID is valid but the invoice is not approved.

  • 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 paid from a wallet.

  • The source invoice ID is valid but the invoice is already split.

  • 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.

Code Sample

//API Details For Split Functions
//===============================
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
(
'a6I7e000000l1uc', //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.BillingService.createSplitInvoices(splitInvoice);
  
system.debug('Response!!!!'+splitResp);
CODE