Description
Assign the Statutory Currency amounts based on the amounts in TC and the exchange rate between TC and the newly entered SC.
Parameters
biPostingLineCounter | input-output | integer | |
olPostingIsProcessed | output | logical | |
ocPostCCBalanceTo | output | character | |
ocErrorMessage | output | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tsetstatutorycurrency.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0
olPostingIsProcessed = false
ocPostCCBalanceTo = ?.
STATCURRBLOCK:
do on error undo, return:
/* Check if this posting is related to supplier payment */
if Journal.JournalTypeCode <> {&JOURNALTYPE-DEBTORADJUSTMENT} and
Journal.JournalTypeCode <> {&JOURNALTYPE-CREDITORADJUSTMENT}
then leave STATCURRBLOCK.
/* Assign type of GL account to be used for posting of any SC balances */
assign ocPostCCBalanceTo = {&GLSYSTEMTYPE-EXCHANGEREALPROFIT}.
/* Go through all posting lines of the posting */
for each PostingLine of Posting exclusive-lock:
assign biPostingLineCounter = biPostingLineCounter + 1
vlIsPostingLineProcessed = false.
/* Check, if the posting is created for Supplier Invoice movement, if yes, take exchange rate of the invoice */
if not vlIsPostingLineProcessed
then do:
for first CInvoiceMovement of PostingLine no-lock,
first CInvoice of CInvoiceMovement no-lock:
<M-91 run PostingLineCCUpdate
(input CInvoice.CInvoiceCCRate (idCCRate),
input CInvoice.CInvoiceCCScale (idCCRateScale),
output vcTempErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave STATCURRBLOCK.
assign vlIsPostingLineProcessed = true.
end. /* for first CInvoiceMovement of PostingLine no-lock, */
end. /* if not vlIsPostingLineProcessed */
/* Check, if the posting is created for Customer Invoice movement, if yes, take exchange rate of the invoice */
if not vlIsPostingLineProcessed
then do:
for first DInvoiceMovement of PostingLine no-lock,
first DInvoice of DInvoiceMovement no-lock:
<M-22 run PostingLineCCUpdate
(input DInvoice.DInvoiceCCRate (idCCRate),
input DInvoice.DInvoiceCCScale (idCCRateScale),
output vcTempErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave STATCURRBLOCK.
assign vlIsPostingLineProcessed = true.
end. /* for first CInvoiceMovement of PostingLine no-lock, */
end. /* if not vlIsPostingLineProcessed */
/* In all other cases just use SC exchange rate of the date of posting, even we know it is not perfect (like for discounts) */
if not vlIsPostingLineProcessed
then do:
<M-38 run PostingLineCCUpdate
(input ? (idCCRate),
input ? (idCCRateScale),
output vcTempErrorMessage (ocErrorMessage),
output viFcReturnSuper (oiReturnStatus)) in TSetStatutoryCurrency>
assign ocErrorMessage = ocErrorMessage + vcTempErrorMessage.
if viFcReturnSuper <> 0 then assign viLocalReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then leave STATCURRBLOCK.
assign vlIsPostingLineProcessed = true.
end. /* if not vlIsPostingLineProcessed */
end. /* PostingLine */
assign olPostingIsProcessed = true.
end. /* STATCURRBLOCK */
assign oiReturnStatus = viLocalReturnStatus.