project QadFinancials > class BDInvoice > method CreateDIPostingGLAccount

Description

Check the gl account, if it works with divisions, cost centres, projects ...


Parameters


icGLCodeinputcharactergl account
iiDivisionIdinputintegerDivision ID
bcDivisionCodeinput-outputcharacterSub-Account Code
olGLIsDivisionAcountoutputlogicalIs this GL a division Account ?
bcCostCentreCodeinput-outputcharacterCost Center Code
bcProjectCodeinput-outputcharacterProject Code
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.CreateDInvoices
method BDInvoice.CreateDIPostingSales


program code (program3/bdinvoice.p)

/* give unknown values the right value */
if iiDivisionId     = ? then assign iiDivisionId        = 0.
if bcDivisionCode   = ? then assign bcDivisionCode      = "":U.
if bcCostCentreCode = ? then assign bcCostCentreCode    = "":U.
if bcProjectCode    = ? then assign bcProjectCode       = "":U.

<Q-1 run GetGLIDBasedOnGLCode (all) (Read) (NoCache)
   (input tDInvoice.Company_ID, (CompanyID)
    input icGLCode, (GLCode)
    output dataset tqGLIDBasedOnGLCode) in BGL >

find first tqGLIDBasedOnGLCode
           no-error.

if not available tqGLIDBasedOnGLCode
then do:
    <M-2 run SetMessage
          (input  trim(subst(#T-9'The GL account &1 cannot be found.':150(1231)t-9#, icGLCode)) (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-682':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDInvoice>

    assign oiReturnStatus = -3.
    return.
end.

if tqGLIDBasedOnGLCode.tlGLIsDivisionAccount        and
   iiDivisionId                              = 0    and
   bcDivisionCode                            = "":U and
   tqGLIDBasedOnGLCode.tiDivisionProfile_ID <> ?    and
   tqGLIDBasedOnGLCode.tiDivisionProfile_ID <> 0
then do:
    <Q-3 run GetDivisionFromProfile (all) (Read) (NoCache)
       (input tDInvoice.Company_ID, (CompanyId)
        input tqGLIDBasedOnGLCode.tiDivisionProfile_ID, (DivisionProfileId)
        output dataset tqDivisionFromProfile) in BProfile >

    find first tqDivisionFromProfile
               no-error.

    if available tqDivisionFromProfile
    then assign bcDivisionCode = tqDivisionFromProfile.tcDivisionCode.
    else do:
        <M-4 run SetMessage
          (input  trim(subst(#T-10'No sub-account profile is defined for account &1.':150(1232)t-10#,icGLCode)) (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-683':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDInvoice>

        assign oiReturnStatus = -3.
    end.
end.

if tqGLIDBasedOnGLCode.tlGLIsCostCentreAccount        and
   bcCostCentreCode                            = "":U and
   tqGLIDBasedOnGLCode.tiCostCentreProfile_ID <> 0    and
   tqGLIDBasedOnGLCode.tiCostCentreProfile_ID <> ?
then do:
    <Q-5 run GetCostCentreFromProfile (all) (Read) (NoCache)
       (input tDInvoice.Company_ID, (CompanyId)
        input tqGLIDBasedOnGLCode.tiCostCentreProfile_ID, (CostCentreProfileId)
        output dataset tqCostCentreFromProfile) in BProfile >

    find first tqCostCentreFromProfile
               no-error.

    if available tqCostCentreFromProfile
    then assign bcCostCentreCode = tqCostCentreFromProfile.tcCostCentreCode.
    else do:
        <M-6 run SetMessage
          (input  trim(subst(#T-11'No cost center profile is defined for account &1.':150(1233)t-11#,icGLCode)) (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-684':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDInvoice>

        assign oiReturnStatus = -3.
        return.
    end.
end.

if tqGLIDBasedOnGLCode.tlGLIsProjectAccount           and
   bcProjectCode                               = "":U and
   tqGLIDBasedOnGLCode.tiProjectProfile_ID    <> 0    and
   tqGLIDBasedOnGLCode.tiProjectProfile_ID    <> ?
then do:
    <Q-7 run GetProjectFromProfile (all) (Read) (NoCache)
       (input tDInvoice.Company_ID, (CompanyId)
        input tqGLIDBasedOnGLCode.tiProjectProfile_ID, (ProjectProfileID)
        output dataset tqProjectFromProfile) in BProfile >

    find first tqProjectFromProfile
               no-error.

    if available tqProjectFromProfile
    then assign bcProjectCode = tqProjectFromProfile.tcProjectCode.
    else do:
        <M-8 run SetMessage
          (input  trim(subst(#T-12'No project profile is defined for account.':150(1234)t-12#, icGLCode)) (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-685':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDInvoice>

        assign oiReturnStatus = -3.
        return.
    end.
end.

assign olGLIsDivisionAcount = tqGLIDBasedOnGLCode.tlGLIsDivisionAccount.