project QadFinancials > class BPosting > method GetPostingVatID


Parameters


icDomainCodeinputcharacter
icTxclTaxClsinputcharacter
icTxenvTaxEnvinputcharacter
icTxuTaxUsageinputcharacter
icVatCodeinputcharacter
icVatInOutinputcharacter
iiPostingIDinputinteger
oiPostingVatIDoutputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ApiStdMaintainTTWithExtPost
method BCInvoiceJournalEntry.ApiStdMaintainTTSub
method BDInvoiceJournalEntry.ApiStdMaintainTT


program code (program6/bposting.p)

    
    /* Exception handling */
    oiReturnStatus = -98.
    
    /* Find the Posting */
    find first tPosting where 
               tPosting.Posting_ID = iiPostingID 
               no-lock no-error.
    if not available tPosting
    then do:
        vcMsg = trim(#T-18'The posting does not exist ($1).':255(69144)T-18#).
    	<M-90 run SetMessage
        (input  vcMsg (icMessage), 
         input  string(iipostingID) (icArguments), 
         input  '':U (icFieldName), 
         input  '':U (icFieldValue), 
         input  'E':U (icType), 
         input  1 (iiSeverity), 
         input  '':U (icRowid), 
         input  'qadfin-182689':U (icFcMsgNumber), 
         input  '':U (icFcExplanation), 
         input  '':U (icFcIdentification), 
         input  '':U (icFcContext), 
         output viFcReturnSuper (oiReturnStatus)) in BPosting>
    	  oiReturnStatus = -1.
    	return.
    end. /* if not available tPosting */
    
    /* Look for a PostingVat that completely fits the input */    	
    assign vlMatchFound = false.
    for each tPostingLine where 
             tPostingLine.tc_ParentRowid = tPosting.tc_Rowid,
        each tPostingVat where 
             tPostingVat.tc_ParentRowid     = tPostingLine.tc_Rowid and
             tPostingVat.TxclTaxCls         = icTxclTaxCls          and
             tPostingVat.TxuTaxUsage        = icTxuTaxUsage         and
             tPostingVat.TxenvTaxEnv        = icTxenvTaxEnv         and
             tPostingVat.tcVatCode          = icVatCode             and
             tPostingVat.tcVatInOut         = icVatInOut            and
             tPostingVat.tcDomainCode       = icDomainCode          and
             tPostingVat.PostingVatIsAbsRet = false:
        if vlMatchFound = false 
        then assign oiPostingVatID   = tPostingVat.PostingVat_ID
                    vlMatchFound     = true.
        else do:
            assign vcMsgExplanation = <M-51 GetErrorExplanation
                                         (input  tPosting.tc_Rowid (icPostingRowId), 
                                          input  tPostingLine.tc_Rowid (icPostingLineRowId), 
                                          output viFcReturnSuper (oiReturnStatus)) in BPosting>
                   vcMsg = trim(#T-46'More then one PostingVat found for specified unique tax data.':255(835265263)T-46#).
    	    <M-60 run SetMessage
            (input  vcMsg (icMessage), 
             input  '':U (icArguments), 
             input  '':U (icFieldName), 
             input  '':U (icFieldValue), 
             input  'E':U (icType), 
             input  1 (iiSeverity), 
             input  '':U (icRowid), 
             input  'qadfin-573577':U (icFcMsgNumber), 
             input  vcMsgExplanation (icFcExplanation), 
             input  '':U (icFcIdentification), 
             input  '':U (icFcContext), 
             output viFcReturnSuper (oiReturnStatus)) in BPosting>
    	    assign oiReturnStatus = -1.
    	    return.
    	end. /* Not if vlMatchFound = false */        
    end. /* for each tPostingLine where */
    
    /* If no PostingVat found yet then look with less criteria */
    if oiPostingVatID = 0  or 
       oiPostingVatID = ?
    then do :
        assign vlMatchFound = false.
        for each tPostingLine where 
                 tPostingLine.tc_ParentRowid = tPosting.tc_Rowid,
            each tPostingVat where 
                 tPostingVat.tc_ParentRowid     = tPostingLine.tc_Rowid and
                 tPostingVat.tcVatCode          = icVatCode             and
                 tPostingVat.tcVatInOut         = icVatInOut            and
                 tPostingVat.tcDomainCode       = icDomainCode          and
                 tPostingVat.PostingVatIsAbsRet = false:
            if vlMatchFound = false 
            then assign oiPostingVatID   = tPostingVat.PostingVat_ID
                        vlMatchFound     = yes.
            else assign oiPostingVatID = 0.
        end. /* for each tPostingLine where */
    end. /*  if oiPostingVatID = 0  or */
    if oiPostingVatID = 0  or 
       oiPostingVatID = ?
    then do :
        assign vlMatchFound = false. 
        for each tPostingLine where 
                 tPostingLine.tc_ParentRowid = tPosting.tc_Rowid,
            each tPostingVat where 
                 tPostingVat.tc_ParentRowid     = tPostingLine.tc_Rowid and
                 tPostingVat.tcVatCode          = icVatCode             and
                 tPostingVat.PostingVatIsAbsRet = false:
            if vlMatchFound = false 
            then assign oiPostingVatID   = tPostingVat.PostingVat_ID
                        vlMatchFound     = yes.
            else assign oiPostingVatID = 0.
        end. /* for each tPostingLine where */
    end. /*  if oiPostingVatID = 0  or */
    
    /* Exception handling */
    assign oiReturnStatus = 0.