project QadFinancials > class BDInvoice > method ValidateDInvoiceExchangeRate

validation procedure

Description

This method validates the Exchange Rate of the debtor invoice.


Parameters


idDinvoiceExchangeRateinputdecimalExchange Rate of the debtor invoice
icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
iiCurrencyIDinputintegerCurrency ID
icDInvoiceReferenceinputcharacterReference of the Debtor Invoice
icCurrencyCodeinputcharacterCurrency Code
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.DefaultValuesValidate
method BDInvoice.ValidateComponentAllPost


program code (program5/bdinvoice.p)

if iiCurrencyID = ? then assign iiCurrencyID = 0.
if icCurrencyCode = ? then assign icCurrencyCode = "".

if idDinvoiceExchangeRate <> 1 and 
  ((iiCurrencyID = viCompanyLCId and
       iiCurrencyID <> 0) or
       (icCurrencyCode <> "":U and
        icCurrencyCode = vcCompanyLC))
then do :
    assign vcMessage      = trim(substitute(#T-5'The exchange rate should be 1 for invoices (&1) in the base currency.':255(1060)t-5#,trim(icDInvoiceReference))).
           oiReturnStatus = -1.
    <M-1 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'DInvoice.DinvoiceExchangeRate':U (icFieldName), 
        input  string(idDinvoiceExchangeRate) (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  icRowid (icRowid), 
        input  'QADFIN-1146':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end. /* if idDinvoiceExchangeRate = 0 and  */    

if idDinvoiceExchangeRate = 0  and
  ((iiCurrencyID <> viCompanyLCId and
        iiCurrencyID <> 0 )           or
       (icCurrencyCode <> vcCompanyLC and
        icCurrencyCode <> "":U))
then do:
    assign vcMessage      = trim(#T-3'The exchange rate cannot be zero.':250(13844)T-3#)
           oiReturnStatus = -1.
    <M-4 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'DInvoice.DInvoiceExchangeRate':U (icFieldName), 
        input  string(idDinvoiceExchangeRate) (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  icRowid (icRowid), 
        input  'QADFIN-3076':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end.