project QadFinancials > class BAPMatching > method AdditionalUpdatesAllLines
Description
AdditionalUpdatesAllLines; submethod of AdditionalUpdatesAll that is located in the same segment and that takes care of the loop on the tAPMatchingLn record of a single tAPMatching record
Parameters
icAPMatchingPostingRowidID | input | character | APMatchingPostingRowidID |
icPostingText | input | character | PostingText |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bapmatching.p)
/* ======================== */
/* Set default ReturnStatus */
/* ======================== */
assign oiReturnStatus = -98.
/* ============================================================================ */
/* First check whether everything is availablable what is supposed to be avail */
/* ============================================================================ */
if not available tAPMatching or
not available tAPMatchingLn
then do :
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-11'Internal error: information that should have been available is not available.':254(999890204)T-11#)) + chr(10) +
trim(substitute(#T-12'Available matching header: &1.':234(49819)T-12#,available (tAPMatching))) + chr(10) +
trim(substitute(#T-19'Available matching details: &1.':234(49820)T-19#,available (tAPMatchingLn))).
<M-10 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-5417':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if not avail */
/* ===================================================================================================================== */
/* Run once a query that returns all kind of information on the Pvod and related details */
/* Note: the result-set of the query can contain multiple records for a single PvoMstr as in case of logistic charges, */
/* a single PvoMstr can have multiple underlaying PvodDets */
/* ===================================================================================================================== */
<Q-13 run PendingVoucherForMatchingAcc (all) (Read) (NoCache)
(input tAPMatchingLn.PvoDomain, (DomainCode)
input tAPMatchingLn.PvoID, (PvoID)
input tAPMatchingLn.PvodLineID, (PvodLineID)
output dataset tqPendingVoucherForMatchingAcc) in BMfgPendingVoucher >
find first tqPendingVoucherForMatchingAcc where
tqPendingVoucherForMatchingAcc.tcpvo_domain = tAPMatchingLn.PvoDomain and
tqPendingVoucherForMatchingAcc.tipvo_id = tAPMatchingLn.PvoID and
tqPendingVoucherForMatchingAcc.tipvod_id_line = tAPMatchingLn.PvodLineID
no-lock no-error.
if not available tqPendingVoucherForMatchingAcc
then do :
assign oiReturnStatus = -1
vcMsgAPMatching = #T-18'The system cannot submit the receiver matching. Internal error.':255(57568)T-18#
vcContextText = "Domain=&1|PvoId=&2|PvodLineId=&3"
vcContextText = substitute(vcContextText, tAPMatchingLn.PvoDomain, tAPMatchingLn.PvoID, tAPMatchingLn.PvodLineID)
vcContextText = replace(vcContextText, "|", chr(2)).
<M-14 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-5418':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContextText (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if not available tqPendingVoucherForMatchingAcc */
/* ===================================================================================================== */
/* Operational SAFs */
/* This applies to lines which have SAFs on the operational side which need to be applied */
/* ===================================================================================================== */
if tAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-FINISHED}
then do:
<M-27 run AdditionalUpdatesAllLinesDefSafOper
(output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
find first tDefaultSafsCreditor no-lock no-error.
if available tDefaultSafsCreditor
then do:
for each tDefaultSafsCreditor:
create tDefaultSafsOperAPM.
assign tDefaultSafsOperAPM.tcSafConceptCode = tDefaultSafsCreditor.tcSafConceptCode
tDefaultSafsOperAPM.tcSafCode = tDefaultSafsCreditor.tcSafCode.
end.
end.
end.
/* ===================================================================================================== */
/* RECEIPT account or LOGISTIC-ACCRUAL account */
/* This applies to lines for logistic-charges and for other-lines (independant on the item-type) */
/* Create a posting-line based on the values of tAPMatchingLn.APMatchingLnMatchQty and */
/* tAPMatchingLn.APMatchingLnPvodUnitPrice and store the PostingLine_ID in */
/* tAPMatchingLn.PvodPostingLine_ID */
/* The amount equals the UnitPrice-TC (at receipt) * Qty (invoiced qty) */
/* ===================================================================================================== */
<M-16 run AdditionalUpdatesAllLinesPLReceiptPvod
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowidID),
input icPostingText (icPostingText),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
/* ===================================================================================================== */
/* USAGE Variances (Not applicable to lines with Logistic Charges, only applicable to finished pvod's) */
/* If tAPMatchingLn.APMatchingLnPvodIsLgCharge=false & tAPMatchingLn.APMatchingLnIsPvodFinished=true & */
/* tAPMatchingLn.APMatchingLnVarUsageTC is filled */
/* then: */
/* create a posting-line based on the values of tAPMatchingLn.APMatchingLnVarUsageTC and */
/* tAPMatchingLn.APMatchingLnVarUsageLc and keep PostingLine_ID in tAPMatchingLn.VarUsagePostingLine_ID */
/* ===================================================================================================== */
if tAPMatchingLn.APMatchingLnIsPvodFinished = true and
tAPMatchingLn.APMatchingLnPvodIsLgCharge = false and
tAPMatchingLn.APMatchingLnVarUsageTC <> 0 and
tAPMatchingLn.APMatchingLnVarUsageTC <> ?
then do :
<M-23 run AdditionalUpdatesAllLinesPLVarUsage
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowidID),
input icPostingText (icPostingText),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
end. /* if tAPMatchingLn.APMatchingLnIsPvodFinished = true and */
/* ===================================================================================================== */
/* RATE Variances (Also for Logistic Charges) */
/* If tAPMatchingLn.APMatchingLnVarRateTC is filled then create a posting-line based on the values of */
/* tAPMatchingLn.APMatchingLnVarRateTC and tAPMatchingLn.APMatchingLnVarRateLc and store the */
/* PostingLine_ID in tAPMatchingLn.VarRatePostingLine_ID */
/* ===================================================================================================== */
if tAPMatchingLn.APMatchingLnVarRateTC <> 0 and
tAPMatchingLn.APMatchingLnVarRateTC <> ?
then do :
<M-20 run AdditionalUpdatesAllLinesPLVarRate
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowidID),
input icPostingText (icPostingText),
output tAPMatchingLn.tcAPMatchingLnCostAdjGLCode (ocNormalRateVarGLCode),
output tAPMatchingLn.tcAPMatchingLnCostAdjDivCode (ocNormalRateVarDivisionCode),
output tAPMatchingLn.tcAPMatchingLnCostAdjCCCode (ocNormalRateVarCostCentreCode),
output tAPMatchingLn.tcAPMatchingLnDiscrpGLCode (ocDiscrepancyGLCode),
output tAPMatchingLn.tcAPMatchingLnDiscrpDivCode (ocDiscrepancyDivisionCode),
output tAPMatchingLn.tcAPMatchingLnDiscrpCCCode (ocDiscrepancyCostCentreCode),
output vcLogRateVarGLCode (ocLogRateVarGLCode),
output vcLogRateVarDivisionCode (ocLogRateVarDivisionCode),
output vcLogRateVarCostCentreCode (ocLogRateVarCostCentreCode),
output tAPMatchingLn.tcAPMatchingLnPVVGLCode (ocPPVGLCode),
output tAPMatchingLn.tcAPMatchingLnPVVDivCode (ocPPVDivCode),
output tAPMatchingLn.tcAPMatchingLnPVVCCCode (ocPPVCCCode),
output tAPMatchingLn.tcAPMatchingLnRateVarGLCode (ocRateVarGLCode),
output tAPMatchingLn.tcAPMatchingLnRateVarDivCode (ocRateVarDivisionCode),
output tAPMatchingLn.tcAPMatchingLnRateVarCCCode (ocRateVarCostCentreCode),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
end. /* if tAPMatchingLn.APMatchingLnVarRateTC <> 0 and */
/* ===================================================================================================== */
/* EXCHANGE-RATE Variances (Also for Logistic Charges) */
/* If the Receipt-ExchRate differs from the Invoice-ExchRate then APMatchingLnVarExchRateLC should be */
/* filled and thus we should create an addtional PostingLine with the TC-amounts = 0 and an LC-amount */
/* filled to make sure the posting is also balanced in LC (as it was already in TC) and store the */
/* PostingLine_ID in tAPMatchingLn.VarExchRatePostingLine_ID */
/* The similar is done for the ExchRate-differences: Sored in tAPMatchingLn.VarExchRatCCPostingLine_ID */
/* ===================================================================================================== */
if /* Rate varaiance in LC */
(tAPMatchingLn.APMatchingLnVarExchRateLC <> 0 and
tAPMatchingLn.APMatchingLnVarExchRateLC <> ?) OR
/* Rate varaiance in SC */
(tAPMatchingLn.APMatchingLnVarExchRateCC <> 0 and
tAPMatchingLn.APMatchingLnVarExchRateCC <> ?)
then do :
<M-25 run AdditionalUpdatesAllLinesPLVarExchRate
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowidID),
input icPostingText (icPostingText),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
end. /* if /* Rate varaiance in LC */ */
/* ===================================================================================================== */
/* MEMO-items - EXPENSE account posting-lines */
/* If tAPMatchingLn.APMatchingLnPvodIsLgCharge = false and tAPMatchingLn.APMatchingLnPvodItemType = Memo */
/* and the value of the GL, Division or CostCentre differs from the corresponding fields in pvod_det, */
/* then we will; */
/* - create a first posting-line that reversed the posting-line that was created during the creation of */
/* the pvod_det and used pvod_accrual_acc, pvod_accrual_sub and pvod_accrual_cc */
/* - create a second posting-line that is similar to the first one but with the newly specified GL, */
/* Division, CostCentre and Project and with the amount shifted from credit>debit and debit>credit */
/* The amount equals the UnitPrice-TC (at receipt) * Allocated-Qty */
/* ===================================================================================================== */
if tAPMatchingLn.APMatchingLnPvodIsLgCharge = false and
tAPMatchingLn.APMatchingLnPvodItemType = {&APMATCHINGLNPVODITEMTYPE-MEMO} and
(tAPMatchingLn.tcGLCode <> tAPMatchingLn.APMatchingLnPvodGLCode or
tAPMatchingLn.tcDivisionCode <> tAPMatchingLn.APMatchingLnPvodDivCode or
tAPMatchingLn.tcCostCentreCode <> tAPMatchingLn.APMatchingLnPvodCCCode or
tAPMatchingLn.tcProjectCode <> tAPMatchingLn.APMatchingLnPvodPrjCode)
then do :
<M-21 run AdditionalUpdatesAllLinesPLExpenseAcruals
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowidID),
input icPostingText (icPostingText),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Return.
end. /* if tAPMatchingLn.APMatchingLnPvodIsLgCharge = true and */
/* ======================== */
/* Set ReturnStatus = OK */
/* ======================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.