project QadFinancials > class BYearClosing > method DefaultValuesLayer

Description

Gets the layer description for the layer code.


Parameters


icYearCloseTcRowIdinputcharacter
icLayerTypeCodeinputcharacter
biLayerIDinput-outputinteger
bcLayerCodeinput-outputcharacter
ocLayerDescriptionoutputcharacter
oiClosingTransferJournal_IDoutputinteger
ocClosingTransferJournalCodeoutputcharacter
oiClosingPLJournalIDoutputinteger
ocClosingPLJournalCodeoutputcharacter
oiClosingBalanceJournalIDoutputinteger
ocClosingBalanceJournalCodeoutputcharacter
olLayerIsAddGLNbroutputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BYearClosing.InitialValues


program code (program6/byearclosing.p)

/* Normalize input parameters */
if icLayerTypeCode = "":U then assign icLayerTypeCode = ?.
if biLayerID       = 0    then assign biLayerID = ?.
if bcLayerCode     = '':U then assign bcLayerCode = ?.

/* Default output values */
assign ocLayerDescription           = ?
       oiClosingTransferJournal_ID  = ?
       ocClosingTransferJournalCode = ?
       oiClosingBalanceJournalID    = ?
       ocClosingBalanceJournalCode  = ?
       oiClosingPLJournalID         = ?
       ocClosingPLJournalCode       = ?.


/* Precondition */
if icLayerTypeCode = ? and
   bcLayerCode     = ?
then return.


/* Get Year-End-Closing record */
find tYearClosing where
     tYearClosing.tc_Rowid = icYearCloseTcRowId
     no-error.
if not available tYearClosing
then do:
    assign oiReturnStatus  = -3
           vcMessage       = "There is not available tYearClosing record.":U
           vcContext       = "icYearCloseTcRowId=&1"
           vcContext       = substitute(vcContext, icYearCloseTcRowId).   
    <M-67 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'S':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-865755':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
    return.
end. /* if not available tYearClosing */


/* Get details of the Layer */
<Q-46 run LayerByCodeTypeCode (all) (Read) (NoCache)
   (input icLayerTypeCode, (LayerTypeCode)
    input bcLayerCode, (LayerCode)
    output dataset tqLayerByCodeTypeCode) in BLayer>

find tqLayerByCodeTypeCode where
     (tqLayerByCodeTypeCode.tcLayerCode     = bcLayerCode     or bcLayerCode     = ?) and
     (tqLayerByCodeTypeCode.tcLayerTypeCode = icLayerTypeCode or icLayerTypeCode = ?)
     no-error.

if not available tqLayerByCodeTypeCode
then do:
    assign vcMessage = #T-48'Layer &1 does not exist':30(924878227)T-48#
           vcMessage = substitute(vcMessage, bcLayerCode)
           vcContext = "bcLayerCode=&1|icLayerTypeCode=&2"
           vcContext = replace(vcContext, "|":U, chr(2))
           vcContext = substitute(vcContext, bcLayerCode, icLayerTypeCode).
    <M-50 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'YearClosing.tcLayerCode' (icFieldName), 
        input  bcLayerCode (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-703634':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
    assign oiReturnStatus = -1.
    return.
end.

/* Check, if the layer is or Official or Management */
if lookup(tqLayerByCodeTypeCode.tcLayerTypeCode,  {&LAYERTYPECODE-OFFICIAL} + ",":U + {&LAYERTYPECODE-MANAGEMENT}) = 0
then do:
    assign vcMessage = #T-65'Layer &1 is a transient layer. Year-end closing supports closing of official and management layers only.':255(289983644)T-65#
           vcMessage = substitute(vcMessage, bcLayerCode)
           vcContext = "bcLayerCode=&1|icLayerTypeCode=&2"
           vcContext = replace(vcContext, "|":U, chr(2))
           vcContext = substitute(vcContext, bcLayerCode, icLayerTypeCode).
    <M-51 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'YearClosing.tcLayerCode' (icFieldName), 
        input  bcLayerCode (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-864934':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
    assign oiReturnStatus = -1.
    return.
end. /* Check, if the layer is or Official or Management */


/* Check, if layer is active */
if not tqLayerByCodeTypeCode.tlLayerIsActive
then do:
    assign vcMessage = #T-52'The layer is not active.':100(2722)T-52#.
    <M-77 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'YearClosing.tcLayerCode' (icFieldName), 
        input  bcLayerCode (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-506218':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
    assign oiReturnStatus = -1.
    return.
end. /* if not tqLayerByCodeTypeCode.tlLayerIsActive */
     

assign biLayerID          = tqLayerByCodeTypeCode.tiLayer_ID
       bcLayerCode        = tqLayerByCodeTypeCode.tcLayerCode
       ocLayerDescription = tqLayerByCodeTypeCode.tcLayerDescription.



/* Check, if the layer requires additional numbering */
if tqLayerByCodeTypeCode.tcLayerTypeCode = {&LAYERTYPECODE-OFFICIAL}
then assign olLayerIsAddGLNbr = tYearClosing.tlCompanyPropertyIsAddGLNbr.
else assign olLayerIsAddGLNbr = tYearClosing.tlCompanyPropertyIsAddGLNbr AND
                                tqLayerByCodeTypeCode.tlLayerIsAddGLNbr.


/* Default closing daybook                          */
/* Get default daybooks for year-end closing        */
/* 1. Try to retrieve it from last year-end closing */
<Q-79 run YearClosingByCyYearID (last) (Read) (NoCache)
   (input tYearClosing.Company_ID, (CompanyId)
    input ?, (YearClosingAccountingYear)
    input ?, (YearClosingID)
    input biLayerID, (LayerID)
    output dataset tqYearClosingByCyYearID) in BYearClosing>
find last tqYearClosingByCyYearID where
          tqYearClosingByCyYearID.tiCompany_ID = tYearClosing.Company_ID and
          tqYearClosingByCyYearID.tiLayer_ID   = biLayerID
          no-error.

/* Backward compatibility - before creation of Layer_ID field in YearClosing, values is blank for */
/* official layer                                                                                 */
if not available tqYearClosingByCyYearID and
   tqLayerByCodeTypeCode.tcLayerTypeCode = {&LAYERTYPECODE-OFFICIAL}
then do:
    <Q-11 run YearClosingByCyYearID (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input ?, (YearClosingAccountingYear)
        input ?, (YearClosingID)
        input ?, (LayerID)
        output dataset tqYearClosingByCyYearID) in BYearClosing>
    find last tqYearClosingByCyYearID where
              tqYearClosingByCyYearID.tiCompany_ID = tYearClosing.Company_ID and
              (tqYearClosingByCyYearID.tiLayer_ID   = 0 or
               tqYearClosingByCyYearID.tiLayer_ID   = ?)
              no-error.
end.

if available tqYearClosingByCyYearID
then assign oiClosingTransferJournal_ID  = tqYearClosingByCyYearID.tiClosingTransferJournal_ID
            ocClosingTransferJournalCode = tqYearClosingByCyYearID.tcClosingTransferJournalCode
            oiClosingBalanceJournalID    = tqYearClosingByCyYearID.tiClosingBalanceJournal_ID
            ocClosingBalanceJournalCode  = tqYearClosingByCyYearID.tcClosingBalanceJournalCode
            oiClosingPLJournalID         = tqYearClosingByCyYearID.tiClosingPLJournal_ID
            ocClosingPLJournalCode       = tqYearClosingByCyYearID.tcClosingPLJournalCode.
else do:
    /* If we don't have default daybooks from previous year, check there is only one daybook  */
    <Q-1 run JournalByJournalTypeLayerType (all) (Read) (NoCache)
       (input tYearClosing.Company_ID, (CompanyId)
        input {&JOURNALTYPE-YEARLYCLOSING}, (JournalTypeCode)
        input bcLayerCode, (LayerCode)
        input true, (JournalIsActive)
        output dataset tqJournalByJournalTypeLayerType) in BJournal>
    
    find tqJournalByJournalTypeLayerType where
         tqJournalByJournalTypeLayerType.tcJournalTypeCode = {&JOURNALTYPE-YEARLYCLOSING} and
         tqJournalByJournalTypeLayerType.tcLayerCode       = bcLayerCode                  and
         tqJournalByJournalTypeLayerType.tlJournalIsActive = true
         no-error.
    if available tqJournalByJournalTypeLayerType
    then assign oiClosingTransferJournal_ID  = tqJournalByJournalTypeLayerType.tiJournal_ID
                ocClosingTransferJournalCode = tqJournalByJournalTypeLayerType.tcJournalCode
                oiClosingBalanceJournalID    = tqJournalByJournalTypeLayerType.tiJournal_ID
                ocClosingBalanceJournalCode  = tqJournalByJournalTypeLayerType.tcJournalCode
                oiClosingPLJournalID         = tqJournalByJournalTypeLayerType.tiJournal_ID
                ocClosingPLJournalCode       = tqJournalByJournalTypeLayerType.tcJournalCode.

end. /* else if available tqYearClosingByCyYearID  */