project QadFinancials > class BDPaymentSelection > method InitialValues

Description

Add code here to initialize the calculated fields of a 'new' record (= a record that must be created in the application database) in a class temp-table.


Parameters


icTableNameinputcharacterName of the database table of which a record is created in the class temp-table.
oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bdpaymentselection.p)

<ANCESTOR-CODE>

if icTableName = "DPaySel":U
then do:    
    <Q-81 run DDocumentStatusByTypeStatusGL (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input {&PAYFORMATPAYINSTRUMENT-DIRECTDEBIT}, (DDocumentStatusDocumentType)
        input {&DOCUMENTSTATUS-INCASSO}, (DDocumentStatusStatus)
        input ?, (BankGLId)
        input ?, (BankGLCode)
        output dataset tqDDocumentStatusByTypeStatusGL) in BDDocumentStatus>
    
    find first tqDDocumentStatusByTypeStatusGL where
               tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusDocType = {&PAYFORMATPAYINSTRUMENT-DIRECTDEBIT} and
               tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusStatus  = {&DOCUMENTSTATUS-INCASSO}
               no-error.
    
    if not available tqDDocumentStatusByTypeStatusGL
    then do:
        <Q-79 run DDocumentStatusByTypeStatusGL (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input {&PAYFORMATPAYINSTRUMENT-DIRECTDEBIT}, (DDocumentStatusDocumentType)
            input {&DOCUMENTSTATUS-PORTFOLIO}, (DDocumentStatusStatus)
            input ?, (BankGLId)
            input ?, (BankGLCode)
            output dataset tqDDocumentStatusByTypeStatusGL) in BDDocumentStatus>
    
        find first tqDDocumentStatusByTypeStatusGL where
                   tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusDocType = {&PAYFORMATPAYINSTRUMENT-DIRECTDEBIT} and
                   tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusStatus  = {&DOCUMENTSTATUS-PORTFOLIO}
                   no-error.
    end.
    
    if not available tqDDocumentStatusByTypeStatusGL
    then do:
        <Q-55 run DDocumentStatusByTypeStatusGL (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input ?, (DDocumentStatusDocumentType)
            input {&DOCUMENTSTATUS-INCASSO}, (DDocumentStatusStatus)
            input ?, (BankGLId)
            input ?, (BankGLCode)
            output dataset tqDDocumentStatusByTypeStatusGL) in BDDocumentStatus>
    
        find first tqDDocumentStatusByTypeStatusGL where
                   tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusStatus = {&DOCUMENTSTATUS-INCASSO}
                   no-error.
    end.
    
    if not available tqDDocumentStatusByTypeStatusGL
    then do:
        <Q-20 run DDocumentStatusByTypeStatusGL (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input ?, (DDocumentStatusDocumentType)
            input {&DOCUMENTSTATUS-PORTFOLIO}, (DDocumentStatusStatus)
            input ?, (BankGLId)
            input ?, (BankGLCode)
            output dataset tqDDocumentStatusByTypeStatusGL) in BDDocumentStatus>
    
        find first tqDDocumentStatusByTypeStatusGL where
                   tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusStatus = {&DOCUMENTSTATUS-PORTFOLIO}
                   no-error.
    end.
    
    assign           
        tDPaySel.DPaySelStatus                = if available tqDDocumentStatusByTypeStatusGL
                                              then tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusStatus
                                              else "":U                                          
        tDPaySel.tcDPaySelStatusTR            = vcTranslatedStatus
        tDPaySel.tcDDocumentType              = if available tqDDocumentStatusByTypeStatusGL
                                              then tqDDocumentStatusByTypeStatusGL.tcDDocumentStatusDocType
                                              else {&PAYFORMATPAYINSTRUMENT-CHEQUE}                                                    
        tDPaySel.DPaySelIsDocPerDueDate       = false                      
        tDPaySel.DPaySelDate                  = today
        tDPaySel.Company_ID                   = viCompanyId.
    
    assign vcTranslatedStatus = "":U. 
    if tDPaySel.DPaySelStatus <> "":U
    then do:    
        do viCounter = num-entries({&DOCUMENTSTATUSS},chr(2)) to 1 by -2 :
            if entry(viCounter,{&DOCUMENTSTATUSS},chr(2)) = tDPaySel.DPaySelStatus
                then assign vcTranslatedStatus = entry(viCounter - 1,{&DOCUMENTSTATUSS},chr(2)) no-error.       
        end. /* do */ 
    end. /* if available */

end. /* if if icTableName = "DPaySel":U */