Description
Main method used for ERS processing: all pending voucher records flagged by the user will be processed: the pending vouchers will be validated. If the validation is passed, the supplier invoices and AP matching records will be created for the pending vouchers.
Parameters
biNumberOfProcessedRecords | input-output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bersprocessor.p)
/* Get legal documents details */
<Q-35 run LegalDocumentByLegalDocNbr (all) (Read) (NoCache)
(input tERSProcessorRef.tcDomainCode, (DomainCode)
input tERSProcessorRef.tcLegalDocNbr, (LegalDocNbr)
input tERSProcessorRef.ttEffectiveIssueDate, (EffIssueDate)
input ?, (Supplier)
output dataset tqLegalDocumentByLegalDocNbr) in BMFGLegalDocument>
find first tqLegalDocumentByLegalDocNbr where
tqLegalDocumentByLegalDocNbr.tclgd_domain = tERSProcessorRef.tcDomainCode and
tqLegalDocumentByLegalDocNbr.tclgd_nbr = tERSProcessorRef.tcLegalDocNbr and
tqLegalDocumentByLegalDocNbr.tclgd_shipfrom = tERSProcessorRef.tcShipFrom and
tqLegalDocumentByLegalDocNbr.ttlgd_effdate = tERSProcessorRef.ttEffectiveIssueDate
no-error.
/* =============================================================================================== */
/* Execute validateions valid for the whole Legal document */
/* =============================================================================================== */
<M-48 run ERSProcessLegalDocumentsVal (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viRecLineReturn = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =============================================================================================== */
/* Pickup all lines of the legal document */
/* =============================================================================================== */
/* Calculate total Invoice amount */
assign vdAPMatchingLnRecTotAmt = 0.
for each bERSProcessorRef where
bERSProcessorRef.tcDomainCode = tERSProcessorRef.tcDomainCode and
bERSProcessorRef.tcLegalDocNbr = tERSProcessorRef.tcLegalDocNbr and
bERSProcessorRef.tcShipFrom = tERSProcessorRef.tcShipFrom and
bERSProcessorRef.ttEffectiveIssueDate = tERSProcessorRef.ttEffectiveIssueDate and
bERSProcessorRef.tiERSOpt = tERSProcessorRef.tiERSOpt and
bERSProcessorRef.tlIsSelected = true and
bERSProcessorRef.tlIsProcessed = false and
(bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_0} or
bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_1} or
bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_ERROR}):
assign vdAPMatchingLnRecTotAmt = vdAPMatchingLnRecTotAmt +
((if bERSProcessorRef.tdAPMatchingLnMatchQty = 0 then 1 else bERSProcessorRef.tdAPMatchingLnMatchQty) *
bERSProcessorRef.tdAPMatchingLnMatchUnitPriceTC).
end.
LEGAL_DOC_BLOCK:
for each bERSProcessorRef where
bERSProcessorRef.tcDomainCode = tERSProcessorRef.tcDomainCode and
bERSProcessorRef.tcLegalDocNbr = tERSProcessorRef.tcLegalDocNbr and
bERSProcessorRef.tcShipFrom = tERSProcessorRef.tcShipFrom and
bERSProcessorRef.ttEffectiveIssueDate = tERSProcessorRef.ttEffectiveIssueDate and
bERSProcessorRef.tiERSOpt = tERSProcessorRef.tiERSOpt and
bERSProcessorRef.tlIsSelected = true and
bERSProcessorRef.tlIsProcessed = false and
(bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_0} or
bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_READY_1} or
bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_ERROR})
break by bERSProcessorRef.tcDomainCode
by bERSProcessorRef.tcLegalDocNbr
by bERSProcessorRef.ttEffectiveIssueDate
by bERSProcessorRef.tcSupplier
by bERSProcessorRef.tlIsLogCharge:
assign viRecLineReturn = 0
biNumberOfProcessedRecords = biNumberOfProcessedRecords + 1.
RECEIPT_LINE_BLOCK:
do:
/* ==================================== */
/* Get some details about this receipt */
/* ==================================== */
if tlIsLogCharge
then do:
if first-of(bERSProcessorRef.tlIsLogCharge)
then do:
<Q-93 run LegalDocumentPendVoucherLCForERS (all) (Read) (NoCache)
(input vcDomainCode, (Domain)
input ?, (Supplier)
input ?, (SupplierFrom)
input ?, (SupplierTo)
input ?, (Site)
input ?, (SiteFrom)
input ?, (SiteTo)
input ?, (ReceiptDate)
input ?, (ReceiptDateFrom)
input ?, (ReceiptDateTo)
input bERSProcessorRef.tcLegalDocNbr, (LegalDoc)
input bERSProcessorRef.tcLegalDocNbr, (LegalDocFrom)
input bERSProcessorRef.tcLegalDocNbr, (LegalDocTo)
input bERSProcessorRef.ttEffectiveIssueDate, (EffDate)
input bERSProcessorRef.ttEffectiveIssueDate, (EffDateFrom)
input bERSProcessorRef.ttEffectiveIssueDate, (EffDateTo)
output dataset tqLegalDocumentPendVoucherLCForE) in BMFGLegalDocument>
find first tqLegalDocumentPendVoucherLCForE where
tqLegalDocumentPendVoucherLCForE.ttlgd_effdate = bERSProcessorRef.ttEffectiveIssueDate and
tqLegalDocumentPendVoucherLCForE.tclgd_nbr = bERSProcessorRef.tcLegalDocNbr and
tqLegalDocumentPendVoucherLCForE.tclgdd_doc_type = {&LEGALDOCUMENT-LINE-TYPE-LC}
no-lock no-error.
if not available tqLegalDocumentPendVoucherLCForE
then do:
assign vcMessage = #T-40'System did not find a Pending vouchers for the Logistic charges.':255(572110566)T-40#
vcContext = "DomainCode=&1|Supplier=&2|Legal Document=&3|Effective Issue Date=&4":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, bERSProcessorRef.tcDomainCode, bERSProcessorRef.tcSupplier, bERSProcessorRef.tcLegalDocNbr, bERSProcessorRef.ttEffectiveIssueDate).
<M-67 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-427705':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
assign viRecLineReturn = -1.
leave RECEIPT_LINE_BLOCK.
end.
assign vcdelimitor = '::':U
vcInternalReference = tqLegalDocumentPendVoucherLCForE.tclgd_nbr + vcDelimitor +
tqLegalDocumentPendVoucherLCForE.tclgd_shipfrom + vcDelimitor +
string(year(tqLegalDocumentPendVoucherLCForE.ttlgd_effdate),"9999") +
string(month(tqLegalDocumentPendVoucherLCForE.ttlgd_effdate),"9999") +
string(day(tqLegalDocumentPendVoucherLCForE.ttlgd_effdate),"99") + vcDelimitor +
tqLegalDocumentPendVoucherLCForE.tclgdd_order + vcdelimitor +
string(tqLegalDocumentPendVoucherLCForE.tilgdd_line,">>9") + vcDelimitor +
string(tqLegalDocumentPendVoucherLCForE.tilgdd_order_line,">>9").
<Q-61 run LogAcctPendingVoucherForERS (all) (Read) (NoCache)
(input vcInternalReference, (InternalReference)
input vcDomainCode, (Domain)
output dataset tqLogAcctPendingVoucherForERS) in BMFGLogisiticsAccounting>
end. /* if tlIsLogCharge */
find first tqLogAcctPendingVoucherForERS where
tqLogAcctPendingVoucherForERS.tclacd_domain = bERSProcessorRef.tcDomainCode and
tqLogAcctPendingVoucherForERS.tclacd_internal_ref = vcInternalReference
no-error.
if not available tqLogAcctPendingVoucherForERS
then do:
assign vcMessage = #T-23'Cannot get purchase and receipt details for validation executed during processing of ERS.':255(70683)T-23#
vcContext = "DomainCode=&1|Supplier=&2|Legal Document=&3":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, bERSProcessorRef.tcDomainCode, bERSProcessorRef.tcSupplier, bERSProcessorRef.tcLegalDocNbr).
<M-8 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-759100':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
assign viRecLineReturn = -1.
leave RECEIPT_LINE_BLOCK.
end. /* if not available tqLegalDocumentPendVoucherDetail */
end. /* if tlIsLogCharge */
else do:
if first-of(bERSProcessorRef.tlIsLogCharge)
then do:
<Q-73 run LegalDocumentPendVoucherDetail (all) (Read) (NoCache)
(input bERSProcessorRef.tcDomainCode, (Domain)
input bERSProcessorRef.tcSupplier, (Supplier)
input bERSProcessorRef.tcLegalDocNbr, (LegalNbr)
input bERSProcessorRef.ttEffectiveIssueDate, (EffDate)
output dataset tqLegalDocumentPendVoucherDetail) in BMFGLegalDocument >
end.
find first tqLegalDocumentPendVoucherDetail where
tqLegalDocumentPendVoucherDetail.tclgd_domain = bERSProcessorRef.tcDomainCode and
tqLegalDocumentPendVoucherDetail.tclgd_nbr = bERSProcessorRef.tcLegalDocNbr and
tqLegalDocumentPendVoucherDetail.tcpo_vend = bERSProcessorRef.tcSupplier and
tqLegalDocumentPendVoucherDetail.ttlgd_effdate = bERSProcessorRef.ttEffectiveIssueDate and
tqLegalDocumentPendVoucherDetail.tcprh_receiver = bERSProcessorRef.tcReceiverNbr and
tqLegalDocumentPendVoucherDetail.tipvod_id = bERSProcessorRef.tiPvoId and
tqLegalDocumentPendVoucherDetail.tipvod_id_line = bERSProcessorRef.tiPvodLineId
no-error.
if not available tqLegalDocumentPendVoucherDetail
then do:
assign vcMessage = #T-798'Cannot get purchase and receipt details for validation executed during processing of ERS.':255(70683)T-798#
vcContext = "DomainCode=&1|Supplier=&2|Legal Document=&3":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, bERSProcessorRef.tcDomainCode, bERSProcessorRef.tcSupplier, bERSProcessorRef.tcLegalDocNbr).
<M-60 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-351719':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
assign viRecLineReturn = -1.
leave RECEIPT_LINE_BLOCK.
end. /* if not available tqLegalDocumentPendVoucherDetail */
end. /* else of if tlIsLogCharge */
/* =========================================================================================== */
/* Validate receipt */
/* =========================================================================================== */
if bERSProcessorRef.tlIsLogCharge
then do:
<M-81 run ValidateLogisticCharge
(input bERSProcessorRef.tcDomainCode (icDomain),
input bERSProcessorRef.tiPvoId (iiPvoId),
input bERSProcessorRef.tiPvodLineId (iiPvodLineId),
input bERSProcessorRef.tdAPMatchingLnExtendedCostLC (idMatchQty),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viRecLineReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave RECEIPT_LINE_BLOCK.
end.
else do:
<M-34 run ValidateReceipt
(input bERSProcessorRef.tcDomainCode (icDomain),
input bERSProcessorRef.tiPvoId (iiPvoId),
input bERSProcessorRef.tiPvodLineId (iiPvodLineId),
input bERSProcessorRef.tdAPMatchingLnMatchQty (idMatchQty),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viRecLineReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave RECEIPT_LINE_BLOCK.
end.
/* =========================================================================================== */
/* Create supplier invoice */
/* =========================================================================================== */
if first-of(bERSProcessorRef.tcSupplier)
then do:
<M-63 run ERSProcessCInvoice
(input bERSProcessorRef.tcFcRowid (icERSProcessorRefRowId),
input vdAPMatchingLnRecTotAmt (idAPMatchingLnRecTotAmt),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viRecLineReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave RECEIPT_LINE_BLOCK.
end.
/* =========================================================================================== */
/* Create supplier invoice PO lines */
/* =========================================================================================== */
if not bERSProcessorRef.tlIsLogCharge
then do:
<M-70 run ERSProcessCInvoicePO
(input bERSProcessorRef.tcFcRowid (icERSProcessorRefRowId),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viRecLineReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave RECEIPT_LINE_BLOCK.
end.
/* =========================================================================================== */
/* Create matching line */
/* =========================================================================================== */
<M-58 run ERSProcessAPMatching
(input bERSProcessorRef.tcFcRowid (icERSProcessorRefRowId),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viRecLineReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave RECEIPT_LINE_BLOCK.
end. /* of RECEIPT_LINE_BLOCK: */
/* =========================================================================================== */
/* Copy all errors to current record */
/* =========================================================================================== */
if viRecLineReturn < 0
then assign bERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_ERROR_PROCESS}
bERSProcessorRef.tlIsProcessed = true.
<M-68 run CopyToReceiptErrors
(input bERSProcessorRef.tcFcRowid (icReceiptRowId),
input true (ilDeleteSystemErrors),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign viExternalReturn = viFcReturnSuper.
if viRecLineReturn < 0
then do:
assign oiReturnStatus = viRecLineReturn.
leave LEGAL_DOC_BLOCK.
end.
end. /* of LEGAL_DOC_BLOCK */