project QadFinancials > class BDDocument > method ValidateComponentPreInvXrefPrep
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program4/bddocument.p)
/* ====================================================================================== *
* Method : ValidateComponentPreInvXrefPrep *
* Description : Complete calcualted fields in DDocumentInvoiceXrefTable for Prepayment *
* -------------------------------------------------------------------------------------- *
* Parameters : *
* ====================================================================================== */
assign oiReturnStatus = -98
viLocalReturn = 0.
MAIN_BLOCK:
do on error undo, return:
/* ====================================================================================== *
* If exchange rates are alreday assigned, skip this assignment *
* ====================================================================================== */
if t_sDDocumentInvoiceXref.tdLCExchangeRate = 0 or
t_sDDocumentInvoiceXref.tdLCExchangeRate = ? or
t_sDDocumentInvoiceXref.tdLCExchangeRateScale = 0 or
t_sDDocumentInvoiceXref.tdLCExchangeRateScale = ? or
t_sDDocumentInvoiceXref.tdCCExchangeRate = 0 or
t_sDDocumentInvoiceXref.tdCCExchangeRate = ? or
t_sDDocumentInvoiceXref.tdCCExchangeRateScale = 0 or
t_sDDocumentInvoiceXref.tdCCExchangeRateScale = ?
then do:
/* ================================================================================================ *
* Calculate LC exchange rate which will be used for allocation posting *
* ================================================================================================ */
/* If transaction currency of the invoice is the same as local currency of the payment */
if t_sDDocumentInvoiceXref.tcCurrencyCode = vcCompanyLC
then assign t_sDDocumentInvoiceXref.tdLCExchangeRate = 1
t_sDDocumentInvoiceXref.tdLCExchangeRateScale = 1.
/* Transaction currency of the Prepayment is different to Local Currency */
else do:
<M-14 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sDDocumentInvoiceXref.tcCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode),
input t_sDDocument.ttPostingDate (itValidityDate),
output t_sDDocumentInvoiceXref.tdLCExchangeRate (odExchangeRate),
output t_sDDocumentInvoiceXref.tdLCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
/* ================================================================================================ *
* Calculate CC exchange rate which will be used for allocation posting *
* ================================================================================================ */
/* If transaction currency of the invoice is the same as transactional currency of the payment */
if t_sDDocumentInvoiceXref.tcCurrencyCode = vcCompanyCC
then assign t_sDDocumentInvoiceXref.tdCCExchangeRate = 1
t_sDDocumentInvoiceXref.tdCCExchangeRateScale = 1.
/* If statutory currencies are different, take current exchange rate between TC and LC */
else if not vlDomainIsStatutory
then assign t_sDDocumentInvoiceXref.tdCCExchangeRate = t_sDDocumentInvoiceXref.tdLCExchangeRate
t_sDDocumentInvoiceXref.tdCCExchangeRateScale = t_sDDocumentInvoiceXref.tdLCExchangeRateScale.
else do:
<M-49 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input t_sDDocumentInvoiceXref.tcCurrencyCode (icFromCurrencyCode),
input viCompanyCCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input {&EXCHANGERATETYPE-STATUTORY} (icExchangeRateTypeCode),
input t_sDDocument.ttPostingDate (itValidityDate),
output t_sDDocumentInvoiceXref.tdCCExchangeRate (odExchangeRate),
output t_sDDocumentInvoiceXref.tdCCExchangeRateScale (odExchangeScaleFactor),
output viFcReturnSuper (oiReturnStatus)) in BDDocument>
if viFcReturnSuper < 0 or viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave MAIN_BLOCK.
end.
end. /* of if t_sDDocumentInvoiceXref.tdLCExchangeRate <> 0 and */
end. /* MAIN_BLOCK */
/* Error handling */
assign oiReturnStatus = viLocalReturn.