project QadFinancials > class BCashBox > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bcashbox.p)
/*define yet another buffer for t_sBankStateAlloc table,
one buffer is already generated by CB locally in the method, that is t_sBankStateAlloc */
define buffer bBankStateAlloc for t_sBankStateAlloc.
for each t_sBankState where
t_sBankState.tc_Status = "N":U:
assign t_sBankState.BankStateYear = t_sBankState.tiPeriodYear.
if (t_sBankState.GL_ID > 0 or (t_sBankState.tcGLCode <> "":U and t_sBankState.tcGLCode <> ?)) and
t_sBankState.BankStateYear > 0
then do:
<M-1 run GetNewBankStateNumber
(input viCompanyId (iiCompanyID),
input t_sBankState.GL_ID (iiBankGLID),
input t_sBankState.tcGLCode (icBankGLCode),
input t_sBankState.BankStateYear (iiBankStateYear),
output t_sBankState.BankStateNumber (ocNewBankStateNumber),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0
then assign oiReturnStatus = viFcReturnSuper.
end.
end.
<ANCESTOR-CODE>
for each t_sBankState:
BankStateLine_Block:
for each t_sBankStateLine where
t_sBankStateLine.tc_ParentRowid = t_sBankState.tc_Rowid and
(t_sBankStateLine.tc_Status = "N":U or t_sBankStateLine.tc_Status = "C":U):
for each t_sBankStateAlloc where
t_sBankStateAlloc.tc_ParentRowid = t_sBankStateLine.tc_Rowid and
(t_sBankStateAlloc.tc_Status = "N":U or t_sBankStateAlloc.tc_Status = "C":U):
/*as the BankState cannot be allocated partially, we can find all allocations in t_s table.
Otherwise we should include also the existing/older allocations, meaning t_o records*/
if can-find (first bBankStateAlloc where
bBankStateAlloc.tc_ParentRowid = t_sBankStateAlloc.tc_ParentRowid and
bBankStateAlloc.tc_Rowid <> t_sBankStateAlloc.tc_Rowid and
bBankStateAlloc.tc_Status <> "D":U and
bBankStateAlloc.tcDocBusinessRelationCode <> "":U and
bBankStateAlloc.tcDocBusinessRelationCode <> ? and
bBankStateAlloc.tcDocBusinessRelationCode <> t_sBankStateAlloc.tcDocBusinessRelationCode)
then do:
/*Maximum one business relation can be linked to one single BankStateLine*/
assign vcMessage = trim(subst(#T-2'You cannot use multiple business relations when allocating the transaction line.':200(17071)t-2#)) + " ":U +
trim(subst(#T-3'GL Calendar Year: &1; GL period: &2; Daybook: &3; Voucher: &4; Description: &5.':255(17072)t-3#,
string(t_sBankStateLine.tiPeriodYear),
string(t_sBankStateLine.tiPeriodPeriod),
trim(t_sBankStateLine.tcPostingJournalCode),
string(t_sBankStateLine.tiPostingVoucher),
trim(t_sBankStateLine.BankStateLineDescription)))
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tBankStateAlloc.tcDocBusinessRelationCode':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBankStateLine.tc_Rowid (icRowid),
input 'QADFIN-4191':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCashBox>
/*NEXT Line -> check each BankStateLine only once, in order not to get this error message multiple times*/
next BankStateLine_Block.
end.
end.
end.
end.