project QadFinancials > class BCInvoice > 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


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bcinvoice.p)

/* ================================================================================================================ */       
/* Make sure this component is saved before posting (in matching), to make sure the new voucher is saved in posting */
/* ================================================================================================================ */  
if viTransactionID <> 0 and
   viTransactionID <> ?
then do:
    <I-75 {bFcOpenInstance
         &CLASS           = "Transaction"}>
    
    <M-30 run SetPriority
       (input  viFcCurrentInstanceId (iiInstanceNr), 
        input  'FIRST':U (icPriority), 
        output viFcReturnSuper (oiReturnStatus)) in Transaction>
    if viFcReturnSuper <> 0 and oiReturnStatus >= 0
    then assign oiReturnStatus = viFcReturnSuper.    
    
    <I-29 {bFcCloseInstance
         &CLASS           = "Transaction"}>
end. /* if viTransactionID <> 0 and */     

/* Initialize */
assign vlStartVal1 = false.

/*stop the instance of bqcinvoicemovement so that if there are warnings during invoice save the movement records are not duplicated*/
if viBQCInvoiceMovementID <> 0 and
   viBQCInvoiceMovementID <> ?
then do:
    <I-55 {bFcStopInstance
         &CLASS           = "BQCInvoiceMovement"}>     
end. /*IF viBQCInvoiceMovementID <> 0*/      

/* backwards compatibility : fill new mandatory field when not filled yet */
for each t_sCInvoice where
         t_sCInvoice.CInvoiceIsWHT = ?:
    assign t_sCInvoice.CInvoiceIsWHT = false.
end.

/* Fill some values before validating */
<M-102 run ValidateComponentPre
   (input-output vlStartVal1 (blStartVal1), 
    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 and
   oiReturnStatus  >= 0
then assign oiReturnStatus = viFcReturnSuper.


if oiReturnStatus < 0
then do:
    <M-104 run ValidateComponentFinalize
       (input  vlStartVal1 (ilStartVal1), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>

    return.
end.

<ANCESTOR-CODE>

for each tApproveWarningInvLst:
    for each t_sCInvoice where t_sCInvoice.CInvoice_ID = tApproveWarningInvLst.tiInvoiceId:
        assign  t_sCInvoice.CInvoiceIsInvoiceApproved = no.
    end.
end.   
    

/* Do not proceed in case of errors */
if oiReturnStatus < 0
then do:
    <M-106 run ValidateComponentFinalize
       (input  vlStartVal1 (ilStartVal1), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>

    return.
end.

/* Validate */
<M-103 run ValidateComponentPost
   (input-output vlStartVal1 (blStartVal1), 
    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>

if viFcReturnSuper <> 0 and
   oiReturnStatus  >= 0
then assign oiReturnStatus = viFcReturnSuper.

if oiReturnStatus < 0
then do:
    <M-107 run ValidateComponentFinalize
       (input  vlStartVal1 (ilStartVal1), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>

    return.
end.

<M-108 run ValidateComponentFinalize
   (input  vlStartVal1 (ilStartVal1), 
    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>