Description
Assign the Statutory Currency Amounts based on the amounts in TC and the exchange Rate between TC and the newly entered SC.
Split into detail method, because main method would get to big.
Parameters
ocErrorMessage | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tsetstatutorycurrency.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
STATCURRDETBLOCK:
do:
/* GLOpenItem */
for each GLOpenItem of company exclusive-lock Transaction:
find PostingLine where
PostingLine.PostingLine_ID = GLOpenItem.PostingLine_ID
no-lock no-error.
if available PostingLine
then assign GLOpenItem.GLOpenItemOriginalDebitCC = PostingLine.PostingLineDebitCC
GLOpenItem.GLOpenItemOriginalCreditCC = PostingLine.PostingLineCreditCC
GLOpenItem.GLOpenItemBalanceDebitCC = PostingLine.PostingLineDebitCC
GLOpenItem.GLOpenItemBalanceCreditCC = PostingLine.PostingLineCreditCC
GLOpenItem.GLOpenItemBalanceCC = PostingLine.PostingLineDebitCC - PostingLine.PostingLineCreditCC.
else assign GLOpenItem.GLOpenItemOriginalDebitCC = 0
GLOpenItem.GLOpenItemOriginalCreditCC = 0
GLOpenItem.GLOpenItemBalanceDebitCC = 0
GLOpenItem.GLOpenItemBalanceCreditCC = 0
GLOpenItem.GLOpenItemBalanceCC = 0.
for each GLOpenItemMovement where
GLOpenItemMovement.GLOpenItem_ID = GLOpenItem.GLOpenItem_ID and
GLOpenItemMovement.GLOpenItemMovementType = {&MOVEMENTTYPE-MOVEMENT}
no-lock:
find PostingLine where
PostingLine.PostingLine_ID = GLOpenItemMovement.PostingLine_ID
no-lock no-error.
if available PostingLine
then assign GLOpenItem.GLOpenItemBalanceDebitCC = GLOpenItem.GLOpenItemBalanceDebitCC - PostingLine.PostingLineDebitCC
GLOpenItem.GLOpenItemBalanceCreditCC = GLOpenItem.GLOpenItemBalanceCreditCC - PostingLine.PostingLineCreditCC
GLOpenItem.GLOpenItemBalanceCC = GLOpenItem.GLOpenItemBalanceCC - (PostingLine.PostingLineDebitCC - PostingLine.PostingLineCreditCC).
end. /* for each GLOpenItemMovement where */
end. /* GLOpenItem */
/* ExpNoteLine */
for each ExpNote of company exclusive-lock Transaction:
/* Get Exchange Rates */
<M-4 run GetExchangeRate
(input ExpNote.Currency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viSCExchangeRateTypeID (iiExchangeRateTypeID),
input ExpNote.ExpNoteRegistrationDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdRate (odExchangeRate),
output vdScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
assign ExpNote.ExpNoteCCRate = vdRate
ExpNote.ExpNoteCCScale = vdScale.
for each ExpNoteLine of ExpNote exclusive-lock:
/* Get Exchange Rates */
<M-3 run GetExchangeRate
(input ExpNoteLine.Currency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viSCExchangeRateTypeID (iiExchangeRateTypeID),
input ExpNoteLine.ExpNoteLineDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdRate (odExchangeRate),
output vdScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
assign ExpNoteLine.ExpNoteLineAmountCC = <M-9 RoundSCAmount (input ExpNoteLine.ExpNoteLineAmountTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
ExpNoteLine.ExpNoteLineCCRate = vdRate
ExpNoteLine.ExpNoteLineCCScale = vdScale.
end. /* ExpNoteLine */
end. /* ExpNote */
/* Fixed Asset Module is not operational yet in the software, for now, we put all CC amounts to zero */
/* FAAssetBook */
for each FAAsset of company exclusive-lock Transaction:
assign FAAsset.FAAssetExchangeRateCC = 0
FAAsset.FAAssetExchangeRateScaleCC = 0. /* This is the rate between LC and CC */
for each FAAssetBook of FAAsset exclusive-lock :
assign FAAssetBook.FAAssetBookAmountCC = 0
FAAssetBook.FAAssetBookDeprAmountCC = 0
FAAssetBook.FAAssetBookDisposedCC = 0
FAAssetBook.FAAssetBookDisposedDeprCC = 0
FAAssetBook.FAAssetBookSalvageAmountCC = 0.
/* FADisposal */
for each FADisposal of FAAssetBook exclusive-lock:
assign FADisposal.FADisposalAmountCC = 0.
/* FADisposalDet */
for each FADisposalDet of FADisposal exclusive-lock:
assign FADisposalDet.FADisposalDetAmountCC = 0.
end. /* FADisposalDet */
end. /* FADisposal */
/* FAReval */
for each FAReval of FAAssetBook exclusive-lock:
assign FAReval.FARevalAmountCC = 0.
end. /* FAReval */
/* FARevalDet */
for each FARevalDet of FAReval exclusive-lock:
assign FARevalDet.FARevalDetAmountCC = 0.
end. /* FARevalDet */
end. /* FAAssetBook */
end. /* FAAsset */
/* FADepreciation */
for each FADepreciation of company exclusive-lock Transaction:
assign FADepreciation.FADepreciationAmountCC = 0.
/* FADepreciationDet */
for each FADepreciationDet of FADepreciation exclusive-lock:
assign FADepreciationDet.FADepreciationDetAmountCC = 0.
end. /* FADepreciationDet */
end. /* FADepreciation */
/* Revaluations */
For each RevalHeader of Company exclusive-lock Transaction :
if RevalHeader.RevalHeaderIsForCC = false
then next.
if RevalHeader.RevalHeaderIsForCC = true and
RevalHeader.RevalHeaderIsForLC = false
then do :
For each Reval of RevalHeader exclusive-lock:
For each RevalGL of Reval :
For each RevalDet of RevalGL exclusive-lock:
Delete RevalDet.
End.
Delete RevalGL.
End. /* For each RevalDet of RevalGL */
Delete Reval.
End. /* For each Reval of RevalHeader */
For each RevalRate of RevalHeader exclusive-lock:
Delete RevalRate.
End. /* For each RevalRate of RevalHeader : */
Delete RevalHeader.
next.
End. /* if RevalHeader.RevalHeaderIsForCC = true and */
if RevalHeader.RevalHeaderIsForCC = true and
RevalHeader.RevalHeaderIsForLC = true
then do :
For each Reval of RevalHeader no-lock,
each RevalGL of Reval exclusive-lock:
assign RevalGL.RevalGLCreditCC = 0
RevalGL.RevalGLDebitCC = 0
RevalGL.RevalGLRevCreditCC = 0
RevalGL.RevalGLRevDebitCC = 0
RevalGL.RevalGLCCExchangeRate = 0
RevalGL.RevalGLCCExchangeRateScale = 0.
For each RevalDet of RevalGL exclusive-lock:
assign RevalDet.RevalDetCreditCC = 0
RevalDet.RevalDetDebitCC = 0
RevalDet.RevalDetRevCreditCC = 0
RevalDet.RevalDetRevDebitCC = 0
RevalDet.RevalDetCCExchangeRate = 0
RevalDet.RevalDetCCExchangeScale = 0.
End. /* RevalDet */
End. /* RevalGL */
End. /* if RevalHeader.RevalHeaderIsForCC = true and */
End. /* For each RevalHeader of Compan Transaction */
/* ConsolidDump (not needed. CCRate not used in code) */
/* CashReport (not needed. CC-values do not make any sense on a cash-report according to DDV */
/* BankStateAlloc */
for each BankStateAlloc of company exclusive-lock,
each Posting where
Posting.Posting_ID = BankStateAlloc.Posting_ID no-lock Transaction:
find PostingLine where
PostingLine.Posting_ID = Posting.Posting_ID and
(PostingLine.PostingLineDebitTC = 0 or PostingLine.PostingLineDebitTC = ?) and
(PostingLine.PostingLineCreditTC = 0 or PostingLine.PostingLineCreditTC = ?) and
(PostingLine.PostingLineDebitLC = 0 or PostingLine.PostingLineDebitLC = ?) and
(PostingLine.PostingLineCreditLC = 0 or PostingLine.PostingLineCreditLC = ?) and
((PostingLine.PostingLineDebitCC <> 0 and PostingLine.PostingLineDebitCC <> ?) or
(PostingLine.PostingLineCreditCC <> 0 and PostingLine.PostingLineCreditCC <> ?))
no-lock no-error.
if available PostingLine
then do:
if (BankStateAlloc.CInvoice_ID <> 0 and
BankStateAlloc.CInvoice_ID <> ?) or
(BankStateAlloc.DInvoice_ID <> 0 and
BankStateAlloc.DInvoice_ID <> ?)
then do :
assign BankStateAlloc.BankStateAllocDifferenceCC = PostingLine.PostingLineDebitCC - PostingLine.PostingLineCreditCC
BankStateAlloc.BankStateAllocCCRate = PostingLine.PostingLineCCRate
BankStateAlloc.BankStateAllocCCScale = PostingLine.PostingLineCCScale.
/* Assign the WHT CC-field and Rate */
if BankStateAlloc.CInvoice_ID <> 0 and
BankStateAlloc.CInvoice_ID <> ?
then do :
for each CInvoice where
CInvoice.CInvoice_ID = CDocumentInvoiceXRef.CInvoice_ID
no-lock:
<M-80 run GetExchangeRate
(input CInvoice.CInvoiceCurrency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viTXExchangeRateTypeID (iiExchangeRateTypeID),
input PostingLine.PostingDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdRate (odExchangeRate),
output vdScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
/* Assign the WHT CC-field and Rate */
assign BankStateAlloc.BankStateAllocWHTAmtCC = <M-5 RoundSCAmount (input BankStateAlloc.BankStateAllocWHTAmtTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
BankStateAlloc.BankStateAllocWHTCCRate = vdRate
BankStateAlloc.BankStateAllocWHTCCScale = vdScale.
end. /* for each CInvoice where */
end. /* if BankStateAlloc.CInvoice_ID <> 0 and */
end. /* if (BankStateAlloc.CInvoice_ID <> 0 and */
else do:
/* BankStateAllocColl */
for each BankStateAllocColl of BankStateAlloc
exclusive-lock
break by BankStateAllocColl_ID:
if first(BankStateAllocColl.BankStateAllocColl_ID)
then assign BankStateAllocColl.BankStateAllocCollDiffCC = PostingLine.PostingLineDebitCC - PostingLine.PostingLineCreditCC
BankStateAllocColl.BankStateAllocCollCCRate = PostingLine.PostingLineCCRate
BankStateAllocColl.BankStateAllocCollCCScale = PostingLine.PostingLineCCScale.
else assign BankStateAllocColl.BankStateAllocCollDiffCC = 0
BankStateAllocColl.BankStateAllocCollCCRate = 0
BankStateAllocColl.BankStateAllocCollCCScale = 0.
end. /* BankStateAllocColl */
end. /* else do */
end. /* if available PostingLine */
end. /* BankStateAlloc */
end. /* STATCURRDETBLOCK */
assign oiReturnStatus = viLocalReturnStatus.