project QadFinancials > class BDDocument > method ValidateComponentPre


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.ValidateComponent


program code (program4/bddocument.p)

    
    /* ========================================================== */
    /* Validate current activity agains the status of the peyment */
    /* ========================================================== */
    if vcAllowedDDocStatusUptoActivity <> "":U and
       vcAllowedDDocStatusUptoActivity <> ?
    then for each t_sDDocument where
                  t_sDDocument.tc_Status = "C":U:
        find t_iDDocument where
             t_iDDocument.tc_Rowid = t_sDDocument.tc_Rowid
             no-error.
        if not available t_iDDocument
        then do:
            <M-80 run SetMessage
               (input  trim(#T-89'Initial values not found for customer payment with row ID $1.':250(1653)T-89#) (icMessage), 
                input  t_sDDocument.tc_Rowid (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDDocument.tc_Rowid (icRowid), 
                input  'qadfin-97676':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDDocument>
    
            assign oiReturnStatus = -1.
            return.
        end.
        if not can-do(vcAllowedDDocStatusUptoForVal, t_iDDocument.DDocumentStatus)
        then do:
            assign vcDDocumentStatus = <M-44 GetDDocumentStatusTranslation  (input  t_iDDocument.DDocumentStatus (icStatus)) in BDDocument>
                   oiReturnStatus    = -1.
            <M-92 run SetMessage
               (input  trim(#T-95'You are not allowed to modify customer payments with status $1.':250(663363967)T-95#) (icMessage), 
                input  vcDDocumentStatus (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDDocument.tc_Rowid (icRowid), 
                input  'qadfin-677470':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDDocument>
            return.
        end.
    end. /* if vcAllowedDDocStatusUptoActivity <> "":U and */
    
    
    /* ======================================================================= */
    /* Update values of calculated fields in CDocumentInvoiceXref              */
    /* ======================================================================= */
    <M-28 run ValidateComponentPreInvXref  (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
    if viFcReturnSuper < 0 or oiReturnStatus  = 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then return.
    if vcActivityCode = "Create":U or vcActivityCode = "Modify":U
    then do:
        <M-22 run ValidateComponentPreDInvoice  (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then return.
    end.
    if vcActivityCode = "Create":U or vcActivityCode = "Modify":U
    then do:
        <M-54 run ValidateComponentPreDebtor  (output viFcReturnSuper (oiReturnStatus)) in BDDocument>
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then return.
    end.
    
    
    /* ======================================================================= */
    /*  Validate GL Period for Customer Payment                                */
    /* ======================================================================= */
    for each t_sDDocument where (t_sDDocument.tc_Status        = "N":U or t_sDDocument.tc_Status   = "C":U) and
                                 t_sDDocument.DDocumentStatus  <> {&DOCUMENTSTATUS-INIT} and
                                (vcActivityCode = "Create":U   or  vcActivityCode = "Modify":U) :
        <Q-11 run PeriodByStartEndDate (all) (Read) (NoCache)
           (input t_sDDocument.Company_ID, (CompanyId)
            input t_sDDocument.ttPostingDate, (Date)
            output dataset tqPeriodByStartEndDate) in BPeriod>
        find first tqPeriodByStartEndDate where
                   tqPeriodByStartEndDate.ttPeriodStartDate          <= t_sDDocument.ttPostingDate and
                   tqPeriodByStartEndDate.ttPeriodEndDate            >= t_sDDocument.ttPostingDate and
                   tqPeriodByStartEndDate.tcPeriodStatus              = {&PERIODSTATUS-OPEN}     and
                   tqPeriodByStartEndDate.tlPeriodIsPostingSalesAllow = true   
                   no-error.
        if not available tqPeriodByStartEndDate
        then do:
            <M-86 run SetMessage
               (input  trim(#T-72'This GL period is closed for sales transactions.':250(16608)T-72#) (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  string(t_sDDocument.ttPostingDate) (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sDDocument.tc_Rowid (icRowid), 
                input  'qadfin-93348':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output oiReturnStatus (oiReturnStatus)) in BDDocument>
            assign oiReturnStatus = -1.
            return.
        end. /* if not available tqPeriodByStartEndDate */
    end. /* for each t_sDDocument where */             
    
    
    /* =============================================================================== */
    /* Assign DDocumentID on DDocInvoiceXrefStage to improve the performance on        */
    /* dataload by using the OverridePrimary construction for reading the data from db */ 
    /* =============================================================================== */
    for each t_sDDocument where 
             t_sDDocument.tc_Status <> "D":U ,
        each t_sDDocumentInvoiceXref where 
             t_sDDocumentInvoiceXref.tc_ParentRowid = t_sDDocument.tc_Rowid and 
             t_sDDocumentInvoiceXref.tc_Status <> "D":U ,
        each t_sDDocInvoiceXrefStage where 
             t_sDDocInvoiceXrefStage.tc_ParentRowid  = t_sDDocumentInvoiceXref.tc_Rowid and  
             t_sDDocInvoiceXrefStage.DDocument_ID   <> t_sDDocument.DDocument_ID and 
             (t_sDDocInvoiceXrefStage.tc_Status = "N":U or 
              t_sDDocInvoiceXrefStage.tc_Status = "C":U) :
        assign t_sDDocInvoiceXrefStage.DDocument_ID = t_sDDocument.DDocument_ID.
    end. /* for each t_sDDocument */