project QadFinancials > class BBankEntry > method GetGLForCurrencyReferenceLC
Description
Gives the gl account where the currency reference lc must be posted on. The sign of the allocation is an input parmater, if it is credit then
On the profit account, it is debit posted, on the loss acount it is credit posted
if it is debit then
On the profit account, it is credit posted, on the loss acount it is debit posted
Parameters
icAllocationCrDt | input | character | sign of the allocation, Debit or Credit |
idAllocationAmountLCForDocCurr | input | decimal | Allocation amount lc for document currency |
idAllocationAmountLCForBankCurr | input | decimal | Allocation Amount LC for bank currency |
ocGLCode | output | character | Gl Code where the currency rate difference must be posted on |
iiCompanyId | input | integer | Company id |
odBankStateAllocDifferenceLC | output | decimal | Difference BC |
ocCurrDifferenceCrDt | output | character | sign of currency difference |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
QadFitnesse
program code (program3/bbankentry.p)
if idAllocationAmountLCForDocCurr = ?
then assign idAllocationAmountLCForDocCurr = 0.
if idAllocationAmountLCForBankCurr = ?
then assign idAllocationAmountLCForBankCurr = 0.
if icAllocationCrDt = ?
then assign icAllocationCrDt = "":U.
if iiCompanyId = ?
then assign iiCompanyId = 0.
if iiCompanyId = 0
then assign iiCompanyId = viCompanyId.
assign idAllocationAmountLCForDocCurr = <M-9 RoundAmount
(input idAllocationAmountLCForDocCurr (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>
idAllocationAmountLCForBankCurr = <M-10 RoundAmount
(input idAllocationAmountLCForBankCurr (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in business>.
if idAllocationAmountLCForDocCurr = idAllocationAmountLCForBankCurr
then do:
assign ocGLCode = "":U
odBankStateAllocDifferenceLC = 0
ocCurrDifferenceCrDt = {&CREDITDEBITABBREVIATION-DEBIT}.
return.
end.
/* Validate input parameters */
if icAllocationCrDt <> {&CREDITDEBITABBREVIATION-CREDIT} and
icAllocationCrDt <> {&CREDITDEBITABBREVIATION-DEBIT}
then do:
assign vcMessage = trim(subst(#T-6'The allocation sign must be of type '&1' or '&2'.':150(303)T-6#, {&CREDITDEBITABBREVIATION-DEBIT-TR}, {&CREDITDEBITABBREVIATION-CREDIT-TR}))
oiReturnStatus = -1.
<M-5 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-774':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
end.
/* Search the profit gl if necessary */
if icAllocationCrDt = {&CREDITDEBITABBREVIATION-CREDIT} and
idAllocationAmountLCForBankCurr > idAllocationAmountLCForDocCurr or
icAllocationCrDt = {&CREDITDEBITABBREVIATION-DEBIT} and
idAllocationAmountLCForBankCurr < idAllocationAmountLCForDocCurr
then do:
<Q-1 run GLByGLSystemType (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input {&GLSYSTEMTYPE-EXCHANGEREALPROFIT}, (GLSystemTypeCode)
input {&GLTYPECODE-SYST}, (GlTypeCode)
input ?, (GlIsDivisionAccount)
output dataset tqGLByGLSystemType) in BGL >
find first tqGLByGLSystemType where
tqGLByGLSystemType.tcGLSystemTypeCode = {&GLSYSTEMTYPE-EXCHANGEREALPROFIT} and
tqGLByGLSystemType.tcGLTypeCode = {&GLTYPECODE-SYST}
no-error.
if not available tqGLByGLSystemType
then do:
assign vcMessage = trim(#T-7'The revaluation account (realized profit) is not defined.':150(304)t-7#)
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-772':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end.
assign vcProfitGLCode = tqGLByGLSystemType.tcGLCode.
end.
/* Search the loss gl if necessary */
if icAllocationCrDt = {&CREDITDEBITABBREVIATION-CREDIT} and
idAllocationAmountLCForBankCurr < idAllocationAmountLCForDocCurr or
icAllocationCrDt = {&CREDITDEBITABBREVIATION-DEBIT} and
idAllocationAmountLCForBankCurr > idAllocationAmountLCForDocCurr
then do:
<Q-3 run GLByGLSystemType (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input {&GLSYSTEMTYPE-EXCHANGEREALLOSS}, (GLSystemTypeCode)
input {&GLTYPECODE-SYST}, (GlTypeCode)
input ?, (GlIsDivisionAccount)
output dataset tqGLByGLSystemType) in BGL >
find first tqGLByGLSystemType where
tqGLByGLSystemType.tcGLSystemTypeCode = {&GLSYSTEMTYPE-EXCHANGEREALLOSS} and
tqGLByGLSystemType.tcGLTypeCode = {&GLTYPECODE-SYST}
no-error.
if not available tqGLByGLSystemType
then do:
assign vcMessage = trim(#T-8'The revaluation account (realized loss) is not defined.':150(305)t-8#)
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-773':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
return.
end.
assign vcLossGLCode = tqGLByGLSystemType.tcGLCode.
end.
/* Check wchich gl must be used */
assign ocGLCode = if icAllocationCrDt = {&CREDITDEBITABBREVIATION-CREDIT}
then if idAllocationAmountLCForBankCurr > idAllocationAmountLCForDocCurr
then vcProfitGLCode
else if idAllocationAmountLCForBankCurr < idAllocationAmountLCForDocCurr
then vcLossGLCode
else "":U
else if idAllocationAmountLCForBankCurr > idAllocationAmountLCForDocCurr
then vcLossGLCode
else if idAllocationAmountLCForBankCurr < idAllocationAmountLCForDocCurr
then vcProfitGLCode
else "":U
ocCurrDifferenceCrDt = if ocGLCode = vcProfitGLCode
then {&CREDITDEBITABBREVIATION-CREDIT}
else {&CREDITDEBITABBREVIATION-DEBIT}
odBankStateAllocDifferenceLC = absolute(idAllocationAmountLCForBankCurr - idAllocationAmountLCForDocCurr).