CombinationInvoiceMatch

Combination Invoice Match Using Cache

Minor Business Rule

Object Name: B03B0119

Parent DLL: CFIN

Location: Client/Server

Language: C

Functional Description

Purpose

The purpose of the Combination Invoice Match Using Cache business function is to match a receipt to a 

combination of invoices up to a pre-determined number of invoices and combinations.  In other words, 

the calling program should specify the maximum number (up to ten) of invoices and the maximum number 

of combinations (up to ten) that may be attempted by the function.  If this information is not 

specified, the function will use the number ten for both the number of invoices and combinations of those 

invoices when attempting a match.


Setup Notes and Prerequisites

None


Special Logic

None



Technical Specification


Parameters

ItemDescription    I/OReq?Notes

PYIDmnRcptPaymentID    IYReceipt 
Payment ID

ICUTszRcptBatchType    IYReceipt 

Batch Type

ICUmnRcptBatchNumber    IYReceipt 

Batch Number

DGJjdRcptGLDate    IYReceipt GL 

Date

DICJjdRcptBatchDate    I Y    Receipt Batch Date

AAPmnRcptOpenAmount    I YReceipt Open 

Amount - Domestic:  should pass AAP; Foreign:  should pass FAP

CRDCszRcptBaseCurrency    I  YReceipt Base 

Currency (for foreign receipts)

CRCDszRcptCurrencyCodeFrom    IYReceipt 

Currency Code (for foreign receipts)

CRRMcRcptCurrencyMode    IYReceipt 

Currency Mode

CRRmnRcptExchangeRate    IYReceipt 

Exchange Rate  (for foreign receipts)

AN8mnRcptCustomerNumber    IYReceipt 

Customer Number

PYRmnRcptPayorNumber    IYReceipt 

Payor Number

DOCmnInvoiceNumber    IYInvoice 

Document Number

DCTszDocumentType    IYInvoice 

Document Type

KCOszInvoiceCompanyKey    IYInvoice 

Document Company

PAAPmnInvoiceTotalOpenAmount      I    Y   Required if want to match to total Open Invoice 

Amt

AGmnInvoiceTotalAvailableAmount   I    Y   Required if want to match to total Avail Invoice 

Amt

AAmnInvoiceTotalEarnableAmount   I    Y   Required if want to match to total Earn Invoice 

Amt

EV01cMatchToOpen    IYPO Value - 

Match to Open (?)

EV02cMatchToAvailable    IYPO Value - 

Match to Open Less Avail (?)

EV03cMatchToEarnable    IYPO Value - 

Match to Open Less Earn (?)

EV04cPerformInvertedProcessing    IYPO Value - 

Perform Inverted Processing;  read oldest invoices first and match receipt to invoices not paid

MATH03      mnRcptEarnableAmount            I    Y    Receipt earnable amount

EV05cUnearnedDiscountMethod    IYPO Value - 

How to handle Unearned Discts -  WO, CB, Partial pay invoice

ARCRszUnearnedReasonCode    IYPO Value - 

must be passed for WO/CBs

INT01nNumberGraceDays    I YPO Value - 

grace days for earned discounts 

INT02nCurrentInvoiceNumber    IYCurrent 

Invoice Number (i.e., should keep running total outside this function of number invoices processed)

INT03nInvoiceCombinationLimit    IYPO Value - 

Maximum combinations that may beattempted by program

EV06cIncludeCreditMemos    IYPO Value - 

Wish to include Credit Memos (?)

EV07cReturnCode    O Returns 

either 'N' (Not Applied) or 'Y' (Applied)

MATH02     mnRcptAvailableAmount           I    Y    Receipt Available amount

EV04       cPartialReceiptStatus           O         '1' means unsuccessfully apply receipt to 

invoices.

ECBR        szChargebackReasonCode          I    N    Reason code for the chargeback. Required if 

chargeback amount is not zero.

DDEX        szReasonCodeforClaim            I    N    Reason code for the deduction. Required if 

deduction amount is not zero.


Related Tables 

F03B11Customer Ledger Table


Related Functions

B03B0012ARApplyReceiptToInvoice

B0000028Soft Round Currency Conversion, Calculate

B0000055F0012 Get AAI Account Number


Processing

Initialize and set up Cache structure and Index.

Get handle to Cache.

Determine the current invoice.


If MatchToEarnable 

If Doing Inverted Processing

If Receipt Earnable Amount EQ  Invoice Total Earnable Amount 
Execute Apply_Inverse_Receipt 
Else
If Rcpt Open Amount EQ Invoice Total Earnable Amount
Execute Apply_Receipt

If MatchToAvailable 

If Doing Inverted Processing

If Rcpt Available Amount EQ Invoice Total Available Amount
Execute Apply_Inverse_Receipt 
Else

If Rcpt Open Amount EQ Invoice Total Available Amount
Execute Apply_Receipt

If MatchToOpen 

If Rcpt Open Amount EQ Invoice Total Open Amount
If Doing Inverted Processing

Execute Apply_Inverse_Receipt 
Else

Execute Apply_Receipt

If Receipt NE to Current Invoice Amounts 

If Including Credit Memos

 ALWAYS Write Current Invoice Totals to Cache
Else

If Receipt GT Current Invoice 

 write to Cache
Else

return "N";

As long as it is NOT First Invoice, Process Current Invoice

Execute Process_Invoice

I_B03B0119_Process_Invoice


Initialize and set up Cache structure and Index.

Get handle to Cache.

Determine the current invoice.

Open Totals Cache - Point to first record in cache

while Record successfully read from the Cache and match the specific criteria

If Record successfully read from the Cache

Save Index of record read

If Index of Current Invoice equal to Index of Record Read from Cache
End of Loop

Else

Concatenate Indexes - Current Invoice index + Cache Index  
If Concatenated Index IS GT Combination Limit 
Skip this Cache record - get next record from Totals Cache

Else

If MatchToEarnable 

If Doing Inverted Processing

If Receipt Earnable Amount EQ Invoice Total Earnable Amount 
Apply_Inverse_Receipt 
Else

If Rcpt Open Amount EQ Invoice Total Earnable Amount
Apply_Receipt

If MatchToAvailable and matchthe specific criteria
If Doing Inverted Processing

If Rcpt Available Amount EQ Invoice  
   Total Available Amount

Apply_Inverse_Receipt
Else

If Rcpt Open Amount EQ Invoice Total Available Amount
Apply_Receipt

If MatchToOpen and match the specific criteria
If Rcpt Open Amount EQ Invoice Total Open   Amount
If Doing Inverted Processing
Apply_Inverse_Receipt
Else

Apply_Receipt

If the process not finished

If Including Credit Memos

ALWAYS Write Current Invoice Totals to Cache
Else

If Receipt GT Current Invoice 
 write to Cache
Else

set process to finished status

Reset the Fetch Cursor and read next record

Close the Cache Cursor

I_B03B0119_Apply_Receipt


Initialize and set up Cache structure and Index.

While loop - Read each Invoice that makes up Index

Open Totals Cache - Point to first record in cache

Read ALL records in Cache matching Invoice
For each pay Item on Invoice

If match type is 'E'

Check for if discount earnable
Calculate domestic and foreign amount with/out discount according  

to the currency mode

Call ARApplyReceiptToInvoice (B03B0012)

If match type is 'A'

Check for if discount earnable
• 
Allow unearned discount
• Monitor unearned discount (create write-off, chargeback, deduction, or leave 
the invoice open)

Calculate domestic and foreign amount with/out discount according to the currency 
mode

Call ARApplyReceiptToInvoice (B03B0012)

If match type is 'O'

Calculate domestic and foreign amount according to the currency mode 
Call ARApplyReceiptToInvoice (B03B0012)

Close the Cache Cursor



I_B03B0119_Apply_Inverse_Receipt


Initialize and set up Cache structure and Index.

Get handle to Cache.

Open Totals Cache - Point to first record in cache

while Record successfully read from the Cache

If Invoice read match the specified criteria

Skip Invoice 

Else

For each pay Item on Invoice

If match type is 'E'

Check for if discount earnable
Calculate domestic and foreign amount with/out discount according to the currency 

mode

Call ARApplyReceiptToInvoice (B03B0012)

If match type is 'A'

Check for if discount earnable
• 
Allow unearned discount
• Monitor unearned discount (create write-off, chargeback, deduction, or leave 
the invoice open)

Calculate domestic and foreign amount with/out discount according to the currency 
mode

Call ARApplyReceiptToInvoice (B03B0012)

If match type is 'O'

Calculate domestic and foreign amount according to the currency mode 
Call ARApplyReceiptToInvoice (B03B0012)

Read next record from the Cache

Close the Cache Cursor.

  



Data Structure

D03B0119 - DS for Combination Invoice Match Using Cache

Purpose
This function data structure is used by Combination Invoice Match Using Cache function.

Parameters

ItemDescription    I/OReq?Notes


PYIDmnRcptPaymentID    IYReceipt 
Payment ID

ICUTszRcptBatchType    IYReceipt 

Batch Type

ICUmnRcptBatchNumber    IYReceipt 

Batch Number

DGJjdRcptGLDate    IYReceipt GL 

Date

DICJjdRcptBatchDate    I Y    Receipt Batch Date

AAPmnRcptOpenAmount    I YReceipt Open 

Amount - Domestic:  should pass AAP; Foreign:  should pass FAP

CRDCszRcptBaseCurrency    I  YReceipt Base 

Currency (for foreign receipts)

CRCDszRcptCurrencyCodeFrom    IYReceipt 

Currency Code (for foreign receipts)

CRRMcRcptCurrencyMode    IYReceipt 

Currency Mode

CRRmnRcptExchangeRate    IYReceipt 

Exchange Rate  (for foreign receipts)

AN8mnRcptCustomerNumber    IYReceipt 

Customer Number

PYRmnRcptPayorNumber    IYReceipt 

Payor Number

DOCmnInvoiceNumber    IYInvoice 

Document Number

DCTszDocumentType    IYInvoice 

Document Type

KCOszInvoiceCompanyKey    IYInvoice 

Document Company

PAAPmnInvoiceTotalOpenAmount      I    Y   Required if want to match to total Open Invoice 

Amt

AGmnInvoiceTotalAvailableAmount   I    Y   Required if want to match to total Avail Invoice 

Amt

AAmnInvoiceTotalEarnableAmount   I    Y   Required if want to match to total Earn Invoice 

Amt

EV01cMatchToOpen    IYPO Value - 

Match to Open (?)

EV02cMatchToAvailable    IYPO Value - 

Match to Open Less Avail (?)

EV03cMatchToEarnable    IYPO Value - 

Match to Open Less Earn (?)

EV04cPerformInvertedProcessing    IYPO Value - 

Perform Inverted Processing;  read oldest invoices first and match receipt to invoices not paid

MATH03      mnRcptEarnableAmount            I    Y    Receipt earnable amount

EV05cUnearnedDiscountMethod    IYPO Value - 

How to handle Unearned Discts -  WO, CB, Partial pay invoice

ARCRszUnearnedReasonCode    IYPO Value - 

must be passed for WO/CBs

INT01nNumberGraceDays    I YPO Value - 

grace days for earned discounts 

INT02nCurrentInvoiceNumber    IYCurrent 

Invoice Number (i.e., should keep running total outside this function of number invoices processed)

INT03nInvoiceCombinationLimit    IYPO Value - 

Maximum combinations that may beattempted by program

EV06cIncludeCreditMemos    IYPO Value - 

Wish to include Credit Memos (?)

EV07cReturnCode    O Returns 

either 'N' (Not Applied) or 'Y' (Applied)

MATH02     mnRcptAvailableAmount           I    Y    Receipt Available amount

EV04       cPartialReceiptStatus           O         '1' means unsuccessfully apply receipt to 

invoices.

ECBR        szChargebackReasonCode          I    N    Reason code for the chargeback. Required if 

chargeback amount is not zero.

DDEX        szReasonCodeforClaim            I    N    Reason code for the deduction. Required if 

deduction amount is not zero.

^

Parameter NameData ItemData TypeReq/OptI/O/Both
mnRcptPaymentIDPYIDMATH_NUMERICNONENONE

Item       Description           I/Oab Req?   Notes
PYIDab       mnRcptPaymentIDab    Iab    Y  ab    Receipt Payment ID


^

szRcptBatchTypeICUTcharNONENONE

Itemab Description          I/Oab Req?    Notes
ICUTab szRcptBatchType      Iab  Yab      Receipt Batch Type

^

mnRcptBatchNumberICUMATH_NUMERICNONENONE

Itemab  Descriptionab I/O    Req?ab  Notes
ICUab  mnRcptBatchNumberab  Iab     Yab  Receipt Batch Number

^

jdRcptGLDateDGJJDEDATENONENONE

Itemab Description       I/O    Req?ab   Notes
DGJab jdRcptGLDate      I     Y  ab      Receipt GL Date

^

jdRcptBatchDateDICJJDEDATENONENONE

Itemab Description          I/Oab  Req?   Notes
DICJab jdRcptBatchDate     I  ab  Y      Receipt Batch Date

^

mnRcptOpenAmountAAPMATH_NUMERICNONENONE

Itemab Description             I/Oab      Req?ab Notes
AAPab mnRcptOpenAmount       I  ab      Yab Receipt Open Amount - Domestic:  should pass AAP; Foreign:  
should pass FAP


^

szRcptBaseCurrencyCRDCcharNONENONE

Itemab  Descriptionab I/O   Req?ab Notes
CRDCab  szRcptBaseCurrencyab I     Yab Receipt Base Currency (for foreign receipts)

^

szRcptCurrencyCodeFromCRCDcharNONENONE

Itemab  Descriptionab  ab I/O    Req?ab Notes
CRCDab  szRcptCurrencyCodeFromab   ab I      Yab      Receipt Currency Code (for foreign receipts)

^

cRcptCurrencyModeCRRMcharNONENONE

Itemab  Descriptionab I/O    Req?   Notes
CRRMab  cRcptCurrencyModeab I       Yab    Receipt Currency Mode

^

mnRcptExchangeRateCRRMATH_NUMERICNONENONE

Itemab  Descriptionab I/O   Req?ab  Notes
CRR    ab  mnRcptExchangeRateab    Iab    Yab   Receipt Exchange Rate  (for foreign receipts)


^

mnRcptCustomerNumberAN8MATH_NUMERICNONENONE

Itemab  Descriptionab  ab I/O    Req?ab Notes
AN8ab  mnRcptCustomerNumberab   ab I      Yab      Receipt Customer Number

^

mnRcptPayorNumberPYRMATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
PYRab  mnRcptPayorNumberab   ab     Iab  Yab Receipt Payor Number

^

mnInvoiceNumberDOCMATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
DOCab  mnInvoiceNumberab   ab     Iab  Yab Invoice Document Number

^

szDocumentTypeDCTcharNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
DCTab  szDocumentTypeab   ab     Iab  Yab Invoice Document Type

^

szInvoiceCompanyKeyKCOcharNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
KCOab  szInvoiceCompanyKeyab   ab     Iab  Yab Invoice Document Company

^

mnInvoiceTotalOpenAmountPAAPMATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
PAAPab  mnInvoiceTotalOpenAmountab       I    Y   Required if want to match to total Open Invoice Amt


^

mnInvoiceTotalAvailableAmountAGMATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
AGab mnInvoiceTotalAvailableAmount   I    Y   Required if want to match to total Avail Invoice Amt

^

mnInvoiceTotalEarnableAmountAAMATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
AAab  mnInvoiceTotalEarnableAmountab    I    Y   Required if want to match to total Earn Invoice Amt


^

cMatchToOpenEV01charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
  EV01ab  cMatchToOpenab  ab     Iab  Yab PO Value - Match to Open (?)


^

cMatchToAvailableEV02charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV02ab  cMatchToAvailableab  ab     Iab  Yab PO Value - Match to Open Less Avail (?)


^

cMatchToEarnableEV03charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV03ab  cMatchToEarnableab  ab     Iab  Yab PO Value - Match to Open Less Earn (?)


^

cPerformInvertedProcessingEV04charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV04ab  cPerformInvertedProcessingab  ab     Iab  Yab PO Value - Perform Inverted Processing;  read 
oldest invoices first and match receipt to invoices not paid



^

cUnearnedDiscountMethodEV05charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV05ab  cUnearnedDiscountMethodab  ab     Iab  Yab PO Value - How to handle Unearned Discts -  WO, CB, 
Partial pay invoice


^

szUnearnedReasonCodeARCRcharNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
ARCRab  szUnearnedReasonCodeab  ab     Iab  Yab PO Value - must be passed for WO


^

nNumberGraceDaysINT01integerNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
INT01ab  nNumberGraceDaysab  ab    I  ab  Yab PO Value - grace days for earned discounts 


^

nCurrentInvoiceNumberINT02integerNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
INT02ab  nCurrentInvoiceNumberab  ab     Iab  Yab Current Invoice Number (i.e., should keep running total 
outside this function of number invoices processed)



^

nInvoiceCombinationLimitINT03integerNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
INT03ab  nInvoiceCombinationLimitab  ab     Iab  Yab PO Value - Maximum combinations that may  beab 
attempted by program



^

cIncludeCreditMemosEV06charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV06ab  cIncludeCreditMemosab  ab     Iab  Yab PO Value - Wish to include Credit Memos (?)


^

cReturnCodeEV07charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV07ab  cReturnCodeab  ab     Oab  ab Returns either 'N' (Not Applied) or 'Y' (Applied)

^

mnRcptAvailableAmountMATH02MATH_NUMERICNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
MATH02      mnRcptAvailableAmount           I    Y    Receipt Available amount


^

mnRcptEarnableAmountMATH03MATH_NUMERICNONENONE

Itemab Description                  I/O  Req?   Notes MATH03      mnRcptEarnableAmount         I    Y 
   Receipt earnable amount


^

cPartialReceiptStatusEV04charNONENONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
EV04        cPartialReceiptStatus           O         '1' means unsuccessfully apply receipt to 
invoices.



^

szChargebackReasonCodeECBRcharOPTNONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
ECBR        szChargebackReasonCode          I    N    Reason code for the chargeback. Required if 

chargeback amount is not zero.


^

szReasonCodeforClaimDDEXcharOPTNONE

Itemab  Descriptionab  ab     I/Oab  Req?ab Notes
DDEX        szReasonCodeforClaim            I    N    Reason code for the deduction. Required if 

deduction amount is not zero.




^

szDiscountReasonCodeDRCOcharOPTNONE

A code that specifies the reason that a discount is given.

Related Functions

B0000028 CurrencyConvSftRound
B0000055 ValidateAAICompletely
B03B0012 F03B14 Apply Receipt to Invoice

Related Tables

F03B11 Customer Ledger
left: 0.500000in">Else

If Rcpt Open Amount EQ Invoice Total Available Amount
Apply_Receipt

If MatchToOpen and match the specific criteria
If Rcpt Open Amount EQ Invoice Total Open   Amount
If Doing Inverted Processing