project QadFinancials > class BJournalEntryMultiCy > method GetIntercompanyJEGLAccount

Description

This method takes the cross company entity code for the target entity and returns the manual journal entry GL code stored on the domain the company is in. The GL codes are cached in the ttCompanyJEGL temptable to improved performance.


Parameters


icCompanyCodeinputcharacterCompany code
ocGLCodeoutputcharacterManual Journal Entry GL code stored on domain of passed in company
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BJournalEntryMultiCy.ApiCreateCrossCyPostingsAddCCyPostings


program code (program9/bjournalentrymulticy.p)

/* ================================================================ */
/* This method gets the value of the cross-company manual gl code   */
/* defined on the domain                                            */
/* To improve performance, we store the gl codes in ttCompanyJEGL   */
/* so that they are only retrieved and validated once.              */
/* ================================================================ */

find first ttCompanyJEGL where ttCompanyJEGL.tcCompanyCode = icCompanyCode no-error.
if available ttcompanyJEGL 
then do:
    assign ocGLCode = ttCompanyJEGL.tcGlCode.
    return.
end.

<Q-54 run CompanyByCodeCurrActiveID (all) (Read) (NoCache)
   (input ?, (CompanyId)
    input icCompanyCode, (CompanyCode)
    input true, (CompanyIsActive)
    input ?, (CurrencyID)
    output dataset tqCompanyByCodeCurrActiveID) in BCompany >

/* Get the id for the passed in icCompanyCode */
find tqCompanyByCodeCurrActiveID no-lock no-error.
if not available tqCompanyByCodeCurrActiveID 
then do:    
    assign 
        vcMessage = trim(substitute(#T-38'Cannot find the company code &1 specified in the posting.':255(380821480)T-38#,icCompanyCode)) 
        oiReturnStatus = -1.
        <M-66 run SetMessage
           (input  vcMessage (icMessage), 
            input  ' ':U (icArguments), 
            input  ' ':U (icFieldName), 
            input  icCompanyCode (icFieldValue), 
            input  ' E':U (icType), 
            input  3 (iiSeverity), 
            input  ' ':U (icRowid), 
            input  'qadfin-713788':U (icFcMsgNumber), 
            input  ' ':U (icFcExplanation), 
            input  ' ':U (icFcIdentification), 
            input  ' ':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
        return.
end.  /* if not available tqCompanyByCodeCurrActiveID */    

/* Ensure that the company is active */
if tqCompanyByCodeCurrActiveID.tlDomainIsActive <> true 
then do:   
    assign 
        vcMessage = trim(substitute(#T-90'The company code &1 specified in the posting is not active.':255(173849755)T-90#,icCompanyCode)) 
        oiReturnStatus = -1.
        <M-39 run SetMessage
           (input  vcMessage (icMessage), 
            input  ' ':U (icArguments), 
            input  ' ':U (icFieldName), 
            input  icCompanyCode (icFieldValue), 
            input  ' E':U (icType), 
            input  3 (iiSeverity), 
            input  ' ':U (icRowid), 
            input  'qadfin-427469':U (icFcMsgNumber), 
            input  ' ':U (icFcExplanation), 
            input  ' ':U (icFcIdentification), 
            input  ' ':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
         return.
end.  /* if tqCompanyByCodeCurrActiveID.tlDomainIsActive <> true */    

/* ================================================================================= */
/* Assign the output paramater ocCrossCompanyGLCode:                                 */
/* GLCode that is to be used on the compensating posting-line in the target-company  */
/* ================================================================================= */
/* Get cross company G/L accounts for domain of posting company */ 
<Q-28 run DomainForInterCompany (all) (Read) (NoCache)
   (input tqCompanyByCodeCurrActiveID.tiDomain_ID, (DomainID)
    input ?, (DomainCode)
    input ?, (CompanyID)
    output dataset tqDomainForInterCompany) in BDomain >
    
find first tqDomainForInterCompany no-lock no-error.
if not available tqDomainForInterCompany
then do :
    assign vcMessage = trim(substitute(#T-7'Internal error: cannot find the domain based on the domain ID &2 specified in the setup of the company &1.':255(60937)T-7#,
                                    icCompanyCode,string(tqCompanyByCodeCurrActiveID.tiDomain_ID)))
    oiReturnStatus = -1.
    <M-55 run SetMessage
       (input  vcMessage (icMessage), 
        input  ' ':U (icArguments), 
        input  ' ':U (icFieldName), 
        input  ' ':U (icFieldValue), 
        input  ' E':U (icType), 
        input  3 (iiSeverity), 
        input  ' ':U (icRowid), 
        input  'qadfin-121622':U (icFcMsgNumber), 
        input  ' ':U (icFcExplanation), 
        input  ' ':U (icFcIdentification), 
        input  ' ':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
     return.
end. /* if not available tqDomainForInterCompany */

if tqDomainForInterCompany.tcIntercoJEGLCode = "":U or
   tqDomainForInterCompany.tcIntercoJEGLCode = ?
then do:
    assign vcMessage      = trim(substitute(#T-75'Cannot create cross-company posting lines in the journal entry because the cross-company accounts have not been defined for the domain &1.':255(63255)T-75#,
                            tqDomainForInterCompany.tcDomainCode))
           oiReturnStatus = -1.
    <M-27 run SetMessage
      (input  vcMessage (icMessage), 
       input  ' ':U (icArguments), 
       input  ' ':U (icFieldName), 
       input  ' ':U (icFieldValue), 
       input  ' E':U (icType), 
       input  3 (iiSeverity), 
       input  ' ':U (icRowid), 
       input  'qadfin-120243':U (icFcMsgNumber), 
       input  ' ':U (icFcExplanation), 
       input  ' ':U (icFcIdentification), 
       input  ' ':U (icFcContext), 
       output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
     Return.
end. /* tqDomainForInterCompany.tcIntercoJEGLCode = "":U */ 

/* Check the type of th g/l account in the target company */
<Q-40 run GLByGLType (all) (Read) (NoCache)
   (input tqcompanyByCodeCurrActiveID.tiCompany_ID, (CompanyId)
    input ?, (GLId)
    input tqDomainForInterCompany.tcIntercoJEGLCode, (GLCode)
    input ?, (GLTypeCode)
    input ?, (GLIsDivisionAccount)
    output dataset tqGLByGLType) in BGL >
        
find tqGLByGLType no-lock no-error.
if not available tqGLByGLType
then do :
    assign vcMessage     = trim(substitute(#T-29'Cannot find the account &1 specified as the manual journal entry account in the cross-company setup for the domain &2.':255(60939)T-29#,tqDomainForInterCompany.tcIntercoJEGLCode,tqDomainForInterCompany.tcDomainCode)) + chr(10) + 
                           trim(substitute(#T-65'Current Company ID: &1.':255(60940)T-65#,trim(string(tqDomainForInterCompany.tiPrimaryCompany_ID))))
           oiReturnStatus = -1.
    /* Create a corruption */        
    assign vhFcComponent = ?.
    <M-76 run CreateCorruption
       (input  'DomainProperty':U (icTableName), 
        input  trim(substitute('Domain: &1.':U,tqDomainForInterCompany.tcDomainCode)) (icKey), 
        input  vcMessage (icDescription), 
        input  false (ilSkipMessage), 
        output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
    <M-68 run SetMessage
       (input  vcMessage (icMessage), 
        input  ' ':U (icArguments), 
        input  ' ':U (icFieldName), 
        input  ' ':U (icFieldValue), 
        input  ' E':U (icType), 
        input  3 (iiSeverity), 
        input  ' ':U (icRowid), 
        input  'qadfin-543250':U (icFcMsgNumber), 
        input  ' ':U (icFcExplanation), 
        input  ' ':U (icFcIdentification), 
        input  ' ':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
    return.
end. /* if not available tqGLByGLType */

if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS}
then do :
    assign vcMessage     = trim(substitute(#T-18'The account &1 is defined as the manual journal entry account in the cross-company setup of the domain &2. Account &1 is not a cross-company account.':255(60941)T-18#,tqDomainForInterCompany.tcIntercoJEGLCode,tqDomainForInterCompany.tcDomainCode)) + chr(10) + 
                           trim(substitute(#T-91'Current Company ID: &1.':255(60940)T-91#,trim(string(tqDomainForInterCompany.tiPrimaryCompany_ID))))
          oiReturnStatus = -1.
    /* Create a corruption */
    assign vhFcComponent = ?.                    
    <M-92 run CreateCorruption
      (input  'DomainProperty':U (icTableName), 
       input  trim(substitute('Domain: &1.':U,tqDomainForInterCompany.tcDomainCode)) (icKey), 
       input  vcMessage (icDescription), 
       input  false (ilSkipMessage), 
       output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
    <M-82 run SetMessage
       (input  vcMessage (icMessage), 
        input  ' ':U (icArguments), 
        input  ' ':U (icFieldName), 
        input  ' ':U (icFieldValue), 
        input  ' E':U (icType), 
        input  3 (iiSeverity), 
        input  ' ':U (icRowid), 
        input  'qadfin-275930':U (icFcMsgNumber), 
        input  ' ':U (icFcExplanation), 
        input  ' ':U (icFcIdentification), 
        input  ' ':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
    Return.
end. /* if tqGLByGLType.tcGLTypeCode <> {&GLTYPECODE-CROSS} */

/* set the values in ttCompanyJEGL so that they can simply be retrieved */
create ttCompanyJEGL.
assign 
    ttCompanyJEGL.tcCompanyCode = icCompanyCode
    ttCompanyJEGL.tcGlCode = tqDomainForInterCompany.tcIntercoJEGLCode
    ttCompanyJEGL.tiCompanyId = tqCompanyByCodeCurrActiveID.tiCompany_ID
    ocGLCode = tqDomainForInterCompany.tcIntercoJEGLCode.