project QadFinancials > class BPaymentSelection > method CalculatePaySelLineWhtGetData

Description

Get WHT data for all invoices of the payment


Parameters


icPaySelRowIdinputcharacter
tDefaultWHTDataForPaySeloutputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.CalculatePaySelLine


program code (program3/bpaymentselection.p)

/* ====================================================================================== *
 * Method       : CalculateGetWhtData                                                     *
 * Description  : Retrieve WHT data for Supplier invoices on the Payment                  *
 * -------------------------------------------------------------------------------------- *
 * Parameters   :                                                                         *
 * ====================================================================================== */
 
MAIN_BLOCK:
do on error undo, throw:
    /* Default output parameters */
    empty temp-table tDefaultWHTDataForPaySel.
    
    /* Pre-validation block */
    if icPaySelRowId = ? or icPaySelRowId = "":U then return.

    /* Create list of all invoices for which data should be retrieved */
    for each tPaySelLine where
             tPaySelLine.tc_ParentRowid             = icPaySelRowId and
             tPaySelLine.PaySelLineParentObject_ID <> ?             and
             tPaySelLine.PaySelLineParentObject_ID <> 0:              
        
        if can-find(first tDefaultWHTDataForPaySel where
                          tDefaultWHTDataForPaySel.tiCInvoiceID = tPaySelLine.PaySelLineParentObject_ID)
        then next.
                               
        create tDefaultWHTDataForPaySel.
        assign tDefaultWHTDataForPaySel.tiCInvoiceID = tPaySelLine.PaySelLineParentObject_ID.
    end.

    
    /* ================================================================================== *
     * Get all wht data                                                                   *
     * ================================================================================== */
    if can-find(first tDefaultWHTDataForPaySel)
    then do:
        if viBCInvoicePaySelID = 0 or
           viBCInvoicePaySelID = ?
        then do:
            <I-12 {bFcStartAndOpenInstance
                 &ADD-TO-TRANSACTION   = "false"
                 &CLASS                = "BCInvoice"}>
        end. /* end if viBCInvoicePaySelID = 0 .. */
        else do:
            <I-73 {bFcOpenInstance
                 &CLASS           = "BCInvoice"}>
        end. /* end else if viBCInvoicePaySelID = 0 */
        
        <M-81 run DefaultWHTDataBasedOnCInvoice
           (input-output tDefaultWHTDataForPaySel (tDefaultWHTData), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave MAIN_BLOCK.
    end. /* end can-find(first tDefaultWHTDataForPaySel) */

    
    /* Finally block */
    finally:
        if valid-handle (vhBCInvoicePaySelInst)
        then do:
            <I-46 {bFcCloseAndStopInstance
                 &CLASS           = "BCInvoice"}>
        end.
    end.
end. /* MAIN_BLOCK */