project QadFinancials > class BAPMatching > method AdditionalUpdatesAllTaxOldOne
Description
AdditionalUpdatesAllTaxOldl: submethod of AdditionalUpdatesAll that will reverse the taxes of the matched pvo
Parameters
icAPMatchingPostingRowidID | input | character | Rowid of the posting |
icPostingText | input | character | Text of the posting |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bapmatching.p)
/* ========================================================================================== */
/* This method creates the posting-lines that will reverse the taxes of the pvod. For every */
/* posting-line we create in this method, we will also create a record in tAPMatchingLnRevTax */
/* as this is needed to keep track of every posting-line in the matching-posting */
/* ========================================================================================== */
/* ================== */
/* 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 t_iAPMatchingLnTax
then do :
assign viLocalReturnStatus = -3
vcMsgAPMatching = trim(substitute(#T-30'Internal error: information is missing.':255(49818)T-30#)) + chr(10) +
trim(substitute(#T-31'Available matching header: &1.':234(49819)T-31#,available (tAPMatching))) + chr(10) +
trim(substitute(#T-28'Available matching details: &1.':234(49820)T-28#,available (tAPMatchingLn))) + chr(10) +
trim(substitute(#T-29'Available original matching taxes: &1.':255(68805)T-29#,available (t_iAPMatchingLnTax))).
<M-26 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-7835':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Leave TAXHANDLINGBLOCK.
end. /* if not avail */
/* =========================================================================== */
/* The original-tax-line has non-recoverable taxes and AccrueAtReceipt = true: */
/* PostingLine created on the purchase-price-variance account */
/* =========================================================================== */
if t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and
t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> ? and
t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then do :
/* ======================================================================================================= */
/* Call a submethod in case the PPV account is not yet known: this account is also used in AddUpdAllTaxNew */
/* and is the same for all t_iAPMatchingLnTax-records of a single tAPMatchingLn. */
/* We store this information in some calculated fields on tAPMatchingLn so both methods can use this */
/* ======================================================================================================= */
if tAPMatchingLn.tcAPMatchingLnPVVGLCode = "":U or
tAPMatchingLn.tcAPMatchingLnPVVGLCode = ?
then do :
<M-32 run AdditionalUpdatesAllTaxGetPPV (output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
end. /* if */
assign vdUnroundedTC = t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC *
(if tAPMatchingLn.APMatchingLnIsPvodFinished = true
then tAPMatchingLn.APMatchingLnPvodOpenQty
else tAPMatchingLn.APMatchingLnMatchQty) /
tAPMatchingLn.APMatchingLnPvodReceiptQty
vdUnroundedLC = vdUnroundedTC * tAPMatchingLn.APMatchingLnPvodExchRate2 / tAPMatchingLn.APMatchingLnPvodExchRate
vdAmountLC = <M-33 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountTC = <M-34 RoundAmount
(input vdUnroundedTC (idUnroundedAmount),
input tAPMatching.Currency_ID (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountCC = if viCompanyCCID = viCompanyLCID
then vdAmountLC
else if viCompanyCCID = tAPMatching.Currency_ID
then vdAmountTC
else <M-39 RoundAmount
(input vdUnroundedLC * tAPMatchingLn.APMatchingLnPvodCCRate * tAPMatchingLn.APMatchingLnPvodCCScale (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 * -1 else 0
else if vdAmountTC > 0 then vdAmountTC * -1 else 0
vdDebitLC = 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
vdDebitCC = 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
vdCreditTC = 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
vdCreditLC = 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
vdCreditCC = 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.
<M-35 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input tAPMatchingLn.tcAPMatchingLnPVVGLCode (icGLCode),
input tAPMatchingLn.tcAPMatchingLnPVVDivCode (icDivisionCode),
input tAPMatchingLn.tcAPMatchingLnPVVCCCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input (if tAPMatchingLn.tcAPMatchingLnPVVGLCode = '':U or tAPMatchingLn.tcAPMatchingLnPVVGLCode = ? then tAPMatchingLn.APMatchingLnOpAllocCode 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 tDefaultSafsAPM (tDefaultSafsAPM),
output viPostingLineID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
/* ======================================================================================== */
/* Create a tAPMatchingLnRevTax to keep track of every posting-line in the matching-posting */
/* ======================================================================================== */
<M-36 run AddDetailLine
(input 'APMatchingLnRevTax':U (icTable),
input tAPMatchingLn.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
assign tAPMatchingLnRevTax.APMatching_ID = tAPMatching.APMatching_ID
tAPMatchingLnRevTax.PostingLine_ID = viPostingLineID.
end. /* if if t_iAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and */
/* ===================================================================================================== */
/* The original-tax-line has recov. taxes and AccrueAtReceipt = true: PostingLine created on tax account */
/* Taxes are allways 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 t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and
t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> ? and
t_iAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then do :
assign vdUnroundedTC = t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC *
(if tAPMatchingLn.APMatchingLnIsPvodFinished = true
then tAPMatchingLn.APMatchingLnPvodOpenQty
else tAPMatchingLn.APMatchingLnMatchQty) /
tAPMatchingLn.APMatchingLnPvodReceiptQty
vdUnroundedLC = vdUnroundedTC * tAPMatchingLn.APMatchingLnPvodExchRate2 / tAPMatchingLn.APMatchingLnPvodExchRate
vdAmountLC = <M-37 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountTC = <M-23 RoundAmount
(input vdUnroundedTC (idUnroundedAmount),
input ? (iiCurrencyID),
input tAPMatching.tcCurrencyCode (icCurrencyCode)) in BAPMatching>
vdAmountCC = if viCompanyCCID = viCompanyLCID
then vdAmountLC
else if viCompanyCCID = tAPMatching.Currency_ID
then vdAmountTC
else <M-40 RoundAmount
(input vdUnroundedLC * tAPMatchingLn.APMatchingLnPvodCCRate * tAPMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdBaseAmountCC = if viCompanyCCID = viCompanyLCID
then t_iAPMatchingLnTax.APMatchingLnTaxBaseLC
else if viCompanyCCID = tAPMatching.Currency_ID
then t_iAPMatchingLnTax.APMatchingLnTaxBaseTC
else <M-41 RoundAmount
(input t_iAPMatchingLnTax.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 * -1 else 0
else if vdAmountTC > 0 then vdAmountTC * -1 else 0
vdDebitLC = 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
vdDebitCC = 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
vdBaseDebitCC = 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
vdCreditTC = 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
vdCreditLC = 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
vdCreditCC = 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
vdBaseCreditCC = 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.
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-17 run AddPostingLineTax
(input icAPMatchingPostingRowidID (icPostingTcRowid),
input tAPMatching.ttCInvoiceTaxPointDate (itTaxPointDate),
input icPostingText (icPostingLineText),
input tAPMatching.tcCurrencyCode (icCurrencyCode),
input t_iAPMatchingLnTax.tcVatInOut (icPostingVatInOut),
input t_iAPMatchingLnTax.tcVatCode (icPostingVatCode),
input t_iAPMatchingLnTax.tcDomainCode (icPostingVatDomain),
input tAPMatching.tdCInvoiceExchangeRate (idExchangeRate),
input tAPMatching.tdCInvoiceRateScale (idExchangeRateScale),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType),
input ? (idCCExchangeRate),
input ? (idCCExchangeRateScale),
input vcTransactionType (icTransactionType),
input t_iAPMatchingLnTax.APMatchingLnTaxTaxTrType (icTaxTransactionType),
input (if vdDebitTC = 0 then 0 else t_iAPMatchingLnTax.APMatchingLnTaxBaseTC) (idBaseDebitTC),
input (if vdCreditTC = 0 then 0 else t_iAPMatchingLnTax.APMatchingLnTaxBaseTC) (idBaseCreditTC),
input (if vdDebitTC = 0 then 0 else t_iAPMatchingLnTax.APMatchingLnTaxBaseLC) (idBaseDebitLC),
input (if vdCreditTC = 0 then 0 else t_iAPMatchingLnTax.APMatchingLnTaxBaseLC) (idBaseCreditLC),
input vdBaseDebitCC (idBaseDebitCC),
input vdBaseCreditCC (idBaseCreditCC),
input (if vdDebitTC = 0 then 0 else vdDebitTC ) (idVatDebitTC),
input (if vdCreditTC = 0 then 0 else vdCreditTC ) (idVatCreditTC),
input (if vdDebitLC = 0 then 0 else vdDebitLC ) (idVatDebitLC),
input (if vdCreditLC = 0 then 0 else vdCreditLC ) (idVatCreditLC),
input vdDebitCC (idVatDebitCC),
input vdCreditCC (idVatCreditCC),
input t_iAPMatchingLnTax.tcNormalTaxGLCode (icNormalTaxGLCode),
input t_iAPMatchingLnTax.tcNormalTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input '':U (icAbsRetTaxGLCode),
input '':U (icAbsRetTaxDivisionCode),
input '':U (icFromTaxZone),
input '':U (icToTaxZone),
input tAPMatchingLn.APMatchingLnPvodTaxEnv (icTaxEnvrionment),
input tAPMatchingLn.APMatchingLnPvodIsTaxable (ilIsTaxable),
input tAPMatchingLn.APMatchingLnPvodTaxClass (icTaxClass),
input tAPMatchingLn.APMatchingLnPvodTaxUsage (icTaxUsage),
input t_iAPMatchingLnTax.APMatchingLnTaxTaxType (icTaxType),
input t_iAPMatchingLnTax.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 t_iAPMatchingLnTax.APMatchingLnTaxIsSuspDel (ilIsSuspDel),
output viPostingLineID (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viNormalTaxPostingVatID (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input no (ilCalledFromMoveSuspDelTax),
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-93 run SetPostingLineLegalDocNumber
(input ? (icPostingLineTcRowID),
input viPostingLineID (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 <> ? */
/* ======================================================================================== */
/* Create a tAPMatchingLnRevTax to keep track of every posting-line in the matching-posting */
/* ======================================================================================== */
<M-38 run AddDetailLine
(input 'APMatchingLnRevTax':U (icTable),
input tAPMatchingLn.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
assign tAPMatchingLnRevTax.APMatching_ID = tAPMatching.APMatching_ID
tAPMatchingLnRevTax.PostingLine_ID = viPostingLineID.
end. /* if t_iAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and */
END. /* TAXHANDLINGBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.