project QadFinancials > class BVAT > method ValidateComponentPreAncestor

Description

This method is a submethod of ValidateComponent.
This method includes validations that are done before the ancestor code of ValidateComponent.
Give some fields of the vat and his sub-tables the right value.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BVAT.ValidateComponent


program code (program4/bvat.p)

/* Check the Detail VAT Rules Line definition */
for each t_sVatRule where 
         t_sVatRule.tc_status = "C":U or
         t_sVatRule.tc_status = "N":U:
         
    if t_sVatRule.tcVatPercentCode = "":U or
       t_sVatRule.tcVatPercentCode = ?
    then assign t_sVatRule.VatPercent_ID = ?.
    else do:
        <Q-8 run GetVatPercentActive (all) (Read) (NoCache)
          (input ?, (VatPercent_ID)
           input t_sVatRule.tcVatPercentCode, (VatPercentCode)
           output dataset tqGetVatPercentActive) in BVatPercent >
        find first tqGetVatPercentActive no-error.
        if available tqGetVatPercentActive
        then assign t_sVatRule.VatPercent_ID = tqGetVatPercentActive.tiVatPercent_ID.
        else do:
            <M-9 run SetMessage
          (input  #T-29'The tax percentage code is invalid or inactive.':70(3835)t-29# (icMessage), 
           input  '':U (icArguments), 
           input  'tVatRule.tcVatPercentCode':U (icFieldName), 
           input  t_sVatRule.tcVatPercentCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-270':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* not if t_sVatRule.tcVatPercentCode = "":U or */
    
    if t_sVatRule.tcInvoiceGLProfileCode = "":U or
       t_sVatRule.tcInvoiceGLProfileCode = ?
    then assign t_sVatRule.InvoiceGLProfile_ID = ?.
    else do:        
        assign vcProfileTypeVatRoleAccount = {&PROFILETYPECODE-VATCONTROLACCOUNT}.
        <Q-12 run ProfileByCodeAndType (all) (Read) (NoCache)
          (input t_sVatRule.tcInvoiceGLProfileCode, (ProfileCode)
           input vcProfileTypeVatRoleAccount, (ProfileTypeCode)
           output dataset tqProfileByCodeAndType) in BProfile >
        find first tqProfileByCodeAndType no-error.
        if available tqProfileByCodeAndType
        then assign t_sVatRule.InvoiceGLProfile_ID = tqProfileByCodeAndType.tiProfile_ID.
        else do:
            <M-11 run SetMessage
          (input  #T-30'$1 GL profile does not exist or is not of the correct type.':100(3836)t-30# (icMessage), 
           input  t_sVatRule.tcInvoiceGLProfileCode (icArguments), 
           input  'tVatRule.tcInvoiceGLProfileCode':U (icFieldName), 
           input  t_sVatRule.tcInvoiceGLProfileCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-275':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* not if t_sVatRule.tcInvoiceGLProfileCode = "":U or */

    if t_sVatRule.tcCreditNoteGLProfileCode = "":U or
       t_sVatRule.tcCreditNoteGLProfileCode = ?
    then assign t_sVatRule.CreditNoteGLProfile_ID = ?.
    else do:
        assign vcProfileTypeVatRoleAccount = {&PROFILETYPECODE-VATCONTROLACCOUNT}.
        <Q-18 run ProfileByCodeAndType (all) (Read) (NoCache)
          (input t_sVatRule.tcCreditNoteGLProfileCode, (ProfileCode)
           input vcProfileTypeVatRoleAccount, (ProfileTypeCode)
           output dataset tqProfileByCodeAndType) in BProfile >
        find first tqProfileByCodeAndType no-error.
        if available tqProfileByCodeAndType
        then assign t_sVatRule.CreditNoteGLProfile_ID = tqProfileByCodeAndType.tiProfile_ID.
        else do:
            <M-19 run SetMessage
          (input  #T-31'$1 GL profile does not exist or is not of the correct type.':100(3836)t-31# (icMessage), 
           input  t_sVatRule.tcCreditNoteGLProfileCode (icArguments), 
           input  'tVatRule.tcCreditNoteGLProfileCode':U (icFieldName), 
           input  t_sVatRule.tcCreditNoteGLProfileCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-739':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* if t_sVatRule.tcCreditNoteGLProfileCode = "":U or */

    if t_sVatRule.tcDelayedGLProfileCode = "":U or
       t_sVatRule.tcDelayedGLProfileCode = ?
    then assign t_sVatRule.DelayedGLProfile_ID = ?.
    else do:
        /* 03/10/2005 MARLAM : DELAYED VAT */
        assign vcProfileTypeVatRoleAccount = {&PROFILETYPECODE-STANDARDACCOUNT}. /*{&PROFILETYPECODE-VATCONTROLACCOUNT}*/
        <Q-13 run ProfileByCodeAndType (all) (Read) (NoCache)
          (input t_sVatRule.tcDelayedGLProfileCode, (ProfileCode)
           input vcProfileTypeVatRoleAccount, (ProfileTypeCode)
           output dataset tqProfileByCodeAndType) in BProfile >
        find first tqProfileByCodeAndType no-error.
        if available tqProfileByCodeAndType
        then assign t_sVatRule.DelayedGLProfile_ID = tqProfileByCodeAndType.tiProfile_ID.
        else do:
            <M-14 run SetMessage
          (input  #T-32'$1 GL profile does not exist or is not of the correct type.':100(3836)t-32# (icMessage), 
           input  t_sVatRule.tcDelayedGLProfileCode (icArguments), 
           input  'tVatRule.tcDelayedGLProfileCode':U (icFieldName), 
           input  t_sVatRule.tcDelayedGLProfileCode (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-276':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* not if t_sVatRule.tcDelayedGLProfileCode = "":U or */
    
    if t_sVatRule.VatRuleRef1 <> "":U                   and
       t_sVatRule.VatRuleRef1 <> ?                      and
       t_sVatRule.VatRuleRef1 <> {&VATRULEREF-INITIAL}  and
       t_sVatRule.VatRuleRef1 <> {&VATRULEREF-DISCOUNT} and
       t_sVatRule.VatRuleRef1 <> {&VATRULEREF-QUANTITY}
    then do:
        assign viReferencedSeq = integer(t_sVatRule.VatRuleRef1) no-error.
        if error-status:error or
           viReferencedSeq = ?  or
           viReferencedSeq > t_sVatRule.VatRuleSequence
        then do:
            assign vcInitialTr  = {&VATRULEREF-INITIAL-TR}
                   vcDiscountTr = {&VATRULEREF-DISCOUNT-TR}
                   vcQuantityTr = {&VATRULEREF-QUANTITY-TR}.
            <M-15 run SetMessage
          (input  #T-33'Invalid reference: reference $1 must contain a reference to one of the preceding lines or to value $2 $3 or &4.':150(3837)t-33# (icMessage), 
           input  vcInitialTr + chr(2) + vcDiscountTr + chr(2) + vcQuantityTr (icArguments), 
           input  'tVatRule.VatRuleRef1':U (icFieldName), 
           input  t_sVatRule.VatRuleRef1 (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-277':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* if t_sVatRule.VatRuleRef1 <> "":U and */

    if t_sVatRule.VatRuleRef2 <> "":U      and
       t_sVatRule.VatRuleRef2 <> ?         and
       t_sVatRule.VatRuleRef2 <> {&VATRULEREF-NONE} AND
       t_sVatRule.VatRuleRef2 <> {&VATRULEREF-INITIAL} and
       t_sVatRule.VatRuleRef2 <> {&VATRULEREF-DISCOUNT} and
       t_sVatRule.VatRuleRef2 <> {&VATRULEREF-QUANTITY}
    then do:
        assign viReferencedSeq = integer(t_sVatRule.VatRuleRef2) no-error.
        if error-status:error or
           viReferencedSeq = ?  or
           viReferencedSeq > t_sVatRule.VatRuleSequence
        then do:
            assign vcInitialTr = {&VATRULEREF-INITIAL-TR}.
            <M-17 run SetMessage
          (input  #T-34'Invalid reference: reference $1 must refer to one of the preceding lines or to value &2.':100(3838)t-34# (icMessage), 
           input  vcInitialTr (icArguments), 
           input  'tVatRule.VatRuleRef2':U (icFieldName), 
           input  t_sVatRule.VatRuleRef2 (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-278':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* if t_sVatRule.VatRuleRef2 <> "":U and */

    if t_sVatRule.VatRuleIsPosting and 
       (t_sVatRule.VatRuleMovementType = ? or
        t_sVatRule.VatRuleMovementType = "":U)
    then do:
        <M-20 run SetMessage
          (input  #T-35'The activity type is mandatory when the posting field is selected.':100(3839)t-35# (icMessage), 
           input  '':U (icArguments), 
           input  'tVatRule.VatRuleMovementType':U (icFieldName), 
           input  t_sVatRule.VatRuleMovementType (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-839':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
        assign oiReturnStatus = -1.
    end. /* if t_sVatRule.VatRuleIsPosting and  */

    if t_sVatRule.VatRuleIsPosting
    then do :
        if (t_sVatRule.tcInvoiceGLProfileCode = "":U     or t_sVatRule.tcInvoiceGLProfileCode = ?)     or
           (t_sVatRule.tcCreditNoteGLProfileCode = "":U  or t_sVatRule.tcCreditNoteGLProfileCode = ?)  or
           (t_sVatRule.tcInvoiceVatGroupCode = "":U      or t_sVatRule.tcInvoiceVatGroupCode = ?)      or
           (t_sVatRule.tcCreditNoteVatGroupCode = "":U   or t_sVatRule.tcCreditNoteVatGroupCode = ?)
        then do :
            <M-21 run SetMessage
          (input  #T-36'Accounts and/or tax groups are mandatory when the Posting field is selected.':100(3840)T-36# (icMessage), 
           input  '':U (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  t_sVatRule.tc_Rowid (icRowid), 
           input  'QADFIN-909':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVAT>
            assign oiReturnStatus = -1.
        end.
    end. /* if t_sVatRule.VatRuleIsPosting */

end. /* for each t_sVatRule where  */