project QadFinancials > class BAPMatching > method ValidateComponentPreAPMLnTax
validation procedure
Description
ValidateComponentPreValidateAPMLnTax: submethod of ValidateComponentPreValidate that will create the the underlaying tax-records when needed
Parameters
odSumARRecTaxTC | output | decimal | SumARRecTaxTC |
odSumARNRecTaxTC | output | decimal | SumARNRecTaxTC |
odSumAIRecTaxTC | output | decimal | SumAIRecTaxTC |
odSumAINRecTaxTC | output | decimal | SumAINRecTaxTC |
odSumOrigARRetainTaxTC | output | decimal | SumAROrigRetainTaxTC |
odSumOrigARRecTaxTC | output | decimal | SumOrigARRecTaxTC |
odSumOrigARNRecTaxTC | output | decimal | SumOrigARNRecTaxTC |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bapmatching.p)
/* ========================= */
/* Set default return-status */
/* ========================= */
assign oiReturnStatus = -98.
/* ============================= */
/* Check for record-availability */
/* ============================= */
if not available t_sAPMatching or
not available t_sAPMatchingLn
then do:
assign vcMessage = trim(#T-3'Internal error: Not all records in internal tables are available.':255(65370)T-3#)
vcContext = "available t_sAPMatching=&1|available t_sAPMatchingLn=&2":U
vcContext = substitute(vcContext, available t_sAPMatching, available t_sAPMatchingLn)
vcContext = replace(vcContext, "|":U, chr(2)).
<M-2 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-7014':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
assign oiReturnStatus = -1.
Return.
end. /* if not available t_sAPMatching */
/* =========================================================================== */
/* Go through all tax-details of the line */
/* =========================================================================== */
for each t_sAPMatchingLnTax where
t_sAPMatchingLnTax.tc_ParentRowid = t_sAPMatchingLn.tc_Rowid and
t_sAPMatchingLnTax.tc_Status <> "D":U :
/* ===================================================================== */
/* backwards compatibility : fill all mandatory fields if not filled yet */
/* ===================================================================== */
if t_sAPMatchingLnTax.tc_Status = "N":U or
t_sAPMatchingLnTax.tc_Status = "C":U
then do :
if t_sAPMatchingLnTax.APMatchingLnTaxIsTIAllowed = ?
then assign t_sAPMatchingLnTax.APMatchingLnTaxIsTIAllowed = false.
if t_sAPMatchingLnTax.APMatchingLnTaxIsTaxIncl = ?
then assign t_sAPMatchingLnTax.APMatchingLnTaxIsTaxIncl = false.
end. /* if t_sAPMatchingLnTax.tc_Status = "N":U or */
/* =========================================================================== */
/* Make sure to establish database relation between MatchingLnTax and Matching */
/* =========================================================================== */
if t_sAPMatchingLnTax.tc_Status <> "":U and
(t_sAPMatchingLnTax.APMatching_ID <> t_sAPMatching.APMatching_ID)
then assign t_sAPMatchingLnTax.APMatching_ID = t_sAPMatching.APMatching_ID.
/* ======================================================================================== */
/* Round the calculated splitted taxes as they are pro-rated by the UI but not rounded */
/* ======================================================================================== */
if t_sAPMatchingLnTax.tc_Status = "C":U
then do :
find t_iAPMatchingLnTax where
t_iAPMatchingLnTax.tc_Rowid = t_sAPMatchingLnTax.tc_Rowid
no-lock no-error.
if not available t_iAPMatchingLnTax
then next. /* in this case error wil be raised by the framework */
end. /* if t_sAPMatchingLnTax.tc_Status = "C":U */
if t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and
(t_sAPMatchingLnTax.tc_Status = "N":U or
(t_sAPMatchingLnTax.tc_Status = "C":U and
t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC))
then do :
assign vdRoundedAmountTC = <M-7 RoundAmount
(input t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>.
if t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> vdRoundedAmountTC
then assign t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC = vdRoundedAmountTC
t_sAPMatchingLnTax.tc_Status = (if t_sAPMatchingLnTax.tc_Status = "":U then "C":U else t_sAPMatchingLnTax.tc_Status).
end. /* if t_sAPMatchingLnTax.tc_Status = "N":U or */
if t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and
(t_sAPMatchingLnTax.tc_Status = "N":U or
(t_sAPMatchingLnTax.tc_Status = "C":U and
t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC))
then do :
assign vdRoundedAmountTC = <M-8 RoundAmount
(input t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>.
if t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> vdRoundedAmountTC
then assign t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC = vdRoundedAmountTC
t_sAPMatchingLnTax.tc_Status = (if t_sAPMatchingLnTax.tc_Status = "":U then "C":U else t_sAPMatchingLnTax.tc_Status).
end. /* if t_sAPMatchingLnTax.tc_Status = "N":U or */
if t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC <> 0 and
(t_sAPMatchingLnTax.tc_Status = "N":U or
(t_sAPMatchingLnTax.tc_Status = "C":U and
t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC <> t_iAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC))
then do :
assign vdRoundedAmountTC = <M-9 RoundAmount
(input t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>.
if t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC <> vdRoundedAmountTC
then assign t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC = vdRoundedAmountTC
t_sAPMatchingLnTax.tc_Status = (if t_sAPMatchingLnTax.tc_Status = "":U then "C":U else t_sAPMatchingLnTax.tc_Status).
end. /* if t_sAPMatchingLnTax.tc_Status = "N":U or */
if t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> 0 and
(t_sAPMatchingLnTax.tc_Status = "N":U or
(t_sAPMatchingLnTax.tc_Status = "C":U and
t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> t_iAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC))
then do :
assign vdRoundedAmountTC = <M-10 RoundAmount
(input t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>.
if t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> vdRoundedAmountTC
then assign t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC = vdRoundedAmountTC
t_sAPMatchingLnTax.tc_Status = (if t_sAPMatchingLnTax.tc_Status = "":U then "C":U else t_sAPMatchingLnTax.tc_Status).
end. /* if t_sAPMatchingLnTax.tc_Status = "N":U or */
/* ======================================================================================== */
/* Assign the tax-amount sums on the line-level by filling output parameters of the method */
/* ======================================================================================== */
assign odSumARRecTaxTC = odSumARRecTaxTC + t_sAPMatchingLnTax.APMatchingLnTaxARRecTaxTC
odSumARNRecTaxTC = odSumARNRecTaxTC + t_sAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC
odSumAIRecTaxTC = odSumAIRecTaxTC + t_sAPMatchingLnTax.APMatchingLnTaxAIRecTaxTC
odSumAINRecTaxTC = odSumAINRecTaxTC + t_sAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC.
end. /* for each t_sAPMatchingLnTax where */
/* ========================================================================================= */
/* Go through all t_iAPMatchingLnTax records where t_iAPMatchingLnTax.tc_ParentRowid is just */
/* a reference to the pvod: they hold the taxes of the pending-voucher. From these taxes we */
/* need to sum the taxes that are accrued at receipt and that are marked as retained-taxes */
/* Note that this shoudl be pro-rated against the receipt-qty as these figures hold the */
/* tax-amounts for the full receipt and we can also match only a part of it */
/* ========================================================================================= */
for each t_iAPMatchingLnTax where
t_iAPMatchingLnTax.tc_ParentRowid = trim(t_sAPMatchingLn.PvoDomain) + "-":U + trim(string(t_sAPMatchingLn.PvoID)) + "-":U + trim(string(t_sAPMatchingLn.PvodLineID)) and
t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true :
if t_iAPMatchingLnTax.APMatchingLnTaxIsAbsRet = true
then assign odSumOrigARRetainTaxTC = odSumOrigARRetainTaxTC +
((t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC + t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC) *
(if t_sAPMatchingLn.APMatchingLnIsPvodFinished = true
then t_sAPMatchingLn.APMatchingLnPvodOpenQty
else t_sAPMatchingLn.APMatchingLnMatchQty) /
t_sAPMatchingLn.APMatchingLnPvodReceiptQty).
assign odSumOrigARRecTaxTC = odSumOrigARRecTaxTC +
(t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC *
(if t_sAPMatchingLn.APMatchingLnIsPvodFinished = true
then t_sAPMatchingLn.APMatchingLnPvodOpenQty
else t_sAPMatchingLn.APMatchingLnMatchQty) /
t_sAPMatchingLn.APMatchingLnPvodReceiptQty)
odSumOrigARNRecTaxTC = odSumOrigARNRecTaxTC +
(t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC *
(if t_sAPMatchingLn.APMatchingLnIsPvodFinished = true
then t_sAPMatchingLn.APMatchingLnPvodOpenQty
else t_sAPMatchingLn.APMatchingLnMatchQty) /
t_sAPMatchingLn.APMatchingLnPvodReceiptQty).
assign odSumOrigARRetainTaxTC = <M-4 RoundAmount
(input odSumOrigARRetainTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>
odSumOrigARRecTaxTC = <M-5 RoundAmount
(input odSumOrigARRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>
odSumOrigARNRecTaxTC = <M-6 RoundAmount
(input odSumOrigARNRecTaxTC (idUnroundedAmount),
input ? (iiCurrencyID),
input t_sAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>.
end. /* for each t_iAPMatchingLnTax where */
/* =========================================================================== */
/* Go through all wht-details of the line */
/* =========================================================================== */
for each t_sAPMatchingLnWHT where
t_sAPMatchingLnWHT.tc_ParentRowid = t_sAPMatchingLn.tc_Rowid and
t_sAPMatchingLnWHT.tc_Status <> "D":U :
/* =========================================================================== */
/* Make sure to establish database relation between MatchingLnWHT and Matching */
/* =========================================================================== */
if t_sAPMatchingLnWHT.tc_Status <> "":U and
(t_sAPMatchingLnWHT.APMatching_ID <> t_sAPMatching.APMatching_ID)
then assign t_sAPMatchingLnWHT.APMatching_ID = t_sAPMatching.APMatching_ID.
end. /* end for each t_sAPMatchingLnWHT */
/* ====================== */
/* Set Return status = OK */
/* ====================== */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.