project QadFinancials > class BCInvoice > method UpdateCInvoiceVatDelay
Description
This method does update of the Delayed amount of the Tax. It also does generation of the posting to this delayed tax. The method can be only used to correct the delayed tax amount for existing record. Like during payment ....
Parameters
tCInvoiceVatDelayDelta | input | temp-table | |
iiBJournalEntryID | input | integer | ID of the BJournalEntry component. |
ihBJournalEntryHandle | input | handle | Handle for BJournalEntry component |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bcinvoice.p)
/* =============================================================================================================== *
* Method : UpdateCInvoiceVatDelay *
* Description : This method does update of the Delayed amount of the Tax. It also does generation of the posting *
* to this delayed tax. The method can be only used to correct the delayed tax amount for existing *
* record. Like during payment .... *
* --------------------------------------------------------------------------------------------------------------- *
* Parameters : BJournalEntryID Instance ID of the journal entry *
* BJournalEntryHandle Handle to already started journal entry *
* tCInvoiceVatDelayDelta Temp table with all data needed for update of CInvoiceVat records *
* - CInvoice_ID ID of the supplier invoice record *
* - CInvoiceVat_ID ID of the suppleir invoice Vat record that has delayed taxes *
* - PostingRowId Row_ID of the created posting header *
* - DelayedTaxDeltaTC Delta amount of the delayed taxes. This amount is substracted from the *
* remaining delayed tax *
* - IsGenerateJEDelTax Generate Posting to delayed tax GL account *
* - IsGenerateJETax Generate Posting to normal tax account *
* - IsUndoPayment Undo of the payemnt. In this case balance on the delayed tax account *
* is increased *
* =============================================================================================================== */
MAIN_BLOCK:
do on error undo, throw:
/* ================================================================================================ */
/* Pre-validation block */
/* ================================================================================================ */
/* Validate, there is at least one record to be updated */
if not can-find(first tCInvoiceVatDelayDelta)
then leave MAIN_BLOCK.
/* Check, if there is passed BJournalEntry component ID */
if (viBJournalEntryCIID = ? or
viBJournalEntryCIID = 0) and
(not valid-handle(ihBJournalEntryHandle) or
iiBJournalEntryID = 0 or
iiBJournalEntryID = ?)
then do:
assign vcMessage = #T-1'No journal entry component instance passed to this method.':255(14478994)T-1#
vcContext = "viBJournalEntryCIID=&1|valid-handle(ihBJournalEntryHandle)=&2|iiBJournalEntryID=&3":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, viBJournalEntryCIID, valid-handle(ihBJournalEntryHandle),viBJournalEntryCIID).
<M-64 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-658810':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
leave MAIN_BLOCK.
end.
/* ================================================================================================ */
/* Overtake input values */
/* ================================================================================================ */
if viBJournalEntryCIID = 0 or
viBJournalEntryCIID = ?
then assign viBJournalEntryCIID = iiBJournalEntryID
vhBJournalEntryCIInst = ihBJournalEntryHandle
vlBJEIsStartedFromCI = false.
/* ================================================================================================ */
/* Get some details from the Entity definition */
/* ================================================================================================ */
<Q-11 run CompanyPropertyBySuspDelTax (all) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input ?, (DelTax)
input ?, (SuspTax)
output dataset tqCompanyPropertyBySuspDelTax) in BCompanyProperty>
find first tqCompanyPropertyBySuspDelTax where
tqCompanyPropertyBySuspDelTax.tiCompany_ID = viCompanyId no-error.
if not available tqCompanyPropertyBySuspDelTax
then do:
assign vcMessage = #T-84'No entity related data can be retrieved from the database.':255(792521521)T-84#
vcContext = "viCompanyId=&1":U
vcContext = substitute(vcContext, viCompanyId).
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-134591':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
leave MAIN_BLOCK.
end.
/* ================================================================================================ */
/* Read all invoices we need */
/* ================================================================================================ */
assign vcCInvoiceIDList = "":U.
for each tCInvoiceVatDelayDelta
break by tCInvoiceVatDelayDelta.tiCInvoice_ID:
if first-of(tCInvoiceVatDelayDelta.tiCInvoice_ID)
then do:
if can-find(first tCInvoice where
tCInvoice.CInvoice_ID = tCInvoiceVatDelayDelta.tiCInvoice_ID)
then next.
assign vcCInvoiceIDList = vcCInvoiceIDList
+ (if vcCInvoiceIDList = "":U then "":U else chr(4))
+ string(tCInvoiceVatDelayDelta.tiCInvoice_ID).
end.
end.
if vcCInvoiceIDList <> "":U
then do:
<M-52 run DataLoad
(input '':U (icRowids),
input vcCInvoiceIDList (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
/* ================================================================================================ */
/* Update CInvoiceVat records */
/* ================================================================================================ */
for each tCInvoiceVatDelayDelta
break by tCInvoiceVatDelayDelta.tiCInvoice_ID
by tCInvoiceVatDelayDelta.tiCInvoiceVat_ID:
/* Get CInvoice */
if first-of(tCInvoiceVatDelayDelta.tiCInvoice_ID)
then do:
find tCInvoice where
tCInvoice.CInvoice_ID = tCInvoiceVatDelayDelta.tiCInvoice_ID
no-error.
if not available tCInvoice
then do:
assign vcMessage = #T-98'Supplier invoice record not found in the instance of the BCInvoice component.':255(948977549)T-98#
vcContext = "tCInvoiceVatDelayDelta.tiCInvoice_ID=&1":U
vcContext = substitute(vcContext, tCInvoiceVatDelayDelta.tiCInvoice_ID).
<M-73 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-586902':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
leave MAIN_BLOCK.
end. /* if not available tCInvoice */
/* Read original posting vat records that were created for the SI posting */
<Q-76 run CInvoicePostingForDelTax (all) (Read) (NoCache)
(input ?, (CompanyId)
input tCInvoiceVatDelayDelta.tiCInvoice_ID, (CInvoiceId)
input true, (CInvoiceVatIsSuspDel)
output dataset tqCInvoicePostingForDelTax) in BCInvoice>
end. /* if first-of(tCInvoiceVatDelayDelta.tiCInvoice_ID) */
/* Get CInvoiceVat record */
find tCInvoiceVat where
tCInvoiceVat.CInvoice_ID = tCInvoiceVatDelayDelta.tiCInvoice_ID and
tCInvoiceVat.CInvoiceVat_ID = tCInvoiceVatDelayDelta.tiCInvoiceVat_ID
no-error.
if not available tCInvoiceVat
then do:
assign vcMessage = #T-67'Supplier invoice tax record not found in the instance of the BCInvoice component.':255(102623435)T-67#
vcContext = "tCInvoiceVatDelayDelta.tiCInvoice_ID=&1|tCInvoiceVatDelayDelta.tiCInvoiceVat_ID=&2":U
vcContext = substitute(vcContext, tCInvoiceVatDelayDelta.tiCInvoice_ID, tCInvoiceVatDelayDelta.tiCInvoiceVat_ID).
<M-61 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-308780':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
leave MAIN_BLOCK.
end. /* if not available tCInvoiceVat */
/* Check, if the CInvoiceVat record is about delayed taxes */
if tCInvoiceVat.CInvoiceVatIsSuspDel <> true
then do:
assign vcMessage = #T-56'This routine can be used only for update of delayed taxes.':255(557351460)T-56#
vcContext = "tCInvoiceVat.CInvoiceVat_ID=&1|tCInvoiceVat.tcVatCode=&2":U
vcContext = substitute(vcContext, tCInvoiceVat.CInvoiceVat_ID, tCInvoiceVat.tcVatCode).
<M-78 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-712341':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
assign oiReturnStatus = -1.
leave MAIN_BLOCK.
end.
/* Update Delayed tax amount */
assign tCInvoiceVat.CInvoiceVatSuspDelTaxAmtTC = tCInvoiceVat.CInvoiceVatSuspDelTaxAmtTC
+ (if tCInvoiceVatDelayDelta.tlIsUndoPayment <> true
then - tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC
else tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC)
tCInvoiceVat.tc_Status = (if tCInvoiceVat.tc_Status = "":U then "C":U else "":U).
/* ====================================================================================== */
/* Now go through all original CInvoiceVat records and generate postings */
/* ====================================================================================== */
for each tqCInvoicePostingForDelTax where
tqCInvoicePostingForDelTax.tiCInvoice_ID = tCInvoiceVatDelayDelta.tiCInvoice_ID and
tqCInvoicePostingForDelTax.tiCInvoiceVat_ID = tCInvoiceVatDelayDelta.tiCInvoiceVat_ID and
tqCInvoicePostingForDelTax.tlCInvoiceVatIsSuspDel = true:
/* ====================================================================================== */
/* Calculate amounts to be posted. For the posting required exchange rate is used */
/* It can be exchange rate of payment or any other suitable one. */
/* ====================================================================================== */
if tCInvoiceVatDelayDelta.tdLCExchangeRate = 0 or
tCInvoiceVatDelayDelta.tdLCExchangeRate = ? or
tCInvoiceVatDelayDelta.tdLCExchangeRateScale = 0 or
tCInvoiceVatDelayDelta.tdLCExchangeRateScale = ?
then assign vdLCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineExchangeRate
vdLCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineRateScale.
else assign vdLCExchangeRate = tCInvoiceVatDelayDelta.tdLCExchangeRate
vdLCExchangeRateScale = tCInvoiceVatDelayDelta.tdLCExchangeRateScale.
if tCInvoiceVatDelayDelta.tdCCExchangeRate = 0 or
tCInvoiceVatDelayDelta.tdCCExchangeRate = ? or
tCInvoiceVatDelayDelta.tdCCExchangeRateScale = 0 or
tCInvoiceVatDelayDelta.tdCCExchangeRateScale = ?
then assign vdCCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineCCRate
vdCCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineCCScale.
else assign vdCCExchangeRate = tCInvoiceVatDelayDelta.tdCCExchangeRate
vdCCExchangeRateScale = tCInvoiceVatDelayDelta.tdCCExchangeRateScale.
if tqCInvoicePostingForDelTax.tcCInvoiceType = {&INVOICETYPE-INVOICE} or
tqCInvoicePostingForDelTax.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
then assign vdDelayVatBaseDebitTC = 0
vdDelayVatBaseCreditTC = tqCInvoicePostingForDelTax.tdPostingVatBaseDebitTC * tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC / tqCInvoicePostingForDelTax.tdPostingVatTaxDebitTC
vdDelayVatBaseCreditTC = <M-3 RoundAmount
(input vdDelayVatBaseCreditTC (idUnroundedAmount),
input tCInvoice.CInvoiceCurrency_ID (iiCurrencyID),
input tCInvoice.tcCurrencyCode (icCurrencyCode)) in BCInvoice>
vdDelayVatBaseDebitLC = 0
vdDelayVatBaseCreditLC = <M-29 RoundAmount
(input vdDelayVatBaseCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatBaseDebitCC = 0
vdDelayVatBaseCreditCC = <M-32 RoundAmount
(input vdDelayVatBaseCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatDebitTC = 0
vdDelayVatCreditTC = tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC
vdDelayVatDebitLC = 0
vdDelayVatCreditLC = <M-48 RoundAmount
(input vdDelayVatCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatDebitCC = 0
vdDelayVatCreditCC = <M-62 RoundAmount
(input vdDelayVatCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.
else assign vdDelayVatBaseDebitTC = tqCInvoicePostingForDelTax.tdPostingVatBaseCreditTC * tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC / tqCInvoicePostingForDelTax.tdPostingVatTaxCreditTC
vdDelayVatBaseDebitTC = <M-49 RoundAmount
(input vdDelayVatBaseDebitTC (idUnroundedAmount),
input tCInvoice.CInvoiceCurrency_ID (iiCurrencyID),
input tCInvoice.tcCurrencyCode (icCurrencyCode)) in BCInvoice>
vdDelayVatBaseCreditTC = 0
vdDelayVatBaseDebitLC = <M-72 RoundAmount
(input vdDelayVatBaseDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatBaseCreditLC = 0
vdDelayVatBaseDebitCC = <M-93 RoundAmount
(input vdDelayVatBaseDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatBaseCreditCC = 0
vdDelayVatDebitTC = tCInvoiceVatDelayDelta.tdDelTaxAmtDeltaTC
vdDelayVatCreditTC = 0
vdDelayVatDebitLC = <M-55 RoundAmount
(input vdDelayVatDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatCreditLC = 0
vdDelayVatDebitCC = <M-34 RoundAmount
(input vdDelayVatDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdDelayVatCreditCC = 0.
/* Reverse of the payment */
if tCInvoiceVatDelayDelta.tlIsUndoPayment = true
then assign vdDummy = vdDelayVatBaseDebitTC
vdDelayVatBaseDebitTC = vdDelayVatBaseCreditTC
vdDelayVatBaseCreditTC = vdDummy
vdDummy = vdDelayVatBaseDebitCC
vdDelayVatBaseDebitCC = vdDelayVatBaseCreditCC
vdDelayVatBaseCreditCC = vdDummy
vdDummy = vdDelayVatBaseDebitLC
vdDelayVatBaseDebitLC = vdDelayVatBaseCreditLC
vdDelayVatBaseCreditLC = vdDummy
vdDummy = vdDelayVatDebitTC
vdDelayVatDebitTC = vdDelayVatCreditTC
vdDelayVatCreditTC = vdDummy
vdDummy = vdDelayVatDebitCC
vdDelayVatDebitCC = vdDelayVatCreditCC
vdDelayVatCreditCC = vdDummy
vdDummy = vdDelayVatDebitLC
vdDelayVatDebitLC = vdDelayVatCreditLC
vdDelayVatCreditLC = vdDummy.
/* ====================================================================================== */
/* Generate oposite posting on the delayed tax account for changed value */
/* This posting is decreasing trial balance on the delayed tax account */
/* Normally this type of the posting is generated, when there is applied discount tax at */
/* payment for the invoice, or when the invoice gets paied */
/* In case of reverse posting all about is vice versa */
/* ====================================================================================== */
if tCInvoiceVatDelayDelta.tlIsGenerateJEDelTax
then do:
<M-45 run AddPostingLineTax
(input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingTcRowid),
input tqCInvoicePostingForDelTax.ttCInvoiceTaxPointDate (itTaxPointDate),
input tqCInvoicePostingForDelTax.tcCInvoiceCIText (icPostingLineText),
input tqCInvoicePostingForDelTax.tcCurrencyCode (icCurrencyCode),
input tqCInvoicePostingForDelTax.tcVatInOut (icPostingVatInOut),
input tqCInvoicePostingForDelTax.tcVatCode (icPostingVatCode),
input tqCInvoicePostingForDelTax.tcDomainCode (icPostingVatDomain),
input vdLCExchangeRate (idExchangeRate),
input vdLCExchangeRateScale (idExchangeRateScale),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType),
input vdCCExchangeRate (idCCExchangeRate),
input vdCCExchangeRateScale (idCCExchangeRateScale),
input tqCInvoicePostingForDelTax.tcPostingVatTransType (icTransactionType),
input tqCInvoicePostingForDelTax.tcPostingVatTaxTransType (icTaxTransactionType),
input vdDelayVatBaseDebitTC (idBaseDebitTC),
input vdDelayVatBaseCreditTC (idBaseCreditTC),
input vdDelayVatBaseDebitLC (idBaseDebitLC),
input vdDelayVatBaseCreditLC (idBaseCreditLC),
input vdDelayVatBaseDebitCC (idBaseDebitCC),
input vdDelayVatBaseCreditCC (idBaseCreditCC),
input vdDelayVatDebitTC (idVatDebitTC),
input vdDelayVatCreditTC (idVatCreditTC),
input vdDelayVatDebitLC (idVatDebitLC),
input vdDelayVatCreditLC (idVatCreditLC),
input vdDelayVatDebitCC (idVatDebitCC),
input vdDelayVatCreditCC (idVatCreditCC),
input tqCInvoicePostingForDelTax.tcDelTaxGLCode (icNormalTaxGLCode),
input tqCInvoicePostingForDelTax.tcDelTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input ? (icAbsRetTaxGLCode),
input ? (icAbsRetTaxDivisionCode),
input tqCInvoicePostingForDelTax.tcFromTxzTaxZone (icFromTaxZone),
input tqCInvoicePostingForDelTax.tcToTxzTaxZone (icToTaxZone),
input tqCInvoicePostingForDelTax.tcTxenvTaxEnv (icTaxEnvrionment),
input tqCInvoicePostingForDelTax.tlCInvoiceVatIsTaxable (ilIsTaxable),
input tqCInvoicePostingForDelTax.tcTxclTaxCls (icTaxClass),
input tqCInvoicePostingForDelTax.tcTxuTaxUsage (icTaxUsage),
input tqCInvoicePostingForDelTax.tcTxtyTaxType (icTaxType),
input tqCInvoicePostingForDelTax.tlPostingVatIsReversecharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDFeder (icTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDState (icTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc1 (icTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc2 (icTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDFeder (icOwnTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDState (icOwnTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc1 (icOwnTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc2 (icOwnTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc3 (icOwnTaxIDMisc3),
input tqCInvoicePostingForDelTax.tiPostingVatOwnTaxDeclarat (iiOwnTaxIDDeclarat),
input true (ilIsSuspDel),
output viDummy (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viDummy (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input yes (ilCalledFromMoveSuspDelTax),
input ? (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end. /* if tCInvoiceVatDelayDelta.tlIsGenerateJEDelTax */
/* ====================================================================================== */
/* Calculate amounts using the original invoice exchange rate */
/* ====================================================================================== */
assign vdLCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineExchangeRate
vdLCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineRateScale
vdCCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineCCRate
vdCCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineCCScale.
assign vdOrigDelayVatBaseDebitTC = vdDelayVatBaseDebitTC
vdOrigDelayVatBaseCreditTC = vdDelayVatBaseCreditTC
vdOrigDelayVatBaseDebitLC = <M-38 RoundAmount
(input vdOrigDelayVatBaseDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatBaseCreditLC = <M-12 RoundAmount
(input vdOrigDelayVatBaseCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatBaseDebitCC = <M-37 RoundAmount
(input vdOrigDelayVatBaseDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatBaseCreditCC = <M-18 RoundAmount
(input vdOrigDelayVatBaseCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatDebitTC = vdDelayVatDebitTC
vdOrigDelayVatCreditTC = vdDelayVatCreditTC
vdOrigDelayVatDebitLC = <M-80 RoundAmount
(input vdOrigDelayVatDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatCreditLC = <M-85 RoundAmount
(input vdOrigDelayVatCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatDebitCC = <M-725 RoundAmount
(input vdOrigDelayVatDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdOrigDelayVatCreditCC = <M-19 RoundAmount
(input vdOrigDelayVatCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.
/* ===================================================================================================== */
/* When there is any different amount between the updated Delayed Vat amount in LC and CC and originally */
/* posted during invoice creation, we have to create a correction posting that posts just LC and/or CC */
/* on delayed tax account agains exchange rate gain/lose account */
/* ===================================================================================================== */
if tCInvoiceVatDelayDelta.tlIsGenerateJEDelTax and
(vdOrigDelayVatDebitLC <> vdDelayVatDebitLC or
vdOrigDelayVatCreditLC <> vdDelayVatCreditLC or
vdOrigDelayVatDebitCC <> vdDelayVatDebitCC or
vdOrigDelayVatCreditCC <> vdDelayVatCreditCC)
then do:
assign vdCorrVatBaseDebitTC = vdOrigDelayVatBaseDebitTC - vdDelayVatBaseDebitTC
vdCorrVatBaseCreditTC = vdOrigDelayVatBaseCreditTC - vdDelayVatBaseCreditTC
vdCorrVatBaseDebitLC = vdOrigDelayVatBaseDebitLC - vdDelayVatBaseDebitLC
vdCorrVatBaseCreditLC = vdOrigDelayVatBaseCreditLC - vdDelayVatBaseCreditLC
vdCorrVatBaseDebitCC = vdOrigDelayVatBaseDebitCC - vdDelayVatBaseDebitCC
vdCorrVatBaseCreditCC = vdOrigDelayVatBaseCreditCC - vdDelayVatBaseCreditCC
vdCorrVatDebitTC = vdOrigDelayVatDebitTC - vdDelayVatDebitTC
vdCorrVatCreditTC = vdOrigDelayVatCreditTC - vdDelayVatCreditTC
vdCorrVatDebitLC = vdOrigDelayVatDebitLC - vdDelayVatDebitLC
vdCorrVatCreditLC = vdOrigDelayVatCreditLC - vdDelayVatCreditLC
vdCorrVatDebitCC = vdOrigDelayVatDebitCC - vdDelayVatDebitCC
vdCorrVatCreditCC = vdOrigDelayVatCreditCC - vdDelayVatCreditCC
vdLCExchangeRate = tCInvoiceVatDelayDelta.tdLCExchangeRate
vdLCExchangeRateScale = tCInvoiceVatDelayDelta.tdLCExchangeRate
vdCCExchangeRate = tCInvoiceVatDelayDelta.tdLCExchangeRate
vdCCExchangeRateScale = tCInvoiceVatDelayDelta.tdLCExchangeRate
vtTaxPointDate = tCInvoice.CInvoiceTaxPointDate.
/* Change negative signs into positive */
if vdCorrVatDebitLC < 0 then assign vdCorrVatCreditLC = - vdCorrVatDebitLC
vdCorrVatBaseCreditLC = - vdCorrVatBaseDebitLC
vdCorrVatDebitLC = 0
vdCorrVatBaseDebitLC = 0.
if vdCorrVatCreditLC < 0 then assign vdCorrVatDebitLC = - vdCorrVatCreditLC
vdCorrVatBaseDebitLC = - vdCorrVatBaseCreditLC
vdCorrVatCreditLC = 0
vdCorrVatBaseCreditLC = 0.
if vdCorrVatDebitCC < 0 then assign vdCorrVatCreditCC = - vdCorrVatDebitCC
vdCorrVatBaseCreditCC = - vdCorrVatBaseDebitCC
vdCorrVatDebitCC = 0
vdCorrVatBaseDebitCC = 0.
if vdCorrVatCreditCC < 0 then assign vdCorrVatDebitCC = - vdCorrVatCreditCC
vdCorrVatBaseDebitCC = - vdCorrVatBaseCreditCC
vdCorrVatCreditCC = 0
vdCorrVatBaseCreditCC = 0.
/* Create posting to the Normal GL tax account */
<M-51 run AddPostingLineTax
(input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingTcRowid),
input vtTaxPointDate (itTaxPointDate),
input tqCInvoicePostingForDelTax.tcCInvoiceCIText (icPostingLineText),
input tqCInvoicePostingForDelTax.tcCurrencyCode (icCurrencyCode),
input tqCInvoicePostingForDelTax.tcVatInOut (icPostingVatInOut),
input tqCInvoicePostingForDelTax.tcVatCode (icPostingVatCode),
input tqCInvoicePostingForDelTax.tcDomainCode (icPostingVatDomain),
input vdLCExchangeRate (idExchangeRate),
input vdLCExchangeRateScale (idExchangeRateScale),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType),
input vdCCExchangeRate (idCCExchangeRate),
input vdCCExchangeRateScale (idCCExchangeRateScale),
input tqCInvoicePostingForDelTax.tcPostingVatTransType (icTransactionType),
input tqCInvoicePostingForDelTax.tcPostingVatTaxTransType (icTaxTransactionType),
input vdCorrVatBaseDebitTC (idBaseDebitTC),
input vdCorrVatBaseCreditTC (idBaseCreditTC),
input vdCorrVatBaseDebitLC (idBaseDebitLC),
input vdCorrVatBaseCreditLC (idBaseCreditLC),
input vdCorrVatBaseDebitCC (idBaseDebitCC),
input vdCorrVatBaseCreditCC (idBaseCreditCC),
input vdCorrVatDebitTC (idVatDebitTC),
input vdCorrVatCreditTC (idVatCreditTC),
input vdCorrVatDebitLC (idVatDebitLC),
input vdCorrVatCreditLC (idVatCreditLC),
input vdCorrVatDebitCC (idVatDebitCC),
input vdCorrVatCreditCC (idVatCreditCC),
input tqCInvoicePostingForDelTax.tcDelTaxGLCode (icNormalTaxGLCode),
input tqCInvoicePostingForDelTax.tcDelTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input ? (icAbsRetTaxGLCode),
input ? (icAbsRetTaxDivisionCode),
input tqCInvoicePostingForDelTax.tcFromTxzTaxZone (icFromTaxZone),
input tqCInvoicePostingForDelTax.tcToTxzTaxZone (icToTaxZone),
input tqCInvoicePostingForDelTax.tcTxenvTaxEnv (icTaxEnvrionment),
input tqCInvoicePostingForDelTax.tlCInvoiceVatIsTaxable (ilIsTaxable),
input tqCInvoicePostingForDelTax.tcTxclTaxCls (icTaxClass),
input tqCInvoicePostingForDelTax.tcTxuTaxUsage (icTaxUsage),
input tqCInvoicePostingForDelTax.tcTxtyTaxType (icTaxType),
input tqCInvoicePostingForDelTax.tlPostingVatIsReversecharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDFeder (icTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDState (icTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc1 (icTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc2 (icTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDFeder (icOwnTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDState (icOwnTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc1 (icOwnTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc2 (icOwnTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc3 (icOwnTaxIDMisc3),
input tqCInvoicePostingForDelTax.tiPostingVatOwnTaxDeclarat (iiOwnTaxIDDeclarat),
input true (ilIsSuspDel),
output viDummy (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viDummy (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input yes (ilCalledFromMoveSuspDelTax),
input ? (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
/* ==================================================================================================== */
/* Now create corresponding posting on the Exchange rate gain/lose account */
/* ==================================================================================================== */
<M-41 run AddPostingLineExchRateGainLoss
(input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingtcRowId),
input {&EXCHANGERATETYPE_REALIZED} (icExchangeRateGainLoseType),
input vdCorrVatCreditLC (idDeltaDebitLC),
input vdCorrVatDebitLC (idDeltaCreditLC),
input vdCorrVatCreditCC (idDeltaDebitCC),
input vdCorrVatDebitCC (idDeltaCreditCC),
input vdLCExchangeRate (idLCExchangeRate),
input vdLCExchangeRateScale (idLCExchangeRateScale),
input vdCCExchangeRate (idCCExchangeRate),
input vdCCExchangeRateScale (idCCExchangeRateScale),
input 'Del Tax':U (icPostingLineTextPre),
input ? (itExchangeRateDate),
input tCInvoice.tcCurrencyCode (icCurrencyCode),
output viDummy (oiLCPostingLine_ID),
output viDummy (oiCCPostingLine_ID),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end. /* if tCInvoiceVatDelayDelta.tlIsGenerateJEDelTax and */
/* =================================================================================================== */
/* Generate posting of delayed taxes to the normal tax account. This normally happens during payment */
/* of the invoice. But is hihgly dependent on the tax setup in the entity maintenance */
/* =================================================================================================== */
if tCInvoiceVatDelayDelta.tlIsGenerateJETax
then do:
/* ================================================================================== *
* Calculate amounts to be posted on the normal tax GL account *
* When the invoice date should be used for the tax posting, then same ammounts are *
* used as for delayed gl account tax posting *
* When the payment date should be used for the tax posting, then LC and BC amounts *
* needs to be recalcualted based on current exchange rates. *
* ================================================================================== */
if tqCompanyPropertyBySuspDelTax.tcCompanyPropertyDelTaxDateType = {&TAXDATETYPE-PAYMENTDATE}
then do:
/* First we have to get some details about created posting */
<M-21 run GetPostingHeaderByPostingId
(input ? (iiPostingId),
input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingRowID),
output viDummy (oiPostingYear),
output viDummy (oiPostingPeriod),
output vtPostingDate (otPostingDate),
output vcDummy (ocPostingJournalCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
/* LC rate */
if tqCInvoicePostingForDelTax.tcCurrencyCode = vcCompanyLC
then assign vdLCExchangeRate = 1
vdLCExchangeRateScale = 1.
else do:
<M-23 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input tqCInvoicePostingForDelTax.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input vtPostingDate (itValidityDate),
output vdLCExchangeRate (odExchangeRate),
output vdLCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
/* CC rate */
if tqCInvoicePostingForDelTax.tcCurrencyCode = vcCompanyCC
then assign vdCCExchangeRate = 1
vdCCExchangeRateScale = 1.
else if vcCompanyCC = vcCompanyLC
then assign vdCCExchangeRate = vdLCExchangeRate
vdCCExchangeRateScale = vdLCExchangeRateScale.
else do:
<M-66 run GetExchangeRate
(input viCompanyId (iiCompanyID),
input ? (iiFromCurrencyID),
input tqCInvoicePostingForDelTax.tcCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input vtPostingDate (itValidityDate),
output vdCCExchangeRate (odExchangeRate),
output vdCCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
/* Calculate all posting amounts for the Normal GL Tax account */
assign vdNormalVatBaseDebitTC = vdDelayVatBaseCreditTC
vdNormalVatBaseCreditTC = vdDelayVatBaseDebitTC
vdNormalVatBaseDebitLC = <M-57 RoundAmount
(input vdNormalVatBaseDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatBaseCreditLC = <M-4 RoundAmount
(input vdNormalVatBaseCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatBaseDebitCC = <M-28 RoundAmount
(input vdNormalVatBaseDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatBaseCreditCC = <M-39 RoundAmount
(input vdNormalVatBaseCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatDebitTC = vdDelayVatCreditTC
vdNormalVatCreditTC = vdDelayVatDebitTC
vdNormalVatDebitLC = <M-65 RoundAmount
(input vdNormalVatDebitTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatCreditLC = <M-42 RoundAmount
(input vdNormalVatCreditTC * vdLCExchangeRate * vdLCExchangeRateScale (idUnroundedAmount),
input viCompanyLCId (iiCurrencyID),
input vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatDebitCC = <M-95 RoundAmount
(input vdNormalVatDebitTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
vdNormalVatCreditCC = <M-86 RoundAmount
(input vdNormalVatCreditTC * vdCCExchangeRate * vdCCExchangeRateScale (idUnroundedAmount),
input viCompanyCCId (iiCurrencyID),
input vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.
/* Tax point date is payment date */
assign vtTaxPointDate = vtPostingDate.
end. /* if tqCompanyPropertyBySuspDelTax.tcCompanyPropertyDelTaxDateType = {&TAXDATETYPE-PAYMENTDATE} */
/* Invoice date used for the payment posting exchange rate */
else assign vdNormalVatBaseDebitTC = vdDelayVatBaseCreditTC
vdNormalVatBaseCreditTC = vdDelayVatBaseDebitTC
vdNormalVatBaseDebitLC = vdDelayVatBaseCreditLC
vdNormalVatBaseCreditLC = vdDelayVatBaseDebitLC
vdNormalVatBaseDebitCC = vdDelayVatBaseCreditCC
vdNormalVatBaseCreditCC = vdDelayVatBaseDebitCC
vdNormalVatDebitTC = vdDelayVatCreditTC
vdNormalVatCreditTC = vdDelayVatDebitTC
vdNormalVatDebitLC = vdDelayVatCreditLC
vdNormalVatCreditLC = vdDelayVatDebitLC
vdNormalVatDebitCC = vdDelayVatCreditCC
vdNormalVatCreditCC = vdDelayVatDebitCC
vdLCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineExchangeRate
vdLCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineRateScale
vdCCExchangeRate = tqCInvoicePostingForDelTax.tdPostingLineCCRate
vdCCExchangeRateScale = tqCInvoicePostingForDelTax.tdPostingLineCCScale
vtTaxPointDate = tCInvoice.CInvoiceTaxPointDate.
/* Create posting to the Normal GL tax account */
<M-33 run AddPostingLineTax
(input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingTcRowid),
input vtTaxPointDate (itTaxPointDate),
input tqCInvoicePostingForDelTax.tcCInvoiceCIText (icPostingLineText),
input tqCInvoicePostingForDelTax.tcCurrencyCode (icCurrencyCode),
input tqCInvoicePostingForDelTax.tcVatInOut (icPostingVatInOut),
input tqCInvoicePostingForDelTax.tcVatCode (icPostingVatCode),
input tqCInvoicePostingForDelTax.tcDomainCode (icPostingVatDomain),
input vdLCExchangeRate (idExchangeRate),
input vdLCExchangeRateScale (idExchangeRateScale),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType),
input vdCCExchangeRate (idCCExchangeRate),
input vdCCExchangeRateScale (idCCExchangeRateScale),
input tqCInvoicePostingForDelTax.tcPostingVatTransType (icTransactionType),
input tqCInvoicePostingForDelTax.tcPostingVatTaxTransType (icTaxTransactionType),
input vdNormalVatBaseDebitTC (idBaseDebitTC),
input vdNormalVatBaseCreditTC (idBaseCreditTC),
input vdNormalVatBaseDebitLC (idBaseDebitLC),
input vdNormalVatBaseCreditLC (idBaseCreditLC),
input vdNormalVatBaseDebitCC (idBaseDebitCC),
input vdNormalVatBaseCreditCC (idBaseCreditCC),
input vdNormalVatDebitTC (idVatDebitTC),
input vdNormalVatCreditTC (idVatCreditTC),
input vdNormalVatDebitLC (idVatDebitLC),
input vdNormalVatCreditLC (idVatCreditLC),
input vdNormalVatDebitCC (idVatDebitCC),
input vdNormalVatCreditCC (idVatCreditCC),
input tqCInvoicePostingForDelTax.tcNormalTaxGLCode (icNormalTaxGLCode),
input tqCInvoicePostingForDelTax.tcNormalTaxDivisionCode (icNormalTaxDivisionCode),
input false (ilNormalTaxIsAlreadyAbsRet),
input ? (icAbsRetTaxGLCode),
input ? (icAbsRetTaxDivisionCode),
input tqCInvoicePostingForDelTax.tcFromTxzTaxZone (icFromTaxZone),
input tqCInvoicePostingForDelTax.tcToTxzTaxZone (icToTaxZone),
input tqCInvoicePostingForDelTax.tcTxenvTaxEnv (icTaxEnvrionment),
input tqCInvoicePostingForDelTax.tlCInvoiceVatIsTaxable (ilIsTaxable),
input tqCInvoicePostingForDelTax.tcTxclTaxCls (icTaxClass),
input tqCInvoicePostingForDelTax.tcTxuTaxUsage (icTaxUsage),
input tqCInvoicePostingForDelTax.tcTxtyTaxType (icTaxType),
input tqCInvoicePostingForDelTax.tlPostingVatIsReversecharge (ilTaxIsReverseChargeDomestic),
input ? (iiTaxAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDFeder (icTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDState (icTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc1 (icTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc2 (icTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatTaxIDMisc3 (icTaxIDMisc3),
input ? (iiOwnAddressID),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDFeder (icOwnTaxIDFeder),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDState (icOwnTaxIDState),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc1 (icOwnTaxIDMisc1),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc2 (icOwnTaxIDMisc2),
input tqCInvoicePostingForDelTax.tcPostingVatOwnTaxIDMisc3 (icOwnTaxIDMisc3),
input tqCInvoicePostingForDelTax.tiPostingVatOwnTaxDeclarat (iiOwnTaxIDDeclarat),
input true (ilIsSuspDel),
output viDummy (oiNormalTaxPostingLineID),
output vcDummy (ocNormalTaxPostingLineTcRowid),
output viDummy (oiAbsRetTaxPostingLineID),
output vcDummy (ocAbsRetTaxPostingLineTcRowid),
output viDummy (oiNormalTaxPostingVatID),
input false (ilLinkedCrCyDaemonReqExists),
input yes (ilCalledFromMoveSuspDelTax),
input ? (itInvoiceExchangeRateDate),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
/* ======================================================================================================================== *
* When the tax point date is payment date, there can be differnet exchange rate. Post the LC and CC gain/lose to exchange *
* rate gain/lose account *
* ======================================================================================================================== */
/* calculate the delta TAX LC and CC amount */
assign vdDeltaVatDebitLC = vdNormalVatCreditLC - vdDelayVatDebitLC
vdDeltaVatCreditLC = vdNormalVatDebitLC - vdDelayVatCreditLC
vdDeltaVatDebitCC = vdNormalVatCreditCC - vdDelayVatDebitCC
vdDeltaVatCreditCC = vdNormalVatDebitCC - vdDelayVatCreditCC.
<M-83 run AddPostingLineExchRateGainLoss
(input tCInvoiceVatDelayDelta.tcPostingRowId (icPostingtcRowId),
input {&EXCHANGERATETYPE_REALIZED} (icExchangeRateGainLoseType),
input vdDeltaVatDebitLC (idDeltaDebitLC),
input vdDeltaVatCreditLC (idDeltaCreditLC),
input vdDeltaVatDebitCC (idDeltaDebitCC),
input vdDeltaVatCreditCC (idDeltaCreditCC),
input vdLCExchangeRate (idLCExchangeRate),
input vdLCExchangeRateScale (idLCExchangeRateScale),
input vdCCExchangeRate (idCCExchangeRate),
input vdCCExchangeRateScale (idCCExchangeRateScale),
input 'Del Tax':U (icPostingLineTextPre),
input ? (itExchangeRateDate),
input tCInvoice.tcCurrencyCode (icCurrencyCode),
output viDummy (oiLCPostingLine_ID),
output viDummy (oiCCPostingLine_ID),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end. /* if tCInvoiceVatDelayDelta.tlIsGenerateJETax */
end. /* for each tqCInvoicePostingForDelTax where */
end. /* for each tCInvoiceVatDelayDelta */
end. /* MAIN_BLOCK */