project QadFinancials > class BBankEntry > method MarkAllBankEntryLinesAsUnallocated

Description

MarkAllBankEntryLinesAsUnallocated;
This method simply marks all banking-entry lines as unallocated; the idea behind this is that this method gets called from within the BankImport-classes in case something goes wrong.


Parameters


iiBankStateIDinputinteger
icBankStateLineRowIdinputcharacter
ilRemoveBankStateinputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankImportLine.ProcessBankImpLineNewBankEntry


program code (program6/bbankentry.p)

    
    /* ========================================================================================================= */
    /* MarkAllBankEntryLinesAsUnallocated;                                                                       */
    /* This method simply marks all banking-entry lines as unallocated; the idea behind this is that this method */ 
    /* gets called from within the BankImport-classes in case something goes wrong.                              */
    /* Once all BankingEntry lines are marked as Unallocated, the associated postings will be removed from the   */
    /* JournalEntry-instance and thus the JournalEntry-instance will be stopped. These JournalEntry-related      */
    /* actions are done in BBankEntry:StopExternalInstances                                                      */
    /* ========================================================================================================= */
    /* ========================================================================================================= */
    /* PIBF Enhancement                                                                                          */
    /* After pibf enhancement, this method will not mark all banking-entry line, it will only mark one           */
    /* banking-entry as unallocated according to the input bank state id and bank state line id                  */
    /* ========================================================================================================= */
    
if iiBankStateID = ? or iiBankStateID = 0 then return.
if icBankStateLineRowId = ? or icBankStateLineRowId = '':U then return.
                                                                                                             
    for each tBankState where
             tBankState.tc_Status <> "D":U and
             tBankState.BankState_ID  = iiBankStateID
             no-lock ,
        each tBankStateLine where
             tBankStateLine.tc_ParentRowid       = tBankState.tc_Rowid            and 
/*             tBankStateLine.BankStateLineStatus <> {&BANKSTATELINESTATUS-UNALLOC} and */
             tBankStateLine.tiPostingVoucher    <> 0                              and
             tBankStateLine.tiPostingVoucher    <> ?                              and
             tBankStateLine.tc_Status           <> "D":U                          and
             tBankStateLine.tc_Status           <> "":U                           and
             tBankStateLine.tc_Rowid             = icBankStateLineRowId:

        if viBJournalEntryBEID <> 0 and viBJournalEntryBEID <> ?
        then do:
            <M-94 run RemovePosting
               (input  tBankStateLine.Posting_ID (iiPostingId), 
                input  viBJournalEntryBEID (iiBJournalEntryId), 
                output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
        end.

        assign tBankStateLine.BankStateLineStatus = {&BANKSTATELINESTATUS-UNALLOC}
               tBankStateLine.tc_Status           = (if tBankStateLine.tc_Status = "":U 
                                                     then "C":U
                                                     else tBankStateLine.tc_Status)
               tBankStateLine.tiPostingVoucher    = 0
               tBankStateLine.Posting_ID          = 0
               tBankStateLine.tiPostingPeriodYear = 0.

    end. /* for each tBankState where */

    /* Remove bank state */
    if ilRemoveBankState
    then do:
         define buffer btBankState  for tBankState.
         define buffer btBankStateAlloc for tBankStateAlloc.
         define buffer btBankStateLine  for tBankStateLine.
         define buffer btBankStateAllocColl for tBankStateAllocColl.
         define buffer btBankStateStageAlloc for tBankStateStageAlloc.

        for each btBankState where
                 btBankState.tc_Status <> "D":U and
                 btBankState.BankState_ID  = iiBankStateID:
            for each btBankStateLine where
                    btBankStateLine.tc_ParentRowid = btBankState.tc_Rowid:

                for each btBankStateAlloc where
                    btBankStateAlloc.BankStateLine_ID = btBankStateLine.BankStateLine_ID:
                    delete btBankStateAlloc.
                end.
                if btBankStateLine.tc_Status = "N":U and
                   btBankStateLine.tc_Rowid = icBankStateLineRowId
                then delete btBankStateLine.
                else assign vlMultiBankStateLine = true.
            end.
            
            if not vlMultiBankStateLine and
               btBankState.tc_Status = "N":U 
            then delete btBankState.
        end.
    end.