project QadFinancials > class BCInvoice > method DefaultValuesWHTFees

Description

Update the taxable fees and wht amounts based on the fees


Parameters


icCInvoiceRowIdinputcharacterROWID of the invoice
bdCInvoiceWHTFeesDebitTCinput-outputdecimalWHT Fees Debit TC of the invoice
bdCInvoiceWHTFeesCreditTCinput-outputdecimalWHT Fees Credit TC of the invoice
icCInvoiceCurrencyCodeinputcharacterCurrency code of the invoice
iiCInvoiceCurrencyIdinputintegercurrency id of the invoice
idCInvoiceExchangeRateinputdecimalexchange rate of the invoice (obsolete - FIN-6687)
idCInvoiceExchangeRateScaleinputdecimalscale factor of the exchange rate of the invoice (obsolete - FIN-6687)
idWHTBasePercentageinputdecimalWHT tax base percentage
idTxTaxPctinputdecimaltax percentage
itCInvoicePostingDateinputdatePosting date of the invoice
itCInvoiceDateinputdate
odCInvoiceWHTTaxableFeesDebitTCoutputdecimalWHT Taxable Fee Debit TC
odCInvoiceWHTTaxableFeesCreditTCoutputdecimalWHT Taxable Fee Credit TC
odCInvoiceWHTTaxableFeesDebitLCoutputdecimalWHT Taxable Fee Debit LC
odCInvoiceWHTTaxableFeesCreditLCoutputdecimalWHT Taxable Fee Credit LC
odCInvoiceWHTTaxableFeesDebitCCoutputdecimalWHT Taxable Fee Debit CC
odCInvoiceWHTTaxableFeesCreditCCoutputdecimalWHT Taxable Fee Credit CC
odCInvoiceWHTAmountDebitTCoutputdecimalWHT Debit Amount TC
odCInvoiceWHTAmountCreditTCoutputdecimalWHT Credit Amount TC
odCInvoiceWHTAmountDebitLCoutputdecimalWHT Debit Amount LC
odCInvoiceWHTAmountCreditLCoutputdecimalWHT Credit Amount LC
odCInvoiceWHTAmountDebitCCoutputdecimalWHT Debit Amount CC
odCInvoiceWHTAmountCreditCCoutputdecimalWHT Credit Amount CC
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ApiStdMaintainTTWithExtPost
method BCInvoice.DefaultValuesWHTCode


program code (program3/bcinvoice.p)

 assign oiReturnStatus      = -98
       viLocalReturnStatus = 0. 

/******************************/
/* Normalize input parameters */
/******************************/
if icCInvoiceRowId = ? then assign icCInvoiceRowId = "":U.
if bdCInvoiceWHTFeesDebitTC = ? then assign bdCInvoiceWHTFeesDebitTC = 0.
if bdCInvoiceWHTFeesCreditTC = ? then assign bdCInvoiceWHTFeesCreditTC = 0.
if icCInvoiceCurrencyCode = ? then assign icCInvoiceCurrencyCode = "":U.
if iiCInvoiceCurrencyId = ? then assign iiCInvoiceCurrencyId = 0.
if idCInvoiceExchangeRate = ? then assign idCInvoiceExchangeRate = 0.
if idCInvoiceExchangeRateScale = ? then assign idCInvoiceExchangeRateScale = 0.
if idWHTBasePercentage = ? then assign idWHTBasePercentage = 0.
if idTxTaxPct = ? then assign idTxTaxPct = 0.
if itCInvoicePostingDate = ? then assign itCInvoicePostingDate = today.

/*****************************/
/* Default output parameters */
/*****************************/
assign odCInvoiceWHTAmountDebitCC       = 0
       odCInvoiceWHTAmountCreditCC      = 0
       odCInvoiceWHTAmountDebitLC       = 0
       odCInvoiceWHTAmountCreditLC      = 0
       odCInvoiceWHTAmountDebitTC       = 0       
       odCInvoiceWHTAmountCreditTC      = 0
       odCInvoiceWHTTaxableFeesDebitCC  = 0
       odCInvoiceWHTTaxableFeesCreditCC = 0
       odCInvoiceWHTTaxableFeesDebitLC  = 0
       odCInvoiceWHTTaxableFeesCreditLC = 0
       odCInvoiceWHTTaxableFeesDebitTC  = 0
       odCInvoiceWHTTaxableFeesCreditTC = 0.
       
/*****************************/
/* Validate input parameters */       
/*****************************/

if bdCInvoiceWHTFeesDebitTC  = 0 and
   bdCInvoiceWHTFeesCreditTC = 0
then do:
    assign oiReturnStatus = viLocalReturnStatus.
    return.
end.    
if idTxTaxPct = 0 
then do:
    assign oiReturnStatus = viLocalReturnStatus.
    return.
end.
if idWHTBasePercentage = 0 
then do:
    assign oiReturnStatus = viLocalReturnStatus.
    return.
end.

/************************/
/* Get Supplier Invoice */
/************************/
find tCInvoice where
     tCInvoice.tc_Rowid = icCInvoiceRowId
     no-error.     
if not available tCInvoice
then do:
    assign vcMessage      = trim(#T-76'The specified supplier invoice is not defined in the system or is invalid.':80(999890907)T-76#)
           oiReturnStatus = -1.
    <M-20 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'icCInvoiceRowId':U (icFieldName), 
        input  icCInvoiceRowId (icFieldValue), 
        input  'D':U (icType), 
        input  3 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-462573':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end. /* if not available tCInvoice */         

/***********************/
/* Get Currency ID     */
/***********************/
if iiCInvoiceCurrencyId   = 0 and
   icCInvoiceCurrencyCode <> "":U
then do:
    <Q-69 run CurrencyPrim (all) (Read) (NoCache)
       (input icCInvoiceCurrencyCode, (CurrencyCode)
        input ?, (Currency_ID)
        output dataset tqCurrencyPrim) in BCurrency >
    find first tqCurrencyPrim where tqCurrencyPrim.tcCurrencyCode = icCInvoiceCurrencyCode no-error.
    if available tqCurrencyPrim
    then assign iiCInvoiceCurrencyId = tqCurrencyPrim.tiCurrency_ID.   
end. /* if iiCInvoiceCurrencyId = 0 */  
else if available tCInvoice and
        iiCInvoiceCurrencyId   = 0 and
        icCInvoiceCurrencyCode = "":U 
     then assign iiCInvoiceCurrencyId = tCInvoice.CInvoiceCurrency_ID.

/****************************/
/* Calculate Exchange Rates */
/****************************/
/************/
/* TC to LC */
/************/
if iiCInvoiceCurrencyId <> 0 and
   iiCInvoiceCurrencyId = viCompanyLCId
then do:
    assign vdCInvoiceExchangeRateLC      = 1
           vdCInvoiceExchangeRateScaleLC = 1.
end.    
else do:
    
    <M-48 run GetExRateByEntityInvoiceFlag
       (input  itCInvoiceDate (itCInvoiceDate), 
        input  itCInvoicePostingDate (itCInvoicePostingDate), 
        input  iiCInvoiceCurrencyId (iiFromCurrencyId), 
        input  icCInvoiceCurrencyCode (icFromCurrencyCode), 
        input  viCompanyLCId (iiToCurrencyId), 
        input  vcCompanyLC (icToCurrencyCode), 
        input  0 (iiExchangeRateTypeId), 
        input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
        output vdCInvoiceExchangeRateLC (odCInvoiceExchangeRate), 
        output vdCInvoiceExchangeRateScaleLC (odCInvoiceRateScale), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    if viFcReturnSuper < 0 or viLocalReturnStatus = 0
    then assign viLocalReturnStatus = viFcReturnSuper.                    
end. /* else do */    
    
/************/            
/* TC to CC */
/************/
if iiCInvoiceCurrencyId <> 0 and
   iiCInvoiceCurrencyId = viCompanyCCId
then do:
    assign vdCInvoiceExchangeRateCC      = 1
           vdCInvoiceExchangeRateScaleCC = 1.
end.           
else do:
    
    <M-27 run GetExRateByEntityInvoiceFlag
       (input  itCInvoiceDate (itCInvoiceDate), 
        input  itCInvoicePostingDate (itCInvoicePostingDate), 
        input  iiCInvoiceCurrencyId (iiFromCurrencyId), 
        input  icCInvoiceCurrencyCode (icFromCurrencyCode), 
        input  viCompanyCCId (iiToCurrencyId), 
        input  vcCompanyCC (icToCurrencyCode), 
        input  0 (iiExchangeRateTypeId), 
        input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
        output vdCInvoiceExchangeRateCC (odCInvoiceExchangeRate), 
        output vdCInvoiceExchangeRateScaleCC (odCInvoiceRateScale), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    if viFcReturnSuper < 0 or viLocalReturnStatus = 0
    then assign viLocalReturnStatus = viFcReturnSuper.            
end. /* else do */

/*******************************/
/* Calculate output parameters */
/*******************************/
/**************/
/* TC Amounts */
/**************/
if bdCInvoiceWHTFeesDebitTC  <> 0 
then assign odCInvoiceWHTTaxableFeesDebitTC  = <M-80 RoundAmount
                                                  (input  (bdCInvoiceWHTFeesDebitTC / 100) * idWHTBasePercentage (idUnroundedAmount), 
                                                   input  iiCInvoiceCurrencyId (iiCurrencyID), 
                                                   input  icCInvoiceCurrencyCode (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountDebitTC       = <M-7 RoundAmount
                                                  (input  (odCInvoiceWHTTaxableFeesDebitTC / 100) * idTxTaxPct (idUnroundedAmount), 
                                                   input  iiCInvoiceCurrencyId (iiCurrencyID), 
                                                   input  icCInvoiceCurrencyCode (icCurrencyCode)) in BApplicationProperty>.

if bdCInvoiceWHTFeesCreditTC <> 0 
then assign odCInvoiceWHTTaxableFeesCreditTC = <M-95 RoundAmount
                                                  (input  (bdCInvoiceWHTFeesCreditTC / 100) * idWHTBasePercentage (idUnroundedAmount), 
                                                   input  iiCInvoiceCurrencyId (iiCurrencyID), 
                                                   input  icCInvoiceCurrencyCode (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountCreditTC      = <M-4 RoundAmount
                                                  (input  (odCInvoiceWHTTaxableFeesCreditTC / 100) * idTxTaxPct (idUnroundedAmount), 
                                                   input  iiCInvoiceCurrencyId (iiCurrencyID), 
                                                   input  icCInvoiceCurrencyCode (icCurrencyCode)) in BApplicationProperty>.

/**************/        
/* LC Amounts */
/**************/ 
if odCInvoiceWHTTaxableFeesDebitTC <> 0 
then assign odCInvoiceWHTTaxableFeesDebitLC  = <M-98 RoundAmount
                                                  (input  odCInvoiceWHTTaxableFeesDebitTC * vdCInvoiceExchangeRateLC * vdCInvoiceExchangeRateScaleLC (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountDebitLC       = <M-52 RoundAmount
                                                  (input  odCInvoiceWHTAmountDebitTC * vdCInvoiceExchangeRateLC * vdCInvoiceExchangeRateScaleLC (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.

if odCInvoiceWHTTaxableFeesCreditTC <> 0 
then assign odCInvoiceWHTTaxableFeesCreditLC = <M-2 RoundAmount
                                                  (input  odCInvoiceWHTTaxableFeesCreditTC * vdCInvoiceExchangeRateLC * vdCInvoiceExchangeRateScaleLC (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountCreditLC      = <M-77 RoundAmount
                                                  (input  odCInvoiceWHTAmountCreditTC * vdCInvoiceExchangeRateLC * vdCInvoiceExchangeRateScaleLC (idUnroundedAmount), 
                                                   input  viCompanyLCId (iiCurrencyID), 
                                                   input  vcCompanyLC (icCurrencyCode)) in BApplicationProperty>.

/**************/
/* CC Amounts */
/**************/
if odCInvoiceWHTTaxableFeesDebitTC <> 0 
then assign odCInvoiceWHTTaxableFeesDebitCC  = <M-67 RoundAmount
                                                  (input  odCInvoiceWHTTaxableFeesDebitTC * vdCInvoiceExchangeRateCC * vdCInvoiceExchangeRateScaleCC (idUnroundedAmount), 
                                                   input  viCompanyCCId (iiCurrencyID), 
                                                   input  vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountDebitCC       = <M-66 RoundAmount
                                                  (input  odCInvoiceWHTAmountDebitTC * vdCInvoiceExchangeRateCC * vdCInvoiceExchangeRateScaleCC (idUnroundedAmount), 
                                                   input  viCompanyCCId (iiCurrencyID), 
                                                   input  vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.   

if odCInvoiceWHTTaxableFeesCreditTC <> 0 
then assign odCInvoiceWHTTaxableFeesCreditCC = <M-44 RoundAmount
                                                  (input  odCInvoiceWHTTaxableFeesCreditTC * vdCInvoiceExchangeRateCC * vdCInvoiceExchangeRateScaleCC (idUnroundedAmount), 
                                                   input  viCompanyCCId (iiCurrencyID), 
                                                   input  vcCompanyCC (icCurrencyCode)) in BApplicationProperty>
            odCInvoiceWHTAmountCreditCC      = <M-97 RoundAmount
                                                  (input  odCInvoiceWHTAmountCreditTC * vdCInvoiceExchangeRateCC * vdCInvoiceExchangeRateScaleCC (idUnroundedAmount), 
                                                   input  viCompanyCCId (iiCurrencyID), 
                                                   input  vcCompanyCC (icCurrencyCode)) in BApplicationProperty>.

assign oiReturnStatus = viLocalReturnStatus.