InvoiceMatchProcess

F03B11 Invoice Match Process

Major Business Rule

Object Name: B03B0169

Parent DLL: CFIN

Location: Client/Server

Language: C

Functional Description

Purpose

This function is used to find invoices using a generic reference number. The reference number can be 
an invoice number, sales order number, customer reference number, or statement number. The function 

attempts to match against invoices in the order specified until at least one invoice is found. This 

function stores all records found to a temporary cache for later retrieval. The total number of pay items 

found is returned. Also, the total open amount, discount available, and discount earnable of the found 

pay items is returned. The function returns the type of match that was successful. If no invoices 

were found, the match type will be blank. 


Setup Notes and Prerequisites

The Invoice Selection Create Cache (B03B0172) function must be called first to create the temporary 

cache used to hold any invoice pay items found. Call the Receipts Entry Read Cache (B03B0142) function 

in a loop to retrieve each pay item from the temporary cache. Once completed, call the Invoice 

Selection Destroy Cache (B03B0172) function to free the memory used by the cache. Other functions in the 

B03B0172 family may be used to add, delete, and check for records in the cache.


Special Logic

This function will perform a match on all open invoices using the generic reference number and other 

passed criteria. The search order is based on the values for cInvoiceMatchPriority, 

cSalesOrderMatchPriority, cCustomerRefMatchPriority, and cStatementMatchPriority. A '1' is the highest priority and a 

'4' is the lowest priority. Each match process will be run in priority order until at least one invoice 

pay item is found. These values can be overriden by passing a value in cOverrideMatchType. Use a '1' 

for invoice match, '2' for sales order match, '3' for customer reference match, and '4' for statement 

match.


If amounts are passed on mnCustomerAmountApplied and mnCustomerDiscountTaken, a balance forward 

method of application will be applied to any found invoice pay items. If only one item is found, the entire 

amount is applied. If multiple pay items are found, the amount applied will be the lesser of the 

amount remaining to be applied and the invoice open amount. The discount will be the lesser of the total 

discount taken remaining and the invoice discount available. Any remaining amounts after all invoice 

pay items have been applied will be discarded.



Technical Specification



Parameters

Item DescriptionI/OReq?Notes

MATH01mnMatchLineIDIYLine number used to identify the results of the match.
GMFDszGenericReferenceNumberIYNumber used to match against invoices.

MAPRTcOverrideMatchTypeIYType of match to execute. Overrides the match order 

specified on the processing options.

DCTszDocumentTypeINDocument Type of the Invoice. Used to filter invoices.

KCOszDocumentCompanyINDocument Key Company of the Invoice. Used to filter 

invoices.

SFXszDocumentPayItemINDocument Pay Item of the Invoice. Used to filter 

invoices.

PYRmnPayorNumberINPayor Number of the Invoice. Used to filter invoices.

AN8mnCustomerNumberINCustomer Number of the Invoice. Used to filter 

invoices.

PA8mnParentNumberINParent Number of the Invoice. Used to filter invoices.

COszCompanyINCompany Number of the Invoice. Used to filter 

invoices.

BCRCszBaseCurrencyIYRequired if currency is on. Company Base Currency 

Code. Used to filter invoices.

CRRMcCurrencyModeIYRequired if currency is on. The mode specifies the 

currency of the output amounts.

CRCDszTransactionCurrencyIYRequired if currency is on and the mode is foreign. 

Used to filter invoices.

DGJjdDateGLIYTransaction's G/L Date. Determines whether a discount 

is earnable or not.

PIDszProgramIDIYProgram ID of the calling program.

EV01cPayApprovedInvoicesOnlyIY1- Only select approved Invoices BLANK allow Held 

Invoices to be selected.

GPDmnGracePeriodDaysIYGrace days to extended discount due date. 

EV02cInvoiceMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Invoice Number.

EV03cSalesOrderMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Sales Order Number.

EV04cCustomerRefMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Customer Reference.

EV05cStatementMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Statement Number.

NINFDmnTotalPayItemsO Total number of Pay Items.

AAPmnTotalAmountOpenO Total open amount of found invoices.

ADSCmnTotalDiscountAvailableO Total discount available of found invoices.

EDSCmnTotalDiscountEarnableO Total discount earnable of found invoices.

EV06cReturnMatchTypeO Type of match that produced a successful search. This 

value is blank if no invoices were found.

PAAPmnCustomerAmountAppliedINIf used, specifies how much to apply to the pay items 

found.

ADSAmnCustomerDiscountTakenINIf used, specifies how much discount to take on the 

pay items found.

TCRCszReceiptCurrencyCodeINRequired if Receipt is in alternate currency. Receipts 

Currency Code.

CRRmnCurrencyConverRateOVINRequired if Receipt is in alternate currency. Exchange 

Rate between receipt and invoice transaction. 

CRR1mnTriangulationLeg1INRequired if Receipt is in alternate currency. Exchange 

Rate Leg 1.

CRR2mnTriangulationLeg2INRequired if Receipt is in alternate currency. Exchange 

Rate Leg 2.

CRCMcCurrencyConversionMethodINRequired if Receipt is in alternate currency. Currency 

Conversion Method.

ERDJjdExchangeRateDateINRequired if Receipt is in alternate currency. Exchange 

Date.

CRRmnReceiptSpotRateINRequired if foreign receipt is paying a domestic only 

invoice where the receipt base currency is the same as the invoice currency - in such a case the spot 

rate will be used.



Related Tables

F03B11Customer Ledger File

F03B21A/R Notification History Detail


Related Functions

B03B0158Maintain Receipts Entry Cache
B03B0172Maintain Invoice Selection Cache


Processing

Initialize return values.

Validate all required parameters.

Sort match processes in priority order.

Clear the cache of any existing records by mnMatchLineID.

If cOverrideMatchType has been specified,

Execute GenericMatch.

Else,

For each specified match process,

Execute GenericMatch in priority order.

Repeat until at least one invoice pay item was found or all

match processes have been executed.


GenericMatch

If match type is '1',
Set invoice document number (RPDOC) equal to

szGenericReferenceNumber.

Execute F03B11Match.

If match type is '2',

Set invoice sales order number (RPSDOC) equal to

szGenericReferenceNumber.

Execute F03B11Match.

If match type is '3',

Set invoice customer reference number (RPVR01) equal to

szGenericReferenceNumber.

Execute F03B11Match.

If match type is '4',

Execute F03B21Match.

If any invoice pay items were found,

Set cReturnMatchType.


F03B11Match

Open F03B11 table.

Set F03B11 selection using specified criteria.

While a record is found,

If the record already exists in the cache,

Skip record.

Else,

Increment mnTotalPayItems by one.

Accumulate mnTotalAmountOpen and mnTotalDiscountAvailable.

Add mnGracePeriodDays to invoice discount due date.

If jdDateGL is less than or equal to this calculated date,

Accumulate mnTotalDiscountEarnable.

Execute WriteCache.

Repeat until no more records remain.

Close F03B11 table.


F03B21Match

Open F03B11 table.
Open F03B21 table.

Set F03B21 selection using specified criteria.

While a record is found,

Retrieve corresponding F03B11 record.

If invoice pay item does not match the specified criteria,

Skip record.

Else,

If the record already exists in the cache,

Skip record.

Else,

Increment mnTotalPayItems by one.

Accumulate mnTotalAmountOpen and mnTotalDiscountAvailable.

Add mnGracePeriodDays to invoice discount due date.

If jdDateGL is less than or equal to this calculated date,

Accumulate mnTotalDiscountEarnable.

Execute WriteCache.

Repeat until no more records remain.

Close F03B11 table.

Close F03B21 table.


WriteCache

If mnCustomerAmountApplied is greater than zero,

If invoice open amount is greater than mnCustomerAmountApplied,

Set amount applied equal to mnCustomerAmountApplied.

Else,

Set amount applied equal to invoice open amount.

Subtract amount applied from invoice open amount and

mnCustomerAmountApplied.

If mnCustomerDiscountTaken is greater than zero,

If invoice discount available is greater than

mnCustomerDiscountTaken,

Set discount taken equal to mnCustomerDiscountTaken,

Else,

Set discount taken equal to invoice discount available.

Subtract discount taken from invoice discount available and

mnCustomerDiscountTaken.

If amount applied or discount taken is greater than zero,

Set user type input code equal to '10'.

Write record to the invoice selection cache.



Data Structure

D03B0169 - F03B11 Invoice Match Process

Purpose

This Data Structure is used for InvoiceMatchProcess function. 


Parameters
Item DescriptionI/OReq?Notes

MATH01mnMatchLineIDIYLine number used to identify the results of the match.
GMFDszGenericReferenceNumberIYNumber used to match against invoices.

MAPRTcOverrideMatchTypeIYType of match to execute. Overrides the match order 

specified on the processing options.

DCTszDocumentTypeINDocument Type of the Invoice. Used to filter invoices.

KCOszDocumentCompanyINDocument Key Company of the Invoice. Used to filter 

invoices.

SFXszDocumentPayItemINDocument Pay Item of the Invoice. Used to filter 

invoices.

PYRmnPayorNumberINPayor Number of the Invoice. Used to filter invoices.

AN8mnCustomerNumberINCustomer Number of the Invoice. Used to filter 

invoices.

PA8mnParentNumberINParent Number of the Invoice. Used to filter invoices.

COszCompanyINCompany Number of the Invoice. Used to filter 

invoices.

BCRCszBaseCurrencyIYRequired if currency is on. Company Base Currency 

Code. Used to filter invoices.

CRRMcCurrencyModeIYRequired if currency is on. The mode specifies the 

currency of the output amounts.

CRCDszTransactionCurrencyIYRequired if currency is on and the mode is foreign. 

Used to filter invoices.

DGJjdDateGLIYTransaction's G/L Date. Determines whether a discount 

is earnable or not.

PIDszProgramIDIYProgram ID of the calling program.

EV01cPayApprovedInvoicesOnlyIY1- Only select approved Invoices BLANK allow Held 

Invoices to be selected.

GPDmnGracePeriodDaysIYGrace days to extended discount due date. 

EV02cInvoiceMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Invoice Number.

EV03cSalesOrderMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Sales Order Number.

EV04cCustomerRefMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Customer Reference.

EV05cStatementMatchPriorityIYA value 1-4 priority to assigned to search Generic 

Reference as a Statement Number.

NINFDmnTotalPayItemsO Total number of Pay Items.

AAPmnTotalAmountOpenO Total open amount of found invoices.

ADSCmnTotalDiscountAvailableO Total discount available of found invoices.

EDSCmnTotalDiscountEarnableO Total discount earnable of found invoices.

EV06cReturnMatchTypeO Type of match that produced a successful search. This 

value is blank if no invoices were found.

PAAPmnCustomerAmountAppliedINIf used, specifies how much to apply to the pay items 

found.

ADSAmnCustomerDiscountTakenINIf used, specifies how much discount to take on the 

pay items found.

TCRCszReceiptCurrencyCodeINRequired if Receipt is in alternate currency. Receipts 

Currency Code.

CRRmnCurrencyConverRateOVINRequired if Receipt is in alternate currency. Exchange 

Rate between receipt and invoice transaction. 

CRR1mnTriangulationLeg1INRequired if Receipt is in alternate currency. Exchange 

Rate Leg 1.

CRR2mnTriangulationLeg2INRequired if Receipt is in alternate currency. Exchange 

Rate Leg 2.

CRCMcCurrencyConversionMethodINRequired if Receipt is in alternate currency. Currency 

Conversion Method.

ERDJjdExchangeRateDateINRequired if Receipt is in alternate currency. Exchange 

Date.


^

Parameter NameData ItemData TypeReq/OptI/O/Both
mnMatchLineIDMATH01MATH_NUMERICNONENONE

- - - Good Performance Low Value. 

szGenericReferenceNumberGMFDcharNONENONE

An identification number that the system uses to locate invoice records for receipt matching. The system can locate invoices by the 
following references:   o Invoice number     o Statement number     o Sales order number     o Customer reference number     o Shipment number  The 
system uses the value of this field in conjunction with the Match Priority processing options or the Override Type field to determine which of the 
five options the value represents.

cOverrideMatchTypeMAPRTcharNONENONE

A number that the system uses to identify which matching process to run to locate invoices. If you leave the field blank, the system uses the 
matching process that is specified in the processing options for the Standard Receipts Entry program (P03B102). Valid values are: 1 Invoice 
Match   2 Sales Order Match   3 Customer Reference Match   4 Statement Number Match   5 Shipment Number Match    

szDocumentTypeDCTcharNONENONE

A user defined code (00/DT) that identifies the origin and purpose of the transaction.  PeopleSoft reserves several prefixes for document 
types, such as, vouchers, invoices, receipts, and timesheets. The reserved document type prefixes for codes are: P Accounts payable 
documents R Accounts receivable documents  T Time and Pay documents I Inventory documents  O Purchase order documents  S Sales order 
documents 

szDocumentCompanyKCOcharNONENONE

A number that, with the document number, document type and G/L date, uniquely identifies an original document, such as invoice, voucher, 
or journal entry. If you use the Next Numbers by Company/Fiscal Year feature, the Automatic Next Numbers program (X0010) uses the 
document company to retrieve the correct next number for that company. If two or more original documents have the same document number and 
document type, you can use the document company to locate the desired document.

szDocumentPayItemSFXcharNONENONE

A number that identifies the pay item for a voucher or an invoice. The system assigns the pay item number. If the voucher or invoice has 
multiple pay items, the numbers are sequential.

mnPayorNumberPYRMATH_NUMERICNONENONE

The address book number of the person or company that sends the payment.

mnCustomerNumberAN8MATH_NUMERICNONENONE

A number that identifies an entry in the Address Book system, such as employee, applicant, participant, customer, supplier, tenant, or 
location.

mnParentNumberPA8MATH_NUMERICNONENONE

The address book number of the parent company. The system uses this number to associate a particular address with a parent company 
or location. Any value that you enter in this field updates the Address Organizational Structure Master table (F0150) for the blank structure 
type. This address number must exist in the Address Book Master table (F0101) for validation purposes. Examples of address book records 
that would have a parent number include:   o  Subsidiaries with parent companies     o  Branches with a home office     o  Job sites with a general 
contractor 

szCompanyCOcharNONENONE

A code that identifies a specific organization, fund, or other reporting entity. The company code must already exist in the Company 
Constants table (F0010) and must identify a reporting entity that has a complete balance sheet. At this level, you can have intercompany 
transactions. Note: You can use company 00000 for default values such as dates and automatic accounting instructions. You cannot use company 00000 
for transaction entries.

szBaseCurrencyBCRCcharNONENONE

A code that represents the currency of the company for a transaction. For a foreign currency transaction, this is the currency code of the 
domestic side of the transaction.

cCurrencyModeCRRMcharNONENONE

An option that specifies whether the system displays amounts in the domestic or foreign currency. On  The system displays amounts in the 
foreign currency of the transaction. Off  The system displays amounts in the domestic currency of the transaction.

szTransactionCurrencyCRCDcharNONENONE

A code that identifies the currency of a transaction. 

jdDateGLDGJJDEDATENONENONE

A date that identifies the financial period to which the transaction will be posted. You define financial periods for a date pattern code that you 
assign to the company record. The system compares the date that you enter on the transaction to the fiscal date pattern assigned to the 
company to retrieve the appropriate fiscal period number, as well as to perform date validations.

szProgramIDPIDcharNONENONE

The number that identifies the batch or interactive program (batch or interactive object). For example, the number of the Sales Order Entry 
interactive program is P4210, and the number of the Print Invoices batch process report is R42565. The program ID is a variable length value. 
It is assigned according to a structured syntax in the form TSSXXX, where: T The first character of the number is alphabetic and identifies the 
type, such as P for Program, R for Report, and so on. For example, the value P in the number P4210 indicates that the object is a 
program. SS The second and third characters of the number are numeric and identify the system code. For example, the value 42 in the number P4210 
indicates that this program belongs to system 42, which is the Sales Order Processing system. XXX The remaining characters of the numer are 
numeric and identify a unique program or report. For example, the value 10 in the number P4210 indicates that this is the Sales Order Entry 
program.

cPayApprovedInvoicesOnlyEV01charNONENONE

An option that specifies the type of processing for an event.

mnGracePeriodDaysGPDMATH_NUMERICNONENONE

A number that the system adds to the invoice due date to extend it for collection purposes. Generally, you specify the number of days 
required for a payment to arrive if it were mailed on the invoice due date. 

cInvoiceMatchPriorityEV02charNONENONE

An option that specifies the type of processing for an event.

cSalesOrderMatchPriorityEV03charNONENONE

A radio button that specifies the level at which trace/track result is to be displayed.  Select the Detail to display all transactions except IB, IX, 
and IZ types.  Or, select Derivative Lots Only to display only those transactions that may have created new derivative lot. 

cCustomerRefMatchPriorityEV04charNONENONE

PeopleSoft event point processing flag 04.

cStatementMatchPriorityEV05charNONENONE

A flag that indicates whether automatic spell check is turned on.

mnTotalPayItemsNINFDMATH_NUMERICNONENONE

The number of invoices that the system located based on the information provided on the remittance form. 

mnTotalAmountOpenAAPMATH_NUMERICNONENONE

The amount of an invoice or voucher pay item that is unpaid.

mnTotalDiscountAvailableADSCMATH_NUMERICNONENONE

The amount of the invoice or voucher pay item that is eligible to be subtracted from the gross amount when the transaction is paid. The 
system calculates discount amounts based on the payment term entered on the transaction.  Note: If the system calculates the discount, verify 
that it applies to the pay item specified. Usually, freight, sales tax, and labor charges that are included in the gross amount do not qualify for 
discounts.

mnTotalDiscountEarnableEDSCMATH_NUMERICNONENONE

The amount of the discount that is taken on or before the discount due date.

cReturnMatchTypeEV06charNONENONE

An option that specifies the type of processing for an event.

szReceiptCurrencyCodeTCRCcharOPTNONE

A code that represents the currency of a receipt when it is different from the base currency of the company for which the receipt was entered.

mnCurrencyConverRateOvCRRMATH_NUMERICOPTNONE

A number (exchange rate) that a foreign currency amount is multiplied by to calculate a domestic currency amount.  The number in this field 
can have a maximum of seven decimal positions. If more are entered, the system adjusts to the nearest seven decimal positions. 

mnTriangulationLeg1CRR1MATH_NUMERICOPTNONE

The exchange rate from the foreign currency of the invoice to the triangulation currency (leg 1). This rate applies when you use triangulation 
to calculate the exchange rate for a receipt.

mnTriangulationLeg2CRR2MATH_NUMERICOPTNONE

The exchange rate from the triangulation currency to the domestic currency (leg 2). This rate applies when you use triangulation to calculate 
the exchange rate for a receipt.

cCurrencyConversionMethodCRCMcharOPTNONE

A value that specifies which method to use when converting from one currency to another. Valid values are:  Y  Multiplier method. The 
system multiplies the foreign amount by the multiplier exchange rate to calculate the domestic amount. Z Divisor method. The system divides the 
foreign amount by the divisor exchange rate to calculate the domestic amount.

jdExchangeRateDateERDJJDEDATEOPTNONE

The date that the system uses to retrieve the exchange rate from the Currency Exchange Rates table (F0015). 

szUserTypeInputCodeUTICcharOPTNONE

A code that specifies how the system processes a transaction during receipts entry. The system will not process transactions with a blank 
or invalid type input.

mnReceiptSpotRateCRRMATH_NUMERICOPTNONE

A number (exchange rate) that a foreign currency amount is multiplied by to calculate a domestic currency amount.  The number in this field 
can have a maximum of seven decimal positions. If more are entered, the system adjusts to the nearest seven decimal positions. 

cShipmentNumberMatchPriorityEV07charOPTNONE

An option that specifies the type of processing for an event.

Related Functions

B0000027 CurrencyConvForAndDom
B03B0158 Maintain Receipts Entry Cache
B03B0172 Maintain Invoice Selection Cache

Related Tables

F03B11 Customer Ledger
F03B21 A/R Notification History Detail