project QadFinancials > class BDPaymentSelection > method GetPaymentCurrencyAmounts

Description

The the LC and CC currency amounts for the passed in Invoice ID and payment amount


Parameters


iiInvoiceIDinputinteger
iiExchangeRateSharedSetIDinputinteger
idPaymentAmountTCinputdecimal
icBankCurrencyCodeinputcharacter
idBankRateinputdecimal
idBankRateScaleinputdecimal
odInvoiceCCTotaloutputdecimal
odInvoiceLCTotaloutputdecimal
odInvoiceBCTotaloutputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDPaymentSelection.AdditionalUpdatesDCollection


program code (program1/bdpaymentselection.p)

if iiInvoiceID = 0 or iiInvoiceID = ?
then return.           

<Q-17 run DInvoiceForPayment (all) (Read) (NoCache)
  (input viCompanyID, (CompanyId)
   input iiInvoiceID, (DInvoiceId)
   output dataset tqDInvoiceForPayment) in BDInvoice>
   
for first tqDInvoiceForPayment 
   where tqDInvoiceForPayment.tiDinvoice_ID = iiInvoiceID:
              
     /*Calculate LC totals */
    if tqDInvoiceForPayment.tiDInvoiceCurrency_ID = viCompanyLCID
    then 
        assign 
            vdLCExchangeRate = 1
            vdLCRateScale    = 1.
    else if tqDInvoiceForPayment.tiLCCurrency_ID = viCompanyLCID
    then 
        assign 
            vdLCExchangeRate = tqDInvoiceForPayment.tdDInvoiceExchangeRate
            vdLCRateScale    = tqDInvoiceForPayment.tdDInvoiceRateScale.
    else do:
        <M-16 run GetExchangeRate
           (input  ? (iiCompanyID), 
            input  tqDInvoiceForPayment.tiDInvoiceCurrency_ID (iiFromCurrencyID), 
            input  ? (icFromCurrencyCode), 
            input  viCompanyLCId (iiToCurrencyID), 
            input  ? (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
            input  tqDInvoiceForPayment.ttDInvoicePostingDate (itValidityDate), 
            output vdLCExchangeRate (odExchangeRate), 
            output vdLCRateScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>
        if viFcReturnSuper < 0 then return.                
    end. /* else do */
    
    assign odInvoiceLCTotal = <M-3 RoundAmount
                                 (input  idPaymentAmountTC * vdLCExchangeRate * vdLCRateScale (idUnroundedAmount), 
                                  input  viCompanyLCId (iiCurrencyID), 
                                  input  vcCompanyLC (icCurrencyCode)) in BDPaymentSelection>.            
                                  
    /*Calculate CC totals */                                   
    if tqDInvoiceForPayment.tiDInvoiceCurrency_ID = viCompanyCCID
    then 
        assign 
            vdCCExchangeRate = 1
            vdCCRateScale = 1.
    else if tqDInvoiceForPayment.tiStatutoryCurrency_ID = viCompanyCCID
        and tqDInvoiceForPayment.tiExchangeRateSharedSet_ID = iiExchangeRateSharedSetID
    then 
        assign 
            vdCCExchangeRate = tqDInvoiceForPayment.tdDInvoiceCCScale
            vdCCRateScale = tqDInvoiceForPayment.tdDInvoiceCCRate.            
    else if not vlDomainIsStatutory 
    then 
        assign 
            vdCCExchangeRate = vdLCExchangeRate
            vdCCRateScale = vdCCRateScale.
    else do:
        <M-59 run GetExchangeRate
           (input  ? (iiCompanyID), 
            input  tqDInvoiceForPayment.tiDInvoiceCurrency_ID (iiFromCurrencyID), 
            input  ? (icFromCurrencyCode), 
            input  viCompanyCCId (iiToCurrencyID), 
            input  ? (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
            input  tqDInvoiceForPayment.ttDInvoicePostingDate (itValidityDate), 
            output vdCCExchangeRate (odExchangeRate), 
            output vdCCRateScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BDPaymentSelection>        
        if viFcReturnSuper < 0 then return.            
    
    end. /* else do */
    assign 
        odInvoiceCCTotal = <M-74 RoundAmount
                                 (input  idPaymentAmountTC * vdCCExchangeRate * vdCCRateScale (idUnroundedAmount), 
                                  input  viCompanyCCId (iiCurrencyID), 
                                  input  vcCompanyCC (icCurrencyCode)) in BDPaymentSelection>                                             
        odInvoiceBCTotal = <M-60 RoundAmount
                              (input  idPaymentAmountTC * tqDInvoiceForPayment.tdDInvoiceExchangeRate * tqDInvoiceForPayment.tdDInvoiceRateScale / (idBankRate * idBankRateScale) (idUnroundedAmount), 
                               input  '':U (iiCurrencyID), 
                               input  icBankCurrencyCode (icCurrencyCode)) in BDPaymentSelection>.
end.