Accounting Apex API Developer Reference

c2g.BackgroundMatchingService

global with sharing class BackgroundMatchingService

The service class relating to Background Matching.

Enums

MatchAction

Specifies match actions on which the matching should be performed.

Value Description
CASHREFUND_TO_CREDITNOTE Initiates subprocesses based on MatchMode to match cash entry refund (source) and credit note (target).
CASHREFUND_TO_CASHRECEIPT Initiates subprocesses based on MatchMode to match cash entry refund (source) and cash entry receipt (target).
CASHRECEIPT_TO_CASHREFUND Initiates subprocesses based on MatchMode to match cash entry receipt (source) and cash entry refund (target).
CREDITNOTE_TO_INVOICE Initiates subprocesses based on MatchMode to match credit note (source) and invoice (target).
CASHRECEIPT_TO_INVOICE Initiates subprocesses based on MatchMode to match cash entry receipt (source) and invoice(target).
JOURNAL_TO_INVOICE Initiates subprocesses based on MatchMode to match journal (source) and invoice(target).
JOURNAL_TO_CREDITNOTE Initiates subprocesses based on MatchMode to match journal (source) and credit note (target).
CASHRECEIPT_TO_JOURNAL Initiates subprocesses based on MatchMode to match cash entry receipt (source) and journal(target).
CASHREFUND_TO_JOURNAL Initiates subprocesses based on MatchMode to match cash entry refund (source) and journal(target).
NEGINVOICE_TO_POSINVOICE Initiates subprocesses based on MatchMode to match negative invoice (source) and invoice(target).

MatchType

Specifies whether matching should be performed based on Customer Reference or Document Number.

Value Description
DocumentReference Match cash entries, journals, sales invoices, and credit notes based on Customer Reference.
DocumentNumber Match cash entries, journals, sales invoices, and credit notes based on Document Number.

MatchMode

Specifies how any available outstanding cash, journal or credit note is automatically matched to other sales invoices, credit notes, journals or cash for the same account.

Value Description
ExactOnly Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries only if all have the same reference value. This is the default option.
DocumentNumberOldestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the oldest document number and so on. For example, an invoice with the number SIN000067 will be matched before an invoice with the number SIN000100.
DocumentNumberNewestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the newest document number and so on. For example, an invoice with the number SIN000100 will be matched before an invoice with the number SIN000067.
OutstandingValueHighestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the highest outstanding value and so on. For example, an invoice with an outstanding value of 300.00 will be matched before an invoice with an outstanding value of 150.00.
OutstandingValueLowestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the lowest outstanding value. For example, an invoice with an outstanding value of 150.00 will be matched before an invoice with an outstanding value of 300.00.
DateOldestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the oldest date and so on. For example, an invoice with a date of May 30 2015 will be matched before an invoice with a date of June 1 2015.
DateNewestFirst Cash entry will be matched to sales invoices, credit notes, journals, or other cash entries starting from the document with the newest date and so on. For example, an invoice with a date of June 1 2015 will be matched before an invoice with a date of May 30 2015.

CurrencyMode

Indicates whether matching should be in the currency of the account, or the currency of the posted document.

Value Description
Document Document currency
Account Account currency

MatchingDateMode

Indicates whether the matching date on the cash matching history is populated by a custom date or the cash entry date or the journal date.

Value Description
CustomDate Custom Date
CashEntryDate Cash Entry Date
JournalDate Journal Date

Methods

match

global static Id match(c2g.BackgroundMatchingService.Configuration configuration)

This service allows you to match outstanding transactions asynchronously. See "About Background Matching" in the Certinia Help for more details. Use the CashEntryMatch (Process Cash Matching) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
configuration c2g.BackgroundMatchingService.Configuration Starts an AsyncApexJob that matches invoices to cash based on the provided configuration.

Return Value

This service returns the ID of an Accounting Background Worker object.

matchCash

global static Id matchCash(c2g.BackgroundMatchingService.Configuration configuration)

This service allows you to match outstanding transactions asynchronously. See "About Background Matching" in the Certinia Help for more details. Use the CashEntryMatch (Process Cash Matching) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
configuration c2g.BackgroundMatchingService.Configuration Starts an AsyncApexJob that matches Cash Entry Lines/Credit Note Lines/Journal Lines/Negative Invoice Lines to Cash Entry Lines/Invoice/Credit Note Lines/Journal Lines based on the provided configuration using Async API Framework. If nothing is provided in the configuration, it is reverted to the company default values, except for the values in the Match Mode and the Matching Date fields. The Matching Date field is set to current date and the Match Mode field specifies “Exact Only”. In Configuration, you cannot provide Company IDs when you are providing transaction line items.

Return Value

This service returns the ID of a Process Run object.

match

global static c2g.BackgroundMatchingService.MatchResult match(c2g.BackgroundMatchingService.Configuration configuration, List<Id> transactionLines)

This service allows you to match outstanding transactions synchronously. See "About Background Matching" in the Certinia Help for more details. Use the CashEntryMatch (Process Cash Matching) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
configuration c2g.BackgroundMatchingService.Configuration This service matches invoices to cash based on the provided configuration synchronously.
transactionLines List<Id> Matches invoice transaction lines, specified by their IDs, to cash based on the provided configuration synchronously.

Return Value

This service returns a c2g.BackgroundMatchingService.MatchResult object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Standard data setup.
1 - Create and select company.
2 - Setup accounting currencies, GLAs and Years and periods, tax codes, bank account etc.
3 - Create and post cash entries and invoices.
4 - Find out the ids of the transaction lines that relate to the invoice lines you have created.
// Create the configuration
BackGroundMatchingService.Configuration configuration = new BackGroundMatchingService.Configuration();
// Set the Match Type
configuration.MatchType = BackGroundMatchingService.MatchType.DocumentReference;
// Do the Matching
BackgroundMatchingService.MatchResult matchResult = BackgroundMatchingService.match( configuration, transactionLineIds);
This performs background matching for all the invoice transaction lines retrieved using the passed IDs and applying the following conditions:
    MatchingStatus = 'Available'
    LineType__c = 'Account'
    Transaction__r.TransactionType__c = 'Invoice'
    OwnerCompany__c = current company

matchCash

global static c2g.BackgroundMatchingService.MatchResult matchCash(c2g.BackgroundMatchingService.Configuration configuration, List<Id> transactionLines)

This service allows you to match outstanding transactions synchronously. See "About Background Matching" in the Certinia Help for more details. Use the CashEntryMatch (Process Cash Matching) custom permission to grant permissions on this method.

Input Parameters

Name Type Description
configuration c2g.BackgroundMatchingService.Configuration Matches Cash Entry Lines/Credit Note Lines/Journal Lines/Negative Invoice Lines to Cash Entry Lines/Invoice/Credit Note Lines/Journal Lines based on the provided configuration synchronously.
transactionLines List<Id> Collection of transaction line IDs. Matches cash entry/journal transaction lines, specified by their IDs, to invoice or credit notes based on the provided configuration synchronously.

Return Value

This service returns a c2g.BackgroundMatchingService.MatchResult object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Standard data setup.
1 - Create and select company.
2 - Setup accounting currencies, GLAs and Years and periods, tax codes, bank account etc.
3 - Create and post cash entries and invoices.
4 - Find out the ids of the transaction lines that relate to the cash lines you have created.
// Create the configuration
BackGroundMatchingService.Configuration configuration = new BackGroundMatchingService.Configuration();
// Set the Match Type
configuration.MatchType = BackGroundMatchingService.MatchType.DocumentReference;
// Do the Matching
BackgroundMatchingService.MatchResult matchResult = BackgroundMatchingService.matchCash( configuration, transactionLineIds);
This performs background matching for all the cash transaction lines retrieved using the passed IDs and applying the following conditions:
    MatchingStatus = 'Available'
    LineType__c = 'Account'
    Transaction__r.TransactionType__c = 'Cash'
    OwnerCompany__c = current company
    
Standard data setup.
1 - Create and select multiple companies.
2 - Setup accounting currencies, GLAs and Years and periods, tax codes, bank account etc.
3 - Create and post cash entries and invoices for those companies.
// Create the configuration
BackGroundMatchingService.Configuration configuration = new BackGroundMatchingService.Configuration();
// Set the Match Type
configuration.MatchType = BackgroundMatchingService.MatchType.DocumentNumber;
configuration.CurrencyMode = BackgroundMatchingService.CurrencyMode.Account;
configuration.Mode = BackgroundMatchingService.MatchMode.DocumentNumberNewestFirst;
configuration.CompanyIds = new List<Id>{'a3m56000000L4bKAAS', 'a3m56000000L4bHASS'};
configuration.MatchingDateModeType = BackgroundMatchingService.MatchingDateMode.CashEntryDate;
// Do the Matching
Id processRunId = BackgroundMatchingService.matchCash( configuration);

c2g.BackgroundMatchingService.Configuration

global with sharing class Configuration

Holds parameters used by the background matching process.

This class contains deprecated items.

Properties

Name Type Description
MatchType c2g.BackgroundMatchingService.MatchType Specifies whether matching should be performed based on Customer Reference or Document Number. This is required when using Company IDs to match for single or multiple companies. In single company mode, this takes the default value from the selected company.
PartialPayment Boolean If true, two transaction lines can be matched, even if their amounts are not same. This is required when using Company IDs to match for single or multiple companies. In single company mode, this takes the default value from the selected company.
MatchingDate Date The matching date. Current date is used by default.
MatchUptoDate Date The date to match up to. Any cash entries, journals, sales invoices, and sales credit notes with a date later than this date are not matched. The current date is used by default.
Mode c2g.BackgroundMatchingService.MatchMode Specifies how any available outstanding cash entry, journal, or credit note should be automatically matched to other sales invoice or credit note for the same account.
AccountIds Set<Id> Identifies the accounts whose transactions you want to match. By default background matching is performed for all accounts.
CashEntryIds Set<Id> Identifies the Cash Entry whose transactions you want to match.
CurrencyMode c2g.BackgroundMatchingService.CurrencyMode Specifies whether matching should be in the currency of the account, or the currency of the posted document. This is required when using Company IDs to match for single or multiple companies. In single company mode, this takes the default value from the selected company.
MatchCurrency String Specifies whether you are interested in one particular currency, or all currencies. The default value is All Currencies.
CompanyIds List<Id> Specifies whether matching should be performed for single or multiple companies.
MatchActions List<c2g.BackgroundMatchingService.MatchAction> Specifies match actions to execute in the process. The processes are executed in the order in which match actions are passed. Till Spring 21 release, matchCash() synchronous method was matching cash entries to invoices and credit notes. Fall 21 onwards, if no Match Action is passed explicitly then it will match cash entries to invoices only. By default, the CASHRECEIPT_TO_INVOICE match action is executed in the synchronous call if nothing is passed. The CASHRECEIPT_TO_INVOICE and CASHREFUND_TO_CREDITNOTE match actions are executed in the asynchronous call if nothing is passed. We recommend that you check the default order in the "About Background Matching" in the Accounting Help.
MatchingDateModeType c2g.BackgroundMatchingService.MatchingDateMode Specifies whether the matching date should be populated by custom date or cash entry date or journal date.

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Properties

Name Type Description Deprecation Details
MatchingDateMode String Specifies whether the matching date should be populated by custom date or cash entry date or journal date.

c2g.BackgroundMatchingService.MatchDetails

global with sharing class MatchDetails

Holds summary values for all the lines of the Transaction Type.

Properties

Name Type Description
TransactionType c2g.CommonService.TransactionType The type of transaction for which the details relate.
TotalMatchValue Decimal The total value matched for this Transaction Type. The value could be postive or negative based on the type of document: SIN: Positive SCN: Negative CSH(Receipt): Negative CSH(Refund): Positive
Discount Decimal The total discount applied for the Transaction Type.
Matches Integer The total number of matches performed for this Transaction Type.
DocumentNumbers Set<String> The document numbers which are matched.

c2g.BackgroundMatchingService.MatchResult

global with sharing class MatchResult

Holds the details of the match.

Properties

Name Type Description
MatchDetails List<c2g.BackgroundMatchingService.MatchDetails> The details of the match separated by Transaction Type.
CashMatchingReferences List<Id> The IDs of the cash matching references created during the match.
UnProcessedTransactionLineIdSet List<Id> Contains transaction line IDs which are to be matched but were not processed because the number of matching references created exceeds the custom setting "Cash Matching Settings (FF) - Background Matching References Threshold", or a service limitation is reached.
© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.