project QadFinancials > class BBankEntry > method GetNewBankStateNumber
Description
This method will return a bank-state-number of a new bank-state. This will be the last used bank-state-number for the GL (of type bank) + 1
Parameters
| iiCompanyID | input | integer | Entity ID |
| iiBankGLID | input | integer | Id of thebank-gl |
| icBankGLCode | input | character | Bank GL-Code of the bank-gl; this parameter is not used in case iiBnakGLID was passed |
| iiBankStateYear | input | integer | Year of bankstatement |
| ocNewBankStateNumber | output | character | Default bank state number for a new bank-state |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bbankentry.p)
/* ========================= */
/* Validate input parameters */
/* ========================= */
if iiCompanyID = ? then assign iiCompanyID = 0.
if iiBankGLID = ? then assign iiBankGLID = 0.
if icBankGLCode = ? then assign icBankGLCode = "":U.
if iiBankStateYear = ? then assign iiBankStateYear = 0.
if iiBankStateYear = 0
then do:
assign ocNewBankStateNumber = "":U.
return.
end.
if iiCompanyID = 0 or
(iiBankGLID = 0 and icBankGLCode = "":U)
then do :
assign oiReturnStatus = -3
vcMessage = trim(#T-7'Incomplete information was passed to generate a default bank statement number. The entity and either the GL ID or the account code is required. See further for more details.':200(13861)t-7#) + chr(10) +
trim(SUBSTITUTE(#T-8'Entity: &1.':255(353)T-8#,string(iiCompanyID))) + chr(10) +
trim(SUBSTITUTE(#T-9'GL account: &1.':255(354)T-9#,icBankGLCode)) + chr(10) +
trim(SUBSTITUTE(#T-10'GL ID: &1.':255(355)T-10#,string(iiBankGLID))).
<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-615':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if iiCompanyID = 0 or */
/* ============================================= */
/* Convert the GLCode into the GL-ID when needed */
/* ============================================= */
if iiBankGLID = 0
then do :
<Q-3 run GLPrim (all) (Read) (NoCache)
(input iiCompanyID, (CompanyId)
input icBankGLCode, (GLCode)
input ?, (GLId)
output dataset tqGLPrim) in BGL >
find first tqGLPrim where
tqGLPrim.tcGLCode = icBankGLCode
no-lock no-error.
if not available tqGLPrim
then do :
assign oiReturnStatus = -3
vcMessage = trim(SUBSTITUTE(#T-11'An invalid bank account code (&1) was passed to generate a default bank statement number.':255(356)T-11#,icBankGLCode)) + chr(10) +
trim(SUBSTITUTE(#T-12'GL account: &1.':255(354)T-12#,icBankGLCode)).
<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-616':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if not available tqGLPrim */
assign iiBankGLID = tqGLPrim.tiGL_ID.
end. /* if iiBankGLID = 0 */
/* ================================================================== */
/* 1: Get the Highest number in alfabetical order */
/* Check both memory and database */
/* ================================================================== */
assign vcHighestNumber = '':U.
for each bt_oBankState where
bt_oBankState.Company_ID = iiCompanyID and
bt_oBankState.BankStateYear = iiBankStateYear and
bt_oBankState.GL_ID = iiBankGLID
no-lock :
if bt_oBankState.BankStateNumber > vcHighestNumber
then assign vcHighestNumber = bt_oBankState.BankStateNumber.
end.
<Q-6 run BankStateByHighestNumberGLId (last) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiBankGLID, (GLId)
input iiBankStateYear, (BankStateYear)
output dataset tqBankStateByHighestNumberGLId) in BBankEntry >
for each tqBankStateByHighestNumberGLId
by tqBankStateByHighestNumberGLId.tcBankStateNumber descending :
if tqBankStateByHighestNumberGLId.tcBankStateNumber > vcHighestNumber
then assign vcHighestNumber = tqBankStateByHighestNumberGLId.tcBankStateNumber.
leave.
end.
/* =============================================================================== */
/* 2: Increase the numerical part of the number with 1 and (try to) keep the format */
/* =============================================================================== */
<M-95 run GetNewBankStateNumberIncrease
(input vcHighestNumber (icBankStateNumber),
output ocNewBankStateNumber (ocNewBankStateNumber),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>