project QadFinancials > class BPaymentSelection > method AdditionalUpdatesDInvoice

Description

update the selected flag of the dinvoices


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.AdditionalUpdates


program code (program5/bpaymentselection.p)

empty temp-table tSelectedDInvoicePaySel.

for each tPaySelLine where
         tPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} or
         tPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE}:
    if tPaySelLine.tc_Status = "":U                               and
       vcActivityCode       <> {&PAYMENTSELECTIONACTIVITY-DELETE} and
       vcActivityCode       <> {&PAYMENTSELECTIONACTIVITY-REGISTER}
    then next.

    find tSelectedDInvoicePaySel where
         tSelectedDInvoicePaySel.tiDInvoiceId = tPaySelLine.PaySelLineParentObject_ID
         no-error.

    if not available tSelectedDInvoicePaySel
    then do:

        /* IsSelected should only be updated for Non-Cross Company Invoices */
        /* Cross-company invoices are being updated by bCinvoice.Presave */
        <Q-57 assign vlFcQueryRecordsAvailable = DInvoicePrim (NoCache)
           (input viCompanyId, (CompanyId)
            input t_sPaySelLine.PaySelLineParentObject_ID, (DInvoiceId)
            input , (PeriodYear)
            input , (JournalId)
            input , (JournalCode)
            input ?, (DInvoiceVoucher)) in BDInvoice >
        if vlFcQueryRecordsAvailable <> TRUE
        then next.
        
        create tSelectedDInvoicePaySel.
        assign tSelectedDInvoicePaySel.tiDInvoiceId = tPaySelLine.PaySelLineParentObject_ID.
    end.

    if vcActivityCode        = {&PAYMENTSELECTIONACTIVITY-REGISTER} or
       vcActivityCode        = {&PAYMENTSELECTIONACTIVITY-DELETE}   or
       tPaySelLine.tc_Status = "D":U
    then assign tSelectedDInvoicePaySel.tlDInvoiceIsSelected = false.
    else assign tSelectedDInvoicePaySel.tlDInvoiceIsSelected = tPaySelLine.tlProposedLineIsSelected.
end.

if can-find(first tSelectedDInvoicePaySel)
then do:
    if viBDInvoicePaySelID = 0 or
       viBDInvoicePaySelID = ?
    then do:
        <I-1 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BDInvoice"}>

        assign vlBDInvIsStartedFromPaySel = true.
    end.
    else do:
         <I-2 {bFcOpenInstance
            &CLASS           = "BDInvoice"}>
    end.
    /* shx 10/11/07 ilClearData must be false otherwise the information in the ValidatecomponentPrebank will be lost */
    <M-5 run UpdateDInvoiceIsSelected
       (input  tSelectedDInvoicePaySel (tSelectedDInvoice), 
        input  false (ilClearData), 
        output viReturn (oiReturnStatus)) in BDInvoice>
    
    /* ========================================================================================================= */
    /* Normally we would here close BDInvoice but we will not do it for performance                              */
    /* reasons as this way the Commit of the transaction does not have to re-open the instance to commit it.     */
    /* And in all other scenario's the instance of the class ill be closed by the de-activiate procedure of the  */
    /* appserver that is executed after each call to the appserver                                               */
    /* ========================================================================================================= */
    
    if viReturn       < 0 or
       oiReturnStatus = 0
    then assign oiReturnStatus = viReturn.

    if oiReturnStatus < 0
    then return.
end.