project QadFinancials > class BPosting > method CalculateOpenItems

Description

Lookup open item references


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.Calculate


program code (program1/bposting.p)

for each tPosting,
    each tPostingLine where
         tPostingLine.tc_ParentRowid = tPosting.tc_Rowid and
         tPostingLine.tcGLTypeCode = {&GLTYPECODE-OPEN}:

    if vlOpen = no
    then do:
        <Q-2 run GLOpenItemByCyKeyGLPostingLine  (Start) in BGLOpenItem >
        assign vlOpen = true.
    end.

    <Q-3 run GLOpenItemByCyKeyGLPostingLine (all) (Read) (Cache)
       (input tPostingLine.GL_ID, (GL_ID)
        input tPostingLine.PostingLine_ID, (PostingLine_ID)
        input '', (Key)
        input tPosting.Company_ID, (CompanyId)
        output dataset tqGLOpenItemByCyKeyGLPostingLine) in BGLOpenItem >
    find first tqGLOpenItemByCyKeyGLPostingLine no-error.
    if available tqGLOpenItemByCyKeyGLPostingLine
    then assign tPostingLine.tcAllocationType = {&ALLOCATIONTYPE-NEW}
                tPostingLine.tcAllocationKey  = tqGLOpenItemByCyKeyGLPostingLine.tcGLOpenItemKey
                tPostingLine.tcAllocationPostingLine =
                 string(tPosting.PostingYear,"9999":U) + "/":U +
                 string(tPosting.PostingPeriod,"99":U) + "/":U +
                 tPosting.tcJournalCode + "/":U +
                 string(tPosting.PostingVoucher,"999999999":U).
    else do:
        if vlMove = no
        then do:
            <Q-4 run GLOpenItemMovementByGLPosting  (Start) in BGLOpenItem >
            assign vlMove = true.
        end.

        <Q-5 run GLOpenItemMovementByGLPosting (all) (Read) (Cache)
           (input tPostingLine.GL_ID, (GL_ID)
            input tPostingLine.PostingLine_ID, (PostingLine_ID)
            input tPosting.Company_ID, (CompanyId)
            output dataset tqGLOpenItemMovementByGLPosting) in BGLOpenItem >
        find first tqGLOpenItemMovementByGLPosting no-error.
        if available tqGLOpenItemMovementByGLPosting
        then assign tPostingLine.tcAllocationType = {&ALLOCATIONTYPE-LINK}
                    tPostingLine.tcAllocationKey  = tqGLOpenItemMovementByGLPosting.tcGLOpenItemKey
                    tPostingLine.tcAllocationPostingLine =
                     string(tqGLOpenItemMovementByGLPosting.tiPeriodYear,"9999":U) + "/":U +
                     string(tqGLOpenItemMovementByGLPosting.tiPeriodPeriod,"99":U) + "/":U +
                     tqGLOpenItemMovementByGLPosting.tcJournalCode + "/":U +
                     string(tqGLOpenItemMovementByGLPosting.tiPostingVoucher,"999999999":U).
        else assign tPostingLine.tcAllocationType           = {&ALLOCATIONTYPE-LATER}
                    tPostingLine.tcAllocationKey            = "":U
                    tPostingLine.tcAllocationPostingLine    = "":U.
    end.

    /* Copy to before-image for later use */
    find t_iPostingLine where
         t_iPostingLine.tc_Rowid = tPostingLine.tc_Rowid no-error.
    if available t_iPostingLine
    then assign t_iPostingLine.tcGLTypeCode = tPostingLine.tcGLTypeCode
                t_iPostingLine.tcAllocationType = tPostingLine.tcAllocationType
                t_iPostingLine.tcAllocationKey = tPostingLine.tcAllocationKey.
end.

if vlOpen
then do:
    <Q-6 run GLOpenItemByCyKeyGLPostingLine  (Stop) in BGLOpenItem >
end.

if vlMove
then do:
    <Q-7 run GLOpenItemMovementByGLPosting  (Stop) in BGLOpenItem >
end.