project QadFinancials > class BAPMatching > method AdditionalUpdatesAllLinesPLVarRate
Description
AdditionalUpdatesAllLinesPLVarRate; submethod of AdditionalUpdatesAllLines that is located in the same segment and that takes care of the creation of a posting-line for the RateVariance (difference in price)
Parameters
icAPMatchingPostingRowidID | input | character | APMatchingPostingRowidID |
icPostingText | input | character | Posting Text |
ocNormalRateVarGLCode | output | character | |
ocNormalRateVarDivisionCode | output | character | |
ocNormalRateVarCostCentreCode | output | character | CostCentreCode |
ocDiscrepancyGLCode | output | character | |
ocDiscrepancyDivisionCode | output | character | |
ocDiscrepancyCostCentreCode | output | character | |
ocLogRateVarGLCode | output | character | |
ocLogRateVarDivisionCode | output | character | |
ocLogRateVarCostCentreCode | output | character | |
ocPPVGLCode | output | character | |
ocPPVDivCode | output | character | |
ocPPVCCCode | output | character | |
ocRateVarGLCode | output | character | |
ocRateVarDivisionCode | output | character | |
ocRateVarCostCentreCode | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bapmatching.p)
/* =================================================================================================== */
/* This method takes care of the creation of a posting-line for the RateVariance (difference in price) */
/* =================================================================================================== */
assign vlIsPLVarRatePosted = false.
/* ============================================================================ */
/* First check whether everything is availablable what is supposed to be avail */
/* ============================================================================ */
if not available tAPMatching or
not available tAPMatchingLn or
not available tqPendingVoucherForMatchingAcc
then do :
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-14'Internal error: information is missing.':255(49818)T-14#)) + chr(10) +
trim(substitute(#T-15'Available matching header: &1.':234(49819)T-15#,available (tAPMatching))) + chr(10) +
trim(substitute(#T-21'No default accounting data is defined for supplier &1. Please check the supplier definition for further details.':255(49837)T-21#,available (tAPMatchingLn))) + chr(10) +
trim(substitute(#T-27'The system cannot find the required accounting information for the pending invoice details (Domain:&1, Pinv: &2, Pinv det: &3).':255(49838)T-27#,available (tqPendingVoucherForMatchingAcc))) + chr(10) +
trim(substitute(#T-31'Technical details: &1.':222(55526)T-31#,"RateVar/1":U)).
<M-8 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-9548':U:U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if not avail */
/* =================================================== */
/* Elementary check to avoid mis-usage of this method */
/* =================================================== */
if tAPMatchingLn.APMatchingLnVarRateTC = 0 or
tAPMatchingLn.APMatchingLnVarRateTC = ?
then do :
assign oiReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-38'Internal error: invalid call to the method that creates the posting line on the rate variances for the finished pending invoices.':255(55540)T-38#)) + chr(10) +
trim(substitute(#T-39'Pending invoice that includes logistic charges: &1.':234(53219)T-39#,string(tAPMatchingLn.APMatchingLnPvodIsLgCharg))) + chr(10) +
trim(substitute(#T-40'Finished pending invoice: &1':234(53220)T-40#,string(tAPMatchingLn.APMatchingLnIsPvodFinished))) + chr(10) +
trim(substitute(#T-41'Variance amount: &1':234(53221)T-41#,string(tAPMatchingLn.APMatchingLnVarUsageTC))) + chr(10) +
trim(substitute(#T-42'Technical details: &1.':222(55526)T-42#,"RateVar/2":U)).
<M-37 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-5531':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Return.
end. /* if vcMsgAPMatching <> "":U */
/* ==================================================================================== */
/* Retrieve the GL account, sub-account and cost centre where the rate variance is */
/* posted to= */
/* ==================================================================================== */
<M-26 run GetGLPLVarRate
(input if tAPMatchingLn.tcGLCode NE '' then tAPMatchingLn.tcGLCode else tAPMatchingLn.APMatchingLnOpAllocCode (icAPMatchingLnGLCode),
input tAPMatchingLn.tcDivisionCode (icAPMatchingLnDivCode),
input tAPMatchingLn.tcCostCentreCode (icAPMatchingLnCCCode),
input tAPMatchingLn.APMatchingLnIsVarGLPosting (ilAPMatchingLnIsVarGLPosting),
input tAPMatchingLn.APMatchingLnMatchQty (idAPMatchingLnMatchQty),
input tAPMatchingLn.APMatchingLnMatchUnitPrice (idAPMatchingLnMatchUnitPrice),
input tAPMatchingLn.APMatchingLnPvodCCCode (icAPMatchingLnPvodCCCode),
input tAPMatchingLn.APMatchingLnPvodCostMtdCur (icAPMatchingLnPvodCostMtdCur),
input tAPMatchingLn.APMatchingLnPvodCostMtdGL (icAPMatchingLnPvodCostMtdGL),
input tAPMatchingLn.APMatchingLnPvodDivCode (icAPMatchingLnPvodDivCode),
input tAPMatchingLn.APMatchingLnPvodGLCode (icAPMatchingLnPvodGLCode),
input tAPMatchingLn.APMatchingLnPvodIsLgCharge (ilAPMatchingLnPvodIsLgCharge),
input tAPMatchingLn.APMatchingLnPvodItem (icAPMatchingLnPvodItem),
input tAPMatchingLn.APMatchingLnPvodItemType (icAPMatchingLnPvodItemType),
input tAPMatchingLn.APMatchingLnPvodLgCharge (icAPMatchingLnPvodLgCharge),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icAPMatchingLnPvodPrjCode),
input tAPMatchingLn.APMatchingLnPvodReceiptQty (idAPMatchingLnPvodReceiptQty),
input tAPMatchingLn.APMatchingLnPvodSite (icAPMatchingLnPvodSite),
input tAPMatchingLn.APMatchingLnPvodUnitPrice (idAPMatchingLnPvodUnitPrice),
input tAPMatchingLn.APMatchingLnVarRateTC (idAPMatchingLnVarRateTC),
input tAPMatchingLn.PvoDomain (icPvoDomain),
input tAPMatchingLn.PvoID (iiPvoId),
input tAPMatchingLn.PvodLineID (iiPvodLineID),
input tAPMatchingLn.APMatchingLnPvodOpAllocCode (icQADC01),
input tAPMatchingLn.APMatchingLnOpAllocCode (icQADC02),
input tqPendingVoucherForMatchingAcc.tcpod_loc (icpod_loc),
input tqPendingVoucherForMatchingAcc.tipod_op (iipod_op),
input tqPendingVoucherForMatchingAcc.tcpod_wo_lot (icpod_wo_Lot),
input tqPendingVoucherForMatchingAcc.tcprh_site (icprh_site),
input tqPendingVoucherForMatchingAcc.tcprh_type (icprh_type),
input tqPendingVoucherForMatchingAcc.tcprh_vend (icprh_vend),
input tqPendingVoucherForMatchingAcc.tcpt_prod_line (icpt_prod_line),
input tqPendingVoucherForMatchingAcc.tcpt_site (icpt_site),
input tqPendingVoucherForMatchingAcc.tcpvo_order_type (icpvo_order_type),
input tqPendingVoucherForMatchingAcc.tcpvo_shipfrom (icpvo_shipfrom),
input tqPendingVoucherForMatchingAcc.tcpvo_shipto (icpvo_shipto),
input tqPendingVoucherForMatchingAcc.tcpvod_channel (icpvod_channel),
input tqPendingVoucherForMatchingAcc.tcpvod_shipto (icpvod_shipto),
input tqPendingVoucherForMatchingAcc.tcvd_type (icvd_type),
output ocNormalRateVarGLCode (ocNormalRateVarGLCode),
output ocNormalRateVarDivisionCode (ocNormalRateVarDivisionCode),
output ocNormalRateVarCostCentreCode (ocNormalRateVarCostCentreCode),
output ocDiscrepancyGLCode (ocDiscrepancyGLCode),
output ocDiscrepancyDivisionCode (ocDiscrepancyDivisionCode),
output ocDiscrepancyCostCentreCode (ocDiscrepancyCostCentreCode),
output ocLogRateVarGLCode (ocLogRateVarGLCode),
output ocLogRateVarDivisionCode (ocLogRateVarDivisionCode),
output ocLogRateVarCostCentreCode (ocLogRateVarCostCentreCode),
output ocPPVGLCode (ocPPVGLCode),
output ocPPVDivCode (ocPPVDivCode),
output ocPPVCCCode (ocPPVCCCode),
output ocRateVarGLCode (ocRateVarGLCode),
output ocRateVarDivisionCode (ocRateVarDivisionCode),
output ocRateVarCostCentreCode (ocRateVarCostCentreCode),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
/* ==================================================================================== */
/* Possibilities: */
/* 1: Logistic charges */
/* 2: Non-logistic charages & Discrepancy-accounts */
/* 3: Non-logistic charages & Average-costing */
/* 4: Non-logistic charages & Non-Average-costing & Non-discrepancy-accounts */
/* ==================================================================================== */
/* Case 1: Logistic charges */
if tAPMatchingLn.APMatchingLnPvodIsLgCharge = true
then assign vcGLCode = ocLogRateVarGLCode
vcDivisionCode = ocLogRateVarDivisionCode
vcCostCentreCode = ocLogRateVarCostCentreCode.
else do:
/* Case 2: Non-logistic charages & Discrepancy-accounts */
if tAPMatchingLn.APMatchingLnPvodItemType = {&APMATCHINGLNPVODITEMTYPE-NORMAL} and
tAPMatchingLn.APMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE} and
tAPMatchingLn.APMatchingLnPvodReceiptQty < 0
then assign vcGLCode = ocDiscrepancyGLCode
vcDivisionCode = ocDiscrepancyDivisionCode
vcCostCentreCode = ocDiscrepancyCostCentreCode.
else do:
/* Case 3: Non-logistic charages & Average-costing */
if tAPMatchingLn.APMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE} and
tAPMatchingLn.APMatchingLnPvodItemType = {&APMATCHINGLNPVODITEMTYPE-NORMAL} and
tAPMatchingLn.APMatchingLnIsVarGLPosting = false and
tAPMatchingLn.APMatchingLnPvodGLCode <> "":U and
tAPMatchingLn.APMatchingLnPvodGLCode <> ?
then do:
/* Check if Qty On hand for Item < matcheed Qty, if yes, retrive Inventory Discrepency Account Details */
<Q-61 run InventoryOnHandQtyForItem (all) (Read) (Cache)
(input tAPMatchingLn.PvoDomain, (Domain)
input tAPMatchingLn.APMatchingLnPvodSite, (Site)
input tAPMatchingLn.APMatchingLnPvodItem, (Part)
output dataset tqInventoryOnHandQtyForItem) in BMfgInventory>
find first tqInventoryOnHandQtyForItem where
tqInventoryOnHandQtyForItem.tcin_domain = tAPMatchingLn.PvoDomain and
tqInventoryOnHandQtyForItem.tcin_site = tAPMatchingLn.APMatchingLnPvodSite and
tqInventoryOnHandQtyForItem.tcin_part = tAPMatchingLn.APMatchingLnPvodItem
no-error.
if available tqInventoryOnHandQtyForItem
then assign vdOnHandQty = tqInventoryOnHandQtyForItem.tdin_qty_oh +
tqInventoryOnHandQtyForItem.tdin_qty_nonet.
if vdOnHandQty < tAPMatchingLn.APMatchingLnMatchQty and
vdOnHandQty >= 0
then do:
assign vlIsPLVarRatePosted = true
vdUnitVarRate = tAPMatchingLn.APMatchingLnMatchUnitPrice - tAPMatchingLn.APMatchingLnPvodUnitPrice
vdVarRateForInvTC = <M-94 RoundAmount
(input vdOnHandQty * vdUnitVarRate (idUnroundedAmount),
input ? (iiCurrencyID),
input tAPMatchingLn.APMatchingLnPvodCurrency (icCurrencyCode)) in BApplicationProperty>
vdVarRateForInvLC = <M-9 RoundAmount
(input vdVarRateForInvTC * tAPMatchingLn.APMatchingLnPvodExchRate / tApmatchingln.APMatchingLnPvodExchRate2 (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BApplicationProperty>
vdVarRateForInvCC = <M-81 RoundAmount
(input vdVarRateForInvTC * tAPMatchingLn.APMatchingLnPvodCCRate * tapmatchingln.APMatchingLnPvodCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BApplicationProperty> .
/* For On Hand Qty, if variance is > 0, get Inventory Account Details */
if vdVarRateForInvTC > 0
then do:
assign vcGLCode = ocPPVGLCode
vcDivisionCode = ocPPVDivCode
vcCostCentreCode = ocPPVCCCode.
assign vdDebitTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvTC > 0 then vdVarRateForInvTC else 0
else if vdVarRateForInvTC < 0 then vdVarRateForInvTC else 0
vdDebitLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvLC > 0 then vdVarRateForInvLC else 0
else if vdVarRateForInvLC < 0 then vdVarRateForInvLC else 0
vdDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvCC > 0 then vdVarRateForInvCC else 0
else if vdVarRateForInvCC < 0 then vdVarRateForInvCC else 0
vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvTC < 0 then vdVarRateForInvTC * -1 else 0
else if vdVarRateForInvTC > 0 then vdVarRateForInvTC * -1 else 0
vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvLC < 0 then vdVarRateForInvLC * -1 else 0
else if vdVarRateForInvLC > 0 then vdVarRateForInvLC * -1 else 0
vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateForInvCC < 0 then vdVarRateForInvCC * -1 else 0
else if vdVarRateForInvCC > 0 then vdVarRateForInvCC * -1 else 0.
<M-367 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then '':U else vcGLCode (icGLCode),
input vcDivisionCode (icDivisionCode),
input vcCostCentreCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then vcGLCode else '':U (icOpAllocCode),
input vdDebitTC (idDebitTC),
input vdDebitLC (idDebitLC),
input vdDebitCC (idDebitCC),
input vdCreditTC (idCreditTC),
input vdCreditLC (idCreditLC),
input vdCreditCC (idCreditCC),
input icPostingText (icPostingText),
input tAPMatching.tdCInvoiceExchangeRate (idTCLCExchangeRate),
input tAPMatching.tdCinvoiceRateScale (idTCLCExchangeScale),
input ? (idTCCCExchangeRate),
input ? (idTCCCExchangeScale),
input tDefaultSafsOperAPM (tDefaultSafsAPM),
output tAPMatchingLn.VarRatePostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* if vdVarRateForInvTC > 0 */
/* Get Inventory Discrepancy Account Details for remaing variance amount */
assign vdVarRateforInvDiscripancyTC = tAPMatchingLn.APMatchingLnVarRateTC - vdVarRateForInvTC
vdVarRateforInvDiscripancyLC = <M-63 RoundAmount
(input vdVarRateforInvDiscripancyTC * tAPMatchingLn.APMatchingLnPvodExchRate / tApmatchingln.APMatchingLnPvodExchRate2 (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BApplicationProperty>
vdVarRateforInvDiscripancyCC = <M-166 RoundAmount
(input vdVarRateforInvDiscripancyTC * tAPMatchingLn.APMatchingLnPvodCCRate * tapmatchingln.APMatchingLnPvodCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BApplicationProperty> .
assign vcGLCode = ocDiscrepancyGLCode
vcDivisionCode = ocDiscrepancyDivisionCode
vcCostCentreCode = ocDiscrepancyCostCentreCode.
assign vdDebitDiscTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyTC > 0 then vdVarRateforInvDiscripancyTC else 0
else if vdVarRateforInvDiscripancyTC < 0 then vdVarRateforInvDiscripancyTC else 0
vdDebitDiscLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyLC > 0 then vdVarRateforInvDiscripancyLC else 0
else if vdVarRateforInvDiscripancyLC < 0 then vdVarRateforInvDiscripancyLC else 0
vdDebitDiscCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyCC > 0 then vdVarRateforInvDiscripancyCC else 0
else if vdVarRateforInvDiscripancyCC < 0 then vdVarRateforInvDiscripancyCC else 0
vdCreditDiscTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyTC < 0 then vdVarRateforInvDiscripancyTC * -1 else 0
else if vdVarRateforInvDiscripancyTC > 0 then vdVarRateforInvDiscripancyTC * -1 else 0
vdCreditDiscLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyLC < 0 then vdVarRateforInvDiscripancyLC * -1 else 0
else if vdVarRateforInvDiscripancyLC > 0 then vdVarRateforInvDiscripancyLC * -1 else 0
vdCreditDiscCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdVarRateforInvDiscripancyCC < 0 then vdVarRateforInvDiscripancyCC * -1 else 0
else if vdVarRateforInvDiscripancyTC > 0 then vdVarRateforInvDiscripancyTC * -1 else 0.
<M-11 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then '':U else vcGLCode (icGLCode),
input vcDivisionCode (icDivisionCode),
input vcCostCentreCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then vcGLCode else '':U (icOpAllocCode),
input vdDebitDiscTC (idDebitTC),
input vdDebitDiscLC (idDebitLC),
input vdDebitDiscCC (idDebitCC),
input vdCreditDiscTC (idCreditTC),
input vdCreditDiscLC (idCreditLC),
input vdCreditDiscCC (idCreditCC),
input icPostingText (icPostingText),
input tAPMatching.tdCInvoiceExchangeRate (idTCLCExchangeRate),
input tAPMatching.tdCinvoiceRateScale (idTCLCExchangeScale),
input ? (idTCCCExchangeRate),
input ? (idTCCCExchangeScale),
input tDefaultSafsOperAPM (tDefaultSafsAPM),
output tAPMatchingLn.VarRatePostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* if vdOnHandQty < tAPMatchingLn.APMatchingLnMatchQty */
else assign vcGLCode = ocPPVGLCode
vcDivisionCode = ocPPVDivCode
vcCostCentreCode = ocPPVCCCode.
end. /* if tAPMatchingLn.APMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE} and */
/* Case 4: Non-logistic charages & Non-Average-costing & Non-discrepancy-accounts */
else assign vcGLCode = ocNormalRateVarGLCode
vcDivisionCode = ocNormalRateVarDivisionCode
vcCostCentreCode = ocNormalRateVarCostCentreCode.
end. /* NOT if tAPMatchingLn.APMatchingLnPvodItemType = {&APMATCHINGLNPVODITEMTYPE-NORMAL} and */
end. /* NOT if tAPMatchingLn.APMatchingLnPvodIsLgCharge = true */
if viFcReturnSuper <> 0 and oiReturnStatus >= 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Return.
if not vlIsPLVarRatePosted
then do:
/* ==================================================================================== */
/* Create the posting line that reverses the receipt posting-line for the allocated qty */
/* - we use the GL-Div-CC-PRJ as stated above */
/* - the amount equals the APMatchingLnVarRateTC */
/* - Positive amounts: posted on Debtit */
/* - Negative amounts: posted on Credit */
/* ==================================================================================== */
assign vdDebitTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateTC > 0 then tAPMatchingLn.APMatchingLnVarRateTC else 0
else if tAPMatchingLn.APMatchingLnVarRateTC < 0 then tAPMatchingLn.APMatchingLnVarRateTC else 0
vdDebitLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateLC > 0 then tAPMatchingLn.APMatchingLnVarRateLC else 0
else if tAPMatchingLn.APMatchingLnVarRateLC < 0 then tAPMatchingLn.APMatchingLnVarRateLC else 0
vdDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateCC > 0 then tAPMatchingLn.APMatchingLnVarRateCC else 0
else if tAPMatchingLn.APMatchingLnVarRateCC < 0 then tAPMatchingLn.APMatchingLnVarRateCC else 0
vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateTC < 0 then tAPMatchingLn.APMatchingLnVarRateTC * -1 else 0
else if tAPMatchingLn.APMatchingLnVarRateTC > 0 then tAPMatchingLn.APMatchingLnVarRateTC * -1 else 0
vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateLC < 0 then tAPMatchingLn.APMatchingLnVarRateLC * -1 else 0
else if tAPMatchingLn.APMatchingLnVarRateLC > 0 then tAPMatchingLn.APMatchingLnVarRateLC * -1 else 0
vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if tAPMatchingLn.APMatchingLnVarRateCC < 0 then tAPMatchingLn.APMatchingLnVarRateCC * -1 else 0
else if tAPMatchingLn.APMatchingLnVarRateCC > 0 then tAPMatchingLn.APMatchingLnVarRateCC * -1 else 0.
<M-43 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then '':U else vcGLCode (icGLCode),
input vcDivisionCode (icDivisionCode),
input vcCostCentreCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input if vcGLCode = tAPMatchingLn.APMatchingLnOpAllocCode and tAPMatchingLn.tcGLCode = '':U then vcGLCode else '':U (icOpAllocCode),
input vdDebitTC (idDebitTC),
input vdDebitLC (idDebitLC),
input vdDebitCC (idDebitCC),
input vdCreditTC (idCreditTC),
input vdCreditLC (idCreditLC),
input vdCreditCC (idCreditCC),
input icPostingText (icPostingText),
input tAPMatching.tdCInvoiceExchangeRate (idTCLCExchangeRate),
input tAPMatching.tdCinvoiceRateScale (idTCLCExchangeScale),
input ? (idTCCCExchangeRate),
input ? (idTCCCExchangeScale),
input tDefaultSafsOperAPM (tDefaultSafsAPM),
output tAPMatchingLn.VarRatePostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end.