project QadFinancials > class BDeductionCat > method GetDeductionStatus

Description

Get Status of Deduction Line


Parameters


icDomainCodeinputcharacter
idAmountinputdecimal
icCurrencyCodeinputcharacter
ocStatusoutputcharacter
itTransactionDateinputdate
icDedCatCodeinputcharacter
ocStatusForPreProcessoroutputcharacterReturn Status string with PreProcessor format
ilIsExchangeRateGiveninputlogical
idGivenExchangeRateinputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDDocument.ApiGetDeductionStatus
method BDeductionCat.ApiGetDeductionStatus


program code (program3/bdeductioncat.p)

assign
   ocStatus = ""
   ocStatusForPreProcessor = "".

<Q-39 run DomainPropertyByDomainCodeID (first) (Read) (NoCache)
   (input icDomainCode, (DomainCode)
    input ?, (DomainID)
    output dataset tqDomainPropertyByDomainCodeID) in BDomainProperty>

find first tqDomainPropertyByDomainCodeID no-error.

if not available(tqDomainPropertyByDomainCodeID)  then
do:
   vcMessage = #T-33'Invalid Domain Code':255(750394444)T-33#.
   <M-83 run SetMessage
          (input  vcMessage (icMessage), 
           input  ? (icArguments), 
           input  'icDomainCode':U (icFieldName), 
           input  icDomainCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  ? (icRowid), 
           input  'qadfin-755438':U (icFcMsgNumber), 
           input  ? (icFcExplanation), 
           input  ? (icFcIdentification), 
           input  ? (icFcContext), 
           output oiReturnStatus (oiReturnStatus)) in BDeductionCat>

   return.
end.


 <Q-31 run GetDeductionByCodeDomain (first) (Read) (NoCache)
    (input icDomainCode, (DomainCode)
     input icDedCatCode, (DeductionCatCode)
     output dataset tqGetDeductionByCodeDomain) in BDeductionCat>

find first tqGetDeductionByCodeDomain no-error.

if not available(tqGetDeductionByCodeDomain) then
do:
   vcMessage = #T-98'Invalid Deduction Category Code':255(957933114)T-98#.
   <M-8 run SetMessage
          (input  vcMessage (icMessage), 
           input  ? (icArguments), 
           input  'icDeductionCatCode':U (icFieldName), 
           input  icDedCatCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  ? (icRowid), 
           input  'qadfin-682012':U (icFcMsgNumber), 
           input  ? (icFcExplanation), 
           input  ? (icFcIdentification), 
           input  ? (icFcContext), 
           output oiReturnStatus (oiReturnStatus)) in BDeductionCat>
   
   return.
end.

if tqGetDeductionByCodeDomain.tcDeductionCatType <> {&DEDUCTIONCATTYPE-STANDARD} then
do:
   assign
      ocStatus = #T-12'Pending':20(310903858)T-12#
      ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-PENDING}.
   
   return.
end.

/*AutoWriteOff = false, return PENDING*/
if not tqGetDeductionByCodeDomain.tlDeductionCatLineIsAutoWriteOff then
do:
   assign
      ocStatus = #T-30'Pending':20(310903858)T-30#
      ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-PENDING}.
   return.
end.

/* Using the given exchange rate to decide the deduction status */
if ilIsExchangeRateGiven
then do:
    if tqGetDeductionByCodeDomain.tdDeductionCatWriteOffLimit >= idAmount * idGivenExchangeRate then
     do:
        assign
           ocStatus = #T-59'Auto Write-Off':25(663429119)T-59# 
           ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-WRITE-OFF}.
        return.
     end.
     else
     do:
        assign
           ocStatus =  #T-19'Pending':20(310903858)T-19#
           ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-PENDING}.
        return.
     end. 
    return.
end.

/* Autowrite off = true */
/*TC = BC*/
if icCurrencyCode = tqDomainPropertyByDomainCodeID.tcCurrencyCode then
do:
   if tqGetDeductionByCodeDomain.tdDeductionCatWriteOffLimit >= idAmount then
   do:
      assign
         ocStatus = #T-7'Auto Write-Off':25(663429119)T-7# 
         ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-WRITE-OFF}.
      return.              
   end.
   else
   do:
      assign
         ocStatus = #T-56'Pending':20(310903858)T-56#
         ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-PENDING}.
      return.
   end.
end.
else
do:
    if itTransactionDate = ? then
       itTransactionDate = today.
    
    <M-61 run GetExchangeRate
       (input  ? (iiCompanyID), 
        input  ? (iiFromCurrencyID), 
        input  icCurrencyCode (icFromCurrencyCode), 
        input  ? (iiToCurrencyID), 
        input  tqDomainPropertyByDomainCodeID.tcCurrencyCode (icToCurrencyCode), 
        input  ? (iiExchangeRateTypeID), 
        input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
        input  itTransactionDate (itValidityDate), 
        output vdExchangeRateTCtoRC (odExchangeRate), 
        output vdExchangeRateScaleFactor (odExchangeScaleFactor), 
        output oiReturnStatus (oiReturnStatus)) in BDeductionCat>
    
     if oiReturnStatus < 0 then 
     do:
        assign oiReturnStatus = -1.    
        return.
     end.
     
     vdExchangeRateTCtoRC = vdExchangeRateTCtoRC * vdExchangeRateScaleFactor.
     if tqGetDeductionByCodeDomain.tdDeductionCatWriteOffLimit >= idAmount *  vdExchangeRateTCtoRC then
     do:
        assign
           ocStatus = #T-3'Auto Write-Off':25(663429119)T-3# 
           ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-WRITE-OFF}.
        return.
     end.
     else
     do:
        assign
           ocStatus =  #T-36'Pending':20(310903858)T-36#
           ocStatusForPreProcessor = {&INVOICEDEDUCTSTATUS-PENDING}.
        return.
     end.    
end.