project QadFinancials > class BPaymentSelection > method SplitSupplierInvoiceUnconfirm

Description

Used by Payment Selection Unconfirm. Split the PaySelLine batch by CDocument. The Unconfirm will be processed by CDocument.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.ChangeStatusPaymentSelInBatch


program code (program1/bpaymentselection.p)

empty temp-table tSupplierInvoiceGroups.

assign viGroupNumber   = 0
        oiReturnStatus = -98
        viLastCDocumentNumber = 0.

/* Get Document Info */
<Q-75 run CDocumentByPaySelId (all) (Read) (NoCache)
   (input ?, (CompanyId)
    input tPaySel.PaySel_ID, (PaySelId)
    output dataset tqCDocumentByPaySelId) in BCDocument>

for each tqCDocumentByPaySelId where
    tqCDocumentByPaySelId.tiPaySel_ID = tPaySel.PaySel_ID and
    (tqCDocumentByPaySelId.tcCDocumentStatus = {&DOCUMENTSTATUS-INCASSO} or
     tqCDocumentByPaySelId.tcCDocumentStatus = {&DOCUMENTSTATUS-PAID}) break by tqCDocumentByPaySelId.tiCDocument_ID:

    create tCDocumentLines.
    assign tCDocumentLines.tiCDocumentId = tqCDocumentByPaySelId.tiCDocument_ID
           tCDocumentLines.tiPaySelId = tqCDocumentByPaySelId.tiPaySel_ID
           tCDocumentLines.tiPaySelLine_ID = tqCDocumentByPaySelId.tiPaySelLine_ID.
end.

viCDocumentGroupId = 0.
for each tCDocumentLines break by tCDocumentLines.tiCDocumentId:

    if first-of (tCDocumentLines.tiCDocumentId) then
    do:
        viCDocumentGroupId = viCDocumentGroupId + 1.
        viCDocumentLinesCnt = 0.
        for each bCDocumentLines where bCDocumentLines.tiCDocumentId = tCDocumentLines.tiCDocumentId:
            viCDocumentLinesCnt = viCDocumentLinesCnt + 1.
        end.
        create tCDocumentGroup.
        assign tCDocumentGroup.tiCDocumentId = tCDocumentLines.tiCDocumentId.
               tCDocumentGroup.tiLinesNum = viCDocumentLinesCnt.
               tCDocumentGroup.tiCDocumentGroupId = viCDocumentGroupId.
    end.
end.
    
viCurrentGroupId = 0.
BatchLoop:
Do while true:
    assign viGroupNumber = viGroupNumber + 1 
           viCDocumentLinesInBatch = 0.  

    Do while true: 
        vlGroupFound = false.
        for first tCDocumentGroup where tCDocumentGroup.tiCDocumentGroupId > viCurrentGroupId:            
            vlGroupFound = true.         
        end.
        if vlGroupFound = false then leave BatchLoop.
       
        if viCDocumentLinesInBatch <> 0 and tCDocumentGroup.tiLinesNum + viCDocumentLinesInBatch > viMaxBatchSize then
            leave.
        else do:
            viCurrentGroupId = tCDocumentGroup.tiCDocumentGroupId.
            viCDocumentLinesInBatch = viCDocumentLinesInBatch + tCDocumentGroup.tiLinesNum.

            for each tCDocumentLines where tCDocumentLines.tiCDocumentId = tCDocumentGroup.tiCDocumentId: 
                for each tPaySelLine where tPaySelLine.PaySelLine_ID = tCDocumentLines.tiPaySelLine_ID
                                     break by tPaySelLine.PaySelLine_ID:
        
                    create tSupplierInvoiceGroups.
                    assign tSupplierInvoiceGroups.tiGroupNumber             = viGroupNumber 
                           tSupplierInvoiceGroups.tiPaySel_ID               = tPaySel.PaySel_ID
                           tSupplierInvoiceGroups.tiPaymentSelectionLineID  = tPaySelLine.PaySelLine_ID
                           tSupplierInvoiceGroups.tcPaySelLineStatus        = '':U
                           tSupplierInvoiceGroups.tiCDocument_ID            = tCDocumentGroup.tiCDocumentId.
              
                end. /* for each tPaySelLine */
            end. /* for each tCDocumentLines */
        end. /* else do */
    end. /* Do while true */
end. /* BatchLoop */

assign oiReturnStatus = 0.