project QadFinancials > class BFixedAssetRevaluation > method RevaluationCreateVal

Description

Validation of input parameters of the RevaluationCreate method.
NOTE: All these RevaluationCreate... methods should be in one segment


Parameters


icFAAssetCodeinputcharacterAsset Code
icFAAssetTypeCodeinputcharacterAsset type
icFABookTypeCodeinputcharacterBook type
ilIsRevalChildreninputlogicalIndicate whether you want to revaluate sub-assests too
icFARevalTypeinputcharacterType of revaluation
idFARevalPercentageinputdecimalRevaluation percentage, e.g +10 or -10
icFARevalIndexTypeinputcharacterIndex revaluation type
idFARevalAmountLCinputdecimalRevaluation Amount in LC
iiAccPeriodYearinputintegerAccounting Year
iiAccPeriodPeriodinputintegeraccounting period
itPostingDateinputdateposting date
oiFAAssetIdoutputintegerFAAssetId
oiFAAssetTypeIdoutputintegerFAAssetTypeID
oiFABookTypeIdoutputintegerFABookTypeId
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BFixedAssetRevaluation.RevaluationCreate


program code (program3/bfixedassetrevaluation.p)

/*AssetTypeCode, BookTypeCode and AssetCode can not all be left blank.*/
if icFAAssetCode = "":U and
   icFAAssetTypeCode = "":U and
   icFABookTypeCode = "":U
then do:
    assign vcMessage = trim(#T-13'You should have specified the asset, the asset type or the book type before running the revaluation procedure.':200(13915)T-13#)
           oiReturnStatus = -1.
    <M-3 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-3125':U (icFcMsgNumber), 
                     input  '':U (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
    return.
end.   
/*The selected AssetTypeCode must exist*/
if icFAAssetTypeCode <> "":U
then do:
    <Q-6 run FAAssetTypePrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (FAAssetTypeID)
           input icFAAssetTypeCode, (FAAssetTypeCode)
           output dataset tqFAAssetTypePrim) in BFixedAssetAssetType >
    find first tqFAAssetTypePrim no-error.
    if available tqFAAssetTypePrim
    then assign oiFAAssetTypeId = tqFAAssetTypePrim.tiFAAssetType_ID.
    else do:
        assign vcMessage = trim(#T-5'The specified asset type code is not defined in the system.':100(13905)t-5#)
               oiReturnStatus = -1.
        <M-4 run SetMessage (input  vcMessage (icMessage), 
                         input  '':U (icArguments), 
                         input  '':U (icFieldName), 
                         input  icFAAssetTypeCode (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  '':U (icRowid), 
                         input  'QADFIN-3127':U (icFcMsgNumber), 
                         input  '':U (icFcExplanation), 
                         input  '':U (icFcIdentification), 
                         input  '':U (icFcContext), 
                         output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
    end.
end.

/*The selected BookTypeCode must exist*/
if icFABookTypeCode <> "":U
then do:
    <Q-9 run FABookTypePrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (FABookTypeID)
           input icFABookTypeCode, (FABookTypeCode)
           output dataset tqFABookTypePrim) in BFixedAssetBookType >
    find first tqFABookTypePrim no-error.
    if available tqFABookTypePrim
    then assign oiFABookTypeId = tqFABookTypePrim.tiFABookType_ID.
    else do:
        assign vcMessage = trim(#T-8'The specified book type code is not defined in the system.':100(13925)t-8#)
               oiReturnStatus = -1.
        <M-7 run SetMessage (input  vcMessage (icMessage), 
                         input  '':U (icArguments), 
                         input  '':U (icFieldName), 
                         input  icFABookTypeCode (icFieldValue), 
                         input  'E':U (icType), 
                         input  3 (iiSeverity), 
                         input  '':U (icRowid), 
                         input  'QADFIN-3129':U (icFcMsgNumber), 
                         input  '':U (icFcExplanation), 
                         input  '':U (icFcIdentification), 
                         input  '':U (icFcContext), 
                         output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
    end.
end.
/*The selected AssetCode must exist*/
if icFAAssetCode <> "":U
then do:
    <Q-12 run FAAssetPrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (FAAssetID)
           input icFAAssetCode, (FAAssetCode)
           output dataset tqFAAssetPrim) in BFixedAssetAsset >
    find first tqFAAssetPrim no-error.
    if available tqFAAssetPrim
    then assign oiFAAssetId = tqFAAssetPrim.tiFAAsset_ID.
    else do:
        assign vcMessage = trim(#T-11'The specified asset code is not defined in the system.':100(13914)t-11#)
               oiReturnStatus = -1.
        <M-10 run SetMessage (input  vcMessage (icMessage), 
                          input  '':U (icArguments), 
                          input  '':U (icFieldName), 
                          input  icFAAssetCode (icFieldValue), 
                          input  'E':U (icType), 
                          input  3 (iiSeverity), 
                          input  '':U (icRowid), 
                          input  'QADFIN-3133':U (icFcMsgNumber), 
                          input  '':U (icFcExplanation), 
                          input  '':U (icFcIdentification), 
                          input  '':U (icFcContext), 
                          output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
    end.
end.
/*AssetCode must be filled when the RevaluateChildren flag is enabled.*/
if icFAAssetCode = "":U and 
   ilIsRevalChildren
then do:
    assign vcMessage = trim(#T-15'You must specify an asset code if when you want to dispose child assets.':200(2045)T-15#)
           oiReturnStatus = -1.
    <M-14 run SetMessage (input  vcMessage (icMessage), 
                      input  '':U (icArguments), 
                      input  '':U (icFieldName), 
                      input  icFAAssetCode (icFieldValue), 
                      input  'E':U (icType), 
                      input  3 (iiSeverity), 
                      input  '':U (icRowid), 
                      input  'QADFIN-3134':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*RevaluationType is mandatory*/    
if icFARevalType = "":U
then do:
    assign vcMessage = trim(#T-39'You must enter the revaluation type.':200(14307)T-39#)
           oiReturnStatus = -1.
    <M-38 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-3243':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.

/*When RevaluationType = {&REVALUATIONTYPE-PERCENTAGE}, the RevaluationIndexType and RevaluationPercentage should be entered.*/
if icFARevalType = {&FAREVALTYPE-PERCENTAGE} and 
  (icFARevalIndexType = "":U or 
   idFARevalPercentage = 0)
then do:
    assign vcMessage = trim(subst(#T-20'You must specify the index revaluation type and percentage when the revaluation type is '&1'.':200(13961)t-20#,
                            {&FAREVALTYPE-PERCENTAGE-TR}))
           oiReturnStatus = -1.
    <M-16 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-3144':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.

/*When RevaluationType = {&REVALUATIONTYPE-PERCENTAGE}, the RevaluationValue should be blank.*/
if icFARevalType = {&FAREVALTYPE-PERCENTAGE} and 
   idFARevalAmountLC <> 0
then do:
    assign vcMessage = trim(subst(#T-21'The revaluation value must be zero when the revaluation type is '&1'.':200(13962)t-21#,
                            {&FAREVALTYPE-PERCENTAGE-TR}))
           oiReturnStatus = -1.
    <M-17 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-3145':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.

/*When RevaluationType = {&REVALUATIONTYPE-VALUE}, the RevaluationValue should be entered.*/
if icFARevalType = {&FAREVALTYPE-VALUE} and 
  idFARevalAmountLC = 0
then do:
    assign vcMessage = trim(subst(#T-22'The revaluation value must be specified when the revaluation type is '&1'.':200(13966)t-22#,
                            {&FAREVALTYPE-VALUE-TR}))
           oiReturnStatus = -1.
    <M-18 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-3146':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
/*When RevaluationType = {&REVALUATIONTYPE-VALUE}, the RevaluationIndexType and RevaluationPercenatage should be blank.*/
if icFARevalType = {&FAREVALTYPE-VALUE} and 
  (icFARevalIndexType <> "":U or 
   idFARevalPercentage <> 0)
then do:
    assign vcMessage = trim(subst(#T-23'You cannot specify an index revaluation type and percentage when the revaluation type is '&1'.':200(13967)t-23#,
                            {&FAREVALTYPE-VALUE-TR}))
           oiReturnStatus = -1.
    <M-19 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-3147':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.

/*The Accounting Year / Period must exist ... */
if iiAccPeriodYear > 0 and
   iiAccPeriodPeriod > 0
then do:
    <Q-24 run PeriodByYearPeriod (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input iiAccPeriodYear, (PeriodYear)
           input iiAccPeriodPeriod, (PeriodPeriod)
           input ?, (PeriodId)
           output dataset tqPeriodByYearPeriod) in BPeriod >
    find first tqPeriodByYearPeriod no-error.
end.

if iiAccPeriodYear = 0 or 
   iiAccPeriodPeriod = 0 or   
  (available tqPeriodByYearPeriod and
  (tqPeriodByYearPeriod.tcPeriodTypeCode <> {&PERIODTYPECODE-NORMAL} or 
   tqPeriodByYearPeriod.tcPeriodStatus <> {&PERIODSTATUS-OPEN} or
   tqPeriodByYearPeriod.tlPeriodIsPostingGLAllowed = false))
then do:
    assign vcMessage = trim(subst(#T-26'The specified GL period: &1/&2 is invalid.':200(3565)t-26#,
                            string(iiAccPeriodYear, "9999":U),
                            string(iiAccPeriodPeriod, "99":U))) + " ":U +  
                       trim(#T-32'You must specify a valid GL calendar year and GL period before running the revaluation procedure.':200(13971)T-32#) + " ":U +
                       trim(subst(#T-27'Only normal and open GL periods that allow GL postings are valid.':200(13970)T-27#))
           oiReturnStatus = -1.
    <M-28 run SetMessage (input  vcMessage (icMessage), 
                      input  '':U (icArguments), 
                      input  '':U (icFieldName), 
                      input  '':U (icFieldValue), 
                      input  '':U (icType), 
                      input  '':U (iiSeverity), 
                      input  '':U (icRowid), 
                      input  'QADFIN-3151':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
else assign viFARevalAccPeriodYear   = iiAccPeriodYear 
            viFARevalAccPeriodPeriod = iiAccPeriodPeriod.
            
/*The Posting date must specified and must be within the limits of the selected accounting year / period*/
if itPostingDate = ? or
  (itPostingDate <> ? and
   available tqPeriodByYearPeriod and   
   not (itPostingDate >= tqPeriodByYearPeriod.ttPeriodStartDate and
        itPostingDate <= tqPeriodByYearPeriod.ttPeriodEndDate))
then do:
    assign vcMessage = trim(#T-36'You must specify a valid posting date before running the revaluation procedure.':200(13987)t-36#) + " ":U +
                       if itPostingDate <> ? and available tqPeriodByYearPeriod
                       then trim(subst(#T-37'The posting date must be between the start (&1) and end (&2) dates of the selected GL period (&3/&4).':200(68659)t-37#,
                            string(tqPeriodByYearPeriod.ttPeriodStartDate),
                            string(tqPeriodByYearPeriod.ttPeriodEndDate),
                            string(tqPeriodByYearPeriod.tiPeriodYear, "9999":U),
                            string(tqPeriodByYearPeriod.tiPeriodPeriod, "99":U)))
                       else "":U
           oiReturnStatus = -1.
    <M-34 run SetMessage (input  vcMessage (icMessage), 
                      input  '':U (icArguments), 
                      input  '':U (icFieldName), 
                      input  '':U (icFieldValue), 
                      input  '':U (icType), 
                      input  '':U (iiSeverity), 
                      input  '':U (icRowid), 
                      input  'QADFIN-3159':U (icFcMsgNumber), 
                      input  '':U (icFcExplanation), 
                      input  '':U (icFcIdentification), 
                      input  '':U (icFcContext), 
                      output viFcReturnSuper (oiReturnStatus)) in BFixedAssetRevaluation>
end.
else assign vtFARevalPostingDate = itPostingDate.