Description
This method does pre-validate before saving data to database
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bbankimportline.p)
/* =================================================================================================== */
/* Method : ValidatePre */
/* Desc : Pre validate before saving data to database */
/* =================================================================================================== */
assign oiReturnStatus = -98.
for each t_sBankImpLine where
t_sBankImpLine.tc_Status = 'N':U or
t_sBankImpLine.tc_Status = 'C':U:
/* =================================================================================================== */
/* If BankImpLineInOut is empty, assign it a value according to business relation type */
/* =================================================================================================== */
if (t_sBankImpLine.BankImpLineInOut = ? or
t_sBankImpLine.BankImpLineInOut = '':U) and
(t_sBankImpLine.BankImpLineBusRelType = ? or
t_sBankImpLine.BankImpLineBusRelType = '':U)
then do:
if t_sBankImpLine.BankImpLineAmountTC < 0
then assign t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT}
t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-CREDITOR}.
else assign t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN}
t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-DEBTOR}.
end.
if t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT} and
t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-DEBTOR}
then do:
assign vcMsg = trim(#T-14'For Customer type transactions only direction IN is allowed':255(733735991)T-14#)
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9484':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
if t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN} and
t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-CREDITOR}
then do:
assign vcMsg = trim(#T-17'For Supplier type transactions only direction OUT is allowed':255(413948518)T-17#)
oiReturnStatus = -1.
<M-16 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9554':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
if t_sBankImpLine.BankImpLineInOut = ? or
t_sBankImpLine.BankImpLineInOut = '':U
then do:
if t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-DEBTOR}
then assign t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN}.
else if t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-CREDITOR}
then assign t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT}.
end.
if t_sBankImpLine.BankImpLineBusRelType = ? or
t_sBankImpLine.BankImpLineBusRelTyp = '':U
then do:
if t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN}
then assign t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-DEBTOR}.
else if t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT}
then assign t_sBankImpLine.BankImpLineBusRelType= {&BANKIMPBUSRELTYPE-CREDITOR}.
end.
if t_sBankImpLine.BankImpLineAmountTC < 0 and
t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-IN}
then do:
assign vdBankImpLineAmountSumTC = 0
viBankImpLineBatchNbr = t_sBankImpLine.BankImpLineBatchNbr
vcBankImpLinePaymentRef = t_sBankImpLine.BankImpLinePaymentRef
vcBankImpLineInOut = t_sBankImpLine.BankImpLineInOut.
for each bsBankImpLine where
bsBankImpLine.BankImpLineBatchNbr = viBankImpLineBatchNbr and
bsBankImpLine.BankImpLinePaymentRef = vcBankImpLinePaymentRef and
bsBankImpLine.BankImpLineInOut = vcBankImpLineInOut:
assign vdBankImpLineAmountSumTC = vdBankImpLineAmountSumTC + bsBankImpLine.BankImpLineAmountTC.
end.
if vdBankImpLineAmountSumTC < 0
then do:
assign vcMsg = trim(#T-18'The negative amount of the transaction is in contradiction with direction IN':255(591272389)T-18#)
oiReturnStatus = -1.
<M-19 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9574':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end.
end.
if t_sBankImpLine.BankImpLineAmountTC > 0 and
t_sBankImpLine.BankImpLineInOut = {&TRANSDIRECTION-OUT}
then assign t_sBankImpLine.BankImpLineAmountTC = - t_sBankImpLine.BankImpLineAmountTC.
/* =================================================================================================== */
/* If BankImpLineAction is empty, assign it a value from BankFileFormatTransType */
/* =================================================================================================== */
if t_sBankImpLine.BankImpLineAction = ? or
t_sBankImpLine.BankImpLineAction = '':U
then do:
<Q-1 run BankFileFormatTransTypeByFormat (all) (Read) (NoCache)
(input t_sBankImpLine.BankImpLineFileFormatCode, (BankFileFormatCode)
input ?, (BankFileFormatTransTypeID)
input t_sBankImpLine.BankImpLineTransType, (BankFileFormatTransTypeCode)
output dataset tqBankFileFormatByTransType) in BBankFileFormat >
find first tqBankFileFormatByTransType no-error.
if available tqBankFileFormatByTransType
then assign t_sBankImpLine.BankImpLineAction = tqBankFileFormatByTransType.tcBankFileFormatTransTypeAct.
else do:
oiReturnStatus = -1.
vcMsg = trim(#T-24'Invalid value. Possible values:CREATEDDOCUMENT, PAIDDDOCUMENT, PAIDCDOCUMENT, BOUNCEDDDOCUMENT, BOUNCEDCDOCUMENT, CREATEBE, CONFIRM, OTHER.':255(604495136)T-24#).
<M-97 run SetMessage
(input vcMsg (icMessage),
input '':U (icArguments),
input 't_sBankImpLine.BankImpLineAction':U (icFieldName),
input t_sBankImpLine.BankImpLineAction (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBankImpLine.tc_Rowid (icRowid),
input 'qadfin-190964':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBankImportLine>
end. /* else if available tqBankFileFormatByTransType */
end. /* if t_sBankImpLine.BankImpLineAction = ? or '':U */
end. /* for each t_sBankImpLine */
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.