project QadFinancials > class BERSProcessor > method GetERSPendingVouchersPORec
Description
Sub-method to obtain a set of pending vouchers to be considered for ERS processing when fiscal receiving is not being used.
Parameters
icSupplierFrom | input | character | Filtering parameter: start value for the supplier codes. |
icSupplierTo | input | character | Filtering parameter: end value for the supplier codes. |
icSiteFrom | input | character | Filtering parameter: start value for the site codes. |
icSiteTo | input | character | Filtering parameter: end value for the site codes. |
icReceiverFrom | input | character | Filtering parameter: start value for the receiver numbers. |
icReceiverTo | input | character | Filtering parameter: end value for the receiver numbers. |
itReceiptDateFrom | input | date | Filtering parameter: beginning date for the receipt dates. |
itReceiptDateTo | input | date | Filtering parameter: ending date for the receipt dates. |
tERSProcessorRef | output | temp-table | Output temp-table: used to store the pending vouchers being considered for ERS Processing. |
tERSProcessorLogRef | output | temp-table | Output temp-table: used to log status information for the pending vouchers being considered by the ERS Processor. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bersprocessor.p)
/* =================================================================================================== */
/* Method : GetERSPendingVouchers */
/* Desc : This method quieries database for pending vouchers which are ERS enabled. These */
/* pending vouchers are used for ERS processing. */
/* Supported types: Normal purchase order receipt */
/* Purchase ledger invoice */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (I) SupplierFrom Suppleir code from (filtering parameter) */
/* (I) SupplierTo Supplier code to (filtering parameter) */
/* (I) SiteFrom Site from (filtering parameter) */
/* (I) SiteTo Site to (filtering parameter) */
/* (I) ReceiverFrom Receiver number from (filtering parameter) */
/* (I) ReceiverTo Receiver number to (filtering parameter) */
/* (I) ReceiptDateFrom Receipt date from (filtering parameter) */
/* (I) ReceiptDateTo Receipt date to (filtering parameter) */
/* (O) tERSProcessorRef Quieried pending voucher(s) ready for ERS processing */
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Default output values */
/* =================================================================================================== */
empty temp-table tERSProcessorRef.
/* =================================================================================================== */
/* Normalize input parameters */
/* =================================================================================================== */
<M-90 run GetERSPendingVouchersNormalize
(input-output icSupplierFrom (bcSupplierFrom),
input-output icSupplierTo (bcSupplierTo),
output vcSupplier (ocSupplier),
input-output icSiteFrom (bcSiteFrom),
input-output icSiteTo (bcSiteTo),
output vcSite (ocSite),
input-output icReceiverFrom (bcReceiverFrom),
input-output icReceiverTo (bcReceiverTo),
output vcReceiver (ocReceiver),
input-output itReceiptDateFrom (btReceiptDateFrom),
input-output itReceiptDateTo (btReceiptDateTo),
output vtReceiptDate (otReceiptDate),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Query database */
/* =================================================================================================== */
<Q-3 run PendingVoucherForERS (all) (Read) (NoCache)
(input icSupplierFrom, (SupplierFrom)
input icSupplierTo, (SupplierTo)
input vcSupplier, (Supplier)
input icSiteFrom, (SiteFrom)
input icSiteTo, (SiteTo)
input vcSite, (Site)
input icReceiverFrom, (ReceiverFrom)
input icReceiverTo, (ReceiverTo)
input vcReceiver, (Receiver)
input itReceiptDateFrom, (ReceiptDateFrom)
input itReceiptDateTo, (ReceiptDateTo)
input vtReceiptDate, (ReceiptDate)
input vcDomainCode, (Domain)
output dataset tqPendingVoucherForERS) in BMfgPendingVoucher >
/* =================================================================================================== */
/* Copy all errors to system cache */
/* =================================================================================================== */
<M-2 run CopyToSystemErrors (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Process retrieved pending vouchers */
/* =================================================================================================== */
for each tqPendingVoucherForERS
break by tqPendingVoucherForERS.tcpvo_internal_ref: /* break by Receiver */
if first-of(tqPendingVoucherForERS.tcpvo_internal_ref)
then do:
/* Get all receipt lines of this receiver, can happend because other filtering *
* parameters some of receiver lines can be excluded from previous query */
<Q-44 run PendingVoucherForERSRcvr (all) (Read) (NoCache)
(input tqPendingVoucherForERS.tcpvo_internal_ref, (Receiver)
input tqPendingVoucherForERS.tcpvo_domain, (Domain)
input tqPendingVoucherForERS.tcpvo_internal_ref_type, (ReceiptType)
output dataset tqPendingVoucherForERSRcvr) in BMfgPendingVoucher >
/* go through all receipt lines of certain receiver */
PENDINGVOUCHERLOOP:
for each tqPendingVoucherForERSRcvr:
assign viLocalReturn = 0.
<Q-57 assign vlFcQueryRecordsAvailable = APMatchingLnByStatusPvod (NoCache)
(input ?, (CompanyId)
input tqPendingVoucherForERSRcvr.tcpvo_domain, (PvoDomain)
input tqPendingVoucherForERSRcvr.tipvo_id, (PvoID)
input tqPendingVoucherForERSRcvr.tipvod_id_line, (PvodLineID)
input {&APMATCHINGSTATUS-INITIAL}, (APMatchingStatus)
input ?, (SkipAPMatchingLnRowid)) in BAPMatching >
if vlFcQueryRecordsAvailable <> FALSE then next PENDINGVOUCHERLOOP.
/* create record in resulting temporary table */
create tERSProcessorRef.
assign tERSProcessorRef.tiPvoId = tqPendingVoucherForERSRcvr.tipvo_id
tERSProcessorRef.tiPvodLineId = tqPendingVoucherForERSRcvr.tipvod_id_line
tERSProcessorRef.tcCInvoiceCurrencyCode = tqPendingVoucherForERSRcvr.tcpvo_curr
tERSProcessorRef.tcCInvoiceReference = (if tqPendingVoucherForERSRcvr.tcprh_ps_nbr <> '':U and
tqPendingVoucherForERSRcvr.tcprh_ps_nbr <> ?
then tqPendingVoucherForERSRcvr.tcprh_ps_nbr
else tqPendingVoucherForERSRcvr.tcpvo_internal_ref)
tERSProcessorRef.tcDomainCode = tqPendingVoucherForERSRcvr.tcpvo_domain
tERSProcessorRef.tcPurchaseOrderNbr = tqPendingVoucherForERSRcvr.tcpvo_order
tERSProcessorRef.tcSupplier = tqPendingVoucherForERSRcvr.tcpvo_supplier
tERSProcessorRef.tcReceiverNbr = tqPendingVoucherForERSRcvr.tcpvo_internal_ref
tERSProcessorRef.tdAPMatchingLnMatchQty = tqPendingVoucherForERSRcvr.tdpvod_trans_qty
tERSProcessorRef.tdAPMatchingLnMatchUnitPriceLC = tqPendingVoucherForERSRcvr.tdpvod_pur_cost
* (if tqPendingVoucherForERSRcvr.tdprh_um_conv = ?
then 1
else tqPendingVoucherForERSRcvr.tdprh_um_conv)
tERSProcessorRef.tdAPMatchingLnMatchUnitPriceTC = if tqPendingVoucherForERSRcvr.tdprh_curr_amt <> ?
then tqPendingVoucherForERSRcvr.tdprh_curr_amt
* (if tqPendingVoucherForERSRcvr.tdprh_um_conv = ?
then 1
else tqPendingVoucherForERSRcvr.tdprh_um_conv)
else tERSProcessorRef.tdAPMatchingLnMatchUnitPriceLC
* tqPendingVoucherForERSRcvr.tdpvod_ex_rate
/ tqPendingVoucherForERSRcvr.tdpvod_ex_rate2
tERSProcessorRef.tdAPMatchingLnExtendedCostLC = tERSProcessorRef.tdAPMatchingLnMatchQty *
tERSProcessorRef.tdAPMatchingLnMatchUnitPriceLC
tERSProcessorRef.tdAPMatchingLnExtendedCostLC = <M-7 RoundAmount
(input tERSProcessorRef.tdAPMatchingLnExtendedCostLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BERSProcessor>
tERSProcessorRef.tdAPMatchingLnExtendedCostTC = tERSProcessorRef.tdAPMatchingLnMatchQty *
tERSProcessorRef.tdAPMatchingLnMatchUnitPriceTC
tERSProcessorRef.tdAPMatchingLnExtendedCostTC = <M-33 RoundAmount
(input tERSProcessorRef.tdAPMatchingLnExtendedCostTC (idUnroundedAmount),
input ? (iiCurrencyID),
input tERSProcessorRef.tcCInvoiceCurrencyCode (icCurrencyCode)) in BERSProcessor>
tERSProcessorRef.tiPlidLine = tqPendingVoucherForERSRcvr.tiplid_line
tERSProcessorRef.tiPliKeyId = tqPendingVoucherForERSRcvr.tiplid_pli_keyid
tERSProcessorRef.tiPurchaseOrderLineNbr = tqPendingVoucherForERSRcvr.tipvo_line
tERSProcessorRef.tlIsLogCharge = false
tERSProcessorRef.tlIsSelected = true
tERSProcessorRef.tlIsProcessed = false
tERSProcessorRef.tcFcRowid = string(tqPendingVoucherForERSRcvr.tdoid_pvod_det)
tERSProcessorRef.tiERSStatus = tqPendingVoucherForERSRcvr.tipvo_ers_status
tERSProcessorRef.tiERSOpt = tqPendingVoucherForERSRcvr.tipod_ers_opt
tERSProcessorRef.tiERSPriceListOption = tqPendingVoucherForERSRcvr.tipod_pr_lst_tp.
/* calculate Receipt ERS option and Price list option */
<M-95 run GetERSPendingVouchersERSOpt
(input tqPendingVoucherForERSRcvr.tcpvo_supplier (icCreditorCode),
input tqPendingVoucherForERSRcvr.tcpvo_shipto (icSiteCode),
input tqPendingVoucherForERSRcvr.tcpvo_part (icPartCode),
input-output tERSProcessorRef.tiERSOpt (biERSOption),
input-output tERSProcessorRef.tiERSPriceListOption (biERSPriceListOption),
output viLocalReturn (oiReturnStatus)) in BERSProcessor>
/* if any error occured during processing of receipt -> remove it from processing */
if viLocalReturn < 0 then assign tERSProcessorRef.tiERSStatus = {&PVO_ERS_STATUS_ERROR_PROCESS}.
/* should be this receipt processed by ERS */
if tERSProcessorRef.tiERSOpt = 0 or /* 0 - should not be, but for sure */
tERSProcessorRef.tiERSOpt = 1 /* 1 - NO ERS Process allowed */
then do:
delete tERSProcessorRef.
empty temp-table tFcMessages.
end.
else do:
<M-83 run CopyToReceiptErrors
(input tERSProcessorRef.tcFcRowid (icReceiptRowId),
input true (ilDeleteSystemErrors),
output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.
end. /* of for each tqPendingVoucherForERSRcvr */
end. /* of if first-of(tqPendingVoucherForERS.tcpvo_internal_ref) */
end. /* of for each tqPendingVoucherForERS */
<M-93 run StopAllQueries (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Restore system errors */
/* =================================================================================================== */
<M-4 run RestoreFromSystemErrors (output viFcReturnSuper (oiReturnStatus)) in BERSProcessor>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.