project QadFinancials > class BDInvoice > method CheckExternalInvoiceCC

Description

Method to check the external invoices statutory exchange rates.


Parameters


icInvoiceRowidinputcharacterInvoice Rowid
bdExchangeRateinput-outputdecimalExcahnge Rate.
bdRateScaleinput-outputdecimalRate Scale.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDInvoice.ValidateComponentPre
method BDInvoice.ValidateComponentPreValidateVat


program code (program7/bdinvoice.p)

assign oiReturnStatus       = -98
       viLocalReturnStatus  = 0.

find first t_sDInvoice where
           t_sDInvoice.tc_Rowid = icInvoiceRowid
exclusive-lock no-error.

/* If the invoice is available and it is a credit note or a correction */
/* then check the statutory currency rates match.                      */       
if available t_sDInvoice                         and
   t_sDinvoice.tiLinkedDInvoiceVoucher <> 0      and
   t_sDinvoice.tiLinkedPeriodYear      <> 0      and
   t_sDinvoice.tcLinkedJournalCode     <> '':U
then do:

    <Q-17 run DInvoiceByInvoiceNumber (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input t_sDInvoice.tiLinkedPeriodYear, (DInvoicePostingYear)
        input t_sDInvoice.tiLinkedDInvoiceVoucher, (DInvoiceVoucher)
        input t_sDInvoice.tcLinkedJournalCode, (JournalCode)
        output dataset tqDInvoiceByInvoiceNumber) in BDInvoice >
     
    find first tqDInvoiceByInvoiceNumber no-lock no-error.
    if available tqDInvoiceByInvoiceNumber
    then do:
        if tqDInvoiceByInvoiceNumber.tdDInvoiceCCRate    <> bdExchangeRate or
           tqDInvoiceByInvoiceNumber.tdDInvoiceCCScale   <> bdRateScale
        then assign bdExchangeRate               = tqDInvoiceByInvoiceNumber.tdDInvoiceCCRate
                    bdRateScale                  = tqDInvoiceByInvoiceNumber.tdDInvoiceRateScale
                    t_sDinvoice.DInvoiceCCRate   = bdExchangeRate 
                    t_sDinvoice.DInvoiceCCScale  = bdRateScale.
        
    end. /* if available tqDInvoiceByInvoiceNumber */
    
end. /* if t_sDInvoice ..... */
/* Only raise an error if the invoice could not be found. */
else if not available t_sDInvoice
then do:
    assign vcMessage           = trim(#T-71'An internal error occured when finding the customer invoice':255(733711355)T-71#)
           viLocalReturnStatus = -1.
    <M-1 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-256133':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
end. /* if not available t_sDInvoice */

assign oiReturnStatus = viLocalReturnStatus.