Description
Assign the Statutory Currency amounts based on the amounts in TC and the exchange rate between TC and the newly entered SC.
Parameters
idCCRate | input | decimal | |
idCCRateScale | input | decimal | |
ocErrorMessage | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tsetstatutorycurrency.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
STATCURRBLOCK:
do on error undo, return:
/* Get Exchange Rates */
if idCCRate = ?
then do:
/* If the PostingLine is about a Tax that refers to a WHT (most tax-fields on the PostingVat are empty and the related Vat is of type non-taxable) then we need to use teh TaxExchangeRate else we need to use the StatutoryExchangeRate */
assign vlUseTaxRateForPostingVat = false
vtPostingVatTaxPointDate = ?.
for each PostingVat of PostingLine where
(PostingVat.TxClTaxCls = ? or
PostingVat.TxClTaxCls = "":U) and
(PostingVat.TxuTaxUsage = ? or
PostingVat.TxuTaxUsage = "":U) and
(PostingVat.TxenvTaxEnv = ? or
PostingVat.TxenvTaxEnv = "":U) and
(PostingVat.FromTxzTaxZone = ? or
PostingVat.FromTxzTaxZone = "":U) and
(PostingVat.ToTxzTaxZone = ? or
PostingVat.ToTxzTaxZone = "":U) and
(PostingVat.TxtyTaxType = ? or
PostingVat.TxtyTaxType = "":U) no-lock,
each Vat of PostingVat where
Vat.VatCode = vcNonTaxableVatCode
no-lock :
assign vlUseTaxRateForPostingVat = true
vtPostingVatTaxPointDate = PostingVat.PostingVatTaxPointDate.
Leave.
end. /* for each PostingVat of PostingLine where */
if vlUseTaxRateForPostingVat = true and
vtPostingVatTaxPointDate <> ?
then do :
<M-48 run GetExchangeRate
(input PostingLine.Currency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viTXExchangeRateTypeID (iiExchangeRateTypeID),
input vtPostingVatTaxPointDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdRate (odExchangeRate),
output vdScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
end. /* if vlUseTaxRateForPostingVat = true */
else do :
<M-34 run GetExchangeRate
(input PostingLine.Currency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viSCExchangeRateTypeID (iiExchangeRateTypeID),
input vtPostingPostingDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdRate (odExchangeRate),
output vdScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
end. /* Not if vlUseTaxRateForPostingVat = true */
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave STATCURRBLOCK.
end. /* if idCCRate = ? */
else assign vdRate = idCCRate
vdScale = idCCRateScale.
/* PostingLine */
assign PostingLine.PostingLineCreditCC = <M-92 RoundSCAmount (input PostingLine.PostingLineCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingLine.PostingLineDebitCC = <M-37 RoundSCAmount (input PostingLine.PostingLineDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingLine.PostingLineCCRate = vdRate
PostingLine.PostingLineCCScale = vdScale
PostingLine.LastModifiedDate = today.
/* PostingVat */
for each PostingVat of PostingLine exclusive-lock:
assign PostingVat.PostingVatBaseCreditCC = <M-57 RoundSCAmount (input PostingVat.PostingVatBaseCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatBaseDebitCC = <M-32 RoundSCAmount (input PostingVat.PostingVatBaseDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatTaxCreditCC = <M-75 RoundSCAmount (input PostingVat.PostingVatTaxCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatTaxDebitCC = <M-5 RoundSCAmount (input PostingVat.PostingVatTaxDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
end. /* PostingVat */
/* PostingVatDelay */
for each PostingVatDelay of PostingLine exclusive-lock:
assign PostingVatDelay.PostingVatDelayBaseCredCC = <M-73 RoundSCAmount (input PostingVatDelay.PostingVatDelayBaseCredTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVatDelay.PostingVatDelayBaseDebCC = <M-54 RoundSCAmount (input PostingVatDelay.PostingVatDelayBaseDebTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
end. /* PostingVatDelay */
end. /* STATCURRBLOCK */
assign oiReturnStatus = viLocalReturnStatus.