project QadFinancials > class BBankEntry > method AdditionalUpdatesInvOptimisticLock

Description

AdditionalUpdatesOptimisticLock: method that contains the optimistic-lcok checks for the involved instances


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBankEntry.AdditionalUpdatesInv


program code (program4/bbankentry.p)

/* ================================================================================================== */
    /* After all DataLoads are done in sub-components (BCInvoice, BDInvoice, BCCollection, BDCollection): */
    /* Compare the data in the db with the initialy read data (fields DocBalance, CollBlance)             */
    /* TODO: extend these method for types EInvoice, DDoc, CDoc                                           */
    /* ================================================================================================== */
    
    /* ======================================= */
    /* Go through all new/modified allocations */
    /* ======================================= */
    for each tBankState where
             tBankState.tc_Status <> "D":U and
             (tBankState.BankStateStatus = {&BANKSTATESTATUS-PARTALLOC} or
              tBankState.BankStateStatus = {&BANKSTATESTATUS-ALLOC}) no-lock,
        each tBankStateLine where
             tBankStateLine.tc_ParentRowid       = tBankState.tc_Rowid           and 
             tBankStateLine.BankStateLineStatus  = {&BANKSTATELINESTATUS-ALLOC}  and
             (tBankStateLine.tc_status           = "N":U or  
             (tBankStateLine.tc_status           = "C":U and
              can-find(first t_iBankStateLine where
                             t_iBankStateLine.tc_Rowid = tBankStateLine.tc_Rowid and
                             t_iBankStateLine.BankStateLineStatus <> {&BANKSTATELINESTATUS-ALLOC} and
                             t_iBankStateLine.BankStateLineStatus <> {&BANKSTATELINESTATUS-ALLOCPOST}))),
        each tBankStateAlloc where
             tBankStateAlloc.tc_ParentRowid  = tBankStateLine.tc_Rowid and 
             (tBankStateAlloc.tc_Status = "N":U or
              tBankStateAlloc.tc_Status = "C":U) and
              tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-NCINV} and
              tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-NDINV} and
              tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-NEINV} and
              tBankStateAlloc.BankStateAllocType <> {&BANKSTATEALLOCTYPE-DEDUCTIONINV}
              no-lock : 
        
        /* =========================== */
        /* Check the allocation-origin */
        /* =========================== */
        case tBankStateAlloc.BankStateAllocType :
            /* =========================== */
            /* CCinvoice/DINVOICe          */
            /* =========================== */
            when {&INVOICETYPE-INVOICE}              or
            when {&INVOICETYPE-INVOICECORRECTION}    or
            when {&INVOICETYPE-CREDITNOTE}           or
            when {&INVOICETYPE-CREDITNOTECORRECTION} or
            when {&INVOICETYPE-PREPAYMENT}           or
            when {&INVOICETYPE-ADJUSTMENT}           or
            when {&INVOICETYPE-FINANCECHARGE}            /* defect FIN-1858 miz */
            then do :
                if tBankStateAlloc.CInvoice_ID <> 0 and tBankStateAlloc.CInvoice_ID <> ?
                then do:
                    <Q-1 assign vlFcQueryRecordsAvailable = CInvoiceByIDBalanceTCDueDates (NoCache)
                       (input ?, (CompanyId)
                        input tBankStateAlloc.CInvoice_ID, (CInvoiceID)
                        input (tBankStateAlloc.BankStateAllocOpenBalTC + tBankStateAlloc.tdInitiallyAllocatedWHTAmntTC), (BalanceTC)
                        input ?, (CInvoiceIsSelected)
                        input ?, (CInvoiceDueDate)
                        input ?, (CInvoiceDiscountDueDate)) in BCInvoice>
                    if vlFcQueryRecordsAvailable <> true
                    then do :
                        assign vcMessage      = trim(subst(#T-18'The supplier invoice &1 has been modified since you loaded it. Refresh your client.':255(271)t-18#,tBankStateAlloc.tcDocNumberReference)) + chr(10) + 
                                                trim(subst(#T-19'The open balance of the supplier invoice &1 you want to update has already been updated by another user.':255(272)t-19#,tBankStateAlloc.tcDocNumberReference)) + chr(10) + 
                                                trim(subst(#T-20'Initial open balance of the supplier invoice: &1.':255(273)T-20#,string(tBankStateAlloc.BankStateAllocOpenBalTC + tBankStateAlloc.tdInitiallyAllocatedWHTAmntTC))) + chr(10) + 
                                                trim(subst(#T-21'Bank statement line: &1.':200(274)t-21#,string(tBankStateLine.BankStateLineNumber)))
                               oiReturnStatus = -1.
                        <M-2 run SetMessage (input  vcMessage (icMessage), 
                                 input  '':U (icArguments), 
                                 input  '':U (icFieldName), 
                                 input  '':U (icFieldValue), 
                                 input  'E':U (icType), 
                                 input  3 (iiSeverity), 
                                 input  tBankStateAlloc.tc_Rowid (icRowid), 
                                 input  'QADFIN-1336':U (icFcMsgNumber), 
                                 input  '' (icFcExplanation), 
                                 input  '' (icFcIdentification), 
                                 input  '' (icFcContext), 
                                 output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                    end. /* if vlFcQueryRecordsAvailable <> true */
                end.

                if tBankStateAlloc.DInvoice_ID <> 0 and tBankStateAlloc.DInvoice_ID <> ?
                then do:
                    <Q-4 assign vlFcQueryRecordsAvailable = DInvoiceByIDBalanceTCDueDates (Cache)
                       (input tBankStateAlloc.Company_ID, (CompanyId)
                        input tBankStateAlloc.DInvoice_ID, (DInvoiceID)
                        input tBankStateAlloc.BankStateAllocOpenBalTC, (BalanceTC)
                        input ?, (DInvoiceIsSelected)
                        input ?, (DInvoiceDueDate)
                        input ?, (DInvoiceDiscountDueDate)) in BDInvoice >
                    if vlFcQueryRecordsAvailable <> true
                    then do :
                        assign vcMessage      = trim(subst(#T-22'The customer invoice &1 has been modified since you loaded it. Refresh your client.':255(275)t-22#,tBankStateAlloc.tcDocNumberReference)) + chr(10) + 
                                                trim(subst(#T-23'The open balance of the customer invoice &1 you want to update has already been updated by another user.':255(276)t-23#,tBankStateAlloc.tcDocNumberReference)) + chr(10) + 
                                                trim(subst(#T-24'Initial open balance of the customer invoice: &1.':255(277)T-24#,string(tBankStateAlloc.BankStateAllocOpenBalTC))) + chr(10) + 
                                                trim(subst(#T-25'Bank statement line: &1.':200(274)t-25#,string(tBankStateLine.BankStateLineNumber)))     
                               oiReturnStatus = -1.
                        <M-3 run SetMessage (input  vcMessage (icMessage),
                                 input  '':U (icArguments),
                                 input  '':U (icFieldName),
                                 input  '':U (icFieldValue),
                                 input  'E':U (icType),
                                 input  3 (iiSeverity),
                                 input  tBankStateAlloc.tc_Rowid (icRowid),
                                 input  'QADFIN-1337':U (icFcMsgNumber),
                                 input  '' (icFcExplanation),
                                 input  '' (icFcIdentification),
                                 input  '' (icFcContext),
                                 output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                    end. /* if vlFcQueryRecordsAvailable <> true */
                end.
            end. /* CINV/DINV */
            
            /* =========================== */
            /* CCollection                 */
            /* =========================== */
            when {&BANKSTATEALLOCTYPE-CCOLL}
            then do :
                if tBankStateAlloc.CCollection_ID = 0 or
                   tBankStateAlloc.CCollection_ID = ?
                then next.
                <Q-9 assign vlFcQueryRecordsAvailable = CCollectionByIDBalanceTC (NoCache)
                   (input tBankStateAlloc.Company_ID, (CompanyId)
                    input tBankStateAlloc.CCollection_ID, (CCollectionID)
                    input ABSOLUTE(tBankStateAlloc.tdCollBalance), (CCollectionBalanceTC)) in BCCollection>
                if vlFcQueryRecordsAvailable <> true
                then do :
                    assign vcMessage      = trim(subst(#T-26'The supplier payment collection &1 has been modified since you loaded it. Refresh your client.':255(278)t-26#,tBankStateAlloc.tcCollReference)) + chr(10) + 
                                            trim(subst(#T-27'The open balance of the supplier payment collection &1 you are want to update has already been updated by another user.':255(279)t-27#,tBankStateAlloc.tcCollReference)) + chr(10) + 
                                            trim(subst(#T-28'Initial open balance of the supplier payment collection: &1.':255(280)T-28#,string(tBankStateAlloc.tdCollBalance))) + chr(10) +
                                            trim(subst(#T-29'Bank statement line: &1.':200(274)t-29#,string(tBankStateLine.BankStateLineNumber)))     
                           oiReturnStatus = -1.
                    <M-10 run SetMessage (input  vcMessage (icMessage),
                             input  '':U (icArguments),
                             input  '':U (icFieldName),
                             input  '':U (icFieldValue),
                             input  'E':U (icType),
                             input  3 (iiSeverity),
                             input  tBankStateAlloc.tc_Rowid (icRowid),
                             input  'QADFIN-1334':U (icFcMsgNumber),
                             input  '' (icFcExplanation),
                             input  '' (icFcIdentification),
                             input  '' (icFcContext),
                             output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                end. /* if vlFcQueryRecordsAvailable <> true */
            end. /* CCOLL */
            
            /* =========================== */
            /* DCollection                 */
            /* =========================== */
            when {&BANKSTATEALLOCTYPE-DCOLL}
            then do :
                if tBankStateAlloc.DCollection_ID = 0 or
                   tBankStateAlloc.DCollection_ID = ?
                then next.
                <Q-13 assign vlFcQueryRecordsAvailable = DCollectionByIDBalanceTC (Cache)
          (input tBankStateAlloc.Company_ID, (CompanyId)
           input tBankStateAlloc.DCollection_ID, (DCollectionID)
           input tBankStateAlloc.tdCollBalance, (DCollectionBalanceTC)) in BDCollection >
                if vlFcQueryRecordsAvailable <> true
                then do :
                    assign vcMessage      = trim(subst(#T-30'The customer payment collection &1 has changed since you selected it. You must refresh the information on your client.':255(281)t-30#,tBankStateAlloc.tcCollReference)) + chr(10) + 
                                            trim(subst(#T-31'The open balance of the customer payment collection &1 you are updating has already been updated by another user.':255(282)t-31#,tBankStateAlloc.tcCollReference)) + chr(10) + 
                                            trim(subst(#T-32'Initial open balance of the customer payment collection: &1.':255(283)T-32#,string(tBankStateAlloc.tdCollBalance))) + chr(10) +
                                            trim(subst(#T-33'Bank statement line: &1.':200(274)t-33#,string(tBankStateLine.BankStateLineNumber)))
                           oiReturnStatus = -1.
                    <M-12 run SetMessage (input  vcMessage (icMessage),
                             input  '':U (icArguments),
                             input  '':U (icFieldName),
                             input  '':U (icFieldValue),
                             input  'E':U (icType),
                             input  3 (iiSeverity),
                             input  tBankStateAlloc.tc_Rowid (icRowid),
                             input  'QADFIN-1335':U (icFcMsgNumber),
                             input  '' (icFcExplanation),
                             input  '' (icFcIdentification),
                             input  '' (icFcContext),
                             output viFcReturnSuper (oiReturnStatus)) in BBankEntry>
                end. /* if vlFcQueryRecordsAvailable <> true */
            end. /* DCOLL */
            
        end case.
                 
    end. /* for each */