project QadFinancials > class BCInvoice > method ValidateComponentPostMovement

validation procedure

Description

This method is a submethod of ValidateComponentAll.

Validates if you can find the postingdate of an invoicemovement of type Movement is smaller than the postingdate of the invoice.


Parameters


blBJEOpenedinput-outputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ValidateComponentPost


program code (program5/bcinvoice.p)

/* Error handling */
assign oiReturnStatus = -98
       viLocalReturn  = 0.

VALIDATE_BLOCK:
do on error undo, return:
    
    empty temp-table tPostingPostingLineInfoCIJE.
    
    
    /* When a movement is created (from Open Item Adjustment, ....) then ending Supplier Invoice balance should not be bellow *
     * Hold amount -> otherwise Warning is raised                                                                             */
    if can-find(first t_sCInvoiceMovement where
                      t_sCInvoiceMovement.tc_ParentRowid       = t_sCInvoice.tc_Rowid     and
                      t_sCInvoiceMovement.CInvoiceMovementType = {&MOVEMENTTYPE-MOVEMENT} and
                      t_sCInvoiceMovement.tc_Status            = "N":U)
    then do:
        if abs(t_sCInvoice.CInvoiceBalanceTC) < t_sCInvoice.CInvoiceHoldAmountTC
        then do:
            assign vcMessage     = #T-9'Balance of the invoice &1/&2/&3 (&4) goes bellow Invoice Hold amount. (Invoice balance = &5, Invoice hold amount &6)':255(413918938)T-9#
                   vcMessage     = substitute(vcMessage, t_sCInvoice.CInvoicePostingYear, t_sCInvoice.tcJournalCode, t_sCInvoice.CInvoiceVoucher, t_sCInvoice.CInvoiceReference, t_sCInvoice.CInvoiceBalanceTC, t_sCInvoice.CInvoiceHoldAmountTC)
                   viLocalReturn = (if viLocalReturn < 0 then viLocalReturn else 1).
            <M-10 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoice.CInvoiceBalanceTC':U (icFieldName), 
                input  t_sCInvoice.CInvoiceBalanceTC (icFieldValue), 
                input  'W':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoice.tc_Rowid (icRowid), 
                input  'QadFin-9731':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end.
    end. /* if can-find(first t_sCInvoiceMovement where */
    
    /* Validate Date of an AP/AR Movement can not be earlier then the Invoice Creation Date */
    for each t_sCInvoiceMovement where
             t_sCInvoiceMovement.CInvoice_ID          = t_sCInvoice.CInvoice_ID  and
             t_sCInvoiceMovement.CInvoiceMovementType = {&MOVEMENTTYPE-MOVEMENT} and
             t_sCInvoiceMovement.tc_Status            = "N":U:
    
        if not can-find(first tPostingPostingLineInfoCIJE where
                              tPostingPostingLineInfoCIJE.tiPostingLine_ID = t_sCInvoiceMovement.PostingLine_ID)
        then do:
            create tPostingPostingLineInfoCIJE.
            assign tPostingPostingLineInfoCIJE.tiPostingLine_ID = t_sCInvoiceMovement.PostingLine_ID.
        end.
        if not valid-handle(vhBJournalEntryCIInst)
        then do:
            <I-7 {bFcOpenInstance
                 &CLASS           = "BJournalEntry"}>
            assign blBJEOpened = true.
        end.
        <M-2 run GetPostingInfoByPostingLineIDTT
           (input-output tPostingPostingLineInfoCIJE (tPostingPostingLineInfo), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
      
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then return.
    
        find first tPostingPostingLineInfoCIJE where
                   tPostingPostingLineInfoCIJE.tiPostingLine_ID = t_sCInvoiceMovement.PostingLine_ID and
                   tPostingPostingLineInfoCIJE.ttPostingDate    < t_sCinvoice.CInvoicePostingDate
                   no-lock no-error.
        if available tPostingPostingLineInfoCIJE
        then do :  
            assign vcDatetemp = <M-65 DisplayDate  (input  tPostingPostingLineInfoCIJE.ttPostingDate (itDate)) in BCInvoice>
                   vcDatetemp1 = <M-22 DisplayDate  (input  t_sCinvoice.CInvoicePostingDate (itDate)) in BCInvoice>.
            assign vcMessage = trim(substitute(#T-31'Date of an AP Movement (&1) can not be earlier then the Supplier Invoice Posting Date (&2).':255(914401938)T-31#,vcDatetemp,vcDatetemp1)).
            <M-4 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingPostingLineInfoCIJE.ttPostingDate':U (icFieldName), 
                input  vcDatetemp (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoiceMovement.tc_Rowid (icRowid), 
                input  'QadFin-9618':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
            assign viLocalReturn = -1.
        end. /* if can-find(first tPostingPostingLineInfoCIJE where */

        find first tCInvoiceMovement where
                   tCInvoiceMovement.CInvoice_ID              = t_sCInvoiceMovement.CInvoice_ID and
                   tCInvoiceMovement.CInvoiceMovementPostDate > t_sCInvoiceMovement.CInvoiceMovementPostDate no-error.
        if available tCInvoiceMovement
        then do : 
            assign vcDatetemp = <M-87 DisplayDate  (input  tCInvoiceMovement.CInvoiceMovementPostDate (itDate)) in BCInvoice>
                   vcDatetemp1 =    <M-57 DisplayDate  (input  t_sCInvoiceMovement.CinvoiceMovementPostDate (itDate)) in BCInvoice>.
            assign vcMessage      = trim(substitute(#T-97'An invoice activity cannot have an earlier posting date &1 than any previous activity posting date. A previous posting date &2 exists.':255(988062127)T-97#,
                                    vcDatetemp1,vcDatetemp))
                   oiReturnStatus = -1.
            
            <M-51 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'CInvoiceMovement.CInvoiceMovementPostDate':U (icFieldName), 
                input  vcDatetemp1 (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoiceMovement.tc_Rowid (icRowid), 
                input  'QadFin-759143':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end. /* if available tCInvoiceMovement */
    end. /* for each t_sCInvoiceMovement where */
end. /* VALIDATE_BLOCK: */

/* Error handling */
assign oiReturnStatus = viLocalReturn.