project QadFinancials > class BCInvoice > method CreateCInvoicesGLAccount

Description

submethod of createcinvoices , check the gl account , if it works with divisions, cost centres .. and default them if necessary


Parameters


bcGLCodeinput-outputcharacterGL Account
iiDivisionIdinputintegerDivision ID
bcDivisionCodeinput-outputcharacterDivision Code
iiCostCentreIdinputintegerCost Centre ID
bcCostCentreCodeinput-outputcharacterCost Centre Code
iiProjectIdinputintegerProject ID
bcProjectCodeinput-outputcharacterProject Code
icCInvoiceTypeinputcharacterType of the creditor invoice
iiInvControlGLProfileIdinputintegerInvoice Control GL Profile ID
iiCnControlGLProfileIdinputintegerCredit Note Control GL Profile ID
iiPrePayControlGLProfileIdinputintegerPrepayment control gl profile id
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCInvoices


program code (program3/bcinvoice.p)

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

if bcGLCode = "":U
then do:
    assign viControlGLProfileId = if icCInvoiceType = {&INVOICETYPE-PREPAYMENT}
                                  then iiPrePayControlGLProfileId
                                  else if icCInvoiceType = {&INVOICETYPE-INVOICE} or
                                          icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                       then iiInvControlGLProfileId
                                       else iiCnControlGLProfileId.
    
    if viControlGLProfileId = ? or viControlGLProfileId = 0
    then assign vlError = true.
    else do:
        <Q-87 run ProfileLinkByGL (all) (Read) (NoCache)
           (input viControlGLProfileId, (GlProfileId)
            input viCompanyId, (CompanyId)
            output dataset tqProfileLinkByGL) in BProfile >
        find first tqProfileLinkByGL where
                   tqProfileLinkByGL.tiProfile_ID = viControlGLProfileId no-error.
        if not available tqProfileLinkByGL
        then assign vlError = true.
    end.
    if vlError
    then do:
        <M-92 run SetMessage
           (input  trim(#T-20'The system could not find a supplier control account record.':150(1053)T-20#) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  tCInvoice.tc_Rowid (icRowid), 
            input  'QadFin-182733':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        assign oiReturnStatus = -1.
        return.
    end.
    assign bcGLCode = tqProfileLinkByGL.tcGLCode.
end.

<Q-45 run GetGLIDBasedOnGLCode (all) (Read) (NoCache)
   (input tCInvoice.Company_ID, (CompanyID)
    input bcGLCode, (GLCode)
    output dataset tqGLIDBasedOnGLCode) in BGL >
find first tqGLIDBasedOnGLCode where
           tqGLIDBasedOnGLCode.tcGLCode = bcGLCode
           no-error.
if not available tqGLIDBasedOnGLCode
then do:
    <M-94 run SetMessage
       (input  trim(subst(#T-74'GL account not found (&1).':150(613986854)T-74#, bcGLCode)) (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-891594':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    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-50 run GetDivisionFromProfile (all) (Read) (NoCache)
        (input tCInvoice.Company_ID, (CompanyId)
         input tqGLIDBasedOnGLCode.tiDivisionProfile_ID, (DivisionProfileId)
         output dataset tqDivisionFromProfile) in BProfile >
    find first tqDivisionFromProfile where
               tqDivisionFromProfile.tiProfile_ID = tqGLIDBasedOnGLCode.tiDivisionProfile_ID
               no-error.
    if available tqDivisionFromProfile
    then assign bcDivisionCode = tqDivisionFromProfile.tcDivisionCode.
    else do:
        <M-41 run SetMessage
           (input  trim(subst(#T-5'Sub-account profile of account &1 not found.':150(220076241)T-5#, bcGLCode)) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-401225':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice> 
        assign oiReturnStatus = -3.
    end.
end.

if tqGLIDBasedOnGLCode.tlGLIsCostCentreAccount        and
   iiCostCentreId                              = 0    and
   bcCostCentreCode                            = "":U and
   tqGLIDBasedOnGLCode.tiCostCentreProfile_ID <> 0    and
   tqGLIDBasedOnGLCode.tiCostCentreProfile_ID <> ?
then do:
    <Q-60 run GetCostCentreFromProfile (all) (Read) (NoCache)
       (input tCInvoice.Company_ID, (CompanyId)
        input tqGLIDBasedOnGLCode.tiCostCentreProfile_ID, (CostCentreProfileId)
        output dataset tqCostCentreFromProfile) in BProfile >
    find first tqCostCentreFromProfile where
               tqCostCentreFromProfile.tiProfile_ID = tqGLIDBasedOnGLCode.tiCostCentreProfile_ID
               no-error.
    if available tqCostCentreFromProfile
    then assign bcCostCentreCode = tqCostCentreFromProfile.tcCostCentreCode.
    else do:
        <M-30 run SetMessage
           (input  trim(subst(#T-85'Cost center profile of account &1 not found.':150(100418206)T-85#, bcGLCode)) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-778818':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        assign oiReturnStatus = -3.
        return.
    end.
end.

if tqGLIDBasedOnGLCode.tlGLIsProjectAccount           and
   iiProjectId                                 = 0    and
   bcProjectCode                               = "":U and
   tqGLIDBasedOnGLCode.tiProjectProfile_ID    <> 0    and
   tqGLIDBasedOnGLCode.tiProjectProfile_ID    <> ?
then do:
    <Q-16 run GetProjectFromProfile (all) (Read) (NoCache)
       (input tCInvoice.Company_ID, (CompanyId)
        input tqGLIDBasedOnGLCode.tiProjectProfile_ID, (ProjectProfileID)
        output dataset tqProjectFromProfile) in BProfile >
    find first tqProjectFromProfile where
               tqProjectFromProfile.tiProfile_ID = tqGLIDBasedOnGLCode.tiProjectProfile_ID
               no-error.
    if available tqProjectFromProfile
    then assign bcProjectCode = tqProjectFromProfile.tcProjectCode.
    else do:
        <M-1 run SetMessage
           (input  trim(subst(#T-6'Project profile of account &1 not found.':150(964728239)T-6#, bcGLCode)) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-919223':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        assign oiReturnStatus = -3.
        return.
    end.
end.