CalculateAmountToPay

Calculate Amount to Pay

Minor Business Rule

Object Name: B03B0028

Parent DLL: CFIN

Location: Client/Server

Language: C

Functional Description  B03B0028

Purpose


Function will calculate the amount to pay and discount to take when applying a receipt to a specific 

invoice. Used in Auto Cash algorithm Balance Forward.



Setup Notes and Prerequisites

None.

Special Logic

None.


Technical Specification


Parameters

Item  DescriptionI/OReq?Notes

AAPmnInvoiceAmountOpenIYes
FAPmnInvoiceAmountForeignOpenIYes

ADSCmnInvoiceAmtDiscountAvailableIYes

CDSmnInvoiceForeignDiscountAvailIYes

DDNJjdInvoiceDateDiscountDueIYes

CRRMcReceiptCurrencyModeIYes

DGJjdReceiptGLDateIYes

EV01cReceiptAllowDiscountTakenIYes

EV02cReceiptApplyDueDateIYes

CRRmnReceiptCurrencyConvRateIYes

CRCDszReceiptCurrencyCodeFromIYes

AAPmnReceiptAmountOpenIYes

FAPmnReceiptAmountForeignOpenIYes

AAPmnAmountToApplyIYes

FAPmnForeignAmountToApplyIYes

ADSAmnDiscountToApplyIYes

CDSAmnForeignDiscountToApplyIYes

CRRmnInvoiceCurrencyConvRateIYes

COszReceiptCompanyIYes




Related Tables

None



Related Functions

B0000027CurrencyConvForAndDom


Processing


If allowing discount to be taken (processing option) :

If processing option set to check discount due date Only allow discount if discount due date 
later or equal to receipt G/L date.


Test if sufficient funds to fully pay invoice (including discount) and if so allow discount.


Calculate amount to apply as:


Invoice open amount minus discount allowed (if this resulting amount is less than or equal to 
the receipt open amount remaining). 


Receipt open amount remaining  (if this amount is less than the invoice open amount minus 

discount allowed).


If a foreign receipt and foreign amount to apply is not zero and receipt exchange rate is 
different to invoice exchange rate:


Call external function B0000027 to recalculate domestic amount applied (at receipt exchange 

rate).


reset domestic amount to apply to amount returned from B0000027.


Check that amount to apply is not more than receipt open amount, if so set it equal (to receipt 

open amount).


This can occur when receipt and invoice exchange rates are different (i.e. there is a currency 

gain/loss) and domestic open amount remaining is zero while foreign isn't (or vice versa).



Data Structure

D03B0028 - Calculate Amount to Pay

Item  DescriptionI/OReq?Notes
AAP  mnInvoiceAmountOpenIYesInvoice Open amount domestic
FAP  mnInvoiceAmountForeignOpenIYesInvoice open amount foreign

ADSC  mnInvoiceAmtDiscountAvailaIYesInvoice discount available doemsitc

CDS  mnInvoiceForeignDiscountAvIYesInvoice discount available foeign

DDNJ  jdInvoiceDateDiscountDueIYesInvoice discount due date

CRRM  cReceiptCurrencyModeIYesReceipt currency mode F/D

DGJ  jdReceiptGLDateIYesReceipt G/L date

EV01  cReceiptAllowDiscountTakenIYesProcessing Option if all discounts are to be taken 1- 

allow discounts other wise no discounts are to be taken

EV02  cReceiptApplyDueDateIYesProcessing option 1- Take only earned discounts Other 

wise take all discounts

CRR  mnReceiptCurrencyConvRateIYesReceipt exchange rate

CRCD  szReceiptCurrencyCodeFromIYesReceipt currency code

AAP  mnReceiptAmountOpenIYesReceipt open amount domestic

FAP  mnReceiptAmountForeignOpenIYesReceipt open amount foreign

AAP  mnAmountToApplyOYesAmount to apply to invoice domestic

FAP  mnForeignAmountToApplyOYesAmount to apply to invoice foreign

ADSA  mnDiscountToApplyOYesAmount of discount to take domestic

CDSA  mnForeignDiscountToApplyOYesAmount of discount to take foreign

CRR  mnInvoiceCurrencyConvRateIYesInvoice exchange rate

CO  szReceiptCompanyNNAParm not used

MATH01  mnMaxAutoCreditWrOffNNAParm not used                

CRR  mnRecTriangulationRate1IYesReceipt Triangulation leg 1 Euro 

CRR  mnRecTriangulationRate2 IYesReceipt Triangulation leg 2 Euro 

CRCM  cRecCurrencyConversionMethIYesReceipt currency conversion method Euro      

EFT  jdRecDateEffectiveRatesIYesReceipt exchange rate effective date Euro             


CRR  mnInvTriangulationRate1IYesInvoice Triangulation leg 1 Euro           

CRR  mnInvTriangulationRate2IYesInvoice Triangulation leg 2 Euro                 

CRCM  cInvCurrencyConversionMethIYesInvoice currency conversion method Euro         

EFT  jdInvTransactionDate IYesReceipt exchange rate effective date Euro             



^

Parameter NameData ItemData TypeReq/OptI/O/Both
mnInvoiceAmountOpenAAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
AAPab    mnInvoiceAmountOpenab  ab  Iab  Yesab Invoice Open amount domestic

^

mnInvoiceAmountForeignOpenFAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
FAPab    mnInvoiceAmountForeignOpenab  Iab  Yesab Invoice open amount foreign

^

mnInvoiceAmtDiscountAvailableADSCMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
ADSCab    mnInvoiceAmtDiscountAvailaab  Iab  Yesab Invoice discount available doemsitc

^

mnInvoiceForeignDiscountAvailCDSMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CDSab    mnInvoiceForeignDiscountAvab  Iab  Yesab Invoice discount available foeign

^

jdInvoiceDateDiscountDueDDNJJDEDATENONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
DDNJab    jdInvoiceDateDiscountDueab  Iab  Yesab Invoice discount due date

^

cReceiptCurrencyModeCRRMcharNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRMab    cReceiptCurrencyModeab  ab  Iab  Yesab Receipt currency mode F/D

^

jdReceiptGLDateDGJJDEDATENONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
DGJab    jdReceiptGLDateab  ab  ab  Iab  Yesab Receipt G/L date

^

cReceiptAllowDiscountTakenEV01charNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
EV01ab    cReceiptAllowDiscountTakenab  Iab  Yesab Processing Option if all discounts are to be taken 1- 
allow discounts other wise no discounts are to be taken


^

cReceiptApplyDueDateEV02charNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
EV02ab    cReceiptApplyDueDateab  ab  Iab  Yesab Processing option 1- Take only earned discounts Other 
wise take all discounts


^

mnReceiptCurrencyConvRateCRRMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab    mnReceiptCurrencyConvRateab  Iab  Yesab Receipt exchange rate

^

szReceiptCurrencyCodeFromCRCDcharNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRCDab    szReceiptCurrencyCodeFromab  Iab  Yesab Receipt currency code

^

mnReceiptAmountOpenAAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
AAPab    mnReceiptAmountOpenab  ab  Iab  Yesab Receipt open amount domestic

^

mnReceiptAmountForeignOpenFAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
FAPab    mnReceiptAmountForeignOpenab  Iab  Yesab Receipt open amount foreign

^

mnAmountToApplyAAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
AAPab    mnAmountToApplyab  ab  ab  Oab  Yesab Amount to apply to invoice domestic

^

mnForeignAmountToApplyFAPMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
FAPab    mnForeignAmountToApplyab  Oab  Yesab Amount to apply to invoice foreign

^

mnDiscountToApplyADSAMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
ADSAab    mnDiscountToApplyab  ab  Oab  Yesab Amount of discount to take domestic

^

mnForeignDiscountToApplyCDSAMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CDSAab    mnForeignDiscountToApplyab  Oab  Yesab Amount of discount to take foreign

^

mnInvoiceCurrencyConvRateCRRMATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab    mnInvoiceCurrencyConvRateab  Iab  Yesab Invoice exchange rate

^

szReceiptCompanyCOcharNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
COab    szReceiptCompanyab  ab  Nab  NAab Parm not used

^

mnMaxAutoCreditWrOffMATH01MATH_NUMERICNONENONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
MATH01   mnMaxAutoCreditWrOffab  ab  Nab  NAab Parm not used                

^

mnRecTriangulationRate1CRRMATH_NUMERICOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab    mnRecTriangulationRate1ab  Iab  Yesab Receipt Triangulation leg 1 Euro 

^

mnRecTriangulationRate2CRRMATH_NUMERICOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab   mnRecTriangulationRate2  ab  Iab  Yesab Receipt Triangulation leg 2 Euro 

^

cRecCurrencyConversionMethodCRCMcharOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRCMab    cRecCurrencyConversionMethab  Iab  Yesab Receipt currency conversion method Euro      

^

jdRecDateEffectiveRatesEFTJDEDATEOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
EFTab    jdRecDateEffectiveRatesab  Iab  Yesab Receipt exchange rate effective date Euro             

^

mnInvTriangulationRate1CRRMATH_NUMERICOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab    mnInvTriangulationRate1ab  Iab  Yesab Invoice Triangulation leg 1 Euro           

^

mnInvTriangulationRate2CRRMATH_NUMERICOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRRab    mnInvTriangulationRate2ab  Iab  Yesab Invoice Triangulation leg 2 Euro                 

^

cInvCurrencyConversionMethodCRCMcharOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
CRCMab    cInvCurrencyConversionMethab  Iab  Yesab Invoice currency conversion method Euro         

^

jdInvTransactionDateEFTJDEDATEOPTNONE

Itemab    Descriptionab  ab  ab  I/Oab  Req?ab Notes
EFTab   jdInvTransactionDate  ab  ab  Iab  Yesab Receipt exchange rate effective date Euro             

^

Related Functions

B0000027 CurrencyConvForAndDom

Related Tables

None