project QadFinancials > class BPaymentSelection > method ValidateComponentPostLine1


Parameters


icLineDescriptinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPaymentSelection.ValidateComponentPost


program code (program4/bpaymentselection.p)

/* New method in same segment (4) as ValdiateComponentPost */

/* ========================================================================== */
/* 5-Check if there is no pending QCrossCyPosting for this Invoice - CA766880 */
/* ========================================================================== */    
if can-find (first tqQCrossCyPostingByCompany where
                   tqQCrossCyPostingByCompany.tiCInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID)
then do :
    <M-1 run SetMessage
       (input  #T-67'This Invoice still exists in the cross-company daemon queue. Please verify. Reference: $1':255(44643496)T-67# (icMessage), 
        input  icLineDescript (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  t_sPaySelLine.tc_Rowid (icRowid), 
        input  'qadfin-763314':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
    assign oiReturnStatus = -1.                    
end.                    

if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTE}     or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-CREDITNOTECORR} or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICE}        or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-INVOICECORR}    or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-PREPAYMENTINV}  or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-ADJUSTMENT}
then do:
    /* ======================================================== */
    /* 1-Check if the IsSelected was changed in another session */
    /* ======================================================== */    
    <Q-15 run CInvoiceBySelected (all) (Read) (Cache)
       (input ?, (CompanyId)
        input t_sPaySelLine.PaySelLineParentObject_ID, (CInvoiceID)
        output dataset tqCInvoiceBySelected) in BCInvoice >
                                           
    find first tqCInvoiceBySelected where
               tqCInvoiceBySelected.tiCInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID
               no-error.
    if (available tqCInvoiceBySelected and tqCInvoiceBySelected.tlCInvoiceIsSelected)
    then do:
        <M-53 run SetMessage
           (input  trim(#T-69'The object has been selected for the payment on another session: $1.':250(677728727)T-69#) (icMessage), 
            input  icLineDescript (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sPaySelLine.tc_Rowid (icRowid), 
            input  'qadfin-836470':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        assign oiReturnStatus = -1.
    end. /* tqCInvoiceBySelected.tlCInvoiceIsSelected */
    else
    /* ============================================================================ */        
    /* 4-Check if Invoice does not belong to any initial payment selection CA766880 */
    /* ============================================================================ */            
    find first tqPaySelLineByPaySelStatus where
               tqPaySelLineByPaySelStatus.tiPaySelLineParentObject_ID = t_sPaySelLine.PaySelLineParentObject_ID and
               (tqPaySelLineByPaySelStatus.tiCompany_ID <> t_sPaySel.Company_ID or tqPaySelLineByPaySelStatus.tcPaySelCode <> t_sPaySel.PaySelCode)
               no-error.
    if available tqPaySelLineByPaySelStatus
    then do:
        <M-73 run SetMessage
           (input  trim(#T-54'The object has been selected for the payment on another session: $1.':250(159281493)T-54#) (icMessage), 
            input  icLineDescript (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sPaySelLine.tc_Rowid (icRowid), 
            input  'qadfin-66059':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  tqPaySelLineByPaySelStatus.tcCompanyCode + ' ' + tqPaySelLineByPaySelStatus.tcPaySelCode (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        assign oiReturnStatus = -1.    
    end.
    
    /* ============================================================================ */        
    /* 4-Check if the payment date is after the posting date of each invoice        */
    /* ============================================================================ */                
    if (available tqCInvoiceBySelected and  tqCInvoiceBySelected.ttCInvoicePostingDate > t_sPaySel.PaySelDate)
    then do:
        <M-81 run SetMessage
           (input  #T-28'The payment date ($1) can not be situated before the posting date ($2) of the invoice ($3).':255(104972641)T-28# (icMessage), 
            input  string(t_sPaySel.PaySelDate) + chr(2) + string(tqCinvoiceBySelected.ttCInvoicePostingDate) + chr(2) + icLineDescript (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sPaySelLine.tc_Rowid (icRowid), 
            input  'qadfin-304964':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        assign oiReturnStatus = -1.        
    end.                                   
    
    /* ===================================================================================== */            
    /* 2-Check if the balance of the invoice was not changed since it was selected - CA766880 */
    /* ===================================================================================== */                
        
    if not available tqCInvoiceBySelected
    then do:
        <M-14 run SetMessage
           (input  trim(#T-78'Supplier invoice (correction) / credit note (correction) / prepayment / adjustment (ID: $1) not found.':250(844408991)T-78#) (icMessage), 
            input  string(t_sPaySelLine.PaySelLineParentObject_ID) (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sPaySelLine.tc_Rowid (icRowid), 
            input  'qadfin-578837':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        assign oiReturnStatus = -1.
    end.
end.
else
if t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} or
   t_sPaySelLine.PaySelLineObjectType = {&PAYMENTSELECTIONTYPE-DEBTORCNCORR}
then do:

    <Q-65 run DInvoiceBySelected (all) (Read) (Cache)
       (input ?, (CompanyId)
        input t_sPaySelLine.PaySelLineParentObject_ID, (DInvoiceID)
        output dataset tqDInvoiceBySelected) in BDInvoice >
    find first tqDInvoiceBySelected where
               tqDInvoiceBySelected.tiDInvoice_ID = t_sPaySelLine.PaySelLineParentObject_ID
               no-error.
    if available tqDInvoiceBySelected
    then do:
        if tqDInvoiceBySelected.tlDInvoiceIsSelected
        then do:
            <M-60 run SetMessage
               (input  trim(#T-72'The object has been selected for payment in another session: $1.':250(86807496)T-72#) (icMessage), 
                input  icLineDescript (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPaySelLine.tc_Rowid (icRowid), 
                input  'qadfin-845722':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            assign oiReturnStatus = -1.
        end.

        /* ============================================================================ */        
        /* 4-Check if the payment date is after the posting date of each invoice        */
        /* ============================================================================ */                        
        if tqDInvoiceBySelected.ttDInvoicePostingDate > t_sPaySel.PaySelDate
        then do:
            <M-93 run SetMessage
               (input  #T-20'The payment date ($1) can not be situated before the posting date ($2) of the invoice ($3).':255(396459816)T-20# (icMessage), 
                input  string(t_sPaySel.PaySelDate) + chr(2) + string(tqDinvoiceBySelected.ttDInvoicePostingDate) + chr(2) + icLineDescript (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPaySelLine.tc_Rowid (icRowid), 
                input  'qadfin-206529':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
            assign oiReturnStatus = -1.                
        end.
    end.
    else do:
        <M-49 run SetMessage
           (input  trim(#T-16'The balance of the invoice has been changed since you selected it. Please Verify. Reference: $1':255(369906059)T-16#) (icMessage), 
            input  string(t_sPaySelLine.PaySelLineParentObject_ID) (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sPaySelLine.tc_Rowid (icRowid), 
            input  'qadfin-463907':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPaymentSelection>
        assign oiReturnStatus = -1.
    end.
    
end. /* {&PAYMENTSELECTIONTYPE-DEBTORCREDITNOTE} {&PAYMENTSELECTIONTYPE-DEBTORCNCORR} */