project QadFinancials > class BDInvoice > method DeleteDInvoiceFromTempTable

Description

Removes DInvoice from temp-table based on its ID.


Parameters


iiDInvoice_IDinputintegerDInvoice ID of the record to remove.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.StopExternalInstances


program code (program3/bdinvoice.p)

/* ======================================================================== */
/* This method was created to clear out the DInvoice record after a failure */
/* in BDDocument - when a period was locked by a journal mask an error is   */
/* produced, but when the status of DDocument is changed and then saved     */
/* another error was produced.  This method was created remove any unwanted */
/* DInvoice records.                                                        */
/* ======================================================================== */
/* Paramters: iiDInvoice_ID - the DInvoice ID to be deleted                 */
/* ======================================================================== */
                                                                              
/* delete any related DInvoice based on the ID passed in */
for each tDInvoice where
         tDInvoice.DInvoice_ID = iiDInvoice_ID and
         tDInvoice.tc_Status   = "N":U:

    /* delete any related DInvoiceMovement */
    for each tDInvoiceMovement where
             tDInvoiceMovement.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceMovement.tc_Status      = "N":U:

        delete tDInvoiceMovement.
    end.
    
    /* delete any related DInvoiceDeduction */
    for each tDInvoiceDeduction where
             tDInvoiceDeduction.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceDeduction.tc_Status      = "N":U:

        delete tDInvoiceDeduction.
    end.

    /* delete any related DInvoiceBank and DInvoiceBankPayCode */
    for each tDInvoiceBank where
             tDInvoiceBank.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceBank.tc_Status      = "N":U:

        for each tDInvoiceBankPayCode where
                 tDInvoiceBankPayCode.tc_ParentRowid = tDInvoiceBank.tc_Rowid and
                 tDInvoiceBankPayCode.tc_Status      = "N":U:

            delete tDInvoiceBankPayCode.
        end.

        delete tDInvoiceBank.
    end.

    /* delete any related DInvoiceOpInfo */
    for each tDInvoiceOpInfo where
             tDInvoiceOpInfo.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceOpInfo.tc_Status      = "N":U:

        delete tDInvoiceOpInfo.
    end.

    /* delete any related DInvoicePosting */
    for each tDInvoicePosting where
             tDInvoicePosting.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoicePosting.tc_Status      = "N":U:

        delete tDInvoicePosting.
    end.

    /* delete any related DInvoiceStage */                                         
    for each tDInvoiceStage where
             tDInvoiceStage.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceStage.tc_Status      = "N":U:
           
        delete tDInvoiceStage.
    end.
            
    /* delete any related DInvoiceVat */             
    for each tDInvoiceVat where
             tDInvoiceVat.tc_ParentRowid = tDInvoice.tc_Rowid and
             tDInvoiceVat.tc_Status      = "N":U:
             
        delete tDInvoiceVat.
    end.

    delete tDInvoice.
end.