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 on error undo, return:
/* DDocument */
for each Company of Domains,
each DDocument of Company exclusive-lock Transaction:
assign DDocument.DDocumentOriginalDebitCC = 0
DDocument.DDocumentOriginalCreditCC = 0
DDocument.DDocumentCCRate = 0
DDocument.DDocumentCCScale = 0.
for each DDocumentInvoiceXRef where
DDocumentInvoiceXRef.DDocument_ID = DDocument.DDocument_ID
no-lock:
/* DInvoice */
for each DInvoice where
DInvoice.DInvoice_ID = DDocumentInvoiceXRef.DInvoice_ID
no-lock:
/* Calculate the Amount of the document based on the allocated amount in the XRef table */
assign vdAmountCC = (absolute(DDocumentInvoiceXRef.DDocumentInvoiceXRefAlloTC) - absolute(DDocumentInvoiceXRef.DDocumentInvoiceXRefDiscTC)) * DInvoice.DInvoiceCCRate * DInvoice.DInvoiceCCScale
vdAmountCC = <M-44 RoundSCAmount (input vdAmountCC (idUnroundedAmount)) in TSetStatutoryCurrency>.
/* Check if the original amount on the invoice was posted as a negative, if so change the sign of our absolute amount */
if DInvoice.DInvoiceOriginalDebitTC < 0 or DInvoice.DInvoiceOriginalCreditTC < 0
then assign vdAmountCC = vdAmountCC * -1.
if DInvoice.DInvoiceOriginalDebitTC <> 0 and DInvoice.DInvoiceOriginalDebitTC <> ?
then assign DDocument.DDocumentOriginalDebitCC = DDocument.DDocumentOriginalDebitCC + vdAmountCC.
else assign DDocument.DDocumentOriginalCreditCC = DDocument.DDocumentOriginalCreditCC + vdAmountCC.
end. /* DInvoice */
end. /* DDocumentInvoiceXRef */
/* Assign Rate */
if DDocument.DDocumentOriginalCreditTC = 0
then assign DDocument.DDocumentCCRate = 0
DDocument.DDocumentCCScale = 0.
else assign DDocument.DDocumentCCRate = DDocument.DDocumentOriginalCreditCC / DDocument.DDocumentOriginalCreditTC
DDocument.DDocumentCCScale = 1.
end. /* DDocument */
/* DCollection */
for each DCollection of company exclusive-lock Transaction:
assign DCollection.DCollectionBalanceCC = 0
DCollection.DCollectionBalanceCreditCC = 0
DCollection.DCollectionBalanceDebitCC = 0
DCollection.DCollectionOrigCreditCC = 0
DCollection.DCollectionOrigDebitCC = 0.
for each DDocument where
DDocument.DCollection_ID = DCollection.DCollection_ID
no-lock:
assign DCollection.DCollectionOrigDebitCC = DCollection.DCollectionOrigDebitCC + DDocument.DDocumentOriginalDebitCC
DCollection.DCollectionOrigCreditCC = DCollection.DCollectionOrigCreditCC + DDocument.DDocumentOriginalCreditCC.
if DDocument.DDocumentIsOpen = true
then assign DCollection.DCollectionBalanceCC = DCollection.DCollectionBalanceCC + (DDocument.DDocumentOriginalDebitCC - DDocument.DDocumentOriginalCreditCC)
DCollection.DCollectionBalanceDebitCC = DCollection.DCollectionBalanceDebitCC + DDocument.DDocumentOriginalDebitCC
DCollection.DCollectionBalanceCreditCC = DCollection.DCollectionBalanceCreditCC + DDocument.DDocumentOriginalCreditCC.
end. /* for each DDocument where */
end. /* DCollection */
end. /* STATCURRDETBLOCK */
assign oiReturnStatus = viLocalReturnStatus.