| icPostingTcRowid | input | character | The tc_rowid of the posting your want a new posting-line for |
| itTaxPointDate | input | date | tax point date of the posting-line |
| icPostingLineText | input | character | Posting-line-text |
| icCurrencyCode | input | character | Currency Code of the posting-line that will be created |
| icPostingVatInOut | input | character | Indicates the direction of the taxes: for supplier invoices this will normaly be the incomming direction. Use proprocessors: VATINOUT |
| icPostingVatCode | input | character | |
| icPostingVatDomain | input | character | |
| idExchangeRate | input | decimal | Exchange Rate of the posting-line that will be created. This is the rate information between TC and LC |
| idExchangeRateScale | input | decimal | Exchange Rate Scale of the posting-line that will be created. This is the rate information between TC and LC |
| icExchangeRateType | input | character | Type of the exchange rate of the posting-line that will be created. This is the rate information between TC and LC |
| idCCExchangeRate | input | decimal | Statutory currency exchange rate |
| idCCExchangeRateScale | input | decimal | Statutory currency exchange rate scale |
| icTransactionType | input | character | Transaction-Type: corresponds with field PostingVat.PostingVatTransType. Use following preprocessores to fill this parameter: VATTRANSACTIONTYPES |
| icTaxTransactionType | input | character | Tax-Transaction-Type: corresponds with no specific field in the posting but is used to determine some other information. Pass following preprocessors for this parameter: VATTAXTRANSACTIONTYPES |
| idBaseDebitTC | input | decimal | Base-Debit -amount in TC of the posting-line that will be created |
| idBaseCreditTC | input | decimal | Base-Credit-amount in TC of the posting-line that will be created |
| idBaseDebitLC | input | decimal | Base-Debit -amount in LC of the posting-line that will be created |
| idBaseCreditLC | input | decimal | Base-Credit-amount in LC of the posting-line that will be created |
| idBaseDebitCC | input | decimal | Base-Debit-amount in CC of the posting-line that will be created |
| idBaseCreditCC | input | decimal | Base-Credit-amount in CC of the posting-line that will be created |
| idVatDebitTC | input | decimal | Vat-Debit-amount in TC of the posting-line that will be created |
| idVatCreditTC | input | decimal | Vat-Credit-amount in TC of the posting-line that will be created |
| idVatDebitLC | input | decimal | Vat-Debit-amount in LC of the posting-line that will be created |
| idVatCreditLC | input | decimal | Vat-Credit-amount in LC of the posting-line that will be created |
| idVatDebitCC | input | decimal | Vat-Debit-amount in CC of the posting-line that will be created |
| idVatCreditCC | input | decimal | Vat-Credit-amount in CC of the posting-line that will be created |
| icNormalTaxGLCode | input | character | GL-code of the posting-line that will be created |
| icNormalTaxDivisionCode | input | character | Division-code of the posting-line that will be created |
| ilNormalTaxIsAlreadyAbsRet | input | logical | NormalTaxIsAlreadyAbsRet: set to true in case the posting-line and posting-vat identified by icNormalTaxGLCode concerns an absorbed or retained tax. If this parameter is true then icAbsRetTaxGLCode should be empty |
| icAbsRetTaxGLCode | input | character | GL-Code that will be used for the tax-postingline that covers the absorbed or retained taxes |
| icAbsRetTaxDivisionCode | input | character | DivisionCode that will be used for the tax-postingline that covers the absorbed or retained taxes |
| icFromTaxZone | input | character | From Tax Zone |
| icToTaxZone | input | character | To Tax Zone |
| icTaxEnvrionment | input | character | Tax Environment |
| ilIsTaxable | input | logical | Is Taxable flag |
| icTaxClass | input | character | Tax Class |
| icTaxUsage | input | character | Tax Usage |
| icTaxType | input | character | Tax Type |
| ilTaxIsReverseChargeDomestic | input | logical | Corresponds with the taxf-lag: tx2_reverse_charge |
| iiTaxAddressID | input | integer | Ship From Address ID in case of purchasing: this paramater is not indeed if the next 5 parameters about the Tax are specified. If this field is filled, then the next 5 parameters are not taken into account. |
| icTaxIDFeder | input | character | TaxIDFeder of the TaxAddress |
| icTaxIDState | input | character | State of the TaxAddress |
| icTaxIDMisc1 | input | character | Misc1 of the TaxAddress |
| icTaxIDMisc2 | input | character | Misc2 of the TaxAddress |
| icTaxIDMisc3 | input | character | Misc3 of the TaxAddress |
| iiOwnAddressID | input | integer | Ship To Address ID (address of our own company) in case of purchasing: this parameter is not indeed if the next 6 parameters about the Own-address are specified. If this field is filled, then the next 6 parameters are not taken into account. |
| icOwnTaxIDFeder | input | character | OwnTaxIDFeder: Feder of the own address |
| icOwnTaxIDState | input | character | OwnTaxIDState: State of the own address |
| icOwnTaxIDMisc1 | input | character | OwnTaxIDMisc1: Misc1 of the own address |
| icOwnTaxIDMisc2 | input | character | OwnTaxIDMisc2: Misc2 of the own address |
| icOwnTaxIDMisc3 | input | character | OwnTaxIDMisc3: Misc3 of the own address |
| iiOwnTaxIDDeclarat | input | integer | OwnTaxIDDeclarat: Declarat of the own address |
| ilIsSuspDel | input | logical | ilIsSuspDel: Is the tax marked as Suspended or Delayed tax |
| oiNormalTaxPostingLineID | output | integer | Posting-line ID of the posting-line on the normal tax-account |
| ocNormalTaxPostingLineTcRowid | output | character | TcRowid of the Posting-line of the posting-line on the normal tax-account |
| oiAbsRetTaxPostingLineID | output | integer | ID of the Posting-line of the posting-line for the absorbed or retained tax |
| ocAbsRetTaxPostingLineTcRowid | output | character | TcRowid of the Posting-line of the posting-line for the absorbed or retained tax |
| oiNormalTaxPostingVatID | output | integer | Posting Vat ID of the normal tax |
| ilLinkedCrCyDaemonReqExists | input | logical | |
| ilCalledFromMoveSuspDelTax | input | logical | |
| itInvoiceExchangeRateDate | input | date | If this is set then this will be the exchange date used to retrieve the exchange rate |
| oiReturnStatus | output | integer | Return status of the method. |
QadFinancials
/* ================== */
/* Exception Handling */
/* ================== */
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* ============================== */
/* Start major tax-handling block */
/* ============================== */
MAJORTAXHANDLINGBLOCK: DO :
/* ============================================================================= */
/* Call sub-method that will do the defaulting and validations of the parameters */
/* ============================================================================= */
<M-145 run AddPostingLineTaxValAndDef
(input-output icPostingTcRowid (bcPostingTcRowid),
input-output itTaxPointDate (btTaxPointDate),
input-output icPostingLineText (bcPostingLineText),
input-output icCurrencyCode (bcCurrencyCode),
input-output icPostingVatInOut (bcPostingVatInOut),
input icPostingVatCode (icPostingVatCode),
input icPostingVatDomain (icPostingVatDomain),
input-output idExchangeRate (bdExchangeRate),
input-output idExchangeRateScale (bdExchangeRateScale),
input-output icExchangeRateType (bcExchangeRateType),
input-output icTransactionType (bcTransactionType),
input-output icTaxTransactionType (bcTaxTransactionType),
input-output idBaseDebitTC (bdBaseDebitTC),
input-output idBaseCreditTC (bdBaseCreditTC),
input-output idBaseDebitLC (bdBaseDebitLC),
input-output idBaseCreditLC (bdBaseCreditLC),
input-output idBaseDebitCC (bdBaseDebitCC),
input-output idBaseCreditCC (bdBaseCreditCC),
input-output idVatDebitTC (bdVatDebitTC),
input-output idVatCreditTC (bdVatCreditTC),
input-output idVatDebitLC (bdVatDebitLC),
input-output idVatCreditLC (bdVatCreditLC),
input-output idVatDebitCC (bdVatDebitCC),
input-output idVatCreditCC (bdVatCreditCC),
input-output icNormalTaxGLCode (bcNormalTaxGLCode),
input-output icNormalTaxDivisionCode (bcNormalTaxDivisionCode),
input-output ilNormalTaxIsAlreadyAbsRet (blNormalTaxIsAlreadyAbsRet),
input-output icAbsRetTaxGLCode (bcAbsRetTaxGLCode),
input-output icAbsRetTaxDivisionCode (bcAbsRetTaxDivisionCode),
input-output icFromTaxZone (bcFromTaxZone),
input-output icToTaxZone (bcToTaxZone),
input-output icTaxEnvrionment (bcTaxEnvrionment),
input-output ilIsTaxable (blIsTaxable),
input-output icTaxClass (bcTaxClass),
input-output icTaxUsage (bcTaxUsage),
input-output icTaxType (bcTaxType),
input iiTaxAddressID (iiTaxAddressID),
input-output icTaxIDFeder (bcTaxIDFeder),
input-output icTaxIDState (bcTaxIDState),
input-output icTaxIDMisc1 (bcTaxIDMisc1),
input-output icTaxIDMisc2 (bcTaxIDMisc2),
input-output icTaxIDMisc3 (bcTaxIDMisc3),
input iiOwnAddressID (iiOwnAddressID),
input-output icOwnTaxIDFeder (bcOwnTaxIDFeder),
input-output icOwnTaxIDState (bcOwnTaxIDState),
input-output icOwnTaxIDMisc1 (bcOwnTaxIDMisc1),
input-output icOwnTaxIDMisc2 (bcOwnTaxIDMisc2),
input-output icOwnTaxIDMisc3 (bcOwnTaxIDMisc3),
input-output iiOwnTaxIDDeclarat (biOwnTaxIDDeclarat),
input-output ilIsSuspDel (blIsSuspDel),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
/* ======================= */
/* Find the posting itself */
/* ======================= */
find tPosting where
tPosting.tc_Rowid = icPostingTcRowid
no-error.
if not available tPosting
then do:
assign vcMessage = trim(substitute(#T-148'Internal error. The system cannot find the posting based upon its row ID (&1).':255(68738)T-148#,icPostingTcRowid))
viLocalReturnStatus = -3.
<M-147 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7811':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave MAJORTAXHANDLINGBLOCK.
end. /* if not available tPosting */
/* =============================================================================== */
/* Create PostingLine and PostingVat and Fill the ID and Rowid in the output */
/* We use a find last + internal index to get the highest PostingLineSequence used */
/* =============================================================================== */
assign viPostingLineSequence = 0.
for last tPostingLine where
tPostingLine.tc_Status <> "D":U and
tPostingLine.Posting_ID = tPosting.Posting_ID
use-index PostingIDLineSeq:
assign viPostingLineSequence = tPostingLine.PostingLineSequence.
end. /* for each tPostingLine where */
/* ====================================== */
/* Create PostingLine and PostingVat and */
/* Fill the ID and Rowid in the output */
/* ====================================== */
<M-146 run AddDetailLine
(input 'PostingLine':U (icTable),
input tPosting.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
<M-149 run AddDetailLine
(input 'PostingVat':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
assign oiNormalTaxPostingLineID = tPostingLine.PostingLine_ID
ocNormalTaxPostingLineTcRowid = tPostingLine.tc_Rowid
oiNormalTaxPostingVatID = tPostingVat.PostingVat_ID.
/* ================= */
/* Get the CC amount */
/* ================= */
assign vdPostingLineCCRate = idCCExchangeRate
vdPostingLineCCScale = idCCExchangeRateScale.
if ilCalledFromMoveSuspDelTax = no or
itTaxPointDate = ?
then do:
/* if the itInvoiceExchangeRate is set then use that date - it could either be
the tax point date or the invoice date depending on the invoice flag */
if itInvoiceExchangeRateDate = ?
then assign vtTaxPostingDate = tPosting.PostingDate.
else assign vtTaxPostingDate = itInvoiceExchangeRateDate.
end.
else do:
assign vtTaxPostingDate = itTaxPointDate.
end.
assign vlCurrFetched = false.
if (idBaseDebitCC = ? or idBaseCreditCC = ? or
(idBaseDebitCC = 0 and idBaseCreditCC = 0)) and
((idBaseDebitTC <> ? and idBaseDebitTC <> 0) or
(idBaseCreditTC <> ? and idBaseCreditTC <> 0))
then do:
<M-165 run CalculateCCAmount
(input tPosting.Company_ID (iiCompanyID),
input idBaseCreditLC (idPostingLineCreditLC),
input idBaseCreditTC (idPostingLineCreditTC),
input idBaseDebitLC (idPostingLineDebitLC),
input idBaseDebitTC (idPostingLineDebitTC),
input vtTaxPostingDate (itPostingDate),
input icCurrencyCode (icCurrencyCode),
input vtTaxPostingDate (itInvoiceExchangeRateDate),
input-output vdPostingLineCCRate (bdCCExchangeRate),
input-output vdPostingLineCCScale (bdCCExchangeRateScale),
input-output vlCurrFetched (blCurrencyFetched),
output idBaseCreditCC (odPostingLineCreditCC),
output idBaseDebitCC (odPostingLineDebitCC),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
end. /* if idBaseDebitCC = ? or idBaseCreditCC = ? */
assign vlCurrFetched = false.
if (idVatDebitCC = ? or idVatCreditCC = ? or
(idVatDebitCC = 0 and idVatCreditCC = 0)) and
((idVatDebitTC <> ? and idVatDebitTC <> 0) or
(idVatCreditTC <> ? and idVatCreditTC <> 0))
then do:
<M-166 run CalculateCCAmount
(input tPosting.Company_ID (iiCompanyID),
input idVatCreditLC (idPostingLineCreditLC),
input idVatCreditTC (idPostingLineCreditTC),
input idVatDebitLC (idPostingLineDebitLC),
input idVatDebitTC (idPostingLineDebitTC),
input vtTaxPostingDate (itPostingDate),
input icCurrencyCode (icCurrencyCode),
input itInvoiceExchangeRateDate (itInvoiceExchangeRateDate),
input-output vdPostingLineCCRate (bdCCExchangeRate),
input-output vdPostingLineCCScale (bdCCExchangeRateScale),
input-output vlCurrFetched (blCurrencyFetched),
output idVatCreditCC (odPostingLineCreditCC),
output idVatDebitCC (odPostingLineDebitCC),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
end. /* if idVatDebitCC = ? or idVatCreditCC = ? */
/* ============================================ */
/* Assign the PostingLine and PostingVat fields */
/* ============================================ */
<Q-36 run GLByCode (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input icNormalTaxGLCode, (GLCode)
output dataset tqGLByCode) in BGL>
find first tqGLByCode where tqGLByCode.tcGLCode = icNormalTaxGLCode no-error.
if available tqGlByCode
then assign vcGLDescription = tqGLByCode.tcGLDescription.
else assign vcGLDescription = "":U.
assign viPostingLineSequence = viPostingLineSequence + 1
tPostingLine.PostingLineSequence = viPostingLineSequence
tPostingLine.Posting_ID = tPosting.Posting_ID
tPostingLine.PostingLineText = icPostingLineText
tPostingLine.tcGLCode = icNormalTaxGLCode
tPostingLine.tcGLDescription = vcGLDescription
tPostingLine.tcGLTypeCode = {&GLTYPECODE-VAT}
tPostingLine.tcDivisionCode = icNormalTaxDivisionCode
tPostingLine.tcCurrencyCode = icCurrencyCode
tPostingLine.PostingLineExchangeRate = idExchangeRate
tPostingLine.PostingLineRateScale = idExchangeRateScale
tPostingLine.tlPostingLineIsLocalCurrency = (tPostingLine.tcCurrencyCode = vcCompanyLC)
tPostingLine.PostingLineDebitTC = idVatDebitTC
tPostingLine.PostingLineCreditTC = idVatCreditTC
tPostingLine.PostingLineDebitLC = idVatDebitLC
tPostingLine.PostingLineCreditLC = idVatCreditLC
tPostingLine.PostingLineDebitCC = idVatDebitCC
tPostingLine.PostingLineCreditCC = idVatCreditCC
tPostingLine.PostingLineCCRate = vdPostingLineCCRate
tPostingLine.PostingLineCCScale = vdPostingLineCCScale
tPostingLine.tlLinkedCrCyDaemonReqExists = ilLinkedCrCyDaemonreqExists
tPostingVat.PostingLine_ID = tPostingLine.PostingLine_ID
tPostingVat.tcCurrencyCode = tPostingLine.tcCurrencyCode
tPostingVat.tcVatCode = icPostingVatCode
tPostingVat.tcDomainCode = icPostingVatDomain
tPostingVat.tcVatInOut = icPostingVatInOut
tPostingVat.PostingVatBaseDebitTC = idBaseDebitTC
tPostingVat.PostingVatBaseCreditTC = idBaseCreditTC
tPostingVat.PostingVatBaseDebitLC = idBaseDebitLC
tPostingVat.PostingVatBaseCreditLC = idBaseCreditLC
tPostingVat.PostingVatBaseDebitCC = idBaseDebitCC
tPostingVat.PostingVatBaseCreditCC = idBaseCreditCC
tPostingVat.PostingVatTaxPointDate = itTaxPointDate
tPostingVat.PostingVatTaxDebitTC = tPostingLine.PostingLineDebitTC
tPostingVat.PostingVatTaxCreditTC = tPostingLine.PostingLineCreditTC
tPostingVat.PostingVatTaxDebitLC = tPostingLine.PostingLineDebitLC
tPostingVat.PostingVatTaxCreditLC = tPostingLine.PostingLineCreditLC
tPostingVat.PostingVatTaxDebitCC = tPostingLine.PostingLineDebitCC
tPostingVat.PostingVatTaxCreditCC = tPostingLine.PostingLineCreditCC
tPostingVat.PostingVatExchangeRate = 1 /* Set to 1 to make sure the VAT reports keep working */
tPostingVat.PostingVatRateScale = 1
tPostingVat.TxtyTaxType = icTaxType
tPostingVat.TxclTaxCls = icTaxClass
tPostingVat.TxuTaxUsage = icTaxUsage
tPostingVat.PostingVatTaxTransType = icTaxTransactionType
tPostingVat.PostingVatInOut = tPostingVat.tcVatInOut
tPostingVat.PostingVatTransType = icTransactionType
tPostingVat.TxenvTaxEnv = icTaxEnvrionment
tPostingVat.FromTxzTaxZone = icFromTaxZone
tPostingVat.ToTxzTaxZone = icToTaxZone
tPostingVat.PostingVatIsReverseCharge = ilTaxIsReverseChargeDomestic
tPostingVat.PostingVatIsAbsRet = ilNormalTaxIsAlreadyAbsRet
tPostingVat.PostingVatOwnTaxIDFeder = icOwnTaxIDFeder
tPostingVat.PostingVatOwnTaxIDState = icOwnTaxIdState
tPostingVat.PostingVatOwnTaxIDMisc1 = icOwnTaxIdMisc1
tPostingVat.PostingVatOwnTaxIDMisc2 = icOwnTaxIdMisc2
tPostingVat.PostingVatOwnTaxIDMisc3 = icOwnTaxIdMisc3
tPostingVat.PostingVatOwnTaxDeclarat = iiOwnTaxIDDeclarat
tPostingVat.PostingVatTaxIDFeder = icTaxIDFeder
tPostingVat.PostingVatTaxIDState = icTaxIDState
tPostingVat.PostingVatTaxIDMisc1 = icTaxIDMisc1
tPostingVat.PostingVatTaxIDMisc2 = icTaxIDMisc2
tPostingVat.PostingVatTaxIDMisc3 = icTaxIDMisc3
tPostingVat.PostingVatIsSuspDel = ilIsSuspDel.
/* Set the CC Rate */
if vdPostingLineCCRate = 0 or vdPostingLineCCScale = 0 or
vdPostingLineCCRate = ? or vdPostingLineCCScale = ?
then do:
if tPostingLine.tcCurrencyCode = vcCompanyCC
then assign tPostingLine.PostingLineCCRate = 1
tPostingLine.PostingLineCCScale = 1.
else if vlDomainIsStatutory = false
then assign tPostingLine.PostingLineCCRate = vdPostingLineCCRate
tPostingLine.PostingLineCCScale = vdPostingLineCCScale.
else if tPostingLine.PostingLineDebitTC - tPostingLine.PostingLineCreditTC = 0
then assign tPostingLine.PostingLineCCRate = 0
tPostingLine.PostingLineCCScale = 0.
else assign tPostingLine.PostingLineCCRate = absolute(round((tPostingLine.PostingLineDebitCC - tPostingLine.PostingLineCreditCC) / (tPostingLine.PostingLineDebitTC - tPostingLine.PostingLineCreditTC), 10))
tPostingLine.PostingLineCCScale = 1.
end. /* if vdPostingLineCCRate = 0 or vdPostingLineCCScale = 0 */
/* ================= */
/* State the VatRule */
/* ================= */
if vlStartedQryVatRuleByVatIDCode = false
then do :
<Q-156 run VatRuleByVatIDCode (Start) in BVAT >
assign vlStartedQryVatRuleByVatIDCode = true.
end. /* if vlStartedQryVatRuleByVatIDCode = true */
<Q-151 run VatRuleByVatIDCode (all) (Read) (NoCache)
(input tPostingVat.tcVatCode, (VatCode)
input ?, (VatID)
input {&VATRULEBASE-FULL}, (VatRuleBaseFull)
input tPostingVat.tcVatInOut, (VatInOut)
input tPostingVat.tcDomainCode, (DomainCode)
output dataset tqVatRuleByVatIDCode) in BVAT >
if ilNormalTaxIsAlreadyAbsRet = true
then find last tqVatRuleByVatIDCode no-error. /* the last one it the one for retained absorbed taxes */
else find first tqVatRuleByVatIDCode no-error. /* the first one it the one for non-retained non-absorbed taxes */
if not available tqVatRuleByVatIDCode
then do:
assign vcMessage = trim(substitute(#T-155'Internal error. The system cannot create the tax posting line because the tax rule cannot be found based on the domain (&1), tax code (&2) and tax direction (&3).':255(68753)T-155#,tPostingVat.tcDomainCode,tPostingVat.tcVatCode,tPostingVat.tcVatInOut))
viLocalReturnStatus = -3.
<M-154 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7813':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave MAJORTAXHANDLINGBLOCK.
end. /* if not available tqVatRuleByVatIDCode */
assign tPostingVat.VatRule_ID = tqVatRuleByVatIDCode.tiVatRule_ID.
/* ===================================================================== */
/* Create the absorbed/retained postingline on tax account when needed */
/* ===================================================================== */
if icAbsRetTaxGLCode <> "":U
then do :
/* =============================================================================== */
/* Hold a buffer to the newly created tPostingLine and tPostingVat as we need them */
/* further on in this method and we will use tPostingLine for the new record */
/* =============================================================================== */
find btPostingLine where
rowid(btPostingLine) = rowid(tPostingLine)
no-lock no-error.
find btPostingVat where
rowid(btPostingVat) = rowid(tPostingVat)
no-lock no-error.
if not available btPostingLine or
not available btPostingVat
then do :
assign vcMessage = trim(substitute(#T-158'Internal error. The system cannot find the tax posting line for the retained/absorbed taxes because the originating posting line cannot be found.':255(68754)T-158#))
viLocalReturnStatus = -3.
<M-157 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7814':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave MAJORTAXHANDLINGBLOCK.
end. /* if not available btPostingLine or */
/* ====================================== */
/* Create PostingLine and PostingVat and */
/* Fill the ID and Rowid in the output */
/* ====================================== */
<Q-13 run GLByCode (all) (Read) (NoCache)
(input tPosting.Company_ID, (CompanyId)
input icAbsRetTaxGLCode, (GLCode)
output dataset tqGLByCode) in BGL>
find first tqGLByCode where tqGLByCode.tcGLCode = icAbsRetTaxGLCode no-error.
if available tqGlByCode
then assign vcGLDescription = tqGLByCode.tcGLDescription.
else assign vcGLDescription = "":U.
<M-159 run AddDetailLine
(input 'PostingLine':U (icTable),
input tPosting.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
<M-160 run AddDetailLine
(input 'PostingVat':U (icTable),
input tPostingLine.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave MAJORTAXHANDLINGBLOCK.
assign oiAbsRetTaxPostingLineID = tPostingLine.PostingLine_ID
ocAbsRetTaxPostingLineTcRowid = tPostingLine.tc_Rowid.
/* =============================================================================================== */
/* Assign the PostingLine and PostingVat fields based upon the original PostingLine and PostingVat */
/* The only differences bwteen the absorbed/retained and the first postingline is that the amounts */
/* are inversed (* -1) in posting-line and posting-vat and that the TaxBase is set to zero */
/* =============================================================================================== */
assign viPostingLineSequence = viPostingLineSequence + 1.
buffer-copy btPostingLine
except tc_rowid tc_parentrowid tc_status PostingLine_ID
to tPostingLine
assign tPostingLine.PostingLineSequence = viPostingLineSequence
tPostingLine.PostingLineDebitTC = btPostingLine.PostingLineCreditTC
tPostingLine.PostingLineCreditTC = btPostingLine.PostingLineDebitTC
tPostingLine.PostingLineDebitLC = btPostingLine.PostingLineCreditLC
tPostingLine.PostingLineCreditLC = btPostingLine.PostingLineDebitLC
tPostingLine.PostingLineDebitCC = btPostingLine.PostingLineCreditCC
tPostingLine.PostingLineCreditCC = btPostingLine.PostingLineDebitCC
tPostingLine.tcGLCode = icAbsRetTaxGLCode
tPostingLine.tcGLDescription = vcGLDescription
tPostingLine.tcDivisionCode = icAbsRetTaxDivisionCode.
buffer-copy btPostingVat
except tc_rowid tc_parentrowid tc_status VatRule_ID PostingLine_ID PostingVat_ID
to tPostingVat
assign tPostingVat.PostingLine_ID = tPostingLine.PostingLine_ID
tPostingVat.PostingVatBaseDebitTC = idBaseCreditTC
tPostingVat.PostingVatBaseCreditTC = idBaseDebitTC
tPostingVat.PostingVatBaseDebitLC = idBaseCreditLC
tPostingVat.PostingVatBaseCreditLC = idBaseDebitLC
tPostingVat.PostingVatBaseDebitCC = idBaseCreditCC
tPostingVat.PostingVatBaseCreditCC = idBaseDebitCC
tPostingVat.PostingVatTaxDebitTC = tPostingLine.PostingLineDebitTC
tPostingVat.PostingVatTaxCreditTC = tPostingLine.PostingLineCreditTC
tPostingVat.PostingVatTaxDebitLC = tPostingLine.PostingLineDebitLC
tPostingVat.PostingVatTaxCreditLC = tPostingLine.PostingLineCreditLC
tPostingVat.PostingVatTaxDebitCC = tPostingLine.PostingLineDebitCC
tPostingVat.PostingVatTaxCreditCC = tPostingLine.PostingLineCreditCC
tPostingVat.PostingVatIsAbsRet = true.
/* ================= */
/* State the VatRule */
/* ================= */
<Q-162 run VatRuleByVatIDCode (all) (Read) (NoCache)
(input tPostingVat.tcVatCode, (VatCode)
input ?, (VatID)
input {&VATRULEBASE-FULL}, (VatRuleBaseFull)
input tPostingVat.tcVatInOut, (VatInOut)
input tPostingVat.tcDomainCode, (DomainCode)
output dataset tqVatRuleByVatIDCode) in BVAT >
find last tqVatRuleByVatIDCode no-error. /* the last one it the one for retained-absorbed taxes */
if not available tqVatRuleByVatIDCode
then do:
assign vcMessage = trim(substitute(#T-164'Internal error. The system cannot create the tax posting line because the tax rule cannot be found based on the domain (&1), tax code (&2) and tax direction (&3).':255(68753)T-164#,tPostingVat.tcDomainCode,tPostingVat.tcVatCode,tPostingVat.tcVatInOut))
viLocalReturnStatus = -3.
<M-163 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-7815':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
Leave MAJORTAXHANDLINGBLOCK.
end. /* if not available tqVatRuleByVatIDCode */
assign tPostingVat.VatRule_ID = tqVatRuleByVatIDCode.tiVatRule_ID.
end. /* if icAbsRetTaxGLCode <> "":U */
END. /* MAJORTAXHANDLINGBLOCK */
/* ================== */
/* Stop Queries */
/* ================== */
if vlStartedQryVatRuleByVatIDCode = true
then do :
<Q-150 run VatRuleByVatIDCode (Stop) in BVAT >
end. /* if vlStartedQryVatRuleByVatIDCode = true */
/* ================== */
/* Exception Handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.