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/bpaymentselection.p)
/* delete the lines with status "" and no t_i line available for this */
/* because when you delete a line on ui, the status will set to blank */
/* very confusing to be sure if you have deleted records or not */
for each t_sPaySel where
t_sPaySel.tc_Status = "":U :
if not can-find(t_iPaySel where
t_iPaySel.tc_Rowid = t_sPaySel.tc_Rowid)
then delete t_sPaySel.
end. /* end for each t_sPaySel */
for each t_sPaySelLine where
t_sPaySelLine.tc_Status = "":U :
if not can-find(t_iPaySelLine where
t_iPaySelLine.tc_Rowid = t_sPaySelLine.tc_Rowid)
then delete t_sPaySelLine.
end. /* end for each t_sPaySelLine */
for each t_sPaySelLineStage where
t_sPaySelLineStage.tc_Status = "":U :
if not can-find(t_iPaySelLineStage where
t_iPaySelLineStage.tc_Rowid = t_sPaySelLineStage.tc_Rowid)
then delete t_sPaySelLineStage.
end. /* end for each t_sPaySelLineStage */
for each t_sPaySelHistory where
t_sPaySelHistory.tc_Status = "":U :
if not can-find(t_iPaySelHistory where
t_iPaySelHistory.tc_Rowid = t_sPaySelHistory.tc_Rowid)
then delete t_sPaySelHistory.
end. /* end for each t_sPaySelHistory */
for each t_sPaySelPayCode where
t_sPaySelPayCode.tc_Status = "":U :
if not can-find(t_iPaySelPayCode where
t_iPaySelPayCode.tc_Rowid = t_sPaySelPayCode.tc_Rowid)
then delete t_sPaySelPayCode.
end. /* end for each t_sPaySelPayCode */
/* shx Make sure all the external instance is clear before validate otherwise it may store wrong data */
/* do this only when the Bank payformat type changed */
find first t_sPaySel where
t_sPaySel.tc_Status = 'C':U
no-error.
if available t_sPaySel
then do:
find first t_iPaySel where
t_iPaySel.tc_Rowid = t_sPaySel.tc_Rowid
no-error.
if available t_iPaySel
then do:
if t_sPaySel.BankPayFormat_ID <> t_iPaySel.BankPayFormat_ID
then do:
<M-15 run StopExternalInstances (output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
end.
end.
end.
<M-8 run ValidateComponentPre (output viFcReturnSuper (OiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
<ANCESTOR-CODE>
/* Set status of modified payment selection codes */
for each t_sPaySelPayCode:
find t_iPaySelPayCode where t_iPaySelPayCode.tc_rowid=t_sPaySelPayCode.tc_rowid no-error.
if(available(t_iPaySelPayCode) and
t_iPaySelPayCode.tcPayFormatCode <> t_sPaySelPayCode.tcPayFormatCode and
(t_sPaySelPayCode.tc_status='' or t_sPaySelPayCode.tc_status=?)) then
t_sPaySelPayCode.tc_status='C':U.
end. /* for each t_sPaySelPayCode */
/* BKW: Instantiate BCInvoice */
if(viBCInvoicePaySelID=0 or viBCInvoicePaySelID = ?) then do:
<I-9 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BCInvoice"}>
vlBCInvIsStartedFromPaySel = true.
end.
else do:
<I-10 {bFcOpenInstance
&CLASS = "BCInvoice"}>
end.
/*BKW*/
/* BKW: Iterate over payment selections and validate hold amount for new and modified lines */
for each t_sPaySelLine where
(t_sPaySelLine.tc_status = 'N':U or t_sPaySelLine.tc_status = 'C':U) and
(t_sPaySelLine.PaySelLineParentObject_ID <> 0 and t_sPaySelLine.PaySelLineParentObject_ID <> ?) and
(t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV} or
t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT}):
<M-12 run ValidateHoldAmountAndLockPayment
(input t_sPaySelLine.PaySelLineParentObject_ID (iiCInvoiceID),
input abs(t_sPaySelLine.PaySelLineAmountTC) - abs(t_sPaySelLine.PaySelLineDiscountTC) (idAllocAmount),
input 'tPaySelLine.PaySelLineAmountTC':U (icFieldName),
input string(abs(t_sPaySelLine.PaySelLineAmountTC) - abs(t_sPaySelLine.PaySelLineDiscountTC)) (icFieldValue),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if(viFcReturnSuper < 0) then
oiReturnStatus = viFcReturnSuper.
end.
/* BKW: Close BCInvoice instance */
<I-13 {bFcCloseInstance
&CLASS = "BCInvoice"}>
if(oiReturnStatus < 0) then
return.
/*BKW*/
<M-7 run ValidateComponentPost (output viFcReturnSuper (OiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
<M-14 run ValidateComponentPaySelPayCode (output viFcReturnSuper (OiReturnStatus)) in BPaymentSelection>
if viFcReturnSuper < 0 or
oiReturnStatus = 0
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.