project QadFinancials > class BDInvoice > method CreateDInvoicesFinChargeSub

Description

Method to update the invoices involved in Finance Charge Calculation with the date the calculation was done on.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ApiCreateDInvoicesFinCharge


program code (program9/bdinvoice.p)

assign oiReturnStatus = -98.

for each tUpdateDILastFinChargeDate:
    if not can-find(first tDInvoice where
                          tDInvoice.DInvoice_ID = tUpdateDILastFinChargeDate.tiDInvoice_ID)
    then assign vcListDInvoiceIDsToLoad = if vcListDInvoiceIDsToLoad = "":U
                                          then string(tUpdateDILastFinChargeDate.tiDInvoice_ID)
                                          else if lookup(string(tUpdateDILastFinChargeDate.tiDInvoice_ID), vcListDInvoiceIDsToLoad,chr(4)) = 0
                                               then vcListDInvoiceIDsToLoad + chr(4) + string(tUpdateDILastFinChargeDate.tiDInvoice_ID)
                                          else vcListDInvoiceIDsToLoad.
end. /* for each tUpdateDILastFinChargeDate  */

if vcListDInvoiceIDsToLoad <> "":U
then do:
     <M-1 run DataLoad
        (input  ? (icRowids), 
         input  vcListDInvoiceIDsToLoad (icPkeys), 
         input  ? (icObjectIds), 
         input  ? (icFreeform), 
         input  ? (ilKeepPrevious), 
         output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
      if viFcReturnSuper <> 0
      then do:
        assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0
        then do:
            assign vcMessage = trim(#T-3'Error in loading Invoices to be updated with the Finance Charge Date.':100(64860)t-3#).
            <M-2 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-6810':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
            Return.
        end.  /* if oiReturnStatus < 0 */
    end. /* if viFcReturnSuper <> 0 */
end. /* if vcListDInvoiceIDsToLoad <> "":U */

for each tUpdateDILastFinChargeDate:
    find first tDInvoice
        where tDInvoice.DInvoice_ID = tUpdateDILastFinChargeDate.tiDInvoice_ID
        no-lock no-error.
    if not available tDInvoice
    then do:
        assign vcMessage = trim(#T-4'The system cannot locate the invoice to update with the Finance Charge Date.':100(64861)t-4#).
        <M-5 run SetMessage
            (input  vcMessage (icMessage), 
             input  '':U (icArguments), 
             input  '':U (icFieldName), 
             input  '':U (icFieldValue), 
             input  'E':U (icType), 
             input  3 (iiSeverity), 
             input  '':U (icRowid), 
             input  'QadFin-6811':U (icFcMsgNumber), 
             input  '':U (icFcExplanation), 
             input  '':U (icFcIdentification), 
             input  '':U (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
        Next.
    end. /* if not available tDInvoice */
    if available tDInvoice
    then do:
         if tDInvoice.DInvoiceLastFinChargeDate = ? or
            tDInvoice.DInvoiceLastFinChargeDate < tUpdateDILastFinChargeDate.ttDInvoiceLastFinChargeDate
         then assign tDInvoice.DInvoiceLastFinChargeDate = tUpdateDILastFinChargeDate.ttDInvoiceLastFinChargeDate
                     tDInvoice.tc_Status = "C":U.
    end. /* find first tDInvoice */
end. /* for each tUpdateDILastFinChargeDate:  */

if oiReturnStatus = -98
     then assign oiReturnStatus = 0.