project QadFinancials > class BAPMatching > method GetPendingVouchersLogChargesTaxWHT

Description

Submethod of GetPendingVouchersLogChargesTax


Parameters


ilCallGTMinputlogicalShould we call GTM
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAPMatching.GetPendingVouchersLogChargesTax
method BAPMatching.GetPendingVouchersLogChargesTaxFiscal


program code (program7/bapmatching.p)

    /* ========================================================================================================= */
    /* ALL DATA WE USE IN HERE SHOULD BE AVAILABLE AS THIS METHOD AND ITS CALLING METHOD ARE IN THE SAME SEGMENT */
    /* ========================================================================================================= */
    
    /* ====================== */
    /* Default return-status  */
    /* ====================== */
    assign oiReturnStatus = -98.
    
    /* =============================================================================== */
    /* Create MatchingLnWHT in case GTM does not need to be called                     */
    /* If GTM needs to be called then this is done by the parent-method of this method */
    /* The amounts here do depend upon the fact whether a pvo is selected or not       */
    /* =============================================================================== */
    if ilCallGTM = false 
    then do :
        create tPendingVoucherWHTAPM. 
        assign tPendingVoucherWHTAPM.tcDomainCode               = tqPendingVoucherForMatchingLC.tctx2_domain
               tPendingVoucherWHTAPM.tcVatCode                  = tqPendingVoucherForMatchingLC.tctx2_tax_code
               tPendingVoucherWHTAPM.tcVatInOut                 = {&VATINOUT-INPUT}
               tPendingVoucherWHTAPM.APMatchingLnWHTTaxType     = tqPendingVoucherForMatchingLC.tctx2d_tax_type
               tPendingVoucherWHTAPM.APMatchingLnWHTTaxTrType   = {&VATTAXTRANSACTIONTYPE-APVOUCHER}
               tPendingVoucherWHTAPM.APMatchingLnWHTTxFeeDebTC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then 0
                                                                  else tqPendingVoucherForMatchingLC.tdtx2d_tottax
               tPendingVoucherWHTAPM.APMatchingLnWHTTxFeeCredTC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tdtx2d_tottax
                                                                  else 0
               tPendingVoucherWHTAPM.APMatchingLnWHTTxFeeDebLC  = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then 0
                                                                  else tqPendingVoucherForMatchingLC.tdtx2d_taxable_amt
               tPendingVoucherWHTAPM.APMatchingLnWHTTxFeeCredLC = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tdtx2d_taxable_amt
                                                                  else 0
               tPendingVoucherWHTAPM.APMatchingLnWHTFeeDebTC    = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then 0
                                                                  else tqPendingVoucherForMatchingLC.tdtx2d_totamt
               tPendingVoucherWHTAPM.APMatchingLnWHTFeeCredTC   = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tdtx2d_totamt
                                                                  else 0
               tPendingVoucherWHTAPM.APMatchingLnWHTExpDebTC    = 0
               tPendingVoucherWHTAPM.APMatchingLnWHTExpCredTC   = 0                                                   
               tPendingVoucherWHTAPM.APMatchingLnWHTAmtDebTC    = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then 0
                                                                  else tqPendingVoucherForMatchingLC.tdtx2d_cur_tax_amt
               tPendingVoucherWHTAPM.APMatchingLnWHTAmtCredTC   = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tdtx2d_cur_tax_amt
                                                                  else 0
               tPendingVoucherWHTAPM.APMatchingLnWHTAmtDebLC    = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then 0
                                                                  else tqPendingVoucherForMatchingLC.tdtx2d_tax_amt
               tPendingVoucherWHTAPM.APMatchingLnWHTAmtCredLC   = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tdtx2d_tax_amt
                                                                  else 0
               tPendingVoucherWHTAPM.APMatchingLnWHTIsUpdAllow  = tqPendingVoucherForMatchingLC.tltx2_update_tax
               tPendingVoucherWHTAPM.APMatchingLnWHTTaxPct      = tqPendingVoucherForMatchingLC.tdtx2_tax_pct
               tPendingVoucherWHTAPM.APMatchingLnWHTRecovTaxPct = tqPendingVoucherForMatchingLC.tdtx2_pct_recv
               tPendingVoucherWHTAPM.tcGLCode                   = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tctx2_ap_acct
                                                                  else tqPendingVoucherForMatchingLC.tctx2_ap_cn_acct
               tPendingVoucherWHTAPM.tcDivisionCode             = if tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICE} or tAPMatching.tcCInvoiceType = {&INVOICETYPE-INVOICECORRECTION}
                                                                  then tqPendingVoucherForMatchingLC.tctx2_ap_sub
                                                                  else tqPendingVoucherForMatchingLC.tctx2_ap_cn_sub
               tPendingVoucherWHTAPM.APMatchingLnTax_ID         = ? /* not linked to any tax record here */
               tPendingVoucherWHTAPM.tc_ParentRowid             = tPendingVoucherAPM.tc_Rowid
               tPendingVoucherWHTAPM.tc_Rowid                   = string(viRowidPendingVoucherWHTAPM)
               tPendingVoucherWHTAPM.tc_Status                  = "N":U
               viRowidPendingVoucherWHTAPM                      = viRowidPendingVoucherWHTAPM + 1.
        <Q-10 run VATPrim (all) (Read) (NoCache)
           (input ?, (VatId)
            input tPendingVoucherWHTAPM.tcVatCode, (VatCode)
            input ?, (DomainId)
            input tPendingVoucherWHTAPM.tcDomainCode, (DomainCode)
            input tPendingVoucherWHTAPM.tcVatInOut, (VatInOut)
            output dataset tqVATPrim) in BVAT >
        find first tqVatPrim where
                   tqVATPrim.tcVatCode = tPendingVoucherWHTAPM.tcVatCode
                   no-lock no-error.
        assign tPendingVoucherWHTAPM.tcVatDescription = if available tqVATPrim
                                                        then tqVATPrim.tcVatDescription
                                                        else "":U.
                                                        
        /* ================================================================= */                                                          
        /* Retrieve tax base for the tax code to get the tax base percentage */
        /* ================================================================= */                 
        assign tPendingVoucherWHTAPM.APMatchingLnWHTBaseTaxPct = 100.
        if tqPendingVoucherForMatchingLC.tctx2_base <> "" and
           tqPendingVoucherForMatchingLC.tctx2_base <> ?
        then do:
            <Q-52 run GeneralizedCodeForSecurity (all) (Read) (Cache)
               (input tPendingVoucherWHTAPM.tcDomainCode, (DomainCode)
                input 'txb_base', (CodeFldName)
                input tqPendingVoucherForMatchingLC.tctx2_base, (CodeValue)
                output dataset tqGeneralizedCodeForSecurity) in BMfgGeneralizedCode>
            find first tqGeneralizedCodeForSecurity where
                       tqGeneralizedCodeForSecurity.tccode_domain  = tPendingVoucherWHTAPM.tcDomainCode and
                       tqGeneralizedCodeForSecurity.tccode_fldname = 'txb_base'   and
                       tqGeneralizedCodeForSecurity.tccode_value   = tqPendingVoucherForMatchingLC.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 tPendingVoucherWHTAPM.APMatchingLnWHTBaseTaxPct = decimal(vcWHTBasePercentage) no-error.
                if error-status:error
                then assign tPendingVoucherWHTAPM.APMatchingLnWHTBaseTaxPct = 100.
            end. /* if available tqGeneralizedCodeForSecurity */
        end. /* if tqPendingVoucherForMatchingLC.tctx2_base <> "" and */                                                         
    end. /* if ilCallGTM = false and  */
    
    /* =================== */
    /* Return-status = OK  */
    /* =================== */
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.