project QadFinancials > class BCompanyProperty > method PreValidateComponent

Description

Validations that are done before the ancestor code of ValidateComponent


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCompanyProperty.ValidateComponent


program code (program1/bcompanyproperty.p)

for each t_sCompanyProperty where
         t_sCompanyProperty.tc_Status = "N":U or
         t_sCompanyProperty.tc_Status = "C":U:
         
    /* give fields correct value if not filled */
    if t_sCompanyProperty.CompanyPropertyOINetRestr = "":U or t_sCompanyProperty.CompanyPropertyOINetRestr = ?
    then assign t_sCompanyProperty.CompanyPropertyOINetRestr = {&COMPANYPROPERTYOINETRESTR-NONE}.
    if t_sCompanyProperty.CompanyPropertyIsOICrossCy = ?
    then assign t_sCompanyProperty.CompanyPropertyIsOICrossCy = true.
    if t_sCompanyProperty.CompanyPropertyIsCompens = ?
    then assign t_sCompanyProperty.CompanyPropertyIsCompens = true.

    /* currency code is mandatory --> retrieve it from domain */
    if t_sCompanyProperty.tcCurrencyCode = "":U  or       
       t_sCompanyProperty.tcCurrencyCode = ?
    then do:
        <Q-26 run DomainPropertyByDomainCodeID (all) (Read) (NoCache)
           (input t_sCompanyProperty.tcDomainCode, (DomainCode)
            input 0, (DomainID)
            output dataset tqDomainPropertyByDomainCodeID) in BDomainProperty >
        find tqDomainPropertyByDomainCodeID where
             tqDomainPropertyByDomainCodeID.tcDomainCode = t_sCompanyProperty.tcDomainCode
             no-lock no-error.
        if available tqDomainPropertyByDomainCodeID
        then assign t_sCompanyProperty.tcCurrencyCode = tqDomainPropertyByDomainCodeID.tcCurrencyCode.
    end.
    /* find currency_ID */
    else do:
        <Q-25 run CurrencyPrim (all) (Read) (NoCache)
           (input t_sCompanyProperty.tcCurrencyCode, (CurrencyCode)
            input 0, (Currency_ID)
            output dataset tqCurrencyPrim) in BCurrency >
        find first tqCurrencyPrim no-error.
        if available tqCurrencyPrim
        then assign t_sCompanyProperty.Currency_ID = tqCurrencyPrim.tiCurrency_ID.
        else do:
            <M-3 run SetMessage
               (input  #T-24'Invalid currency code.':200(16214)T-24# (icMessage), 
                input  '':U (icArguments), 
                input  'tCompanyProperty.tcCurrencyCode':U (icFieldName), 
                input  t_sCompanyProperty.tcCurrencyCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCompanyProperty.tc_Rowid (icRowid), 
                input  'QADFIN-37':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>    
            assign oiReturnStatus = -1.
        end.
    end.

    /* business relation code is mandatory */
    if t_sCompanyProperty.tcBusinessRelationCode = "":U  or
       t_sCompanyProperty.tcBusinessRelationCode = "?":U or
       t_sCompanyProperty.tcBusinessRelationCode = ?
    then do:
        <M-5 run SetMessage
          (input  #T-12'You must enter the business relation code.':60(1303)T-12# (icMessage), 
           input  '':U (icArguments), 
           input  'tCompanyProperty.tcBusinessRelationCode':U (icFieldName), 
           input  t_sCompanyProperty.tcBusinessRelationCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sCompanyProperty.tc_Rowid (icRowid), 
           input  'QADFIN-327':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>
        assign oiReturnStatus = -1.
    end.
    /* find businessRelation_ID */
    else do:
        <Q-8 run BusinessRelationPrim (all) (Read) (NoCache)
          (input ?, (BusinessRelationId)
           input t_sCompanyProperty.tcBusinessRelationCode, (BusinessRelationCode)
           output dataset tqBusinessRelationPrim) in BBusinessRelation >
        find first tqBusinessRelationPrim no-error.
        if available tqBusinessRelationPrim
        then assign t_sCompanyProperty.BusinessRelation_ID = tqBusinessRelationPrim.tiBusinessRelation_ID.
        else do:
            <M-7 run SetMessage
          (input  #T-13'Invalid business relation code.':60(1304)T-13# (icMessage), 
           input  '':U (icArguments), 
           input  'tCompanyProperty.tcBusinessRelationCode':U (icFieldName), 
           input  t_sCompanyProperty.tcBusinessRelationCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sCompanyProperty.tc_Rowid (icRowid), 
           input  'QADFIN-328':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>    
            assign oiReturnStatus = -1.
        end.
    end.
    if t_sCompanyProperty.tc_Status = 'C':U
    then do:
        find first t_iCompanyProperty where t_iCompanyProperty.CompanyProperty_ID = t_sCompanyProperty.CompanyProperty_ID no-error.
        if available t_iCompanyProperty and
           t_iCompanyProperty.tcUnitCode <> "":U and
           t_iCompanyProperty.tcUnitCode <> ? and
           t_iCompanyProperty.tcUnitCode <> t_sCompanyProperty.tcUnitCode
        then do:
            assign vcMessage = trim(#T-20'Cannot modify the unit of measure.':200(15824)t-20#).
            <M-9 run SetMessage (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  'tCompanyProperty.tcUnitCode':U (icFieldName), 
                     input  t_sCompanyProperty.tcUnitCode (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sCompanyProperty.tc_Rowid (icRowid), 
                     input  'QADFIN-1762':U (icFcMsgNumber), 
                     input  '' (icFcExplanation), 
                     input  '' (icFcIdentification), 
                     input  '' (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>    
                assign oiReturnStatus = -1.
        end.
    end. /* if t_sCompanyProperty.tc_Status = 'C':U */
    
    /* Validate that CompanyPropertyQtyNumDec does not exceed 10 */
    if t_sCompanyProperty.CompanyPropertyQtyNumDec > 10 and 
       (t_sCompanyProperty.tc_Status = "N":U or
        (t_sCompanyProperty.tc_Status = "C":U and 
         can-find (t_iCompanyProperty where 
                   t_iCompanyProperty.tc_Rowid                  = t_sCompanyProperty.tc_Rowid and 
                   t_iCompanyProperty.CompanyPropertyQtyNumDec <> t_sCompanyProperty.CompanyPropertyQtyNumDec)))
    then do :
        assign vcMessage = trim(substitute(#T-33'The number of decimals for quantity-fields cannot exceed &1.':254(527055150)T-33#,"10":U)).
        <M-81 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tCompanyProperty.CompanyPropertyQtyNumDec':U (icFieldName), 
            input  t_sCompanyProperty.CompanyPropertyQtyNumDec (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sCompanyProperty.tc_Rowid (icRowid), 
            input  'qadfin-326764':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCompanyProperty>    
        assign oiReturnStatus = -1.
    end. /* if t_sCompanyProperty.CompanyPropertyQtyNumDec > 10 and  */
    
end. /* for each t_sCompanyProperty where*/