project QadFinancials > class BDInvoice > method UpdateDInvoiceDueDate


Parameters


tDInvoiceToChangeinputtemp-table
tDInvoiceStageToChangeinputtemp-table
icActivityCodeinputcharacter
ilSetSelectedinputlogicalIf SetSelected is true then set the IsSelected flag on the invoice or stage line
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDPaymentSelection.AdditionalUpdatesDInvoice


program code (program1/bdinvoice.p)

assign 
    vcDInvoiceIDs = ""
    /* Flag the Invoice Activity to say it was changed from Payment Selection */
    vcActivityCode  = icActivityCode.

/* build up a list of invoice id's to load */
for each tDInvoiceToChange:
    if vcDInvoiceIds = "" then assign vcDInvoiceIds = string(tDInvoiceToChange.tiDInvoiceId).
    else assign vcDInvoiceIds = vcDInvoiceIDs + ',' + string(tDInvoiceToChange.tiDInvoiceId).    
    /* if vcDInvoiceIds > 10000, load the data to prevent vcDInvoiceIds to get out of 32K limit */
    if length(vcDInvoiceIds, "CHARACTER") > 10000
    then do:    
        <M-49 run DataLoad
           (input  '' (icRowids), 
            input  '' (icPkeys), 
            input  vcDInvoiceIds (icObjectIds), 
            input  '' (icFreeform), 
            input  true (ilKeepPrevious), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        if viFcReturnSuper > 0
        then do:
            assign 
                oiReturnStatus = viFcReturnSuper
                vcMessageText =   #T-80'Customer invoices with IDs &1 could not be loaded for modification':255(146197737)T-80# .
            <M-42 run SetMessage
               (input  vcMessageText (icMessage), 
                input  '' (icArguments), 
                input  '' (icFieldName), 
                input  '' (icFieldValue), 
                input  'E' (icType), 
                input  3 (iiSeverity), 
                input  '' (icRowid), 
                input  'qadfin-156897':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDInvoice>    
            return.                
        end. /* if viFcReturnSuper > 0 */ 
        vcDInvoiceIds = '':U.  
    end. /* if length (vcDInvoiceIds, */ 
end.  /* for each tDInvoiceToChange: */  
/* load filtered posting records when there are any that haven't been loaded yet */
if vcDInvoiceIds <> '':U 
then do:   
    <M-72 run DataLoad
        (input  '' (icRowids), 
         input  '' (icPkeys), 
         input  vcDInvoiceIds (icObjectIds), 
         input  '' (icFreeform), 
         input  true (ilKeepPrevious), 
         output viFcReturnSuper (oiReturnStatus)) in BDInvoice>        
    if viFcReturnSuper > 0
    then do:
        assign 
            oiReturnStatus = viFcReturnSuper
            vcMessageText =   #T-98'Customer invoices with IDs &1 could not be loaded for modification':255(146197737)T-98# .
        <M-97 run SetMessage
           (input  vcMessageText (icMessage), 
            input  '' (icArguments), 
            input  '' (icFieldName), 
            input  '' (icFieldValue), 
            input  'E' (icType), 
            input  3 (iiSeverity), 
            input  '' (icRowid), 
            input  'qadfin-883378':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDInvoice>    
        return.                    
    end. /* if viFcReturnSuper > 0 */
    assign vcDInvoiceIds = '':U.
end. /* if vcDInvoiceIds <> '':U */

/* go through the input records and make the change */
for each tDInvoiceToChange:
    
    for first tDInvoice 
        where tDInvoice.Dinvoice_ID = tDInvoiceToChange.tiDInvoiceId:
        assign 
            tDInvoice.DInvoiceDueDate = tDInvoiceToChange.ttDueDate
            tDInvoice.tc_status = "C".
        if ilSetSelected = true and tDInvoice.tcNormalPaymentConditionType = {&PAYMENTCONDITIONPAYMENTTYPE-NORMAL}
        then do:
            if tDInvoiceToChange.tlIsSelected <> ?
                then assign tDInvoice.DInvoiceIsSelected = tDInvoiceToChange.tlIsSelected.
        end. /* if ilSetSelected */                    
    end.
    
    /* update the due date on the stages if there are any */             
    for each tDInvoiceStageToChange
       where tDInvoiceStageToChange.tiDInvoiceId = tDInvoiceToChange.tiDInvoiceId,
       first tDInvoiceStage
       where tDInvoiceStage.DInvoiceStage_ID = tDInvoiceStageToChange.tiDInvoiceStageId:
        assign 
            tDInvoiceStage.DInvoiceStageDueDate = tDInvoiceStageToChange.ttDueDate
            tDInvoiceStage.tc_status = "C". 
       if ilSetSelected = true
       then do:
            if tDInvoiceStageToChange.tlIsSelected <> ?
                then assign tDInvoiceStage.DInvoiceStageIsSelected = tDInvoiceStageToChange.tlIsSelected.            
       end. /* if tDInvoiceStageToCahnge.tcStatus */       
    end.
    
end. /* end for each tDInvoiceToChange */  

<M-66 run ValidateBCAndAdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.