project QadFinancials > class BAPMatching > method AdditionalUpdatesAllTaxNewOne
Description
AdditionalUpdatesAllTaxNew
Parameters
icAPMatchingPostingRowidID | input | character | Rowid of the posting |
icPostingText | input | character | Text of the posting |
bdTaxARNRecTC | input-output | decimal | |
bdTaxAINRecTC | input-output | decimal | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bapmatching.p)
/* ======================================================================================================== */
/* This method contains the creation of the posting-lines based upon the taxes entered on the matching-line */
/* ======================================================================================================== */
define buffer bAPMatchingLn for tAPMatchingLn.
/* ================== */
/* Exception handling */
/* Start Block */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
TAXHANDLINGBLOCK : DO :
/* ======================================================================== */
/* First check whether everything is available what is supposed to be avail */
/* ======================================================================== */
if not available tAPMatching or
not available tAPMatchingLn or
not available tAPMatchingLnTax
then do :
assign viLocalReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-39'Internal error: information is missing.':255(49818)T-39#)) + chr(10) +
trim(substitute(#T-40'Available matching header: &1.':234(49819)T-40#,available (tAPMatching))) + chr(10) +
trim(substitute(#T-37'Available matching details: &1.':234(49820)T-37#,available (tAPMatchingLn))) + chr(10) +
trim(substitute(#T-38'Available matching taxes: &1.':255(68793)T-38#,available (tAPMatchingLnTax))).
<M-33 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-8030':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Leave TAXHANDLINGBLOCK.
end. /* if not avail */
/* ======================================================================================= */
/* The Line has a RateVar: PostingLine created on the same account as the rate-variance */
/* -> the non-rec taxes need to applied on the RateVar */
/* ======================================================================================= */
if tAPMatchingLn.APMatchingLnVarRateTC <> 0 and
tAPMatchingLn.APMatchingLnVarRateTC <> ? and
((tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true and
tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> ?) or
(tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = false and
tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> ?))
then do :
if tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then assign vdUnroundedTC = tAPMatchingLn.APMatchingLnMatchQty * (tAPMatchingLn.APMatchingLnMatchUnitPrice - tAPMatchingLn.APMatchingLnPvodUnitPrice) * tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC / (if tAPMatchingLn.APMatchingLnMatchAmtTC = 0 then 1 else tAPMatchingLn.APMatchingLnMatchAmtTC).
else assign vdUnroundedTC = tAPMatchingLn.APMatchingLnMatchQty * (tAPMatchingLn.APMatchingLnMatchUnitPrice - tAPMatchingLn.APMatchingLnPvodUnitPrice) * tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC / (if tAPMatchingLn.APMatchingLnMatchAmtTC = 0 then 1 else tAPMatchingLn.APMatchingLnMatchAmtTC).
assign vdUnroundedLC = vdUnroundedTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountTC = <M-28 RoundAmount
(input vdUnroundedTC (idUnroundedAmount),
input tAPMatching.Currency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountLC = <M-45 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountCC = if viCompanyCCID = viCompanyLCID
then vdAmountLC
else if viCompanyCCID = tAPMatching.Currency_ID
then vdAmountTC
else <M-24 RoundAmount
(input vdUnroundedTC * tAPMatching.tdCInvoiceCCRate * tAPMatching.tdCInvoiceCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdDebitTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC > 0 then vdAmountTC else 0
else if vdAmountTC < 0 then vdAmountTC else 0
vdDebitLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC > 0 then vdAmountLC else 0
else if vdAmountLC < 0 then vdAmountLC else 0
vdDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC > 0 then vdAmountCC else 0
else if vdAmountCC < 0 then vdAmountCC else 0
vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC < 0 then vdAmountTC * -1 else 0
else if vdAmountTC > 0 then vdAmountTC * -1 else 0
vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC < 0 then vdAmountLC * -1 else 0
else if vdAmountLC > 0 then vdAmountLC * -1 else 0
vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC < 0 then vdAmountCC * -1 else 0
else if vdAmountCC > 0 then vdAmountCC * -1 else 0.
<M-26 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input tAPMatchingLn.tcAPMatchingLnRateVarGLCode (icGLCode),
input tAPMatchingLn.tcAPMatchingLnRateVarDivCode (icDivisionCode),
input tAPMatchingLn.tcAPMatchingLnRateVarCCCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input (if tAPMatchingLn.tcAPMatchingLnRateVarGLCode = '' or tAPMatchingLn.tcAPMatchingLnRateVarGLCode = ? then tAPMatchingLn.APMatchingLnOpAllocCode else '') (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 tDefaultSafsAPM (tDefaultSafsAPM),
output tAPMatchingLnTax.APRatePostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
/* Keep already posted tax amount */
if tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then assign bdTaxARNRecTC = bdTaxARNRecTC - vdAmountTC.
else assign bdTaxAINRecTC = bdTaxAINRecTC - vdAmountTC.
end. /* if tAPMatchingLn.APMatchingLnVarRateTC <> 0 and */
/* ===================================================================================================== */
/* There is recoverable taxes and AccrueAtReceipt = true: PostingLine created on the tax account */
/* Taxes are always posted in the current company: do not use AdditionalUpdatesAllLinesPLAddPostingLine */
/* Do not pass values that may trigger an additional Retained tax-posting as this is not needed in APM */
/* ===================================================================================================== */
if tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> ? and
tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then do :
assign vdAmountTC = tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC
vdUnroundedLC = vdAmountTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountLC = <M-46 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountCC = if viCompanyCCID = viCompanyLCID
then vdAmountLC
else if viCompanyCCID = tAPMatching.Currency_ID
then vdAmountTC
else <M-41 RoundAmount
(input vdAmountTC * tAPMatching.tdCInvoiceCCRate * tAPMatching.tdCInvoiceCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdBaseAmountCC = if viCompanyCCID = viCompanyLCID
then tAPMatchingLnTax.APMatchingLnTaxBaseLC
else if viCompanyCCID = tAPMatching.Currency_ID
then tAPMatchingLnTax.APMatchingLnTaxBaseTC
else <M-42 RoundAmount
(input tAPMatchingLnTax.APMatchingLnTaxBaseTC * tAPMatching.tdCInvoiceCCRate * tAPMatching.tdCInvoiceCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdDebitTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC > 0 then vdAmountTC else 0
else if vdAmountTC < 0 then vdAmountTC else 0
vdDebitLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC > 0 then vdAmountLC else 0
else if vdAmountLC < 0 then vdAmountLC else 0
vdDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC > 0 then vdAmountCC else 0
else if vdAmountCC < 0 then vdAmountCC else 0
vdBaseDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdBaseAmountCC > 0 then vdBaseAmountCC else 0
else if vdBaseAmountCC < 0 then vdBaseAmountCC else 0
vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC < 0 then vdAmountTC * -1 else 0
else if vdAmountTC > 0 then vdAmountTC * -1 else 0
vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC < 0 then vdAmountLC * -1 else 0
else if vdAmountLC > 0 then vdAmountLC * -1 else 0
vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC < 0 then vdAmountCC * -1 else 0
else if vdAmountCC > 0 then vdAmountCC * -1 else 0
vdBaseCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdBaseAmountCC < 0 then vdBaseAmountCC * -1 else 0
else if vdBaseAmountCC > 0 then vdBaseAmountCC * -1 else 0.
if tAPMatching.tcCreditorAddrCountryCode = tAPMatching.tcShipToAddrCountryCode and
tAPMatching.tlCreditorAddrIsEUCountry = tAPMatching.tlShipToAddrIsEUCountry
then assign vcTransactionType = {&VATTRANSACTIONTYPE-PURCHASE}.
else if tAPMatching.tcCreditorAddrCountryCode <> tAPMatching.tcShipToAddrCountryCode
then assign vcTransactionType = if tAPMatching.tlCreditorAddrIsEUCountry = true and
tAPMatching.tlCreditorAddrIsEUCountry = tAPMatching.tlShipToAddrIsEUCountry
then {&VATTRANSACTIONTYPE-ACQUISITION}
else {&VATTRANSACTIONTYPE-IMPORT}.
<M-25 run AddPostingLineTax
(input icAPMatchingPostingRowidID (icPostingTcRowid),
input tAPMatching.ttCInvoiceTaxPointDate (itTaxPointDate),
input icPostingText (icPostingLineText),
input tAPMatching.tcCurrencyCode (icCurrencyCode),
input tAPMatchingLnTax.tcVatInOut (icPostingVatInOut),
input tAPMatchingLnTax.tcVatCode (icPostingVatCode),
input tAPMatchingLnTax.tcDomainCode (icPostingVatDomain),
input tAPMatching.tdCInvoiceExchangeRate (idExchangeRate),
input tAPMatching.tdCInvoiceRateScale (idExchangeRateScale),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType),
input ? (idCCExchangeRate),
input ? (idCCExchangeRateScale),
input vcTransactionType (icTransactionType),
input tAPMatchingLnTax.APMatchingLnTaxTaxTrType (icTaxTransactionType),
input (if vdDebitTC = 0 then 0 else tAPMatchingLnTax.APMatchingLnTaxBaseTC) (idBaseDebitTC),
input (if vdCreditTC = 0 then 0 else tAPMatchingLnTax.APMatchingLnTaxBaseTC) (idBaseCreditTC),
input (if vdDebitTC = 0 then 0 else tAPMatchingLnTax.APMatchingLnTaxBaseLC) (idBaseDebitLC),
input (if vdCreditTC = 0 then 0 else tAPMatchingLnTax.APMatchingLnTaxBaseLC) (idBaseCreditLC),
input vdBaseDebitCC (idBaseDebitCC),
input vdBaseCreditCC (idBaseCreditCC),
input vdDebitTC (idVatDebitTC),
input vdCreditTC (idVatCreditTC),
input vdDebitLC (idVatDebitLC),
input vdCreditLC (idVatCreditLC),
input vdDebitCC (idVatDebitCC),
input vdCreditCC (idVatCreditCC),
input tAPMatchingLnTax.tcNormalTaxGLCode (icNormalTaxGLCode),
input tAPMatchingLnTax.tcNormalTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input '':U (icAbsRetTaxGLCode),
input '':U (icAbsRetTaxDivisionCode),
input '':U (icFromTaxZone),
input '':U (icToTaxZone),
input tAPMatchingLn.APMatchingLnTaxEnv (icTaxEnvrionment),
input tAPMatchingLn.APMatchingLnIsTaxable (ilIsTaxable),
input tAPMatchingLn.APMatchingLnTaxClass (icTaxClass),
input tAPMatchingLn.APMatchingLnTaxUsage (icTaxUsage),
input tAPMatchingLnTax.APMatchingLnTaxTaxType (icTaxType),
input tAPMatchingLnTax.APMatchingLnTaxIsRevCharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input tAPMatching.tcCreditorAddrTaxIDFederal (icTaxIDFeder),
input tAPMatching.tcCreditorAddrTaxIDState (icTaxIDState),
input tAPMatching.tcCreditorAddrTaxIDMisc1 (icTaxIDMisc1),
input tAPMatching.tcCreditorAddrTaxIDMisc2 (icTaxIDMisc2),
input tAPMatching.tcCreditorAddrTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input tAPMatching.tcShipToAddrTaxIDFederal (icOwnTaxIDFeder),
input tAPMatching.tcShipToAddrTaxIDState (icOwnTaxIDState),
input tAPMatching.tcShipToAddrTaxIDMisc1 (icOwnTaxIDMisc1),
input tAPMatching.tcShipToAddrTaxIDMisc2 (icOwnTaxIDMisc2),
input tAPMatching.tcShipToAddrTaxIDMisc3 (icOwnTaxIDMisc3),
input tAPMatching.tiShipToAddrTaxDeclaration (iiOwnTaxIDDeclarat),
input tAPMatchingLnTax.APMatchingLnTaxIsSuspDel (ilIsSuspDel),
output tAPMatchingLnTax.NormalTaxPostingLine_ID (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viNormalTaxPostingVatID (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input no (ilCalledFromMoveSuspDelTax),
input ? (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
/* I19 requirement for Brazil =============================================================== */
/* If the AP matching is for the Legal document, all posting lines needs to contain reference */
/* to this legal document */
/* ========================================================================================== */
if vcLegalDocNbr <> ?
then do:
<M-87 run SetPostingLineLegalDocNumber
(input ? (icPostingLineTcRowID),
input tAPMatchingLnTax.NormalTaxPostingLine_ID (iiPostingLineID),
input vcLegalDocNbr (icLegalDocumentNumber),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper <> 0 and oiReturnStatus >= 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then Leave TAXHANDLINGBLOCK.
end. /* if vcLegalDocNbr <> ? */
end. /* if tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and */
/* ======================================================================================= */
/* PostingLine created on the same account as the usage-variance for recoverable taxes */
/* ======================================================================================= */
if tAPMatchingLn.APMatchingLnVarUsageTC <> 0 and
tAPMatchingLn.APMatchingLnVarUsageTC <> ? and
tAPMatchingLn.APMatchingLnPvodIsLgCharge = false and
tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = false and
tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> ?
then do :
/* ================================================================================================= *
* In case of fiscal receipt, the taxes of one legal document line can be allocated against multiple *
* receipts. But in the receiver matching, taxes are always allocated to only one receipt. So we *
* have to cumulate total receipts for correct tax calculation *
* ================================================================================================= */
assign vdTotalMatchQty = 0
vdTotalPvodOpenQty = 0
vdTotalMatchAmtTC = 0.
if vlDomainIsFiscalConfirm
then do:
/* Go through all receiver matchings of the same legal docuemnt line */
for each bAPMatchingLn where
bAPMatchingLn.tc_ParentRowid = tAPMatchingLn.tc_ParentRowid and
bAPMatchingLn.PvoDomain = tAPMatchingLn.PvoDomain and
bAPMatchingLn.APMatchingLnPvodOrder = tAPMatchingLn.APMatchingLnPvodOrder and
bAPMatchingLn.APMatchingLnPvodOrderLnNbr = tAPMatchingLn.APMatchingLnPvodOrderLnNbr:
assign vdTotalMatchQty = vdTotalMatchQty + bAPMatchingLn.APMatchingLnMatchQty
vdTotalPvodOpenQty = vdTotalPvodOpenQty + bAPMatchingLn.APMatchingLnPvodOpenQty
vdTotalMatchAmtTC = vdTotalMatchAmtTC + bAPMatchingLn.APMatchingLnMatchAmtTC.
end. /* for each bAPMatchingLn where */
end.
else assign vdTotalMatchQty = tAPMatchingLn.APMatchingLnMatchQty
vdTotalPvodOpenQty = tAPMatchingLn.APMatchingLnPvodOpenQty
vdTotalMatchAmtTC = tAPMatchingLn.APMatchingLnMatchAmtTC.
assign vdUnroundedTC = tAPMatchingLn.APMatchingLnPvodUnitPrice * (vdTotalMatchQty - vdTotalPvodOpenQty) * tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC / (if vdTotalMatchAmtTC = 0 then 1 else vdTotalMatchAmtTC)
vdUnroundedLC = vdUnroundedTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountTC = <M-67 RoundAmount
(input vdUnroundedTC (idUnroundedAmount),
input tAPMatching.Currency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountLC = <M-57 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountCC = if viCompanyCCID = viCompanyLCID
then vdAmountLC
else if viCompanyCCID = tAPMatching.Currency_ID
then vdAmountTC
else <M-94 RoundAmount
(input vdUnroundedTC * tAPMatching.tdCInvoiceCCRate * tAPMatching.tdCInvoiceCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdDebitTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC > 0 then vdAmountTC else 0
else if vdAmountTC < 0 then vdAmountTC else 0
vdDebitLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC > 0 then vdAmountLC else 0
else if vdAmountLC < 0 then vdAmountLC else 0
vdDebitCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC > 0 then vdAmountCC else 0
else if vdAmountCC < 0 then vdAmountCC else 0
vdCreditTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountTC < 0 then vdAmountTC * -1 else 0
else if vdAmountTC > 0 then vdAmountTC * -1 else 0
vdCreditLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountLC < 0 then vdAmountLC * -1 else 0
else if vdAmountLC > 0 then vdAmountLC * -1 else 0
vdCreditCC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tAPMatching.tcCInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if vdAmountCC < 0 then vdAmountCC * -1 else 0
else if vdAmountCC > 0 then vdAmountCC * -1 else 0.
<M-13 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input tAPMatchingLn.tcAPMatchingLnUsageVarGLCode (icGLCode),
input tAPMatchingLn.tcAPMatchingLnUsageVarDivCode (icDivisionCode),
input tAPMatchingLn.tcAPMatchingLnUsageVarCCCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input (if tAPMatchingLn.tcAPMatchingLnUsageVarGLCode = '' or tAPMatchingLn.tcAPMatchingLnUsageVarGLCode = ? then tAPMatchingLn.APMatchingLnOpAllocCode else '') (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 tDefaultSafsAPM (tDefaultSafsAPM),
output tAPMatchingLnTax.APRatePostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
assign bdTaxAINRecTC = bdTaxAINRecTC - vdAmountTC.
end. /* if tAPMatchingLn.APMatchingLnVarUsageTC <> 0 and */
END. /* TAXHANDLINGBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.