project QadFinancials > class BAPMatching > method ValidateComponentPostAPM3PLI
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bapmatching.p)
/* ====================================================================================== */
/* Method: ValidateComponentPostPLI */
/* Desc: This method validates AP matching whether there is used Purchase Ledger */
/* invoice in correct way */
/* List of validations: Used PLI cannot have line without PVO */
/* AP matching has to contain all lines of PLI */
/* There has to be the same price */
/* There has to be the same quantity */
/* ====================================================================================== */
define buffer btsAPMatchingLn for t_sAPMatchingLn.
/* Set initial return status */
assign oiReturnStatus = -98.
/* Check for record-availability */
if not available t_sAPMatching
then do :
assign oiReturnStatus = -3
vcMessageText = trim(substitute(#T-1'Internal error: no AP matching record is available.':255(56009)T-1#)).
<M-16 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5796':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
return.
end. /* if not available t_sAPMatching */
/* Go through all matching lines which contains purchase ledger invoice */
for each t_sAPMatchingLn where
t_sAPMatchingLn.tc_ParentRowid = t_sAPMatching.tc_Rowid and
t_sAPMatchingLn.APMatchingLnPvodPLiKeyId <> ? and
t_sAPMatchingLn.APMatchingLnPvodPLiKeyId <> 0 and
t_sAPMatchingLn.tc_Status <> 'D':U
break by t_sAPMatchingLn.APMatchingLnPvodPLiKeyId:
if first-of(t_sAPMatchingLn.APMatchingLnPvodPLiKeyId)
then do:
/* read all lines of purchase invoice and check whether they are correctly used in matching */
<Q-88 run PLInvoiceForMatchingPvo (all) (Read) (NoCache)
(input t_sAPMatchingLn.PvoDomain, (DomainCode)
input ?, (CompanyId)
input ?, (POShipperInvoice)
input ?, (Supplier)
input t_sAPMatchingLn.APMatchingLnPvodPLiKeyId, (PliKeyId)
output dataset tqPLInvoiceForMatchingPvo) in BMfgPLInvoice >
for each tqPLInvoiceForMatchingPvo:
/* ============================================================== */
/* check whether there is pending voucher linked to this PLI line */
/* ============================================================== */
if tqPLInvoiceForMatchingPvo.tiplid_pvo_id = 0
then do:
assign vcMessageText = #T-4'You can only match a supplier invoice when a pending invoice is available for all of its lines.':255(56776)t-4#
+ chr(10)
+ trim(substitute(#T-18'Accounts Payable invoice is &1':255(56778)T-18#, tqPLInvoiceForMatchingPvo.tcpli_invoice))
oiReturnStatus = -1.
<M-17 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5797':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if tqPLInvoiceForMatchingPvo.tiplid_pvo_id = 0 */
/* ============================================================== */
/* check if there is coresponding matching line */
/* ============================================================== */
find btsAPMatchingLn where
btsAPMatchingLn.tc_ParentRowid = t_sAPMatching.tc_Rowid and
btsAPMatchingLn.PvoDomain = tqPLInvoiceForMatchingPvo.tcpli_domain and
btsAPMatchingLn.APMatchingLnPvodPLiKeyId = tqPLInvoiceForMatchingPvo.tipli_keyid and
btsAPMatchingLn.APMatchingLnPvodPLidLine = tqPLInvoiceForMatchingPvo.tiplid_line and
btsAPMatchingLn.tc_Status <> 'D':U
no-error.
if not available btsAPMatchingLn
then do:
assign vcMessageText = #T-3'When a supplier invoice is matched, all its lines must be included in the matching.':255(56781)t-3#
+ chr(10)
+ trim(substitute(#T-11'Accounts Payable invoice is &1':255(56778)T-11#, tqPLInvoiceForMatchingPvo.tcpli_invoice))
+ chr(10)
+ trim(substitute(#T-12'Accounts Payable invoice line is &1':255(56779)T-12#, tqPLInvoiceForMatchingPvo.tiplid_line))
oiReturnStatus = -1.
<M-13 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5793':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if not available btsAPMatchingLn */
/* ============================================================== */
/* check, whether there is the same price */
/* ============================================================== */
if btsAPMatchingLn.APMatchingLnMatchUnitPrice <> tqPLInvoiceForMatchingPvo.tdpvod_pur_cost
then do:
assign vcMessageText = #T-5'The invoiced price cannot be changed when the receipt is linked to a supplier invoice.':255(56777)t-5#
+ chr(10)
+ trim(substitute(#T-6'Accounts Payable invoice is &1':255(56778)T-6#, tqPLInvoiceForMatchingPvo.tcpli_invoice))
+ chr(10)
+ trim(substitute(#T-7'Accounts Payable invoice line is &1':255(56779)T-7#, tqPLInvoiceForMatchingPvo.tiplid_line))
oiReturnStatus = -1.
<M-14 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5794':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if btsAPMatchingLn.APMatchingLnMatchUnitPrice <> tqPLInvoiceForMatchingPvo.tdpvod_pur_cost */
/* ============================================================== */
/* check whether complete quatity was matched */
/* ============================================================== */
if btsAPMatchingLn.APMatchingLnMatchQty <> tqPLInvoiceForMatchingPvo.tdpvo_trans_qty
then do:
assign vcMessageText = #T-8'The invoiced quantity cannot be changed when the receipt is linked to a supplier invoice.':255(56780)t-8#
+ chr(10)
+ trim(substitute(#T-9'Accounts Payable invoice is &1':255(56778)T-9#, tqPLInvoiceForMatchingPvo.tcpli_invoice))
+ chr(10)
+ trim(substitute(#T-10'Accounts Payable invoice line is &1':255(56779)T-10#, tqPLInvoiceForMatchingPvo.tiplid_line))
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5795':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
end. /* if btsAPMatchingLn.APMatchingLnMatchQty <> tqPLInvoiceForMatchingPvo.tdpvo_trans_qty */
end. /* for each tqPLInvoiceForMatchingPvo: */
end. /* if first-of(t_sAPMatchingLn.APMatchingLnPvodPLiKeyId) */
end. /* for each t_sAPMatchingLn where */
/* return */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.