project QadFinancials > class BVAT > method ValidateComponentCheckVatGroups

Description

This method is a submethod of ValidateComponent.
This method includes validations of the vat groups that are done after the ancestor code of ValidateComponent.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BVAT.ValidateComponent


program code (program4/bvat.p)

/* ====================================================================================================================== */
    /* The first (based on VatRuleSequence) VatRule of a Vat should have the VatGroups for the invoice and credit-note filled */
    /* This concerns fields VatRule.InvoiceVatGroupID and VatRule.CreditNoteVatGroupID                                        */
    /* The second (optional) VatRule of a Vat should either have the Absorded, either the Retained VatGroups filled depending */
    /* upon the VatIsRetained and VatIsAbsorded properties. This concerns fields VatRule.AbsordedInvoiceVatGroupID,           */ 
    /* VatRule.AbsordedCreditNVatGroupID, VatRule.RetainVoucherVatGroupID and VatRule.RetainCVoucherVatGroupID                */
    /* ====================================================================================================================== */
    for each t_sVat where 
             t_sVat.tc_status <> "D":U and 
             can-find (first t_sVatRule where 
                             t_sVatRule.tc_ParentRowid  = t_sVat.tc_Rowid and 
                             t_sVatRule.tc_Status      <> "":U) :
                                                                                        
        /* ========================================================================== */
        /* Each vat-records should have a vat-rule with the 2 normal vatgroups filled */
        /* in (fields VatRule.InvoiceVatGroup_ID and VatRule.CreditNoteVatGroup_ID)   */
        /* ========================================================================== */
        if not can-find (first t_sVatRule where 
                               t_sVatRule.tc_ParentRowid         = t_sVat.tc_Rowid  and 
                               t_sVatRule.tc_Status             <> "D":U            and
                               t_sVatRule.InvoiceVatGroup_ID    <> 0                and 
                               t_sVatRule.CreditNoteVatGroup_ID <> 0                and
                               t_sVatRule.InvoiceVatGroup_ID    <> ?                and 
                               t_sVatRule.CreditNoteVatGroup_ID <> ?)
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-23'A tax-record (&1) was detected that does not have a tax rate with the two normal tax groups specified.':255(68755)t-23#,t_sVat.VatCode)) + chr(10) + 
                                    trim(substitute(#T-24'Current domain: &1.':200(64036)T-24#,vcDomainCode)).
            <M-21 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tVat.VatCode':U (icFieldName), 
                input  t_sVat.VatCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sVat.tc_Rowid (icRowid), 
                input  'QadFin-6650':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BVAT>
        end. /* if not can-find */
        
        /* ====================================================================================================== */
        /* Each vat-records with the IsAbsorbed-flag is turned on, should be a vatrule-record with the 2 absorbed */
        /* vatgroups filled in (fields VatRule.AbsorbedInvoiceVatGroup_ID and VatRule.AbsorbedCreditNVatGroup_ID) */
        /* ====================================================================================================== */
        if t_sVat.VatIsAbsorbed = true and 
           not can-find (first t_sVatRule where 
                               t_sVatRule.tc_ParentRowid              = t_sVat.tc_Rowid  and 
                               t_sVatRule.tc_Status                  <> "D":U            and
                               t_sVatRule.AbsorbedInvoiceVatGroup_ID <> 0                and 
                               t_sVatRule.AbsorbedCreditNVatGroup_ID <> 0                and
                               t_sVatRule.AbsorbedInvoiceVatGroup_ID <> ?                and 
                               t_sVatRule.AbsorbedCreditNVatGroup_ID <> ?)
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-26'A tax-record (&1) that is enabled for Absorbed taxes was detected that does not have a tax rate with the two required absorbed tax groups specified.':255(68756)T-26#,t_sVat.VatCode)) + chr(10) + 
                                    trim(substitute(#T-27'Current domain: &1.':200(64036)T-27#,vcDomainCode)).
            <M-25 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tVat.VatCode':U (icFieldName), 
                input  t_sVat.VatCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sVat.tc_Rowid (icRowid), 
                input  'QadFin-6651':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BVAT>
        end. /* if not can-find */
        
        /* ====================================================================================================== */
        /* Each vat-records with the IsRetained-flag is turned on, should be a vatrule-record with the 2 retained */
        /* vatgroups filled in (fields VatRule.RetainVoucherVatGroup_ID and VatRule.RetainCVoucherVatGroup_ID)   */
        /* ====================================================================================================== */
        if t_sVat.VatIsRetained = true and 
           not can-find (first t_sVatRule where 
                               t_sVatRule.tc_ParentRowid             = t_sVat.tc_Rowid  and 
                               t_sVatRule.tc_Status                 <> "D":U            and
                               t_sVatRule.RetainVoucherVatGroup_ID  <> 0                and 
                               t_sVatRule.RetainCVoucherVatGroup_ID <> 0                and
                               t_sVatRule.RetainVoucherVatGroup_ID  <> ?                and 
                               t_sVatRule.RetainCVoucherVatGroup_ID <> ?)
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-29'A tax-record (&1) that is enabled for Retained taxes was detected that does not have a tax rate with the two required retained tax groups specified.':255(68757)T-29#,t_sVat.VatCode)) + chr(10) + 
                                    trim(substitute(#T-30'Current domain: &1.':200(64036)T-30#,vcDomainCode)).
            <M-28 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tVat.VatCode':U (icFieldName), 
                input  t_sVat.VatCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sVat.tc_Rowid (icRowid), 
                input  'QadFin-6652':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BVAT>
        end. /* if not can-find */
        
    end. /* for each t_sVat where  */