project QadFinancials > class BJournal > 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.

Assign the sharedset that is linked to the current company and set the default layer to the official layer.
The project provision for a new journal is set to false by default.


Parameters


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


Internal usage


unused


program code (program/bjournal.p)

<ANCESTOR-CODE>

if oiReturnStatus < 0
then return.

case icTableName:
    when "Journal":U
    then do:
        assign tJournal.JournalIsActive = true.
        /* =============================================================== */
        /* Set the SharedSet-ID                                            */ 
        /* that is linked to the current company (viCompanyId)             */
        /* =============================================================== */
        assign vcSharedSetTypeJournal = {&SHAREDSETTYPECODE-JOURNAL}.
        <Q-1 run LookupSharedSetForCompany (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input vcSharedSetTypeJournal, (SharedSetType)
           output dataset tqSharedSetForCompany) in BCompany >
        find first tqSharedSetForCompany no-error.
        if available tqSharedSetForCompany
        then assign tJournal.SharedSet_ID = tqSharedSetForCompany.tiSharedSet_ID.
        
        /* to be changed - the default layer should be differentiate by the journal type */
        assign vcLayerTypeOfficial = {&LAYERTYPECODE-OFFICIAL}.
        <Q-2 run LayerByCodeTypeCode (all) (Read) (NoCache)
           (input vcLayerTypeOfficial, (LayerTypeCode)
            input ?, (LayerCode)
            output dataset tqLayerByCodeTypeCode) in BLayer >
        find first tqLayerByCodeTypeCode where
                   tqLayerByCodeTypeCode.tcLayerTypeCode = vcLayerTypeOfficial 
                   no-error.
        if available tqLayerByCodeTypeCode
        then assign tJournal.tcLayerCode = tqLayerByCodeTypeCode.tcLayerCode.

        Assign tJournal.JournalIsProjectProvision = False.
        
        /* indiciate if the journal group field should be enabled or not for this screen */
        <Q-3 assign vlFcQueryRecordsAvailable = JournalGroupByCodeByID (NoCache)
           (input ?, (JournalGroupCode)
            input ?, (JournalGroupId)
            input true, (JournalGroupIsActive)
            input viCompanyID, (CompanyId)) in BJournalGroup >         
         assign tJournal.tlJournalGroupsIsEnabled  = if vlFcQueryRecordsAvailable <> false then true else false.

    end.
end case.