project QadFinancials > class BCInvoice > method CheckLinkedInvoiceApiCC

Description

Checked the CC rate for a linked invoice.


Parameters


icApiInvoiceRowidinputcharacterInput parameter for the Api invoice rowid.
bdExchangeRateinput-outputdecimalinput-output exchange rate parameter.
bdRateScaleinput-outputdecimalinput-output parameter for the rate scale.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ApiStdMaintainTTCalcAmounts


program code (program7/bcinvoice.p)

assign oiReturnStatus       = -98
       viLocalReturnStatus  = 0.

find first tAPiCInvoice where
           tAPiCInvoice.tc_Rowid = icApiInvoiceRowid
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 tAPiCInvoice                      and
   tAPiCinvoice.tiLinkedCInvoiceVoucher <> 0   and tAPiCinvoice.tiLinkedCInvoiceVoucher <> ? and 
   tAPiCInvoice.tiLinkedPeriodYear      <> 0   and tAPiCInvoice.tiLinkedPeriodYear      <> ? and
   tAPiCinvoice.tcLinkedJournalCode     <> ?   and tAPiCinvoice.tcLinkedJournalCode     <> '':U
then do:

    <Q-55 run CInvoiceByInvoiceNumber (all) (Read) (NoCache)
       (input viCompanyId, (CompanyId)
        input tApiCInvoice.tiLinkedPeriodYear, (CInvoicePostingYear)
        input tApiCInvoice.tiLinkedCInvoiceVoucher, (CInvoiceVoucher)
        input tApiCInvoice.tcLinkedJournalCode, (JournalCode)
        output dataset tqCInvoiceByInvoiceNumber) in BCInvoice >
     
    find first tqCInvoiceByInvoiceNumber no-lock no-error.
    if available tqCInvoiceByInvoiceNumber
    then do:
        if tqCInvoiceByInvoiceNumber.tdCInvoiceCCRate    <> bdExchangeRate or
           tqCInvoiceByInvoiceNumber.tdCInvoiceCCScale   <> bdRateScale
        then assign bdExchangeRate                = tqCInvoiceByInvoiceNumber.tdCInvoiceCCRate
                    bdRateScale                   = tqCInvoiceByInvoiceNumber.tdCInvoiceRateScale
                    tAPiCinvoice.CInvoiceCCRate   = bdExchangeRate 
                    tAPiCinvoice.CInvoiceCCScale  = bdRateScale.
        
    end. /* if available tqDInvoiceByInvoiceNumber */
    
end. /* if tApiCInvoice ..... */
/* Only raise an error if the invoice could not be found. */
else if not available tApiCInvoice
then do:
    assign vcMessage           = trim(#T-21'An internal error occured when finding the supplier invoice':255(47069726)T-21#)
           viLocalReturnStatus = -1.
    <M-41 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-731704':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
end. /* if not available t_sDInvoice */

assign oiReturnStatus = viLocalReturnStatus.