project QadFinancials > class BQCrossCyPosting > method ApiProcessQCrossCyPostingCalcAmount
Description
Calculate LC and C amounts based on TC
Parameters
odDebitLC | output | decimal | |
odCreditLC | output | decimal | |
odDebitCC | output | decimal | |
odCreditCC | output | decimal | |
odDebitTC | output | decimal | |
odCreditTC | output | decimal | |
odTCLCExchangeRate | output | decimal | |
odTCLCExchangeRateScale | output | decimal | |
odTCCCExchangeRate | output | decimal | |
odTCCCExchangeRateScale | output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bqcrosscyposting.p)
assign oiReturnStatus = -98
viLocalReturn = 0.
MAIN_BLOCK:
do:
/* Precondition */
if not available tQCrossCyPosting
then do:
assign vcMessage = #T-94'Missing record':255(69247)T-94#.
<M-80 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-363438':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
assign viLocalReturn = -1.
leave MAIN_BLOCK.
end.
/* Assign TC amounts */
assign odDebitTC = if tQCrossCyPosting.CrossCompanyGLIsCredit = false
then tQCrossCyPosting.QCrossCyPostingAmountTC
else 0
odCreditTC = if tQCrossCyPosting.CrossCompanyGLIsCredit = true
then tQCrossCyPosting.QCrossCyPostingAmountTC
else 0.
/* Calculate LC amounts */
if tQCrossCyPosting.QCrossCyPostingAmountLC = 0 or
tQCrossCyPosting.QCrossCyPostingAmountLC = ?
then do:
if tQCrossCyPosting.Currency_ID = viCompanyLCId
then assign odDebitLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = false
then tQCrossCyPosting.QCrossCyPostingAmountTC
else 0
odCreditLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = true
then tQCrossCyPosting.QCrossCyPostingAmountTC
else 0
odTCLCExchangeRate = 1
odTCLCExchangeRateScale = 1.
else do :
<M-56 run GetExchangeRate
(input ? (iiCompanyID),
input viCompanyLCId (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input tQCrossCyPosting.Currency_ID (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input tqPostingByPostingId.ttPostingDate (itValidityDate),
output odTCLCExchangeRate (odExchangeRate),
output odTCLCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturn = 0) then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
assign odDebitLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = false
then <M-1 RoundAmount
(input tQCrossCyPosting.QCrossCyPostingAmountTC / (odTCLCExchangeRate * odTCLCExchangeRateScale) (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BQCrossCyPosting>
else 0
odCreditLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = true
then <M-2 RoundAmount
(input tQCrossCyPosting.QCrossCyPostingAmountTC / (odTCLCExchangeRate * odTCLCExchangeRateScale) (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BQCrossCyPosting>
else 0.
end.
end. /* if tQCrossCyPosting.QCrossCyPostingAmountLC = 0 or */
else assign odDebitLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = false
then tQCrossCyPosting.QCrossCyPostingAmountLC
else 0
odCreditLC = if tQCrossCyPosting.CrossCompanyGLIsCredit = true
then tQCrossCyPosting.QCrossCyPostingAmountLC
else 0
odTCLCExchangeRate = tQCrossCyPosting.QCrossCyPostingAmountTC / tQCrossCyPosting.QCrossCyPostingAmountLC
odTCLCExchangeRateScale = 1.
/* Calculate CC amounts */
if tQCrossCyPosting.QCrossCyPostingAmountCC = 0 or
tQCrossCyPosting.QCrossCyPostingAmountCC = ?
then do:
if vlDomainIsStatutory = false
then assign odDebitCC = odDebitLC
odCreditCC = odCreditLC.
else if tQCrossCyPosting.Currency_ID = viCompanyCCId
then assign odDebitCC = odDebitTC
odCreditCC = odCreditTC
odTCCCExchangeRate = 1
odTCCCExchangeRateScale = 1.
else do:
<M-73 run GetExchangeRate
(input ? (iiCompanyID),
input tQCrossCyPosting.Currency_ID (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input tqPostingByPostingId.ttPostingDate (itValidityDate),
output odTCCCExchangeRate (odExchangeRate),
output odTCCCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturn = 0) then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
assign odDebitCC = <M-3 RoundAmount
(input odDebitTC * odTCCCExchangeRate * odTCCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BQCrossCyPosting>
odCreditCC = <M-4 RoundAmount
(input odCreditTC * odTCCCExchangeRate * odTCCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BQCrossCyPosting>.
end.
end. /* if tQCrossCyPosting.QCrossCyPostingAmountCC = 0 or */
else assign odDebitCC = if tQCrossCyPosting.CrossCompanyGLIsCredit = false
then tQCrossCyPosting.QCrossCyPostingAmountCC
else 0
odCreditCC = if tQCrossCyPosting.CrossCompanyGLIsCredit = true
then tQCrossCyPosting.QCrossCyPostingAmountCC
else 0.
end. /* MAIN_BLOCK */
assign oiReturnStatus = viLocalReturn.