project QadFinancials > class BCInvoice > method RemoveInvoiceFromInstance


Parameters


iiOriginalCInvoiceIdinputintegerid of supplier invoice to be copied
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CopyIntoNew
method BCInvoice.ReplaceCInvoice


program code (program1/bcinvoice.p)

/* =================================================================================================== */
/* Method      : RemoveInvoiceFromInstance                                                             */
/* Desc        : This method removes the supplier invoice from Instance                                */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  iiOriginalCInvoiceId             id of supplier invoice to be copied                  */
/* =================================================================================================== */
assign oiReturnStatus = -98.

find tCInvoice where 
         tCInvoice.CInvoice_ID = iiOriginalCInvoiceId no-error.
    
    for each tCInvoiceBank where
              tCInvoiceBank.tc_ParentRowid = tCInvoice.tc_Rowid :
        
        for each tCInvoiceBankPayCode where
                 tCInvoiceBankPayCode.tc_ParentRowid = tCInvoiceBank.tc_Rowid:
             delete tCInvoiceBankPayCode.
        end.
        
        delete tCInvoiceBank.
    end.
    
    for each tCInvoiceMovement where
             tCInvoiceMovement.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoiceMovement.
    end.
    
    for each tCInvoicePO where
             tCInvoicePO.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoicePO.
    end.
    
    for each tCInvoicePosting where
             tCInvoicePosting.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoicePosting.
    end.
    
    for each tCInvoiceStage where
             tCInvoiceStage.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoiceStage.
    end.
    
    for each tCInvoiceVat where
             tCInvoiceVat.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoiceVat.
    end.
    
    for each tCInvoiceWHT where
             tCInvoiceWHT.tc_ParentRowid = tCInvoice.tc_Rowid:
        delete tCInvoiceWHT.
    end.
    
    delete tCInvoice.
/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.