project QadFinancials > class BDInvoice > method PostSaveDynamicCreations

Description

PostSaveDynamicCreations: submethod of the inheritted method PostSave that will create the QDInvoiceMovement records based upon temp-tables


Parameters


oiNbrOfCreatedQDInvoiceMovementoutputintegerQDInvoiceMovementCreated: Returns the number of QDInvoiceMovement records that are created
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.PostSave


program code (program1/bdinvoice.p)

    
    /* ====================================================================================================================== */
    /* IMPORTANT NOTES:                                                                                                       */
    /*                                                                                                                        */
    /* The normal process is that updates towards other classes are done through the normal approach with Starting&Opening    */
    /* the external instance and then call a method in there. But as that decreases the performance to much for frequently    */
    /* used actions like the creation of the QDInvoiceMovement-records, we will here do the creation of these                 */
    /* records here via dynamic buffers.                                                                                      */
    /*                                                                                                                        */
    /* The temp-tables used in here need to be defined with KeepState=true as the records in them are created in method       */
    /* AdditionalUpdates but they are used in PostSave and these method are not always executed in one go.                    */
    /* So the 2 (AdditionalUpdates and PostSave) can be handled by another appserver-process and then PostSave would find     */
    /* the temp-table to empty when they were not defined with KeepState=true.                                                */
    /* ====================================================================================================================== */
    
    /* ====================================================================================== */
    /* Use an include that is only used to track direct writes in the program-code            */
    /* ====================================================================================== */
    <I-85 {WRITEDIRECTDBACCESS
         &WRITETABLENAMES = "'QDInvoiceMovement':U"}>
        
    /* ====================================================================================== */
    /* Start the persistenceLayer once so it can be used for get new db-sequences             */
    /* ====================================================================================== */
    <M-29 run StartPersistence
       (output vhFcComponent (ohPersistence), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>  
        
    /* =============================================================================================== */
    /* QDInvoiceMovement: Transfer the data that is in the temp-tables to the db using dynamic buffers */
    /* =============================================================================================== */
    create buffer vhBufferQDInvoiceMovement for table "QDInvoiceMovement":U in widget-pool "non-persistent":U.

    For each tQDInvoiceMovementToCreate 
             no-lock
             on error undo, throw :

        vhBufferQDInvoiceMovement:Buffer-Create().

        assign oiNbrOfCreatedQDInvoiceMovement                       = oiNbrOfCreatedQDInvoiceMovement + 1
               vhBufferQDInvoiceMovement::QDInvoiceMovement_ID       = <M-48 GetNextValue  (input  'ObjectNumber':U (icSequence)) in Progress>
               vhBufferQDInvoiceMovement::DInvoiceMovementDebitLC    = tQDInvoiceMovementToCreate.DInvoiceMovementDebitLC
               vhBufferQDInvoiceMovement::DInvoiceMovementCreditLC   = tQDInvoiceMovementToCreate.DInvoiceMovementCreditLC
               vhBufferQDInvoiceMovement::DInvoiceMovementDebitTC    = tQDInvoiceMovementToCreate.DInvoiceMovementDebitTC
               vhBufferQDInvoiceMovement::DInvoiceMovementCreditTC   = tQDInvoiceMovementToCreate.DInvoiceMovementCreditTC
               vhBufferQDInvoiceMovement::DInvoiceMovementDebitCC    = tQDInvoiceMovementToCreate.DInvoiceMovementDebitCC
               vhBufferQDInvoiceMovement::DInvoiceMovementCreditCC   = tQDInvoiceMovementToCreate.DInvoiceMovementCreditCC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatDebLC   = tQDInvoiceMovementToCreate.DInvoiceMovementVatDebLC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatCredLC  = tQDInvoiceMovementToCreate.DInvoiceMovementVatCredLC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatDebTC   = tQDInvoiceMovementToCreate.DInvoiceMovementVatDebTC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatCredTC  = tQDInvoiceMovementToCreate.DInvoiceMovementVatCredTC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatDebCC   = tQDInvoiceMovementToCreate.DInvoiceMovementVatDebCC
               vhBufferQDInvoiceMovement::DInvoiceMovementVatCredCC  = tQDInvoiceMovementToCreate.DInvoiceMovementVatCredCC
               vhBufferQDInvoiceMovement::DInvoiceMovementIsInvoice  = tQDInvoiceMovementToCreate.DInvoiceMovementIsInvoice
               vhBufferQDInvoiceMovement::DInvoiceMovementIsCreditN  = tQDInvoiceMovementToCreate.DInvoiceMovementIsCreditN
               vhBufferQDInvoiceMovement::DInvoiceMovementType       = tQDInvoiceMovementToCreate.DInvoiceMovementType
               vhBufferQDInvoiceMovement::DInvoiceMovementInfo       = tQDInvoiceMovementToCreate.DInvoiceMovementInfo
               vhBufferQDInvoiceMovement::MovementYearPeriod         = tQDInvoiceMovementToCreate.MovementYearPeriod
               vhBufferQDInvoiceMovement::Company_ID                 = tQDInvoiceMovementToCreate.Company_ID
               vhBufferQDInvoiceMovement::Currency_ID                = tQDInvoiceMovementToCreate.Currency_ID
               vhBufferQDInvoiceMovement::Debtor_ID                  = tQDInvoiceMovementToCreate.Debtor_ID
               vhBufferQDInvoiceMovement::Period_ID                  = tQDInvoiceMovementToCreate.Period_ID
               vhBufferQDInvoiceMovement::GL_ID                      = tQDInvoiceMovementToCreate.GL_ID
               vhBufferQDInvoiceMovement::Division_ID                = tQDInvoiceMovementToCreate.Division_ID
               vhBufferQDInvoiceMovement::Project_ID                 = tQDInvoiceMovementToCreate.Project_ID
               vhBufferQDInvoiceMovement::CostCentre_ID              = tQDInvoiceMovementToCreate.CostCentre_ID
               vhBufferQDInvoiceMovement::Journal_ID                 = tQDInvoiceMovementToCreate.Journal_ID.

        vhBufferQDInvoiceMovement:Buffer-Release().

    End. /* For each tQDInvoiceMovementToCreate where  */
    
    
    /* ================================================================================================== */
    /* Empty the temp-tables as they are no longer needed and thus only increase the size of the instance */
    /* ================================================================================================== */
    empty temp-table tQDInvoiceMovementToCreate.
        
    
/* =============== */    
/* Finally actions */
/* =============== */
finally:
    if vhBufferQDInvoiceMovement <> ?
    then vhBufferQDInvoiceMovement:buffer-release().
    Delete Object vhBufferQDInvoiceMovement no-error.
end finally.