Description
SetStatutoryCurrencyBasedOnTCAPM:
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 :
/* ========== */
/* APMatching */
/* ========== */
for each APMatching of company no-lock,
each CInvoice where
CInvoice.CInvoice_ID = APMatching.CInvoice_ID
no-lock:
/* Find the Posting (optional as this does not exist for inital matchings ) and find the last posting-line */
find Posting where
Posting.Posting_ID = APMatching.Posting_ID
no-lock no-error.
if available Posting
then do :
find last PostingLine of Posting
use-index PostingIDLineSeq
no-lock no-error.
if available PostingLine
then assign viPostingLineSequence = PostingLine.PostingLineSeq.
else assign viPostingLineSequence = 1.
end. /* if available Posting */
/* Reset some values for every matching */
assign vcListTackledPostingLines = "":U.
/* Update the posting-line on the Cirec-account */
if available Posting
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatching.CirecPostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitTC <> 0 and
PostingLine.PostingLineDebitTC <> ?
then assign PostingLine.PostingLineDebitCC = <M-32 RoundSCAmount (input PostingLine.PostingLineDebitTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditTC <> 0 and
PostingLine.PostingLineCreditTC <> ?
then assign PostingLine.PostingLineCreditCC = <M-40 RoundSCAmount (input PostingLine.PostingLineCreditTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = CInvoice.CInvoiceCCRate
PostingLine.PostingLineCCScale = CInvoice.CInvoiceCCScale
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
/* Go through all lines */
for each APMatchingLn of APMatching exclusive-lock:
/* Get Exchange Rates for LC to CC (Exception for Matching) to be used for the receipt-amount */
<M-44 run GetExchangeRate
(input viLocalCurrencyID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viSCExchangeRateTypeID (iiExchangeRateTypeID),
input APMatchingLn.APMatchingLnPvodTransDate (itDate),
input viExchangeRateSharedSetID (iiSharedSetID),
output vdPvodLCCCRate (odExchangeRate),
output vdPvodLCCCScale (odExchangeRateScale),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
do Transaction :
/* Recalculate the receipt-amount and store the rate */
/* Recalculate the other CC-values and the ExchRate-diff in CC */
assign APMatchingLn.APMatchingLnPvodCCRate = vdPvodLCCCRate
APMatchingLn.APMatchingLnPvodCCScale = vdPvodLCCCScale
APMatchingLn.APMatchingLnReceiptAmtCC = <M-65 RoundSCAmount (input APMatchingLn.APMatchingLnReceiptAmtTC * (APMatchingLn.APMatchingLnPvodExchRate2 / APMatchingLn.APMatchingLnPvodExchRate) * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>
APMatchingLn.APMatchingLnMatchAmtCC = <M-29 RoundSCAmount (input APMatchingLn.APMatchingLnMatchAmtTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>
APMatchingLn.APMatchingLnVarRateCC = <M-30 RoundSCAmount (input APMatchingLn.APMatchingLnVarRateTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>
APMatchingLn.APMatchingLnVarUsageCC = <M-31 RoundSCAmount (input APMatchingLn.APMatchingLnVarUsageTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>
APMatchingLn.APMatchingLnVarExchRateCC = APMatchingLn.APMatchingLnMatchAmtCC - APMatchingLn.APMatchingLnReceiptAmtCC - APMatchingLn.APMatchingLnVarUsageCC - APMatchingLn.APMatchingLnVarRateCC.
End. /* Transaction */
/* Special actions for the ExchRateCC-postingline as that one can be changed from Debit to Credit and vice-versa and it may even be that we need to create a new posting-line in case there was no such yet */
if available Posting
then do Transaction :
/* CC-exch-rate variance */
/* - Positive amounts (meaning a loss): posted on Debit */
/* - Negative amounts (meaning a gain): posted on Credit */
/* Update the associated posting line */
assign vdDebitCC = if CInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} or
CInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if APMatchingLn.APMatchingLnVarExchRateCC > 0 then APMatchingLn.APMatchingLnVarExchRateCC else 0
else if APMatchingLn.APMatchingLnVarExchRateCC < 0 then APMatchingLn.APMatchingLnVarExchRateCC else 0
vdCreditCC = if CInvoice.CInvoiceType = {&INVOICETYPE-INVOICE} or
CInvoice.CInvoiceType = {&INVOICETYPE-CREDITNOTE}
then if APMatchingLn.APMatchingLnVarExchRateCC < 0 then APMatchingLn.APMatchingLnVarExchRateCC * -1 else 0
else if APMatchingLn.APMatchingLnVarExchRateCC > 0 then APMatchingLn.APMatchingLnVarExchRateCC * -1 else 0.
/* Get the correct GL-account to be used - note that this can differ from the existing postingline as a gain now become a loss and vice-versa */
<M-14 run SetStatutoryCurrencyBasedOnTCAPMGetGL
(input (if vdCreditCC <= 0 then false else true) (ilGetGainAccount),
output viGLID (oiGLID),
output viDivisionID (oiDivisionID),
output viCostCentreID (oiCostCentreID),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
/* Update / create the postingline with the correct values */
if APMatchingLn.VarExchRatCCPostingLine_ID <> 0 and
APMatchingLn.VarExchRatCCPostingLine_ID <> ?
then do :
find PostingLine where
PostingLine.Posting_ID = Posting.Posting_ID and
PostingLine.PostingLine_ID = APMatchingLn.VarExchRatCCPostingLine_ID
exclusive-lock no-error.
if available PostingLine
then assign PostingLine.PostingLineDebitCC = vdDebitCC
PostingLine.PostingLineCreditCC = vdCreditCC
PostingLine.PostingLineCCRate = CInvoice.CInvoiceCCRate
PostingLine.PostingLineCCScale = CInvoice.CInvoiceCCScale
PostingLine.GL_ID = viGLID
PostingLine.Division_ID = viDivisionID
PostingLine.CostCentre_ID = viCostCentreID
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if APMatchingLn.VarExchRatCCPostingLine_ID <> 0 and */
else do:
if APMatchingLn.APMatchingLnVarExchRateCC <> 0 and
APMatchingLn.APMatchingLnVarExchRateCC <> ?
then do :
create PostingLine.
assign viPostingLineSequence = viPostingLineSequence + 1
PostingLine.Posting_ID = Posting.Posting_ID
PostingLine.PostingLine_ID = dynamic-function("GetNextValue":U in vhPersistence,"ObjectNumber":U)
PostingLine.Currency_ID = viNewSCID
PostingLine.GL_ID = viGLID
PostingLine.Division_ID = viDivisionID
PostingLine.CostCentre_ID = viCostCentreID
PostingLine.PostingLineSequence = viPostingLineSequence
PostingLine.PostingLineText = "Balanced by Statutory Currency Utility"
PostingLine.PostingLineDebitTC = 0
PostingLine.PostingLineCreditTC = 0
PostingLine.PostingLineDebitLC = 0
PostingLine.PostingLineCreditLC = 0
PostingLine.PostingLineDebitCC = vdDebitCC
PostingLine.PostingLineCreditCC = vdCreditCC
PostingLine.PostingLineCCRate = CInvoice.CInvoiceCCRate
PostingLine.PostingLineCCScale = CInvoice.CInvoiceCCScale
PostingLine.Period_ID = Posting.Period_ID
PostingLine.Company_ID = Posting.Company_ID
PostingLine.PostingYearPeriod = Posting.PostingYearPeriod
PostingLine.PostingDate = Posting.PostingDate
PostingLine.LastModifiedDate = today
APMatchingLn.VarExchRatCCPostingLine_ID = PostingLine.PostingLine_ID
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
<M-66 run SetStatutoryCurrencyBasedOnTCRound
(output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
end. /* if APMatchingLn.APMatchingLnVarExchRateCC <> 0 and */
end. /* Not if APMatchingLn.VarExchRatCCPostingLine_ID <> 0 and */
end. /* if available Posting */
/* Update the posting-line on the RateVar-account */
if available Posting and APMatchingLn.VarRatePostingLine_ID <> 0 and APMatchingLn.VarRatePostingLine_ID <> ?
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatchingLn.VarRatePostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitTC <> 0 and
PostingLine.PostingLineDebitTC <> ?
then assign PostingLine.PostingLineDebitCC = <M-41 RoundSCAmount (input PostingLine.PostingLineDebitTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditTC <> 0 and
PostingLine.PostingLineCreditTC <> ?
then assign PostingLine.PostingLineCreditCC = <M-42 RoundSCAmount (input PostingLine.PostingLineCreditTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = CInvoice.CInvoiceCCRate
PostingLine.PostingLineCCScale = CInvoice.CInvoiceCCScale
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
/* Update the posting-line on the UsageVar-account */
if available Posting and APMatchingLn.VarUsagePostingLine_ID <> 0 and APMatchingLn.VarUsagePostingLine_ID <> ?
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatchingLn.VarUsagePostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitTC <> 0 and
PostingLine.PostingLineDebitTC <> ?
then assign PostingLine.PostingLineDebitCC = <M-50 RoundSCAmount (input PostingLine.PostingLineDebitTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditTC <> 0 and
PostingLine.PostingLineCreditTC <> ?
then assign PostingLine.PostingLineCreditCC = <M-51 RoundSCAmount (input PostingLine.PostingLineCreditTC * CInvoice.CInvoiceCCRate * CInvoice.CInvoiceCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = CInvoice.CInvoiceCCRate
PostingLine.PostingLineCCScale = CInvoice.CInvoiceCCScale
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
/* Update the posting-line on the new Expense-account */
if available Posting and APMatchingLn.NewExpensePostingLine_ID <> 0 and APMatchingLn.NewExpensePostingLine_ID <> ?
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatchingLn.NewExpensePostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitLC <> 0 and
PostingLine.PostingLineDebitLC <> ?
then assign PostingLine.PostingLineDebitCC = <M-52 RoundSCAmount (input PostingLine.PostingLineDebitLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditLC <> 0 and
PostingLine.PostingLineCreditLC <> ?
then assign PostingLine.PostingLineCreditCC = <M-53 RoundSCAmount (input PostingLine.PostingLineCreditLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = APMatchingLn.APMatchingLnPvodExchRate2 / APMatchingLn.APMatchingLnPvodExchRate * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale
PostingLine.PostingLineCCScale = 1
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
/* Update the posting-line on the old Expense-account */
if available Posting and APMatchingLn.RevExpensePostingLine_ID <> 0 and APMatchingLn.RevExpensePostingLine_ID <> ?
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatchingLn.RevExpensePostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitLC <> 0 and
PostingLine.PostingLineDebitLC <> ?
then assign PostingLine.PostingLineDebitCC = <M-54 RoundSCAmount (input PostingLine.PostingLineDebitLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditLC <> 0 and
PostingLine.PostingLineCreditLC <> ?
then assign PostingLine.PostingLineCreditCC = <M-55 RoundSCAmount (input PostingLine.PostingLineCreditLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = APMatchingLn.APMatchingLnPvodExchRate2 / APMatchingLn.APMatchingLnPvodExchRate * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale
PostingLine.PostingLineCCScale = 1
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
/* Update the posting-line on the Receipt-account */
if available Posting and APMatchingLn.PvoPostingLine_ID <> 0 and APMatchingLn.PvoPostingLine_ID <> ?
then do Transaction:
Find PostingLine of Posting where
PostingLine.PostingLine_ID = APMatchingLn.PvoPostingLine_ID
exclusive-lock no-error.
if available PostingLine
then do :
if PostingLine.PostingLineDebitLC <> 0 and
PostingLine.PostingLineDebitLC <> ?
then assign PostingLine.PostingLineDebitCC = <M-56 RoundSCAmount (input PostingLine.PostingLineDebitLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
if PostingLine.PostingLineCreditLC <> 0 and
PostingLine.PostingLineCreditLC <> ?
then assign PostingLine.PostingLineCreditCC = <M-57 RoundSCAmount (input PostingLine.PostingLineCreditLC * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
assign PostingLine.PostingLineCCRate = APMatchingLn.APMatchingLnPvodExchRate2 / APMatchingLn.APMatchingLnPvodExchRate * APMatchingLn.APMatchingLnPvodCCRate * APMatchingLn.APMatchingLnPvodCCScale
PostingLine.PostingLineCCScale = 1
PostingLine.LastModifiedDate = today
vcListTackledPostingLines = vcListTackledPostingLines + ",":U + string(PostingLine.PostingLine_ID).
end. /* if available PostingLine */
end. /* if available Posting */
if available Posting
then do :
<M-64 run SetStatutoryCurrencyBasedOnTCAPMTax
(input-output vcListTackledPostingLines (bcListTackledPostingLines),
output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
end. /* if available Posting */
end. /* for each APMatchingLn of APMatching: */
/* No further actions are needed in case there is not posting */
if not available Posting
then next.
/* Update the posting-lines in the matching-posting that were not yet updated in the previous blocks */
do Transaction:
assign vdBalanceCC = 0.
/* Go through all lines of the posting */
for each PostingLine of Posting
exclusive-lock
by PostingLine.PostingLineSequence:
/* Update the amounts on the posting-lines but not for the posting-lines we already tackeld */
If lookup (string(PostingLine.PostingLine_ID), vcListTackledPostingLines) = 0
then do:
/* Clear all lines with SC amounts only */
if PostingLine.PostingLineDebitTC = 0 and PostingLine.PostingLineCreditTC = 0 and
PostingLine.PostingLineDebitLC = 0 and PostingLine.PostingLineCreditLC = 0 and
(PostingLine.PostingLineDebitCC <> 0 or PostingLine.PostingLineCreditCC <> 0)
then do:
assign PostingLine.PostingLineDebitCC = 0
PostingLine.PostingLineCreditCC = 0
PostingLine.LastModifiedDate = today.
next.
end. /* if PostingLine.PostingLineDebitTC = 0 and PostingLine.PostingLineCreditTC = 0 and */
/* Get Exchange Rates */
<M-45 run GetExchangeRate
(input PostingLine.Currency_ID (iiFromCurrencyID),
input viNewSCID (iiToCurrencyID),
input viSCExchangeRateTypeID (iiExchangeRateTypeID),
input Posting.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 PostingLine.PostingLineCreditCC = <M-39 RoundSCAmount (input PostingLine.PostingLineCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingLine.PostingLineDebitCC = <M-46 RoundSCAmount (input PostingLine.PostingLineDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingLine.PostingLineCCRate = vdRate
PostingLine.PostingLineCCScale = vdScale
PostingLine.LastModifiedDate = today
viPostingLineSequence = PostingLine.PostingLineSequence.
/* PostingVat */
for each PostingVat of PostingLine exclusive-lock:
assign PostingVat.PostingVatBaseCreditCC = <M-47 RoundSCAmount (input PostingVat.PostingVatBaseCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatBaseDebitCC = <M-48 RoundSCAmount (input PostingVat.PostingVatBaseDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatTaxCreditCC = <M-49 RoundSCAmount (input PostingVat.PostingVatTaxCreditTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVat.PostingVatTaxDebitCC = <M-33 RoundSCAmount (input PostingVat.PostingVatTaxDebitTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
end. /* PostingVat */
/* PostingVatDelay */
for each PostingVatDelay of PostingLine exclusive-lock:
assign PostingVatDelay.PostingVatDelayBaseCredCC = <M-34 RoundSCAmount (input PostingVatDelay.PostingVatDelayBaseCredTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>
PostingVatDelay.PostingVatDelayBaseDebCC = <M-35 RoundSCAmount (input PostingVatDelay.PostingVatDelayBaseDebTC * vdRate * vdScale (idUnroundedAmount)) in TSetStatutoryCurrency>.
end. /* PostingVatDelay */
end. /* If lookup (string(PostingLine.PostingLine_ID, vcListTackledPostingLines) = 0 */
assign vdBalanceCC = vdBalanceCC + PostingLine.PostingLineDebitCC - PostingLine.PostingLineCreditCC.
end. /* for each PostingLine where */
/* Balance Complete Matching Posting for CC */
if vdBalanceCC <> 0
then do :
create PostingLine.
assign PostingLine.Posting_ID = Posting.Posting_ID
PostingLine.PostingLine_ID = dynamic-function("GetNextValue":U in vhPersistence,"ObjectNumber":U)
PostingLine.Currency_ID = viNewSCID
PostingLine.GL_ID = viRoundGLID
PostingLine.PostingLineSequence = viPostingLineSequence + 1
PostingLine.PostingLineText = "Balanced by Statutory Currency Utility"
PostingLine.PostingLineDebitTC = 0
PostingLine.PostingLineCreditTC = 0
PostingLine.PostingLineDebitLC = 0
PostingLine.PostingLineCreditLC = 0
PostingLine.PostingLineDebitCC = (if vdBalanceCC < 0 then (vdBalanceCC * -1) else 0)
PostingLine.PostingLineCreditCC = (if vdBalanceCC > 0 then vdBalanceCC else 0)
PostingLine.PostingLineCCRate = 1
PostingLine.PostingLineCCScale = 1
PostingLine.Period_ID = Posting.Period_ID
PostingLine.Company_ID = Posting.Company_ID
PostingLine.PostingYearPeriod = Posting.PostingYearPeriod
PostingLine.PostingDate = Posting.PostingDate
PostingLine.LastModifiedDate = today.
<M-67 run SetStatutoryCurrencyBasedOnTCRound
(output ocErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
if viFcReturnSuper <> 0
then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave STATCURRDETBLOCK.
end. /* if vdBalanceCC <> 0 */
end. /* do Transaction: */
end. /* APMatching */
end. /* STATCURRDETBLOCK */
assign oiReturnStatus = viLocalReturnStatus.