project QadFinancials > class BERSProcessor > method ValidateReceipt

Description

This method validates the pending voucher receipts to determine if the pending voucher is ready to be matched to a supplier invoice.


Parameters


icDomaininputcharacterDomain code for the current working domain.
iiPvoIdinputintegerUnique ID for the pending voucher record.
iiPvodLineIdinputintegerUnique ID for the pending voucher line record.
idMatchQtyinputdecimalThe matching quantity of the pending voucher.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BERSProcessor.ERSProcessLegalDocuments
method BERSProcessor.ERSProcessPORec


program code (program5/bersprocessor.p)

/* =================================================================================================== */
/* Method      : ValidateReceipt                                                                       */
/* Desc        : Validate receipt whether can be processed by ERS Processor                            */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  Domain               Domain code receipt was done in                                  */
/*          (I)  PvoId                Pending voucher ID                                               */
/*          (I)  PvodLineId           Pending voucher line ID                                          */
/*          (I)  MatchQty             Matching quantity (in purchase order UoM)                        */
/* =================================================================================================== */

assign oiReturnStatus = -98
       viLocalReturn  = 0.

/* =================================================================================================== */
/* Normalize input parameters                                                                          */
/* =================================================================================================== */
if icDomain     = '':U then assign icDomain     = ?.
if iiPvoId      = 0    then assign iiPvoId      = ?.
if iiPvodLineId = 0    then assign iiPvodLineId = ?.

if vcGroupBy = {&ERSPROCESSORINVGROUP-LEGALDOC}
then do:

    /* =================================================================================================== */
    /* Validate input parameters                                                                           */
    /* =================================================================================================== */
    if not available tqLegalDocumentPendVoucherDetail
    then do:
        assign vcMessage = #T-63'There is missing expected record in temporary table':255(70754)T-63#.
        <M-36 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'S':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-261992':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
        assign oiReturnStatus = -1.
        return.
    end.

    /* =================================================================================================== */
    /* Has been entered pack slip during receipt                                                           */
    /* =================================================================================================== */
    if tqAccountsPayableCtrlByDomain.tlapc_ers_ps_err = true  and
       tqLegalDocumentPendVoucherDetail.tcprh_rcp_type <> 'R':U and
       (tqLegalDocumentPendVoucherDetail.tcprh_ps_nbr   = '':U or
        tqLegalDocumentPendVoucherDetail.tcprh_ps_nbr   = ?)
    then do:
        assign vcMessage = #T-78'There is missing mandatory packing slip on Receiver &1.':255(70686)T-78#
               vcMessage = substitute(vcMessage, tqPendingVoucherForERSDetail.tcprh_receiver).
        <M-29 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-836532':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
        assign oiReturnStatus = -1.
        return.
    end.

end. /* if vcGroupBy = {&ERSPROCESSORINVGROUP-LEGALDOC} */
else do:

    /* =================================================================================================== */
    /* Validate input parameters                                                                           */
    /* =================================================================================================== */
    if not available tqPendingVoucherForERSDetail
    then do:
        assign vcMessage = #T-88'There is missing expected record in temporary table':255(70754)T-88#.
        <M-77 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'S':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-484634':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
        assign oiReturnStatus = -1.
        return.
    end.

    /* =================================================================================================== */
    /* Still are there the same quantity as we had                                                         */
    /* =================================================================================================== */
    if tqPendingVoucherForERSDetail.tdpvod_trans_qty - tqPendingVoucherForERSDetail.tdpvod_vouchered_qty <>
       idMatchQty
    then do:
        assign vcMessage = #T-8'Quantity ready for invoicing by ERS Processor has changed from this data was originally read from database. This receiver is excluded from procesing.':255(70684)T-8#.
        <M-7 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-8480':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
        assign oiReturnStatus = -1.
        return.
    end.
    
    /* =================================================================================================== */
    /* Has been entered pack slip during receipt                                                           */
    /* =================================================================================================== */
    if tqAccountsPayableCtrlByDomain.tlapc_ers_ps_err = true  and
       tqPendingVoucherForERSDetail.tcprh_rcp_type   <> 'R':U and
       (tqPendingVoucherForERSDetail.tcprh_ps_nbr     = '':U  or
        tqPendingVoucherForERSDetail.tcprh_ps_nbr     = ?)
    then do:
        assign vcMessage = #T-12'There is missing mandatory packing slip on Receiver &1.':255(70686)T-12#
               vcMessage = substitute(vcMessage, tqPendingVoucherForERSDetail.tcprh_receiver).
        <M-11 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-8484':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
        assign oiReturnStatus = -1.
        return.
    end.
end. /* NOT if vcGroupBy = {&ERSPROCESSORINVGROUP-LEGALDOC} */

/* =================================================================================================== */
/* Is there already any Receiver matching for pending voucher (in Final or Init status)                */
/* =================================================================================================== */
if vlIsStartedtqAPMatchingLnBySta <> true
then do:
    <Q-14 run APMatchingLnByStatusPvod  (Start) in BAPMatching >
    assign vlIsStartedtqAPMatchingLnBySta = true.
end.

<Q-13 run APMatchingLnByStatusPvod (all) (Read) (NoCache)
   (input ?, (CompanyId)
    input icDomain, (PvoDomain)
    input iiPvoId, (PvoID)
    input iiPvodLineId, (PvodLineID)
    input ?, (APMatchingStatus)
    input ?, (SkipAPMatchingLnRowid)
    output dataset tqAPMatchingLnByStatusPvod) in BAPMatching >

find first tqAPMatchingLnByStatusPvod where
           tqAPMatchingLnByStatusPvod.tcPvoDomain  = icDomain     and
           tqAPMatchingLnByStatusPvod.tiPvoID      = iiPvoId      and
           tqAPMatchingLnByStatusPvod.tiPvodLineID = iiPvodLineId and
           (tqAPMatchingLnByStatusPvod.tcAPMatchingStatus = {&APMATCHINGSTATUS-INITIAL} or
            tqAPMatchingLnByStatusPvod.tcAPMatchingStatus = {&APMATCHINGSTATUS-FINISHED})
           no-error.
if available tqAPMatchingLnByStatusPvod
then do:
    assign vcMessage = #T-16'This Receiver &1 is already included on other Receiver matching.':255(70691)T-16#
           vcMessage = substitute(vcMessage, tqPendingVoucherForERSDetail.tcprh_receiver).
    <M-15 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-8494':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturn.