Description
Gets the necessary GL information, needed in Cash Box
Parameters
iiGLId | input | integer | GLId |
icGLCode | input | character | GL Account |
ocGLDescription | output | character | GLDescription |
ocCurrencyCode | output | character | Currency Code |
ocCashInJournalCode | output | character | CashInJournalCode |
ocCashInJournalLayerCode | output | character | CashInJournalLayerCode |
ocCashOutJournalCode | output | character | CashOutJournalCode |
ocCashOutJournalLayerCode | output | character | CashOutJournalLayerCode |
odBalanceTC | output | decimal | Balance in TC |
odBalanceLC | output | decimal | Balance in LC |
odBalanceCC | output | decimal | Balance in CC |
odBalanceGLCurr | output | decimal | Balance in GL Currency |
odUnallocStatBalance | output | decimal | Balance of all Unallocated lines |
odBankStateOpeningBalance | output | decimal | BankStateOpeningBalance |
odExchangeRate | output | decimal | ExchangeRate |
odExchangeRateScale | output | decimal | ExchangeRateScale |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program4/bcashbox.p)
if iiGLId = ?
then assign iiGLId = 0.
if icGLCode = ?
then assign icGLCode = "":U.
if iiGLId = 0 and
icGLCode = "":U
then return.
<Q-17 run GLByGLForCashInfo (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiGLId, (GLID)
input if iiGLId = 0 then icGLCode else '':U, (GLCode)
output dataset tqGLByGLForCashInfo) in BGL >
find first tqGLByGLForCashInfo
no-error.
if not available tqGLByGLForCashInfo
then do:
assign vcMessage = trim(#T-18'Check that you have entered a cash account, and that you have set up the cash journal profiles correctly.':250(64244)T-18#)
oiReturnStatus = -1.
<M-19 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-6124':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
return.
end.
/* FIN-199 */
if tqGLByGLForCashInfo.tcAPDiscountGLCode = "":U or
tqGLByGLForCashInfo.tcAPDiscountGLCode = ?
then do:
assign vcMessage = trim(substitute(#T-20'The AP discount account was not specified for cash account &1.':150(999890407)T-20#, tqGLByGLForCashInfo.tcGlcode))
oiReturnStatus = -1.
<M-22 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-9085':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
Return.
end.
if tqGLByGLForCashInfo.tcARDiscountGLCode = "":U or
tqGLByGLForCashInfo.tcARDiscountGLCode = ?
then do:
assign vcMessage = trim(substitute(#T-21'The AR discount account was not specified for cash account &1.':150(999890409)T-21#, tqGLByGLForCashInfo.tcGlcode))
oiReturnStatus = -1.
<M-23 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-9086':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
Return.
end.
assign ocCurrencyCode = if tqGLByGLForCashInfo.tcCurrencyCode = "":U
then vcCompanyLC
else tqGLByGLForCashInfo.tcCurrencyCode
ocGLDescription = tqGLByGLForCashInfo.tcGLDescription
ocCashInJournalCode = tqGLByGLForCashInfo.tcCashInJournalCode
ocCashInJournalLayerCode = tqGLByGLForCashInfo.tcCashInLayerTypeCode
ocCashOutJournalCode = tqGLByGLForCashInfo.tcCashOutJournalCode
ocCashOutJournalLayerCode = tqGLByGLForCashInfo.tcCashOutLayerTypeCode.
/* Get GL account Balance */
assign vhFcComponent = ?.
<M-7 run ApiGetAccountBalance
(input 9999 (iiAccYear),
input 99 (iiAccPeriod),
input tqGLByGLForCashInfo.tiGL_ID (iiGL_ID),
input '':U (icGLCode),
input viCompanyId (iiCompanyID),
input '':U (icCompanyCode),
output odBalanceLC (odBalanceLC),
output odBalanceCC (odBalanceCC),
output odBalanceTC (odBalanceTC),
output viFcReturnSuper (oiReturnStatus)) in BGL>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
if ocCurrencyCode = vcCompanyLC
then assign odBalanceGLCurr = odBalanceLC.
else if ocCurrencyCode = vcCompanyCC
then assign odBalanceGLCurr = odBalanceCC.
else do:
/* try to find an exchange rate of type CASH or the fallback type */
<M-32 run GetExchangeRate
(input ? (iiCompanyID),
input viCompanyLCId (iiFromCurrencyID),
input ? (icFromCurrencyCode),
input ? (iiToCurrencyID),
input ocCurrencyCode (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-CASH} (icExchangeRateTypeCode),
input today (itValidityDate),
output vdExchangeRate (odExchangeRate),
output vdExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
/* calculate the balance if the rate was retrieved correctly */
assign odBalanceGLCurr = <M-15 RoundAmount
(input odBalanceLC * vdExchangeRate * vdExchangeRateScale (idUnroundedAmount),
input ? (iiCurrencyID),
input ocCurrencyCode (icCurrencyCode)) in business>.
end. /* if ocCurrencyCode = vcCompanyLC */
/* Calculate unallocated statement balance */
<Q-10 run BankStateByGLBankStateNbr (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (MinBankStateNumber)
input tqGLByGLForCashInfo.tiGL_ID, (GLID)
input {&BANKSTATELINESTATUS-UNALLOC}, (BankStateLineStatus)
input '':U, (GLCode)
input {&BANKSTATESTATUS-PARTALLOC}, (BankStateStatus)
output dataset tqBankStateByGLBankStateNbr) in BBankEntry>
for each tqBankStateByGLBankStateNbr:
assign odUnallocStatBalance = odUnallocStatBalance + tqBankStateByGLBankStateNbr.tdBankStateLineAmountTC.
end.
/* Calculate opening balance */
assign odBankStateOpeningBalance = odBalanceTC + odUnallocStatBalance.