project QadFinancials > class BDDocument > method AdditionalUpdatesPostingDocCtrl3
Description
This method will calculate and post the Transaction Currency and Base Currency Exchange Gain(Loss).
It will also calculate and post Transaction Currency and Statutory Currency Exchange Gain(Loss).
It also returns the bank debit amount TC based on the currency with which the GL was defined.
Parameters
odBankDebitTC | output | decimal | |
odBankDebitLC | output | decimal | |
odBankDebitCC | output | decimal | |
icPostingRowid | input | character | |
icAllocationKey | input | character | |
odBankLCExchangeRate | output | decimal | |
odBankLCExchangeRateScale | output | decimal | |
odBankCCExchangeRate | output | decimal | |
odBankCCExchangeRateScale | output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bddocument.p)
BLOCKINITAMOUNT: DO:
if vcActivityCode = "Modify":U
then assign vtValidityDate = today.
else assign vtValidityDate = tDDocument.ttPostingDate.
/* ======================================================================= */
/* Get the exchange rate between the document currency and the LC currency */
/* ======================================================================= */
if tDDocument.tcCurrencyCode = vcCompanyLC
then assign odBankLCExchangeRate = 1
odBankLCExchangeRateScale = 1
odBankDebitLC = tDDocument.DDocumentOriginalDebitTC.
else do:
<M-63 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input tDDocument.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input vtValidityDate (itValidityDate),
output odBankLCExchangeRate (odExchangeRate),
output odBankLCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign odBankDebitLC = <M-37 RoundAmount
(input tDDocument.DDocumentOriginalDebitTC * odBankLCExchangeRate * odBankLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.
end.
/* ====================================================================== *
* LC Exchange rate *
* ====================================================================== */
if tDDocument.tcCurrencyCode <> vcCompanyLC
then do:
assign vdTotalAmountLC = 0.
for each tDivisionDDoc:
assign vdTotalAmountLC = vdTotalAmountLC + tDivisionDDoc.tdAmountLC.
end.
/* Create posting on the Realiced Exchange rate Gain/Loos account */
if vdTotalAmountLC <> odBankDebitLC
then do:
/* Get GL accout for Realized exchange rate Gain/Lose */
assign vhFcComponent = ?.
<M-87 run GetGLForCurrencyReferenceLC
(input {&CREDITDEBITABBREVIATION-CREDIT} (icAllocationCrDt),
input tDDocument.DDocumentOriginalDebitLC (idAllocationAmountLCForDocCurr),
input odBankDebitLC (idAllocationAmountLCForBankCurr),
output vcExchGainLossGL (ocGLCode),
input ? (iiCompanyId),
output vdDifference (odBankStateAllocDifferenceLC),
output vcCurrDifferenceCrDt (ocCurrDifferenceCrDt),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
<M-31 run AddStandardPosting
(input icPostingRowid (icPostingtcRowid),
input vcExchGainLossGL (icGLCode),
input '':U (icDivisionCode),
input '':U (icCostCentreCode),
input '':U (icCostCentreText),
input '':U (icProjectCode),
input '':U (icProjectText),
input '':U (icIntercoBusinessRelationCode),
input tDDocument.tcCurrencyCode (icCurrencyCode),
input 0 (idDebitTC),
input if vcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT} then vdDifference else 0 (idDebitLC),
input 0 (idDebitCC),
input 0 (idDebitPC),
input 0 (idCreditTC),
input if vcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT} then vdDifference else 0 (idCreditLC),
input 0 (idCreditCC),
input 0 (idCreditPC),
input 0 (idQty),
input tDDocument.tcPostingText (icLineText),
input '':U (icSafText),
input tDefaultSafsDDoc (tDefaultSafs),
input '':U (icExchangeRateType),
input odBankLCExchangeRate (idExchangeRate),
input odBankLCExchangeRateScale (idExchangeRateScale),
input ? (idPostingLineCCRate),
input ? (idPostingLineCCScale),
output viPostingLineId (oiPostingLineId),
input 0 (iiSafStructureId),
input '':U (icSafStructureCode),
input icAllocationKey (icAllocationKey),
input false (ilLinkedCrCyDaemonReqExists),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* if vdTotalAmountLC <> odBankDebitLC */
end. /* if tDDocument.tcCurrencyCode <> vcCompanyLC */
/* ======================================================================= */
/* Get the exchange rate between the document currency and the LC currency */
/* ======================================================================= */
if tDDocument.tcCurrencyCode = vcCompanyCC
then assign odBankCCExchangeRate = 1
odBankCCExchangeRateScale = 1
odBankDebitCC = tDDocument.DDocumentOriginalDebitTC.
else if not vlDomainIsStatutory
then assign odBankCCExchangeRate = odBankLCExchangeRate
odBankCCExchangeRateScale = odBankCCExchangeRateScale
odBankDebitCC = odBankDebitLC.
else do:
<M-42 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input tDDocument.tcCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input vtValidityDate (itValidityDate),
output odBankCCExchangeRate (odExchangeRate),
output odBankCCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign odBankDebitCC = <M-89 RoundAmount
(input tDDocument.DDocumentOriginalDebitTC * odBankCCExchangeRate * odBankCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.
end.
/* ====================================================================== *
* CC Exchange rate Gain/Loss *
* ====================================================================== */
if tDDocument.tcCurrencyCode <> vcCompanyCC
then do:
assign vdTotalAmountCC = 0.
for each tDivisionDDoc:
assign vdTotalAmountCC = vdTotalAmountCC + tDivisionDDoc.tdAmountCC.
end.
/* Create posting on the Realiced Exchange rate Gain/Loos account */
if vdTotalAmountCC <> odBankDebitCC
then do:
assign vhFcComponent = ?.
<M-11 run GetGLForCurrencyReferenceLC
(input {&CREDITDEBITABBREVIATION-CREDIT} (icAllocationCrDt),
input tDDocument.DDocumentOriginalDebitCC (idAllocationAmountLCForDocCurr),
input odBankDebitCC (idAllocationAmountLCForBankCurr),
output vcExchGainLossGL (ocGLCode),
input ? (iiCompanyId),
output vdDifference (odBankStateAllocDifferenceLC),
output vcCurrDifferenceCrDt (ocCurrDifferenceCrDt),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
<M-12 run AddStandardPosting
(input icPostingRowid (icPostingtcRowid),
input vcExchGainLossGL (icGLCode),
input '':U (icDivisionCode),
input '':U (icCostCentreCode),
input '':U (icCostCentreText),
input '':U (icProjectCode),
input '':U (icProjectText),
input '':U (icIntercoBusinessRelationCode),
input tDDocument.tcCurrencyCode (icCurrencyCode),
input 0 (idDebitTC),
input 0 (idDebitLC),
input if vcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT} then vdDifference else 0 (idDebitCC),
input 0 (idDebitPC),
input 0 (idCreditTC),
input 0 (idCreditLC),
input if vcCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-CREDIT} then vdDifference else 0 (idCreditCC),
input 0 (idCreditPC),
input 0 (idQty),
input tDDocument.tcPostingText (icLineText),
input '':U (icSafText),
input tDefaultSafsDDoc (tDefaultSafs),
input '':U (icExchangeRateType),
input 0 (idExchangeRate),
input 0 (idExchangeRateScale),
input odBankCCExchangeRate (idPostingLineCCRate),
input odBankCCExchangeRateScale (idPostingLineCCScale),
output viPostingLineId (oiPostingLineId),
input 0 (iiSafStructureId),
input '':U (icSafStructureCode),
input icAllocationKey (icAllocationKey),
input false (ilLinkedCrCyDaemonReqExists),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end. /* if vdTotalAmountCC <> odBankDebitCC */
end. /* if tCDocument.tcCurrencyCode <> tqDomainForInterCompany.tcStatutoryCurrencyCode */
/* ============================================================================= */
/* Assign the Bank TC amount based on the currency with which the GL was defined */
/* ============================================================================= */
<Q-13 run GLForCurrency (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (GLId)
input tDDocument.tcGLCode, (GLCode)
output dataset tqGLForCurrency) in BGL >
find first tqGLForCurrency
where tqGLForCurrency.tcGLCode = tDDocument.tcGLCode
no-error.
if available tqGLForCurrency
then do:
if (tqGLForCurrency.tcCurrencyCode = "" or
tqGLForCurrency.tcCurrencyCode = ?) and
tqGLForCurrency.tlGLIsLocalCurrency
then assign tqGLForCurrency.tcCurrencyCode = vcCompanyLC.
if tqGLForCurrency.tcCurrencyCode = tDDocument.tcCurrencyCode
then do:
assign odBankDebitTC = tDDocument.DDocumentOriginalDebitTC.
leave BLOCKINITAMOUNT.
end.
else if tqGLForCurrency.tcCurrencyCode = vcCompanyLC
then do:
assign odBankDebitTC = odBankDebitLC.
leave BLOCKINITAMOUNT.
end.
else if tqGLForCurrency.tcCurrencyCode = vcCompanyCC
then do:
assign odBankDebitTC = odBankDebitCC.
leave BLOCKINITAMOUNT.
end.
else do:
<M-43 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input tDDocument.tcCurrencyCode (icFromCurrencyCode),
input ? (iiToCurrencyID),
input tqGLForCurrency.tcCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input vtValidityDate (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateSCale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
assign odBankDebitTC = <M-22 RoundAmount
(input tDDocument.DDocumentOriginalDebitTC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input 0 (iiCurrencyID),
input tqGLForCurrency.tcCurrencyCode (icCurrencyCode)) in BApplicationProperty>.
end. /* else do: */
end. /* if available tqGLForCurrency */
end. /* BLOCKINITAMOUNT: DO: */