project QadFinancials > class BDCollection > method UpdateDCollection


Parameters


tDCollectionsToUpdateinput-outputtemp-table
ilClearDatainputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.AdditionalUpdatesPosting
method BDPaymentSelection.AdditionalUpdates


program code (program5/bdcollection.p)

if ilClearData
then do:
    <M-6 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BDCollection>

    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.

    if viFcReturnSuper < 0
    then return.
end.

assign vcPKeys = "":U.

for each tDCollectionsToUpdate where
         tDCollectionsToUpdate.DCollection_ID <> 0 and
         tDCollectionsToUpdate.DCollection_ID <> ?:
    assign vcPKeys = if vcPKeys = "":U
                     then string(tDCollectionsToUpdate.DCollection_ID)
                     else if lookup(string(tDCollectionsToUpdate.DCollection_ID), vcPKeys,chr(4)) = 0
                          then vcPKeys + chr(4) + string(tDCollectionsToUpdate.DCollection_ID)
                          else vcPKeys.
end.

if vcPKeys <> "":U
then do:
    <M-7 run DataLoad (input  '':U (icRowids), 
                   input  vcPKeys (icPkeys), 
                   input  '':U (icObjectIds), 
                   input  '':U (icFreeform), 
                   input  not ilClearData (ilKeepPrevious), 
                   output viFcReturnSuper (oiReturnStatus)) in BDCollection>

    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.

    if oiReturnStatus < 0
    then return.
end.

for each tDCollectionsToUpdate:
    if tDCollectionsToUpdate.DCollection_ID = 0 or
       tDCollectionsToUpdate.DCollection_ID = ?
    then do:
        <M-8 run AddDetailLine (input  'DCollection':U (icTable), 
                        input  '':U (icParentRowid), 
                        output viFcReturnSuper (oiReturnStatus)) in BDCollection>

        buffer-copy tDCollectionsToUpdate
             except tDCollectionsToUpdate.CreationUsr_ID
                    tDCollectionsToUpdate.DCollection_ID
                    tDCollectionsToUpdate.DCollectionCreationDate
                    tDCollectionsToUpdate.DCollectionCreationTime
                    tDCollectionsToUpdate.DCollectionNumber
                    tDCollectionsToUpdate.tc_ParentRowid
                    tDCollectionsToUpdate.tc_Rowid
                    tDCollectionsToUpdate.tc_Status
                 to tDCollection.

        assign tDCollectionsToUpdate.DCollection_ID = tDCollection.DCollection_ID
               vhFcComponent                        = ?.

        <M-9 run GetNumber
           (input  tDCollection.Company_ID (iiCompanyId), 
            input  tDCollection.DCollectionYear (iiNumbrYear), 
            input  'DCOL':U (icNumbrType), 
            output tDCollection.DCollectionNumber (oiNumber), 
            input  viFcCurrentInstanceId (iiInstanceId), 
            input  vcFcComponentName (icClassName), 
            output viFcReturnSuper (oiReturnStatus)) in BNumber>

        assign tDCollectionsToUpdate.DCollectionNumber = tDCollection.DCollectionNumber
               tDCollection.DCollectionReference       = string(year(tDCollection.DCollectionRequestedDate) , "9999":U) +
                                                         string(month(tDCollection.DCollectionRequestedDate), "99":U)   +
                                                         string(day(tDCollection.DCollectionRequestedDate)  , "99":U)   + "-":U +
                                                         string(tDCollection.DCollectionNumber).
    end.
    else do:
        find tDCollection where
             tDCollection.DCollection_ID = tDCollectionsToUpdate.DCollection_ID
             no-error.

        if not available tDCollection
        then do:
            <M-10 run SetMessage
          (input  trim(#T-11'The previously loaded supplier payment collection $1 cannot be found.':250(869)t-11#) (icMessage), 
           input  string(tDCollection.DCollection_ID) (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-2542':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BDCollection>

            assign oiReturnStatus = -1.
            return.
        end.
        
        if tDCollectionsToUpdate.tc_Status = "D":U
        then assign tDCollection.DCollectionBalanceCreditTC = 0
                    tDCollection.DCollectionBalanceCreditLC = 0
                    tDCollection.DCollectionBalanceCreditCC = 0
                    tDCollection.DCollectionBalanceDebitTC  = 0
                    tDCollection.DCollectionBalanceDebitLC  = 0
                    tDCollection.DCollectionBalanceDebitCC  = 0
                    tDCollection.tc_Status                  = "C":U.
        else assign tDCollection.DCollectionBalanceDebitTC = tDCollection.DCollectionBalanceDebitTC + tDCollectionsToUpdate.DCollectionBalanceDebitTC
                    tDCollection.DCollectionBalanceDebitLC = tDCollection.DCollectionBalanceDebitLC + tDCollectionsToUpdate.DCollectionBalanceDebitLC
                    tDCollection.DCollectionBalanceDebitCC = tDCollection.DCollectionBalanceDebitCC + tDCollectionsToUpdate.DCollectionBalanceDebitCC.

        delete tDCollectionsToUpdate.
    end.
end.