project QadFinancials > class BAPMatching > method AdditionalUpdatesAllTaxNewTwo
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 */
/* ======================================================================================================== */
/* ================== */
/* 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-2'Internal error: information is missing.':255(49818)T-2#)) + chr(10) +
trim(substitute(#T-3'Available matching header: &1.':234(49819)T-3#,available (tAPMatching))) + chr(10) +
trim(substitute(#T-4'Available matching details: &1.':234(49820)T-4#,available (tAPMatchingLn))) + chr(10) +
trim(substitute(#T-5'Available matching taxes: &1.':255(68793)T-5#,available (tAPMatchingLnTax))).
<M-1 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-7831':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
Leave TAXHANDLINGBLOCK.
end. /* if not avail */
/* ======================================================================================== */
/* There is non-recoverable tax: PostingLine created on the purchase-price-variance account */
/* ======================================================================================== */
if (tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> ? and
tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = false) or
(tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> ? and
tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true)
then do :
/* ======================================================================================================= */
/* Call a submethod in case the PPV account is not yet known: this account is also used in AddUpdAllTaxOld */
/* and is the same for all tAPMatchingLnTax-records of a single tAPMatchingLn. */
/* We store this information in some calculated fields on tAPMatchingLn so both methods can use this */
/* ======================================================================================================= */
if tAPMatchingLn.APMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE}
then do:
<M-61 run AdditionalUpdatesAllTaxGetInvAcc
(output vcInvGLCode (ocInvAccGLCode),
output vcInvAccDivCode (ocInvAccDivCode),
output vcInvAccCCCode (ocInvAccCCCode),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
if tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then assign vdUnroundedTC = bdTaxARNRecTC /* Take tax amount which has not been posted yet */
bdTaxARNRecTC = 0.
else assign vdUnroundedTC = bdTaxAINRecTC
bdTaxAINRecTC = 0.
assign vdUnroundedLC = vdUnroundedTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountLC = <M-50 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountTC = <M-48 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-53 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-18 run AdditionalUpdatesAllLinesPLAddPostingLine
(input icAPMatchingPostingRowidID (icAPMatchingPostingRowId),
input vcInvGLCode (icGLCode),
input vcInvAccDivCode (icDivisionCode),
input vcInvAccCCCode (icCostCentreCode),
input tAPMatchingLn.APMatchingLnPvodPrjCode (icProjectCode),
input (if vcInvGLCode = '' or vcInvGLCode = ? 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.PPVPostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
end. /*if tAPMatchingLn.APMatchingLnPvodCostMtdGL = {&COSTMETHOD-AVERAGE}*/
else do:
if tAPMatchingLn.tcAPMatchingLnPVVGLCode = "":U or
tAPMatchingLn.tcAPMatchingLnPVVGLCode = ?
then do :
<M-10 run AdditionalUpdatesAllTaxGetPPV (output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
end. /* if */
if tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true
then assign vdUnroundedTC = bdTaxARNRecTC /* Take tax amount which has not been posted yet */
bdTaxARNRecTC = 0.
else assign vdUnroundedTC = bdTaxAINRecTC
bdTaxAINRecTC = 0.
assign vdUnroundedLC = vdUnroundedTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountLC = <M-25 RoundAmount
(input vdUnroundedLC (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input ? (icCurrencyCode)) in BAPMatching>
vdAmountTC = <M-27 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-21 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-9 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 = '' or tAPMatchingLn.tcAPMatchingLnPVVGLCode = ? 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.PPVPostingLine_ID (oiPostingLineId),
input true (ilisCallForVarianceOrTax),
output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave TAXHANDLINGBLOCK.
end. /*else do:*/
end. /* if tAPMatchingLnTax.APMatchingLnTaxAINRecTaxTC <> 0 and */
/* ====================================================================================================== */
/* There is Retained-Tax that has AccrueAtReceipt = true: PostingLine created on the retained tax account */
/* Taxes are always posted in the current company: do not use AdditionalUpdatesAllLinesPLAddPostingLine */
/* ===================================================================================================== */
if tAPMatchingLnTax.APMatchingLnTaxIsAbsRet = true and
tAPMatchingLnTax.APMatchingLnTaxIsAccrRcp = true and
((tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC <> ?) or
(tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> 0 and
tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC <> ?))
then do :
assign vdAmountTC = tAPMatchingLnTax.APMatchingLnTaxARRecTaxTC + tAPMatchingLnTax.APMatchingLnTaxARNRecTaxTC
vdUnroundedLC = vdAmountTC * tAPMatching.tdCInvoiceExchangeRate * tAPMatching.tdCinvoiceRateScale
vdAmountLC = <M-24 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-23 RoundAmount
(input vdAmountTC * 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
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.
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-19 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 0 (idBaseDebitTC),
input 0 (idBaseCreditTC),
input 0 (idBaseDebitLC),
input 0 (idBaseCreditLC),
input 0 (idBaseDebitCC),
input 0 (idBaseCreditCC),
input vdDebitTC (idVatDebitTC),
input vdCreditTC (idVatCreditTC),
input vdDebitLC (idVatDebitLC),
input vdCreditLC (idVatCreditLC),
input vdDebitCC (idVatDebitCC),
input vdCreditCC (idVatCreditCC),
input tAPMatchingLnTax.tcAbsRetTaxGLCode (icNormalTaxGLCode),
input tAPMatchingLnTax.tcAbsRetTaxDivisionCode (icNormalTaxDivisionCode),
input true (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.AbsRetTaxGL_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-98 run SetPostingLineLegalDocNumber
(input ? (icPostingLineTcRowID),
input tAPMatchingLnTax.AbsRetTaxGL_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.APMatchingLnTaxIsAbsRet = true and */
END. /* TAXHANDLINGBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.