project QadFinancials > class BCInvoice > method DefaultValuesWHTCode

Description

This method will return the default values associated with a WHT and also the taxable fees and wht amount if required


Parameters


icCInvoiceRowIdinputcharacterCInvoice RowId
icCInvoiceTypeinputcharacterInvoice Type
icWHTCodeinputcharacter
bdCInvoiceWHTFeesDebitTCinput-outputdecimal
bdCInvoiceWHTFeesCreditTCinput-outputdecimal
icCInvoiceCurrencyCodeinputcharacter
iiCInvoiceCurrencyIdinputinteger
idCInvoiceExchangeRateinputdecimal
idCInvoiceExchangeRateScaleinputdecimal
itCInvoicePostingDateinputdatePosting Date of the invoice
itCInvoiceDateinputdate
ocTx2TaxTypeoutputcharacter
ocTx2Descoutputcharacter
odTx2TaxPctoutputdecimal
odWHTBasePercentageoutputdecimal
ocWHTAcctoutputcharacter
ocWHTSubAcctoutputcharacter
odCInvoiceWHTTaxableFeesDebitTCoutputdecimal
odCInvoiceWHTTaxableFeesCreditTCoutputdecimal
odCInvoiceWHTTaxableFeesDebitLCoutputdecimal
odCInvoiceWHTTaxableFeesCreditLCoutputdecimal
odCInvoiceWHTTaxableFeesDebitCCoutputdecimal
odCInvoiceWHTTaxableFeesCreditCCoutputdecimal
odCInvoiceWHTAmountDebitTCoutputdecimal
odCInvoiceWHTAmountCreditTCoutputdecimal
odCInvoiceWHTAmountDebitLCoutputdecimal
odCInvoiceWHTAmountCreditLCoutputdecimal
odCInvoiceWHTAmountDebitCCoutputdecimal
odCInvoiceWHTAmountCreditCCoutputdecimal
olWHTIsUpdAllowoutputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ApiStdMaintainTTWithExtPost
method BCInvoice.CreateCInvoices
method BCInvoice.DefaultValuesSupplier


program code (program3/bcinvoice.p)

assign oiReturnStatus      = -98
       viLocalReturnStatus = 0. 

/******************************/
/* Normalize input parameters */
/******************************/
if icCInvoiceRowId           = ? then assign icCInvoiceRowId           = "":U.
if icWHTCode                 = ? then assign icWHTCode                 = "":U.
if bdCInvoiceWHTFeesDebitTC  = ? then assign bdCInvoiceWHTFeesDebitTC  = 0.
if bdCInvoiceWHTFeesCreditTC = ? then assign bdCInvoiceWHTFeesCreditTC = 0.
if icCInvoiceType            = ? then assign icCInvoiceType            = "":U.

/*****************************/
/* Default output parameters */
/*****************************/
assign ocTx2Desc                        = "":U
       ocTx2TaxType                     = "":U
       ocWHTAcct                        = "":U
       ocWHTSubAcct                     = "":U
       olWHTISUpdAllow                  = false
       odWHTBasePercentage              = 0
       odTx2TaxPct                      = 0 
       odCInvoiceWHTAmountCreditCC      = 0
       odCInvoiceWHTAmountCreditLC      = 0
       odCInvoiceWHTAmountCreditTC      = 0
       odCInvoiceWHTAmountDebitCC       = 0
       odCInvoiceWHTAmountDebitLC       = 0
       odCInvoiceWHTAmountDebitTC       = 0
       odCInvoiceWHTTaxableFeesCreditCC = 0
       odCInvoiceWHTTaxableFeesCreditLC = 0
       odCInvoiceWHTTaxableFeesCreditTC = 0
       odCInvoiceWHTTaxableFeesDebitCC  = 0
       odCInvoiceWHTTaxableFeesDebitLC  = 0
       odCInvoiceWHTTaxableFeesDebitTC  = 0. 
       
/*****************************/
/* Validate input parameters */
/*****************************/   
if icCInvoiceRowId = "":U
then do:
    assign vcMessage      = trim(#T-68'The specified supplier invoice is not defined in the system or is invalid. ':80(2986)T-68#)
           oiReturnStatus = -1.
    <M-40 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'CInvoiceRowid':U (icFieldName), 
        input  icCInvoiceRowId (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-110919':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end.   
if icCInvoiceType = "":U
then do:
    assign vcMessage      = trim(#T-41'The specified supplier invoice type is not defined in the system or is invalid.':80(996402287)T-41#)
           oiReturnStatus = -1.
    <M-73 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'CInvoice Type':U (icFieldName), 
        input  icCInvoiceType (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-795022':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end.  
if icWHTCode = "":U 
then do:
    assign vcMessage      = trim(#T-66'The specified WHT Code is not defined in the system or is invalid.':80(65675538)T-66#)
           oiReturnStatus = -1.    
    <M-74 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'WHT Code':U (icFieldName), 
        input  icWHTCode (icFieldValue), 
        input  'S':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'qadfin-889063':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    return.
end.    

/************************/
/* Get Supplier Invoice */
/************************/
find tCInvoice where
     tCInvoice.tc_Rowid = icCInvoiceRowId
     no-error.

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

/******************/
/* Get Tax Fields */
/******************/
if icWHTCode <> "":U and
   icWHTCode <> ?
then do:    
    assign odWHTBasePercentage = 100.
    
    <Q-37 run MfgTaxCodeByTaxCode (all) (Read) (Cache)
       (input icWHTCode, (TaxCode)
        input vcDomainCode, (DomainCode)
        input ?, (DiscountAtPayment)
        input ?, (IsTaxByLine)
        output dataset tqMfgTaxCodeByTaxCode) in BMfgTaxCode> 
    
    find first tqMfgTaxCodeByTaxCode
         where tqMfgTaxCodeByTaxCode.tctx2_tax_code = icWHTCode no-error.
    if available tqMfgTaxCodeByTaxCode
    then do:
        if tqMfgTaxCodeByTaxCode.tctx2_base <> "" and
           tqMfgTaxCodeByTaxCode.tctx2_base <> ?
        then do:
            <Q-77 run GeneralizedCodeForSecurity (all) (Read) (Cache)
               (input vcDomainCode, (DomainCode)
                input 'txb_base', (CodeFldName)
                input tqMfgTaxCodeByTaxCode.tctx2_base, (CodeValue)
                output dataset tqGeneralizedCodeForSecurity) in BMfgGeneralizedCode>
            find first tqGeneralizedCodeForSecurity where
                       tqGeneralizedCodeForSecurity.tccode_domain  = vcDomainCode and
                       tqGeneralizedCodeForSecurity.tccode_fldname = 'txb_base'   and
                       tqGeneralizedCodeForSecurity.tccode_value   = tqMfgTaxCodeByTaxCode.tctx2_base
                       no-lock no-error.
            if available tqGeneralizedCodeForSecurity
            then do:
                assign vcWHTBasePercentage = substring(tqGeneralizedCodeForSecurity.tccode_cmmt, 1, 9, "CHARACTER").
                if vcWHTBasePercentage <> "" and
                   vcWHTBasePercentage <> ?
                then assign odWHTBasePercentage = decimal(vcWHTBasePercentage) no-error.
                if error-status:error
                then assign odWHTBasePercentage = 100.
            end. /* if available tqGeneralizedCodeForSecurity */
        end. /* if tqMfgTaxCodeByTaxCode.tctx2_base <> "" and */   
        
        assign ocTx2Desc           = tqMfgTaxCodeByTaxCode.tctx2_desc
               ocTx2TaxType        = tqMfgTaxCodeByTaxCode.tctx2_tax_type
               odTx2TaxPct         = tqMfgTaxCodeByTaxCode.tdtx2_tax_pct
               olWHTISUpdAllow     = tqMfgTaxCodeByTaxCode.tltx2_update_tax.               
               
        if icCInvoiceType = {&INVOICETYPE-INVOICE} or
           icCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
        then do:
            assign ocWHTAcct    = tqMfgTaxCodeByTaxCode.tctx2_ap_acct
                   ocWHTSubAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_sub.
        end. /* if icCInvoiceType */          
        else if icCInvoiceType = {&INVOICETYPE-CREDITNOTE} or
                icCInvoiceType = {&INVOICETYPE-CREDITNOTECORRECTION}
        then do:
            assign ocWHTAcct    = tqMfgTaxCodeByTaxCode.tctx2_ap_cn_acct
                   ocWHTSubAcct = tqMfgTaxCodeByTaxCode.tctx2_ap_cn_sub.
        end. /* else if icCInvoiceType */        
    end. /* if available tqMfgTaxCodeByTaxCode */                
end. /* if icWHTCode <> "":U */

/*********************************************/
/* Update Taxable Fees and WHT Amount fields */
/*********************************************/
if (bdCInvoiceWHTFeesDebitTC <> 0 and
    bdCInvoiceWHTFeesDebitTC <> ?) or
   (bdCInvoiceWHTFeesCreditTC <> 0 and
    bdCInvoiceWHTFeesCreditTC <> ?)
then do:   
    <M-15 run DefaultValuesWHTFees
       (input  icCInvoiceRowId (icCInvoiceRowId), 
        input-output bdCInvoiceWHTFeesDebitTC (bdCInvoiceWHTFeesDebitTC), 
        input-output bdCInvoiceWHTFeesCreditTC (bdCInvoiceWHTFeesCreditTC), 
        input  icCInvoiceCurrencyCode (icCInvoiceCurrencyCode), 
        input  iiCInvoiceCurrencyId (iiCInvoiceCurrencyId), 
        input  idCInvoiceExchangeRate (idCInvoiceExchangeRate), 
        input  idCInvoiceExchangeRateScale (idCInvoiceExchangeRateScale), 
        input  odWHTBasePercentage (idWHTBasePercentage), 
        input  odTx2TaxPct (idTxTaxPct), 
        input  itCInvoicePostingDate (itCInvoicePostingDate), 
        input  itCInvoiceDate (itCInvoiceDate), 
        output odCInvoiceWHTTaxableFeesDebitTC (odCInvoiceWHTTaxableFeesDebitTC), 
        output odCInvoiceWHTTaxableFeesCreditTC (odCInvoiceWHTTaxableFeesCreditTC), 
        output odCInvoiceWHTTaxableFeesDebitLC (odCInvoiceWHTTaxableFeesDebitLC), 
        output odCInvoiceWHTTaxableFeesCreditLC (odCInvoiceWHTTaxableFeesCreditLC), 
        output odCInvoiceWHTTaxableFeesDebitCC (odCInvoiceWHTTaxableFeesDebitCC), 
        output odCInvoiceWHTTaxableFeesCreditCC (odCInvoiceWHTTaxableFeesCreditCC), 
        output odCInvoiceWHTAmountDebitTC (odCInvoiceWHTAmountDebitTC), 
        output odCInvoiceWHTAmountCreditTC (odCInvoiceWHTAmountCreditTC), 
        output odCInvoiceWHTAmountDebitLC (odCInvoiceWHTAmountDebitLC), 
        output odCInvoiceWHTAmountCreditLC (odCInvoiceWHTAmountCreditLC), 
        output odCInvoiceWHTAmountDebitCC (odCInvoiceWHTAmountDebitCC), 
        output odCInvoiceWHTAmountCreditCC (odCInvoiceWHTAmountCreditCC), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    if viFcReturnSuper < 0 or viLocalReturnStatus = 0
    then assign viLocalReturnStatus = viFcReturnSuper.        
end. /* if idCInvoiceWHTFeesDebitTC <> 0 */

assign oiReturnStatus = viLocalReturnStatus.