project QadFinancials > class BJournalEntry > method DeleteInstanceLinesExceptGL

Description

Delete all instance lines for this posting, except the line with certain GLCode


Parameters


iiPostingIdinputintegerPosting ID
icGLCodeinputcharacterthis GL Account must not be deleted
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCIPosting
method BDInvoice.CreateDIPosting


program code (program3/bjournalentry.p)

if icGLCode = ? then assign icGLCode = "":U.
    
if iiPostingId = 0
then do:
    assign vcMessage      = trim(#T-2'You must enter the posting ID if you want to delete the instance lines.':150(2735)T-2#)
           oiReturnStatus = -1.
    <M-1 run SetMessage (input  vcMessage (icMessage),
                 input  '':U (icArguments),
                 input  '':U (icFieldName),
                 input  '':U (icFieldValue),
                 input  'E':U (icType),
                 input  3 (iiSeverity),
                 input  '':U (icRowid),
                 input  'QADFIN-712':U (icFcMsgNumber),
                 input  '' (icFcExplanation),
                 input  '' (icFcIdentification),
                 input  '' (icFcContext),
                 output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    return.
end.

/* ======================================================================================== */
/* If GL Account is specified, delete all lines except lines with this G/L account          */
/* ======================================================================================== */
if icGLCode <> "":U
then do:
    for each tPostingLine where
             tPostingLine.Posting_ID = iiPostingId and
             tPostingLine.tcGLCode   <> icGLCode:
        for each tPostingVat where
                 tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tpostingvat.
        end.
        for each tPostingWHT where
                 tPostingWHT.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingWHT.
        end.
        for each tPostingVatDelay where
            tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingVatDelay.
        end.
        for each tPostingSaf where
                 tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingSaf.
        end.
        delete tPostingLine.
    end.
end.
/* ======================================================================================== */
/* If GL Account is NOT specified, delete all posting lines                                 */
/* ======================================================================================== */
else do:
    for each tPostingLine where
             tPostingLine.Posting_ID = iiPostingId:
        for each tpostingvat where
                tPostingVat.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingVat.
        end.
        for each tpostingwht where
                tpostingwht.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tpostingwht.
        end.
        for each tPostingVatDelay where
            tPostingVatDelay.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingVatDelay.
        end.
        for each tPostingSaf where
                 tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid :
            delete tPostingSaf.
        end.
        delete tPostingLine.
    end.
end.