project QadFinancials > class BPosting > method DataLoadByInputVatRule

Description

Set the VatRule for the tPostingVat record


Parameters


blQStartedVatRuleByVatIDCodeinput-outputlogicalLogical to store whether this query has been started
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.DataLoadByInput


program code (program2/bposting.p)

/* ========================================================== */
/* Fill in bVatRule_id                                         */
/* Get all VatRules for this Vat_id and use the same sequence */
/* ========================================================== */
if t_sPostingVat.tcVatCode <> "":U or 
   t_sPostingVat.tcVatCode <> ?
then do:
    if blQStartedVatRuleByVatIDCode = false
    then do :
        <Q-30 run VatRuleByVatIDCode  (Start) in BVAT >
        assign blQStartedVatRuleByVatIDCode = true.
    end. /* if blQStartedVatRuleByVatIDCode = false */
    <Q-70 run VatRuleByVatIDCode (all) (Read) (Cache)
       (input t_sPostingVat.tcVatCode, (VatCode)
        input ?, (VatID)
        input {&VATRULEBASE-FULL}, (VatRuleBaseFull)
        input t_sPostingVat.tcVatInOut, (VatInOut)
        input t_sPostingVat.tcDomainCode, (DomainCode)
        output dataset tqVatRuleByVatIDCode) in BVAT >
    if t_sPostingVat.PostingVatIsAbsRet = true
    then find last tqVatRuleByVatIDCode where
               tqVatRuleByVatIDCode.tcVatCode         = t_sPostingVat.tcVatCode and
               tqVatRuleByVatIDCode.tcVatInOut        = t_sPostingVat.tcVatInOut and
               tqVatRuleByVatIDCode.tcDomainCode      = t_sPostingVat.tcDomainCode and
               tqVatRuleByVatIDCode.tcVatRuleBaseFull = {&VATRULEBASE-FULL}
               no-error. /* First one gives the normal tax - the second one gives the one for retained and absorbed taxes: this needs to be made conditional (first-lat) based upon a new field in PostingVat */
    else find first tqVatRuleByVatIDCode where
                tqVatRuleByVatIDCode.tcVatCode         = t_sPostingVat.tcVatCode and
                tqVatRuleByVatIDCode.tcVatInOut        = t_sPostingVat.tcVatInOut and
                tqVatRuleByVatIDCode.tcDomainCode      = t_sPostingVat.tcDomainCode and
                tqVatRuleByVatIDCode.tcVatRuleBaseFull = {&VATRULEBASE-FULL}
                no-error. /* First one gives the normal tax - the second one gives the one for retained and absorbed taxes: this needs to be made conditional (first-lat) based upon a new field in PostingVat */
    if not available tqVatRuleByVatIDCode
    then do:
        assign vcMessage      = trim(substitute(#T-26'Internal error: the tax-posting-line cannot be created as the Vat-rule cannot be found based upon the Domain (&1), Tax-code (&2) and Tax-direction (&3).':255(332065953)T-26#,t_sPostingVat.tcDomainCode,t_sPostingVat.tcVatCode,t_sPostingVat.tcVatInOut))
           oiReturnStatus = -3.
        <M-59 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-592256':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BPosting>
        Return.
    end. /* if not available tqVatRuleByVatIDCode */
    assign t_sPostingVat.VatRule_ID = tqVatRuleByVatIDCode.tiVatRule_ID.
end.