project QadFinancials > class BDInvoice > method AdditionalUpdatesAllBill


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.AdditionalUpdatesAll


program code (program1/bdinvoice.p)

empty temp-table tBillListInDInvoice.
empty temp-table tFullAdjDInvoiceForBill.

vcChangedBillStatus = "".

for each tDInvoice where tDInvoice.tc_Status = "C":U and
                         tDInvoice.Bill_ID <> 0
                break by tDInvoice.Bill_ID:
    if first-of(tDInvoice.Bill_ID) then 
    do:
        <Q-19 run BillById (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input tDInvoice.Bill_ID, (Bill_ID)
            output dataset tqBillById) in BBill>
        find first tqBillById no-error.
        if available tqBillById then
        do:
            if tqBillById.tcBillStatus = {&BILLSTATUS-INITIAL} then next.

            if not can-find (first tBillListInDInvoice where tBillListInDInvoice.tiBill_ID = tDInvoice.Bill_ID) then
            do:
                create tBillListInDInvoice.
                assign tBillListInDInvoice.tiBill_ID = tDInvoice.Bill_ID.
            end.

            for each bDInvoiceForBill where bDInvoiceForBill.Bill_ID = tDInvoice.Bill_ID:
                find first t_iDInvoice where t_iDInvoice.DInvoice_ID = bDInvoiceForBill.DInvoice_ID no-error.
    
                if not t_iDInvoice.DInvoiceIsOpen and bDInvoiceForBill.DInvoiceIsOpen then
                do:                   
                    vcChangedBillStatus = {&BILLSTATUS-CONFIRM}.
                    leave.
                end.
                else if t_iDInvoice.DInvoiceIsOpen and not bDInvoiceForBill.DInvoiceIsOpen then
                do: 
                    vcChangedBillStatus = {&BILLSTATUS-CLOSED}.
                    create tFullAdjDInvoiceForBill.
                    assign tFullAdjDInvoiceForBill.tiDInvoice_ID = bDInvoiceForBill.DInvoice_ID.                    
                end.
            end.
        end.
    end.        
end.

<I-57 {bFcStartAndOpenInstance
     &ADD-TO-TRANSACTION   = "true"
     &CLASS                = "BBill"}>

if vcChangedBillStatus <> "" then
do:
    <M-18 run ChangeBillStatus
       (input  tBillListInDInvoice (tBillListForChangeStatus), 
        input  tFullAdjDInvoiceForBill (tFullAdjDInvoiceForStatus), 
        input  vcChangedBillStatus (icChangedBillStatus), 
        output oiReturnStatus (oiReturnStatus)) in BBill>
end.

<I-26 {bFcCloseInstance
     &CLASS           = "BBill"}>