project QadFinancials > class BAPMatching > method GetPendingVouchersValidate
Description
This method is used to normalize and validate input parameers for retrieving of pending vouchers
Parameters
icAPMatchingTcRowid | input | character | Rowid (converted to character) of the matching. This corresponds with field tAPMatching.tc_rowid. |
icPendingVoucherType | input | character | |
iiCInvoicePostingYear | input | integer | |
icCInvoiceJournalCode | input | character | |
iiCInvoiceVoucher | input | integer | |
iiCInvoiceRegistrationNr | input | integer | CInvoiceRegistrationNr |
bcCreditorCode | input-output | character | |
bcCurrencyCode | input-output | character | |
bdCInvoiceTCLCRate | input-output | decimal | |
bdCInvoiceTCLCScale | input-output | decimal | |
bdCInvoiceTCCCRate | input-output | decimal | |
bdCInvoiceTCCCScale | input-output | decimal | |
btTransactionDateFrom | input-output | date | |
btTransactionDateTill | input-output | date | |
btTransactionDetailDateFrom | input-output | date | |
btTransactionDetailDateTill | input-output | date | |
bcExternalReferenceFrom | input-output | character | |
bcExternalReferenceTo | input-output | character | |
bcInternalReferenceFrom | input-output | character | |
bcInternalReferenceTo | input-output | character | |
bcShipToFrom | input-output | character | |
bcShipToTo | input-output | character | |
bcItemNumberFrom | input-output | character | |
bcItemNumberTo | input-output | character | |
bcBuyer | input-output | character | |
bcApprovedBy | input-output | character | |
bcLogisticChargeFrom | input-output | character | |
bcLogisticChargeTo | input-output | character | |
bcShipFromFrom | input-output | character | |
bcShipFromTo | input-output | character | |
blAutoSelect | input-output | logical | |
bcPOShipperInvoice | input-output | character | |
bcOrderFrom | input-output | character | |
bcOrderTo | input-output | character | |
blCallGTM | input-output | logical | ilCallGTM: Set to true in case you want this method to call GTM to recalculate the taxes. If false, then the taxes will just be taken from the pending-voucher |
ocExternalReference | output | character | |
ocInternalReference | output | character | |
ocShipFrom | output | character | |
ocShipTo | output | character | |
ocItemNumber | output | character | |
ocLogisticCharge | output | character | |
otTransactionDate | output | date | |
otTransactionDetailDate | output | date | |
ocOrder | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program7/bapmatching.p)
/* ============================================================================ */
/* Method: GetPendingVouchersValidate */
/* Desc: This method is used to normalize and validate input parameers */
/* for retrieving of pending vouchers */
/* ============================================================================ */
assign oiReturnStatus = -98.
/* Normalize input paramters */
assign
icAPMatchingTcRowid = (if icAPMatchingTcRowid = ? then '':U else icAPMatchingTcRowid)
bcCreditorCode = (if bcCreditorCode = ? then '':U else bcCreditorCode)
bcCurrencyCode = (if bcCurrencyCode = ? then '':U else bcCurrencyCode)
bdCInvoiceTCLCRate = (if bdCInvoiceTCLCRate = ? then 0 else Round(bdCInvoiceTCLCRate,10))
bdCInvoiceTCLCScale = (if bdCInvoiceTCLCScale = ? then 0 else bdCInvoiceTCLCScale)
bdCInvoiceTCCCRate = (if bdCInvoiceTCCCRate = ? then 0 else Round(bdCInvoiceTCCCRate,10))
bdCInvoiceTCCCScale = (if bdCInvoiceTCCCScale = ? then 0 else bdCInvoiceTCCCScale)
bcExternalReferenceFrom = (if bcExternalReferenceFrom = ? then '':U else bcExternalReferenceFrom)
bcExternalReferenceTo = (if bcExternalReferenceTo = ? then '':U else bcExternalReferenceTo)
bcInternalReferenceFrom = (if bcInternalReferenceFrom = ? then '':U else bcInternalReferenceFrom)
bcInternalReferenceTo = (if bcInternalReferenceTo = ? then '':U else bcInternalReferenceTo)
bcShipFromFrom = (if bcShipFromFrom = ? then '':U else bcShipFromFrom)
bcShipFromTo = (if bcShipFromTo = ? then '':U else bcShipFromTo)
bcShipToFrom = (if bcShipToFrom = ? then '':U else bcShipToFrom)
bcShipToTo = (if bcShipToTo = ? then '':U else bcShipToTo)
bcItemNumberFrom = (if bcItemNumberFrom = ? then '':U else bcItemNumberFrom)
bcItemNumberTo = (if bcItemNumberTo = ? then '':U else bcItemNumberTo)
bcBuyer = (if bcBuyer = ? then '':U else bcBuyer)
bcApprovedBy = (if bcApprovedBy = ? then '':U else bcApprovedBy)
bcLogisticChargeFrom = (if bcLogisticChargeFrom = ? then '':U else bcLogisticChargeFrom)
bcLogisticChargeTo = (if bcLogisticChargeTo = ? then '':U else bcLogisticChargeTo)
bcPOShipperInvoice = (if bcPOShipperInvoice = ? then '':U else bcPOShipperInvoice)
bcOrderFrom = (if bcOrderFrom = ? then '':U else bcOrderFrom)
bcOrderTo = (if bcOrderTo = ? then '':U else bcOrderTo)
iiCInvoicePostingYear = (if iiCInvoicePostingYear = ? then 0 else iiCInvoicePostingYear)
icCInvoiceJournalCode = (if icCInvoiceJournalCode = ? then '':U else icCInvoiceJournalCode)
iiCInvoiceVoucher = (if iiCInvoiceVoucher = ? then 0 else iiCInvoiceVoucher)
blAutoSelect = (if blAutoSelect = ? then false else blAutoSelect)
blCallGTM = (if blCallGTM = ? or icPendingVoucherType = {&APMATCHINGPVOTYPE-LOGCHARGE} then false else blCallGTM).
/* If from-to paramters are the same, better to use only one paramters with equesl operation */
if btTransactionDateFrom = btTransactionDateTill
then assign otTransactionDate = btTransactionDateFrom
btTransactionDateFrom = ?
btTransactionDateTill = ?.
if btTransactionDetailDateFrom = btTransactionDetailDateTill
then assign otTransactionDetailDate = btTransactionDetailDateFrom
btTransactionDetailDateFrom = ?
btTransactionDetailDateTill = ?.
if bcExternalReferenceFrom = bcExternalReferenceTo
then assign ocExternalReference = bcExternalReferenceFrom
bcExternalReferenceFrom = '':U
bcExternalReferenceTo = '':U.
if bcInternalReferenceFrom = bcInternalReferenceTo
then assign ocInternalReference = bcInternalReferenceFrom
bcInternalReferenceFrom = '':U
bcInternalReferenceTo = '':U.
if bcShipFromFrom = bcShipFromTo
then assign ocShipFrom = bcShipFromFrom
bcShipFromFrom = '':U
bcShipFromTo = '':U.
if bcShipToFrom = bcShipToTo
then assign ocShipTo = bcShipToFrom
bcShipToFrom = '':U
bcShipToTo = '':U.
if bcItemNumberFrom = bcItemNumberTo
then assign ocItemNumber = bcItemNumberFrom
bcItemNumberFrom = '':U
bcItemNumberTo = '':U.
if bcLogisticChargeFrom = bcLogisticChargeTo
then assign ocLogisticCharge = bcLogisticChargeFrom
bcLogisticChargeFrom = '':U
bcLogisticChargeTo = '':U.
if bcOrderFrom = bcOrderTo
then assign ocOrder = bcOrderFrom
bcOrderFrom = '':U
bcOrderTo = '':U.
/* Validate input parameters */
if blAutoSelect = false and blCallGTM = true
then do:
assign oiReturnStatus = -3
vcMsgAPMatching = #T-26'You cannot enable Recalculate Taxes unless you have enabled Auto-Select':255(999890425)T-26#.
<M-22 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7710':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end.
if icAPMatchingTcRowid = '':U
then do :
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-5'Internal error: cannot retrieve pending invoices because the reference to AP matching is missing.':251(56675)T-5#)).
<M-3 run SetMessage
(input vcMsgAPMatching (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5767':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if icAPMatchingTcRowid = '':U */
if not can-do(replace({&APMATCHINGPVOTYPES},chr(2),",":U), icPendingVoucherType)
then do:
assign vcContextText = substitute("icPendingVoucherType=<&1>":U, icPendingVoucherType).
<M-8 run SetMessage
(input #T-27'Cannot retrieve pending invoices. Internal error.':255(56866)T-27# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-5804':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContextText (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
assign oiReturnStatus = -1.
return.
end.
if bcCreditorCode = '':U or
bcCurrencyCode = '':U or
bdCInvoiceTCLCRate = 0 or
bdCInvoiceTCLCScale = 0
then do:
<M-30 run SetMessage
(input #T-29'Please select or enter a valid invoice before clicking the Apply button.':255(999890431)T-29# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9084':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
assign oiReturnStatus = -1.
return.
end.
/* =========================================================================================== */
/* Validate, that credit term of input purchase orders and credit term of supplier invoice */
/* are the same */
/* =========================================================================================== */
if icPendingVoucherType = {&APMATCHINGPVOTYPE-PORECEIPT}
then do:
/* Get supplier invoice */
<Q-15 run CInvoiceForAPMValidation (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiCInvoicePostingYear, (Year)
input icCInvoiceJournalCode, (JournalCode)
input iiCInvoiceVoucher, (Voucher)
input iiCInvoiceRegistrationNr, (CInvoiceRegistrationNr)
output dataset tqCInvoiceForAPMValidation) in BCInvoice >
find tqCInvoiceForAPMValidation where
tqCInvoiceForAPMValidation.tiCompany_ID = viCompanyId and
((tqCInvoiceForAPMValidation.tiCInvoicePostingYear = iiCInvoicePostingYear and
tqCInvoiceForAPMValidation.tcJournalCode = icCInvoiceJournalCode and
tqCInvoiceForAPMValidation.tiCInvoiceVoucher = iiCInvoiceVoucher) Or
(tqCInvoiceForAPMValidation.tiCInvoiceRegistrationNr = iiCInvoiceRegistrationNr))
no-error.
if not available tqCInvoiceForAPMValidation
then do:
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-25'Cannot find the invoice based upon the Year, daybook and Voucher (&1-&2-&3) or based upon the Registration-number (&4).':255(69214)T-25#,string(iiCInvoicePostingYear), icCInvoiceJournalCode, string(iiCInvoiceVoucher),string(iiCInvoiceRegistrationNr))).
<M-13 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-6874':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
return.
end.
/* Get supplier invoice payment condition (credit term) */
for each tOrderFilterAPM where
tOrderFilterAPM.tcPONbr <> '':U and
tOrderFilterAPM.tcPONbr <> ?:
/* ===================================================================== */
/* Get all details of the PO (First check whether the raltion exists) */
/* ===================================================================== */
<Q-17 run PurchaseOrderByDomainNbrVend (all) (Read) (NoCache)
(input vcDomainCode, (DomainCode)
input tOrderFilterAPM.tcPONbr, (PONbr)
input ?, (POVendor)
input ?, (POCurrency)
input ?, (POType)
output dataset tqPurchaseOrderByDomainNbrVend) in BMfgPO >
find tqPurchaseOrderByDomainNbrVend where
tqPurchaseOrderByDomainNbrVend.tcpo_domain = vcDomainCode and
tqPurchaseOrderByDomainNbrVend.tcpo_nbr = tOrderFilterAPM.tcPONbr
no-error.
if not available tqPurchaseOrderByDomainNbrVend
then do :
assign vcMessage = #T-18'Cannot find the purchase order (&1) which should be used for filtering.':255(64983)T-18#
vcMessage = substitute(vcMessage, tOrderFilterAPM.tcPONbr).
<M-19 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6876':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if oiReturnStatus = -98 or oiReturnStatus = 0 then assign oiReturnStatus = 1.
end. /* if not available tqPurchaseOrderByDomainNbrVend */
else do:
if tqCInvoiceForAPMValidation.tcPaymentConditionCode <> tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms
then do:
assign vcMessage = #T-20'The credit terms (&1) of the selected invoice does not match the credit terms (&2) of the purchase order (&3).':255(64986)T-20#
vcMessage = substitute(vcMessage, tqCInvoiceForAPMValidation.tcPaymentConditionCode, tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms, tOrderFilterAPM.tcPONbr).
<M-21 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6877':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if oiReturnStatus = -98 or oiReturnStatus = 0 then assign oiReturnStatus = 1.
end. /* if tqCInvoiceForAPMValidation.tcPaymentConditionCode <> tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms */
end.
end. /* for each tOrderFilterAPM: */
end. /* if icPendingVoucherType = {&APMATCHINGPVOTYPE-PORECEIPT} */
/* Return */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.