project QadFinancials > class BDInvoice > method ValidateComponentAllAnalysis

Description

This method is a submethod of ValidateComponentAll.

This method validates the Debtor Invoices fields related to analysis : division, cost centre and project


Parameters


iiCostCentreIDinputintegerCost centre ID
icCostCentreCodeinputcharacter
iiProjectIDinputintegerProject ID
icDivisionCodeinputcharacterSub-Account Code
iiControlGLIDinputintegercontrol GL Account ID
blstartGLForInvoiceValinput-outputlogicalParameter that shows if query tqGLForInvoiceVal is already started or not
blstartCostCentreForInvoiceinput-outputlogicalParameter that shows if query tqCostCentreForInvoiceVal is already started or not
blstartProjectForInvoiceinput-outputlogicalParameter that shows if query tqProjectFor InvoiceValidation is already started or not
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ValidateComponentAll


program code (program5/bdinvoice.p)

if not(blstartGLForInvoiceVal)
then do:
    <Q-38 run GLForInvoiceVal  (Start) in BGL > 
    assign blstartGLForInvoiceVal = true.
end.
<Q-37 run GLForInvoiceVal (all) (Read) (NoCache)
      (input viCompanyID, (CompanyId)
       input iiControlGLID, (GLId)
       output dataset tqGLForInvoiceVal) in BGL >
              
/* check to see if the required fields for the analysis type on the customer control account are set */
find first tqGLForInvoiceVal where tqGLForInvoiceVal.tiGL_ID = iiControlGLID no-error.

if not available tqGLForInvoiceVal
then do:
    assign 
        vcMessage = #T-33'The specified customer control account is not defined in the system.':150(49402)T-33#
    oiReturnStatus = -1.
    <M-34 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-7407':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.

if tqGLForInvoiceVal.tlGLIsDivisionAccount and (icDivisionCode = "":U or icDivisionCode = ?)
then do:
    assign vcMessage      = trim(#T-30'You must specify a sub-account because the customer control account is defined with sub-account analysis.':150(1792)T-30#)
           oiReturnStatus = -1.
           
    <M-36 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'tDinvoice.tcDivisionCode':U (icFieldName), 
        input  icDivisionCode (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '' (icRowid), 
        input  'QadFin-7410':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>              
end.

/* IF the analysis type on the Customer control account is cost centre then a cost centre must be specified */
if tqGLForInvoiceVal.tlGLIsCostCentreAccount and iiCostCentreID = 0
then do:
             assign vcMessage      = #T-11'You must specify a cost center because customer control account $1 is defined with cost center analysis.':90(59277)T-11#
               oiReturnStatus = -1.
        <M-10 run SetMessage
           (input  vcMessage (icMessage), 
            input  '' (icArguments), 
            input  'tcCostCentreCode' (icFieldName), 
            input  '' (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'QadFin-5955':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.

if blstartCostCentreForInvoice = false
then do:
    <Q-61 run CostCentreForInvoiceVal  (Start) in BCostCentre >
    assign blstartCostCentreForInvoice = true.
end.

if iiCostCentreID <> 0 and
   iiCostCentreID <> ?
then do:

    <Q-56 run CostCentreForInvoiceVal (all) (Read) (NoCache)
               (input viCompanyID, (CompanyId)
                input iiCostCentreID, (CostCentreId)
                output dataset tqCostCentreForInvoiceVal) in BCostCentre >
    
    
    find first tqCostCentreForInvoiceVal where
               tqCostCentreForInvoiceVal.tiCostCentre_ID = iiCostCentreID
               no-error.
    
    if not available tqCostCentreForInvoiceVal
    then do:
       <M-57 run SetMessage
          (input  #T-56'The specified cost center is not defined in the system.':255(65499)T-56# (icMessage), 
           input  '':U (icArguments), 
           input  'tDinvoice.tcCostCentreCode':U (icFieldName), 
           input  '' (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '' (icRowid), 
           input  'QadFin-7421':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDInvoice>        
    
        assign oiReturnStatus = -1.
        return.
    end.
    
end. /* cost centre not 0*/

/* Validate project code*/
/* If the analysis teyp on the customer control account is project then a project must be specified */
if tqGLForInvoiceVal.tlGLIsProjectAccount and (iiProjectId = 0 or iiProjectID = ?)
then do:
      assign vcMessage      = trim(#T-52'Project is mandatory as Customer control account has analysis type of Project':90(999890185)T-52#)
            oiReturnStatus = -1.
        <M-51 run SetMessage
           (input  vcMessage (icMessage), 
            input  '' (icArguments), 
            input  'tcProjectCode':U (icFieldName), 
            input  '' (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'QadFin-7420':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.            

if iiProjectID <> 0 and
   iiProjectID <> ?
then do:

    if blstartProjectForInvoice = false
    then do:
        <Q-46 run ProjectForInvoiceValidation  (Start) in BProject >
      assign blstartProjectForInvoice = true.
    end.
    
    <Q-45 run ProjectForInvoiceValidation (all) (Read) (NoCache)
       (input viCompanyID, (CompanyId)
        input iiProjectId, (ProjectId)
        output dataset tqProjectForInvoiceValidation) in BProject >
    
    find first tqProjectForInvoiceValidation 
        where tqProjectForInvoiceValidation.tiProject_ID = iiProjectID no-error.
    
    if not available tqProjectForInvoiceValidation
    then do:
        assign vcMessage      =                 #T-41'The specified project is not defined in the system or is invalid.':255(65450)T-41#
               oiReturnStatus = -1.
          <M-65 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '' (icArguments), 
                        input  'tDInvoice.tcProjectCode' (icFieldName), 
                        input  '' (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-7427':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
          return.
    end.     

    if tqProjectForInvoiceValidation.tlProjectIsTemplate
    then do:
        assign vcMessage      = trim(#T-42'Template projects are not allowed on supplier invoices.':250(1091)T-42#)
               oiReturnStatus = -1.
          <M-63 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '' (icArguments), 
                        input  'tDInvoice.tcProjectCode' (icFieldName), 
                        input  '' (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-7425':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    end.
    
    if tqProjectForInvoiceValidation.tlProjectStatusIsActive <> true
    then do:
        assign vcMessage      = trim(#T-43'You can only specify active project statuses.':250(65728)T-43#)
               oiReturnStatus = -1.
           <M-62 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '' (icArguments), 
                        input  'tDInvoice.tcProjectCode' (icFieldName), 
                        input  '' (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-7424':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    end.
    
    if tqProjectForInvoiceValidation.tcProjectStatusSystemStatus <> {&PROJECTSYSTEMSTATUS-OPEN} and
       tqProjectForInvoiceValidation.tcProjectStatusSystemStatus <> {&PROJECTSYSTEMSTATUS-CLOSEDCOSTS}
    then do:
        assign vcMessage      = trim(substitute(#T-44'You can only specify projects with system status &1 or &2.':250(1783)T-44#, {&PROJECTSYSTEMSTATUS-OPEN-TR},{&PROJECTSYSTEMSTATUS-CLOSEDCOSTS-TR}))
               oiReturnStatus = -1.
          <M-64 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '' (icArguments), 
                        input  'tDInvoice.tcProjectCode' (icFieldName), 
                        input  '' (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  '' (icRowid), 
                        input  'QadFin-7426':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
    end.
end. /*project specified */