project QadFinancials > class BBankEntry > method AdditionalUpdatesValidations
Description
AddtionalUpdatesValidations; method that contains the validations that could not be written in another kind of method
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bbankentry.p)
/* ========================= */
/* Set default return-status */
/* ========================= */
assign oiReturnStatus = -98.
/* ====================================== */
/* Go through all non-deleted bank-states */
/* ====================================== */
for each tBankState where
tBankState.tc_Status <> "D":U no-lock :
/* ==================================================== */
/* Validations on the status (header-lines-allocations) */
/* ==================================================== */
if (tBankState.BankStateStatus = {&BANKSTATESTATUS-PARTALLOC} or
tBankState.BankStateStatus = {&BANKSTATESTATUS-UNALLOC})
then do :
for each tBankStateLine where
tBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
tBankStateLine.BankStateLineStatus = {&BANKSTATELINESTATUS-UNALLOC} and
(tBankStateLine.tc_status = "N":U or
tBankStateLine.tc_status = "C":U)
by tBankStateLine.BankStateLineNumber :
if can-find(first tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tbankstatealloc.tc_status = "C":U) )
then do:
assign vcMessage = trim(substitute(#T-7'Allocation lines were found for the bank statement line (&2) with status &1.':150(999890509)T-7#, {&BANKSTATELINESTATUS-UNALLOC-TR},string(tBankStateLine.BankStateLineNumber)))
oiReturnStatus = -1.
<M-1 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-4262':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if can-find */
end. /* for each BankStateLine of */
end. /* if */
/* ==================================================== */
/* Validations on the uniqueness of BankStateLineNumber */
/* ==================================================== */
for each tBankStateLine where
tBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
tBankStateLine.tc_status <> "D":U
no-lock :
if can-find (first bBankStateLine where
bBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
bBankStateLine.BankStateLineNumber = tBankStateLine.BankStateLineNumber and
bBankStateLine.tc_Status <> "D":U and
bBankStateLine.tc_Rowid <> tBankStateLine.tc_Rowid)
then do:
assign vcMessage = trim(substitute(#T-30'The bank state (&1) contains duplicate lines with the same line number (&2).':255(999890507)T-30#, tBankState.BankStateNumber,string(tBankStateLine.BankStateLineNumber)))
oiReturnStatus = -1.
<M-29 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBankStateLine.BankStateLineNumber':U (icFieldName),
input string(tBankStateLine.BankStateLineNumber) (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-4442':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if can-find */
end. /* for each tBankStateLine where */
end. /* for each tBankState, */
/* =========================================================== */
/* Validations only the records that are (partially) allocated */
/* =========================================================== */
for each tBankState where
tBankState.tc_Status <> "D":U and
(tBankState.BankStateStatus = {&BANKSTATESTATUS-PARTALLOC} or
tBankState.BankStateStatus = {&BANKSTATESTATUS-ALLOC}) no-lock,
each tBankStateLine where
tBankStateLine.tc_ParentRowid = tBankState.tc_Rowid and
(tBankStateLine.tc_status = "N":U or
tBankStateLine.tc_status = "C":U) and
tBankStateLine.BankStateLineStatus = {&BANKSTATELINESTATUS-ALLOC}
by tBankStateLine.BankStateLineNumber :
/* ============================================ */
/* only one prepayment is allowed for each line */
/* ============================================ */
find first tBankStateAlloc where
tBankStateAlloc.tc_status = "N":U and
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NCINV} or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NDINV})
no-lock no-error.
if available tBankStateAlloc
then do :
assign vrBankStateAllocRowid = ROWID(tBankStateAlloc).
find first tBankStateAlloc where
tBankStateAlloc.tc_status = "N":U and
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NCINV} or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-NDINV}) and
rowid(tBankStateAlloc) <> vrBankStateAllocRowId
no-lock no-error.
if available tBankStateAlloc
then do :
assign vcMessage = trim(substitute(#T-8'You can only specify one prepayment for bank statement line &1.':150(999890508)T-8#,string(tBankStateLine.BankStateLineNumber)))
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-4263':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end.
end. /* if available tBankStateAlloc */
/* ======================================= */
/* validations of the non prepayment lines */
/* ======================================= */
/* - the invoice id's must be filled */
/* - Dt/Cr indication of Allocation must be the opposite of the document */
for each tBankStateAlloc where
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U) and
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-NCINV} and
tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-NDINV} and
tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-DEDUCTIONINV})
no-lock:
if (tBankStateAlloc.CInvoice_ID = 0 or tBankStateAlloc.CInvoice_ID = ?) and
(tBankStateAlloc.DInvoice_ID = 0 or tBankStateAlloc.DInvoice_ID = ?) and
(tBankStateAlloc.CCollection_ID = 0 or tBankStateAlloc.CCollection_ID = ?) and
(tBankStateAlloc.DCollection_ID = 0 or tBankStateAlloc.DCollection_ID = ?)
then do :
assign vcMessage = trim(#T-9'The invoice ID is not defined.':150(365)T-9#) + chr(10) +
trim(substitute(#T-10'Allocation type: &1.':150(366)T-10#,tBankStateAlloc.BankStateAllocType)) + chr(10) +
trim(substitute(#T-11'Invoice: &1.':150(367)T-11#,tBankStateAlloc.tcDocNumberReference)) + chr(10) +
trim(substitute(#T-12'Allocation line: &1.':150(368)T-12#,string(tBankStateAlloc.BankStateLine_ID))) + chr(10) +
trim(substitute(#T-13'Bank statement line: &1.':150(369)T-13#,string(tBankStateLine.BankStateLineNumber)))
oiReturnStatus = -1.
<M-3 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-4264':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if */
if tBankStateAlloc.tcAllocAmountCrDt = tBankStateAlloc.tcDocBalanceCrDt and
tBankStateAlloc.BankStateAllocType <> {&INVOICETYPE-INVOICECORRECTION} and
tBankStateAlloc.BankStateAllocType <> {&INVOICETYPE-CREDITNOTECORRECTION}
then do :
assign vcMessage = trim(substitute(#T-14'The sign of the allocated open balance (&1) must be the opposite of the original open balance (&2).':255(370)T-14#,tBankStateAlloc.tcAllocAmountCrDt,tBankStateAlloc.tcDocBalanceCrDt)) + chr(10) +
trim(substitute(#T-15'Allocation type: &1.':150(366)T-15#,tBankStateAlloc.BankStateAllocType)) + chr(10) +
trim(substitute(#T-16'Invoice: &1.':150(367)T-16#,tBankStateAlloc.tcDocNumberReference)) + chr(10) +
trim(substitute(#T-17'Allocation line: &1.':150(368)T-17#,string(tBankStateAlloc.BankStateLine_ID))) + chr(10) +
trim(substitute(#T-18'Bank statement line: &1.':150(369)T-18#,string(tBankStateLine.BankStateLineNumber)))
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-4265':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end.
end. /* for each tBankStateAlloc where */
/* ======================== */
/* validations of all lines */
/* ======================== */
/* - the allocation amount must be filled */
/* - negative/positive new balance not allowed, depending on allocation type */
for each tBankStateAlloc where
tBankStateAlloc.tc_ParentRowid = tBankStateLine.tc_Rowid and
(tBankStateAlloc.tc_Status = "N":U or
tBankStateAlloc.tc_Status = "C":U)
no-lock:
if (tBankStateAlloc.BankStateAllocAmountTC = 0 or tBankStateAlloc.BankStateAllocAmountTC = ?) and
(tBankStateAlloc.BankStateAllocAmountLC = 0 or tBankStateAlloc.BankStateAllocAmountLC = ?)
then do :
assign vcMessage = trim(substitute(#T-19'The allocated BC amount (&1) and the allocated TC amount (&2) cannot both be zero.':150(371)T-19#,(if tBankStateAlloc.BankStateAllocAmountLC = ? then "?":U else string(tBankStateAlloc.BankStateAllocAmountLC)),(if tBankStateAlloc.BankStateAllocAmountTC = ? then "?":U else string(tBankStateAlloc.BankStateAllocAmountTC)) )) + chr(10) +
trim(substitute(#T-20'Allocation type: &1.':150(366)T-20#,tBankStateAlloc.BankStateAllocType)) + chr(10) +
trim(substitute(#T-21'Invoice: &1.':150(367)T-21#,tBankStateAlloc.tcDocNumberReference)) + chr(10) +
trim(substitute(#T-22'Allocation line: &1.':150(368)T-22#,string(tBankStateAlloc.BankStateLine_ID))) + chr(10) +
trim(substitute(#T-23'Bank statement line: &1.':150(369)T-23#,string(tBankStateLine.BankStateLineNumber)))
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-4266':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end. /* if */
/* change the validation, this validation was there before implementing running and new balance, so now we just check negative/positive balance depending on allocation type */
if ((tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-INVOICECORRECTION} or
tBankStateAlloc.BankStateAllocType = {&INVOICETYPE-CREDITNOTECORRECTION}) and
tBankStateAlloc.tdNewBalanceTC > 0) or
(tBankStateAlloc.BankStateAllocType <> {&INVOICETYPE-INVOICECORRECTION} and
tBankStateAlloc.BankStateAllocType <> {&INVOICETYPE-CREDITNOTECORRECTION} and
tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-CCOLL} and
tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-DCOLL} and
tBankStateAlloc.tdNewBalanceTC < 0)
then do :
assign vcMessage = trim(substitute(#T-31'Overallocation of an Invoice or Credit note is not allowed. You have assigned &1 surplus.':255(999890083)T-31#, abs(tBankStateAlloc.tdNewBalanceTC))) + chr(10) +
trim(substitute(#T-25'Allocation type: &1.':150(366)T-25#,tBankStateAlloc.BankStateAllocType)) + chr(10) +
trim(substitute(#T-26'Invoice: &1.':150(367)T-26#,tBankStateAlloc.tcDocNumberReference)) + chr(10) +
trim(substitute(#T-27'Allocation line: &1.':150(368)T-27#,string(tBankStateAlloc.BankStateLine_ID))) + chr(10) +
trim(substitute(#T-28'Bank statement line: &1.':150(369)T-28#,string(tBankStateLine.BankStateLineNumber)))
oiReturnStatus = -1.
<M-6 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-4267':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end.
if (tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-CCOLL} or
tBankStateAlloc.BankStateAllocType = {&BANKSTATEALLOCTYPE-DCOLL}) and
((tBankStateAlloc.tdCollBalance > tBankStateAlloc.tdNewBalanceTC and
tBankStateAlloc.tdCollBalance <> tBankStateAlloc.tdNewBalanceTC + tBankStateAlloc.BankStateAllocAmountTC) or
(tBankStateAlloc.tdCollBalance < tBankStateAlloc.tdNewBalanceTC and
tBankStateAlloc.tdCollBalance + tBankStateAlloc.BankStateAllocAmountTC <> tBankStateAlloc.tdNewBalanceTC))
then do:
assign vcMessage = trim(#T-33'The allocated amount should be the difference between the document open balance and the new balance':255(999890442)T-33#) + chr(10) +
trim(substitute(#T-34'Allocation type: &1.':150(366)T-34#,tBankStateAlloc.BankStateAllocType)) + chr(10) +
trim(substitute(#T-35'Invoice: &1.':150(367)T-35#,tBankStateAlloc.tcDocNumberReference)) + chr(10) +
trim(substitute(#T-36'Allocation line: &1.':150(368)T-36#,string(tBankStateAlloc.BankStateLine_ID))) + chr(10) +
trim(substitute(#T-37'Bank statement line: &1.':150(369)T-37#,string(tBankStateLine.BankStateLineNumber)))
oiReturnStatus = -1.
<M-32 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-9088':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
Return.
end.
end. /* for each tBankStateAlloc */
end. /* for each tBankState, each tBankStateLine of */
/* ========================= */
/* Return in case of errors */
/* Set return-status = OK */
/* ========================= */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.