project QadFinancials > class BJournalEntry > method GetPostingInfoByPostingLineIDTT

Description

GetPostingInfoByPostingLineID; this method will look in the instance tables for a posting of the posting-line and return its posting-date and some other header-iinfo.
Note that the instance-data should already be laoded as this method onlt checks the instance-data and not the db
=> done for a temp-table, so that multiple records can checked in one time


Parameters


tPostingPostingLineInfoinput-outputtemp-tabletemp-table with all fields needed for method GetPostingInfoByPostingLineIDTT
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.AdditionalUpdatesAllAssignments
method BCInvoice.ValidateCInvoiceMovementCrossCy
method BCInvoice.ValidateComponentPostMovement
method BDInvoice.AdditionalUpdatesAllAssignments
method BDInvoice.ValidateComponentAllMovement


program code (program6/bjournalentry.p)

    assign oiReturnStatus       = -98
           viLocalReturnStatus  = 0.
    
    for each tPostingPostingLineInfo :    
        /* Get the posting-line */
        find tPostingLine where 
             tPostingLine.PostingLine_ID = tPostingPostingLineInfo.tiPostingLine_ID
             no-lock no-error.
        if not available tPostingLine
        then do:
            assign vcMessage            = trim(substitute(#T-30'Internal error: Invalid Posting Line ID &1.':255(999890285)T-30#, string(tPostingPostingLineInfo.tiPostingLine_ID)))
                   viLocalReturnStatus  = -3.
            <M-29 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'S':U (icType), 
                input  3 (iiSeverity), 
                input  ? (icRowid), 
                input  'QadFin-8985':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
            leave.
        end.
    
        /* Get the posting */
        find tPosting where 
             tPosting.tc_Rowid = tPostingLine.tc_ParentRowid
             no-lock no-error.
        if not available tPosting
        then do:
            assign vcMessage            = trim(substitute(#T-33'Internal error: posting record not found for row ID &1.':150(3199)t-33#, tPostingLine.tc_ParentRowid))
                   viLocalReturnStatus  = -3.
            <M-31 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'S':U (icType), 
                input  3 (iiSeverity), 
                input  ? (icRowid), 
                input  'QadFin-8986':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
            leave.
        end.
        
        /* Set the output parameter PostingDate, PeriodID and YearPeriod */
        assign tPostingPostingLineInfo.ttPostingDate       = tPosting.PostingDate
               tPostingPostingLineInfo.tiPostingYearPeriod = tPosting.PostingYear * 100 + tPosting.PostingPeriod.
    
        if (tPosting.Period_ID        = ? or  tPosting.Period_ID    = 0)    and
            tPosting.Company_ID      <> 0 and tPosting.Company_ID    <> ?   and
            tPosting.PostingYear     <> 0 and tPosting.PostingYear   <> ?   and 
            tPosting.PostingPeriod   <> 0 and tPosting.PostingPeriod <> ?
        then do :
            <Q-6 run PeriodPrim (all) (Read) (Cache)
               (input tPosting.Company_ID, (CompanyId)
                input ?, (PeriodId)
                input tPosting.PostingYear, (PeriodYear)
                input tPosting.PostingPeriod, (PeriodPeriod)
                output dataset tqPeriodPrim) in BPeriod>
            find first tqPeriodPrim no-error.
            if available tqPeriodPrim
            then assign tPostingPostingLineInfo.tiPeriod_ID = tqPeriodPrim.tiPeriod_ID. 
        end. /* if tPosting.PostingYear   <> 0 and */
        else assign tPostingPostingLineInfo.tiPeriod_ID = tPosting.Period_ID.
            
        /* this method created and called so that CC amounts are calculated before being sent for invoice movement updates */
        if (tPostingLine.PostingLineDebitCC = 0 or tPostingLine.PostingLineDebitCC = ?) and
           (tPostingLine.PostingLineCreditCC = 0 or tPostingLine.PostingLineCreditCC = ?) 
        then do:
            <M-11 run CalculateCCAmount
               (input  tPosting.Company_ID (iiCompanyID), 
                input  tPostingLine.PostingLineCreditLC (idPostingLineCreditLC), 
                input  tPostingLine.PostingLineCreditTC (idPostingLineCreditTC), 
                input  tPostingLine.PostingLineDebitLC (idPostingLineDebitLC), 
                input  tPostingLine.PostingLineDebitTC (idPostingLineDebitTC), 
                input  tPosting.PostingDate (itPostingDate), 
                input  tPostingLine.tcCurrencyCode (icCurrencyCode), 
                input  tPosting.PostingDate (itInvoiceExchangeRateDate), 
                input-output vdCCExchangeRate (bdCCExchangeRate), 
                input-output vdCCExchangeRateScale (bdCCExchangeRateScale), 
                input-output vlCurrencyFetched (blCurrencyFetched), 
                output tPostingLine.PostingLineCreditCC (odPostingLineCreditCC), 
                output tPostingLine.PostingLineDebitCC (odPostingLineDebitCC), 
                output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>.
            if viFcReturnSuper <> 0 
            then assign viLocalReturnStatus = viFcReturnSuper.
            if viFcReturnSuper < 0 then leave.
        end.
    
        assign tPostingPostingLineInfo.tcJournalCode         = tPosting.tcJournalCode
               tPostingPostingLineInfo.tcLayerTypeCode       = tPosting.tcLayerTypeCode
               tPostingPostingLineInfo.tdPostingLineCreditLC = tPostingLine.PostingLineCreditLC
               tPostingPostingLineInfo.tdPostingLineCreditTC = tPostingLine.PostingLineCreditTC
               tPostingPostingLineInfo.tdPostingLineCreditCC = tPostingLine.PostingLineCreditCC
               tPostingPostingLineInfo.tdPostingLineDebitLC  = tPostingLine.PostingLineDebitLC
               tPostingPostingLineInfo.tdPostingLineDebitTC  = tPostingLine.PostingLineDebitTC
               tPostingPostingLineInfo.tdPostingLineDebitCC  = tPostingLine.PostingLineDebitCC.
    
        if (tPostingLine.GL_ID      = ?     or  tPostingLine.GL_ID      = 0) and
            tPostingLine.tcGLCode   <> "":U and tPostingLine.tcGLCode   <> ?
        then do:
            <Q-13 run GLPrim (all) (Read) (Cache)
               (input viCompanyId, (CompanyId)
                input tPostingLine.tcGLCode, (GLCode)
                input ?, (GLId)
                output dataset tqGLPrim) in BGL>
            find first tqGLPrim where
                       tqGLPrim.tcGLCode = tPostingLine.tcGLCode
                       no-lock no-error.
            assign tPostingPostingLineInfo.tiGL_ID = if available tqGLPrim
                                                     then tqGLPrim.tiGL_ID
                                                     else 0.
        end.
        else assign tPostingPostingLineInfo.tiGL_ID = tPostingLine.GL_ID.
    
        if (tPostingLine.Division_ID    = ?     or tPostingLine.Division_ID     = 0) and
            tPostingLine.tcDivisionCode <> "":U and tPostingLine.tcDivisionCode <> ?
        then do:
            
            <Q-15 run DivisionPrim (all) (Read) (Cache)
               (input viCompanyId, (CompanyId)
                input ?, (DivisionID)
                input tPostingLine.tcDivisionCode, (DivisionCode)
                output dataset tqDivisionPrim) in BDivision>
            find first tqDivisionPrim where
                       tqDivisionPrim.tcDivisionCode = tPostingLine.tcDivisionCode
                       no-lock no-error.
            assign tPostingPostingLineInfo.tiDivision_ID = if available tqDivisionPrim
                                                           then tqDivisionPrim.tiDivision_ID
                                                           else 0.
        end.
        else assign tPostingPostingLineInfo.tiDivision_ID = tPostingLine.Division_ID.
    
        if (tPostingLine.Project_ID     = ?     or tPostingLine.Project_ID      = 0) and
            tPostingLine.tcProjectCode <> "":U and tPostingLine.tcProjectCode   <> ?
        then do:
            <Q-17 run ProjectPrim (all) (Read) (Cache)
               (input viCompanyId, (CompanyId)
                input ?, (ProjectID)
                input tPostingLine.tcProjectCode, (ProjectCode)
                output dataset tqProjectPrim) in BProject>
            find first tqProjectPrim where
                       tqProjectPrim.tcProjectCode = tPostingLine.tcProjectCode
                       no-lock no-error.
            assign tPostingPostingLineInfo.tiProject_ID = if available tqProjectPrim
                                                          then tqProjectPrim.tiProject_ID
                                                          else 0.
        end.
        else assign tPostingPostingLineInfo.tiProject_ID = tPostingLine.Project_ID.
    
        if (tPostingLine.CostCentre_ID      = ?     or  tPostingLine.CostCentre_ID      = 0) and
            tPostingLine.tcCostCentreCode   <> "":U and tPostingLine.tcCostCentreCode   <> ?
        then do:
            <Q-19 run CostCentrePrim (all) (Read) (Cache)
               (input viCompanyId, (CompanyId)
                input ?, (CostCentreID)
                input tPostingLine.tcCostCentreCode, (CostCentreCode)
                output dataset tqCostCentrePrim) in BCostCentre>
            find first tqCostCentrePrim where
                       tqCostCentrePrim.tcCostCentreCode = tPostingLine.tcCostCentreCode
                       no-lock no-error.
            assign tPostingPostingLineInfo.tiCostCentre_ID = if available tqCostCentrePrim
                                                             then tqCostCentrePrim.tiCostCentre_ID
                                                             else 0.
        end.
        else assign tPostingPostingLineInfo.tiCostCentre_ID = tPostingLine.CostCentre_ID.
    
        if (tPosting.Journal_ID    <> ?    and tPosting.Journal_ID      <> 0) or
           (tPosting.tcJournalCode <> "":U and tPosting.tcJournalCode   <> ?)
        then do :
            <Q-28 run JournalByJournalIDCodeType (all) (Read) (Cache)
               (input if tPosting.Journal_ID = ? or tPosting.Journal_ID = 0 then tPosting.Company_ID else ?, (CompanyId)
                input tPosting.Journal_ID, (JournalID)
                input if tPosting.Journal_ID = ? or tPosting.Journal_ID = 0 then tPosting.tcJournalCode else ?, (JournalCode)
                input ?, (JournalTypeCode)
                output dataset tqJournalByJournalIDCodeType) in BJournal>
            find first tqJournalByJournalIDCodeType where
                      (if tPosting.Journal_ID = 0 or tPosting.Journal_ID = ?
                       then tqJournalByJournalIDCodeType.tcJournalCode = tPosting.tcJournalCode
                       else tqJournalByJournalIDCodeType.tiJournal_ID  = tPosting.Journal_ID)
                no-lock no-error.
            if available tqJournalByJournalIDCodeType
            then assign tPostingPostingLineInfo.tcJournalTypeCode = tqJournalByJournalIDCodeType.tcJournalTypeCode
                        tPostingPostingLineInfo.tiJournal_ID      = tqJournalByJournalIDCodeType.tiJournal_ID.
        end. /* if tPosting.tcJournalCode <> "":U and */
    end.
    
    
    
    assign oiReturnStatus = viLocalReturnStatus.