<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="TRI_KEY" fieldtype="string.uni" SUBTYPE="FixedChar" WIDTH="62">
<PARAM Name="ORIGIN" Value="RDB$TRIGGER_NAME" Roundtrip="True"/>
</FIELD>
<FIELD attrname="TAB" fieldtype="string.uni" SUBTYPE="FixedChar" WIDTH="62">
<PARAM Name="ORIGIN" Value="RDB$RELATION_NAME" Roundtrip="True"/>
</FIELD>
<FIELD attrname="TIP" fieldtype="string" SUBTYPE="FixedChar" WIDTH="33">
<PARAM Name="PROVFLAGS" Value="0" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="TIP" Roundtrip="True"/>
</FIELD>
<FIELD attrname="FONTE_FB" fieldtype="bin.hex" SUBTYPE="Text">
<PARAM Name="PROVFLAGS" Value="1" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="RDB$TRIGGER_SOURCE" Roundtrip="True"/>
</FIELD>
</FIELDS>
<PARAMS DEFAULT_ORDER="1"/>
</METADATA>
<ROWDATA>
<ROW TRI_KEY="CALCULOPROFBI" TAB="CALCULOPROF" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.SEQ is null) then&#013;&#010;    new.SEQ = GEN_ID(GEN_SEQCALCULOPROF, 1);&#013;&#010;  else&#013;&#010;    if (new.SEQ &gt; GEN_ID(GEN_SEQCALCULOPROF, 0)) then&#013;&#010;      i = GEN_ID(GEN_SEQCALCULOPROF, new.SEQ - GEN_ID(GEN_SEQCALCULOPROF, 0));&#013;&#010;end"/>
<ROW TRI_KEY="CAMPOVALORESISS_BI" TAB="CAMPOVALORESISS" TIP="BEFORE INSERT" FONTE_FB="AS &#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0); &#013;&#010;BEGIN &#013;&#010;  IF (NEW.CODIGOVALOR IS null) THEN &#013;&#010;    NEW.CODIGOVALOR = GEN_ID(GEN_CAMPOVALORESISS, 1); &#013;&#010;  ELSE &#013;&#010;  BEGIN &#013;&#010;    tmp = GEN_ID(GEN_CAMPOVALORESISS, 0); &#013;&#010;    if (tmp &lt; new.CODIGOVALOR) then &#013;&#010;      tmp = GEN_ID(GEN_CAMPOVALORESISS, new.CODIGOVALOR-tmp); &#013;&#010;  END &#013;&#010;END"/>
<ROW TRI_KEY="CESTBI" TAB="CEST" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i INTEGER;&#013;&#010;begin&#013;&#010;  if (new.CODIGOCEST is null) then&#013;&#010;    new.CODIGOCEST = GEN_ID(GEN_CODIGOCEST, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CODIGOCEST &gt; GEN_ID(GEN_CODIGOCEST, 0)) then&#013;&#010;      i = GEN_ID(GEN_CODIGOCEST, new.CODIGOCEST - GEN_ID(GEN_CODIGOCEST, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="CHEQUEDETALHEAD" TAB="CHEQUEDETALHE" TIP="AFTER DELETE" FONTE_FB="AS&#013;&#010;declare variable AStatusAtual smallint;&#013;&#010;begin&#013;&#010;  select FIRST 1 CHD.STATUSCHEQUE from CHEQUEDETALHE CHD&#013;&#010;  where CHD.CODIGOESCRIT = OLD.CODIGOESCRIT&#013;&#010;    and CHD.CODIGOCHEQUE = OLD.CODIGOCHEQUE&#013;&#010;  order by CHD.SEQCHEQUEDET desc&#013;&#010;  into :AStatusAtual;&#013;&#010;  if (AStatusAtual &gt; 0) then&#013;&#010;  begin&#013;&#010;    update FPRCHEQUE set&#013;&#010;    FPRCHEQUE.STATUSCHEQUE = :AStatusAtual&#013;&#010;     where FPRCHEQUE.CODIGOESCRIT = OLD.CODIGOESCRIT&#013;&#010;       and FPRCHEQUE.CODIGOCHEQUE = OLD.CODIGOCHEQUE;&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="CHEQUEDETALHEAI" TAB="CHEQUEDETALHE" TIP="AFTER INSERT" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  update FPRCHEQUE set&#013;&#010;  FPRCHEQUE.STATUSCHEQUE = NEW.STATUSCHEQUE&#013;&#010;  where FPRCHEQUE.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and FPRCHEQUE.CODIGOCHEQUE = NEW.CODIGOCHEQUE;&#013;&#010;end"/>
<ROW TRI_KEY="CLCREQUESTBI" TAB="CLCREQUEST" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.ID IS NULL) THEN&#013;&#010;    NEW.ID = GEN_ID(GENCLCREQUEST, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GENCLCREQUEST, 0);&#013;&#010;    if (tmp &lt; new.ID) then&#013;&#010;      tmp = GEN_ID(GENCLCREQUEST, new.ID-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="DEBITOFOLHABI" TAB="DEBITOFOLHA" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(18,0);&#013;&#010;begin&#013;&#010;  if (new.CHAVEDEBITOFOLHA is null) then&#013;&#010;    new.CHAVEDEBITOFOLHA = GEN_ID(GEN_CHAVEDEBITOFOLHA, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CHAVEDEBITOFOLHA &gt; GEN_ID(GEN_CHAVEDEBITOFOLHA, 0)) then&#013;&#010;      i = GEN_ID(GEN_CHAVEDEBITOFOLHA, new.CHAVEDEBITOFOLHA - GEN_ID(GEN_CHAVEDEBITOFOLHA, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="DUPLICATASAIPGTOBD" TAB="DUPLICATASAIPGTO" TIP="BEFORE DELETE" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  delete from LCTOFISSAIRETIDOPAGAMENTO&#013;&#010;  where CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;  and CODIGOESTAB = old.CODIGOESTAB&#013;&#010;  and CHAVEDUPLICATASAI = old.CHAVEDUPLICATASAI&#013;&#010;  and NUMEROPARCELA = old.NUMEROPARCELA&#013;&#010;  and SEQDUPLICATA = old.SEQ;&#013;&#010;end"/>
<ROW TRI_KEY="ECFCONTAPARTEBAI" TAB="ECFCONTAPARTEB" TIP="AFTER INSERT" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;  if (new.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = new.VALORCONTA;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = new.VALORCONTA;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEA = VLRCREDPARTEA + :varValorCred,&#013;&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  + :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into ECFMOVCONTAPARTEB (CODIGOEMPRESA,&#013;&#010;                                   TIPOIMPOSTO,&#013;&#010;                                   CODIGOCONTAB,&#013;&#010;                                   DATASALDO,&#013;&#010;                                   VLRCREDPARTEA,&#013;&#010;                                   VLRDEBPARTEA,&#013;&#010;                                   VLRCREDPARTEB,&#013;&#010;                                   VLRDEBPARTEB)&#013;&#010;                           values (new.CODIGOEMPRESA,&#013;&#010;                                   new.TIPOIMPOSTO,&#013;&#010;                                   new.CODIGOCONTAB,&#013;&#010;                                   new.DATALCTOFIS,&#013;&#010;                                   :varValorCred,&#013;&#010;                                   :varValorDeb,&#013;&#010;                                   0,&#013;&#010;                                   0);&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="ECFCONTAPARTEBAU" TAB="ECFCONTAPARTEB" TIP="AFTER UPDATE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;  if (new.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = new.VALORCONTA;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = new.VALORCONTA;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEA = VLRCREDPARTEA + :varValorCred,&#013;&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  + :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;end"/>
<ROW TRI_KEY="ECFCONTAPARTEBBD" TAB="ECFCONTAPARTEB" TIP="BEFORE DELETE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;declare variable varValorMovimento Numeric(14,2);&#013;&#010;begin&#013;&#010;  if (old.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = old.VALORCONTA;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = old.VALORCONTA;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEA = VLRCREDPARTEA - :varValorCred,&#013;&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  - :varValorDeb&#013;&#010;   where CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and DATASALDO     = old.DATALCTOFIS;&#013;&#010;&#013;&#010;  select M.VLRCREDPARTEA +&#013;&#010;         M.VLRDEBPARTEA  +&#013;&#010;         M.VLRCREDPARTEB +&#013;&#010;         M.VLRDEBPARTEB&#013;&#010;    from ECFMOVCONTAPARTEB M&#013;&#010;   where M.CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and M.TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and M.CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and M.DATASALDO     = old.DATALCTOFIS&#013;&#010;    into :varValorMovimento;&#013;&#010;&#013;&#010;  if (varValorMovimento = 0) then&#013;&#010;  begin&#013;&#010;   delete from ECFMOVCONTAPARTEB D&#013;&#010;   where D.CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and D.TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and D.CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and D.DATASALDO     = old.DATALCTOFIS;&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="ECFCONTAPARTEBBU" TAB="ECFCONTAPARTEB" TIP="BEFORE UPDATE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;  if (old.INDVALORCONTA = &apos;C&apos;/*Credito=C;Debito=D*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = old.VALORCONTA;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = old.VALORCONTA;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEA = VLRCREDPARTEA - :varValorCred,&#013;&#010;         VLRDEBPARTEA  = VLRDEBPARTEA  - :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;end"/>
<ROW TRI_KEY="ECFLCTOPARTEBSEMREFLEXOAI" TAB="ECFLCTOPARTEBSEMREFLEXO" TIP="AFTER INSERT" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  if (new.INDVALORLCTO = &apos;CR&apos;/*Credito*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = new.VALORLCTO;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = new.VALORLCTO;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEB = VLRCREDPARTEB + :varValorCred,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  + :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into ECFMOVCONTAPARTEB (CODIGOEMPRESA,&#013;&#010;                                   TIPOIMPOSTO,&#013;&#010;                                   CODIGOCONTAB,&#013;&#010;                                   DATASALDO,&#013;&#010;                                   VLRCREDPARTEA,&#013;&#010;                                   VLRDEBPARTEA,&#013;&#010;                                   VLRCREDPARTEB,&#013;&#010;                                   VLRDEBPARTEB)&#013;&#010;                           values (new.CODIGOEMPRESA,&#013;&#010;                                   new.TIPOIMPOSTO,&#013;&#010;                                   new.CODIGOCONTAB,&#013;&#010;                                   new.DATALCTOFIS,&#013;&#010;                                   0,&#013;&#010;                                   0,&#013;&#010;                                   :varValorCred,&#013;&#010;                                   :varValorDeb);&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="ECFLCTOPARTEBSEMREFLEXOAU" TAB="ECFLCTOPARTEBSEMREFLEXO" TIP="AFTER UPDATE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  if (new.INDVALORLCTO = &apos;CR&apos;/*Credito*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = new.VALORLCTO;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = new.VALORLCTO;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEB = VLRCREDPARTEB + :varValorCred,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  + :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;end"/>
<ROW TRI_KEY="ECFLCTOPARTEBSEMREFLEXOBD" TAB="ECFLCTOPARTEBSEMREFLEXO" TIP="BEFORE DELETE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;declare variable varValorMovimento Numeric(14,2);&#013;&#010;begin&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  if (old.INDVALORLCTO = &apos;CR&apos;/*Credito*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = old.VALORLCTO;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = old.VALORLCTO;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEB = VLRCREDPARTEB - :varValorCred,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  - :varValorDeb&#013;&#010;   where CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and DATASALDO     = old.DATALCTOFIS;&#013;&#010;&#013;&#010;  select M.VLRCREDPARTEA +&#013;&#010;         M.VLRDEBPARTEA  +&#013;&#010;         M.VLRCREDPARTEB +&#013;&#010;         M.VLRDEBPARTEB&#013;&#010;    from ECFMOVCONTAPARTEB M&#013;&#010;   where M.CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and M.TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and M.CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and M.DATASALDO     = old.DATALCTOFIS&#013;&#010;    into :varValorMovimento;&#013;&#010;&#013;&#010;  if (varValorMovimento = 0) then&#013;&#010;  begin&#013;&#010;   delete from ECFMOVCONTAPARTEB D&#013;&#010;   where D.CODIGOEMPRESA = old.CODIGOEMPRESA&#013;&#010;     and D.TIPOIMPOSTO   = old.TIPOIMPOSTO&#013;&#010;     and D.CODIGOCONTAB  = old.CODIGOCONTAB&#013;&#010;     and D.DATASALDO     = old.DATALCTOFIS;&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="ECFLCTOPARTEBSEMREFLEXOBU" TAB="ECFLCTOPARTEBSEMREFLEXO" TIP="BEFORE UPDATE" FONTE_FB="as&#013;&#010;declare variable varValorDeb Numeric(14,2);&#013;&#010;declare variable varValorCred Numeric(14,2);&#013;&#010;begin&#013;&#010;/*Credito=CR&#013;&#010;  Debito=DB&#013;&#010;  Prejuizo do exercicio=PF&#013;&#010;  Base de calculo negativa da CSLL=BC*/&#013;&#010;  if (old.INDVALORLCTO = &apos;CR&apos;/*Credito*/) then&#013;&#010;  begin&#013;&#010;    varValorCred = old.VALORLCTO;&#013;&#010;    varValorDeb  = 0;&#013;&#010;  end&#013;&#010;  else&#013;&#010;  begin&#013;&#010;    varValorCred = 0;&#013;&#010;    varValorDeb  = old.VALORLCTO;&#013;&#010;  end&#013;&#010;&#013;&#010;  update ECFMOVCONTAPARTEB&#013;&#010;     set VLRCREDPARTEB = VLRCREDPARTEB - :varValorCred,&#013;&#010;         VLRDEBPARTEB  = VLRDEBPARTEB  - :varValorDeb&#013;&#010;   where CODIGOEMPRESA = new.CODIGOEMPRESA&#013;&#010;     and TIPOIMPOSTO   = new.TIPOIMPOSTO&#013;&#010;     and CODIGOCONTAB  = new.CODIGOCONTAB&#013;&#010;     and DATASALDO     = new.DATALCTOFIS;&#013;&#010;end"/>
<ROW TRI_KEY="ESOCIALTRANSACAOBD" TAB="ESOCIALTRANSACAO" TIP="BEFORE DELETE" FONTE_FB="AS&#013;&#010;BEGIN&#013;&#010;  EXCEPTION ERROR;&#013;&#010;END"/>
<ROW TRI_KEY="FAILDEL" TAB="SITUACAOMODULO" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010; exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILINS" TAB="SITUACAOMODULO" TIP="BEFORE INSERT" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010; exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUP" TAB="SITUACAOMODULO" TIP="BEFORE UPDATE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010; exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILURE" TAB="LOGDESCR" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREE" TAB="LOGESTACAO" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREG" TAB="LOGGERAL" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREJ" TAB="LOGOBJETO" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREP" TAB="LOGPARAM" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILURER" TAB="LOGOPERACAO" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREV" TAB="LOGPARAMVALOR" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FAILUREVI" TAB="LOGPARAMVALORINCLUSION" TIP="BEFORE DELETE" FONTE_FB="AS &#013;&#010;BEGIN &#013;&#010;    exception Error;&#013;&#010;END"/>
<ROW TRI_KEY="FPRCAIXAAI" TAB="FPRCAIXA" TIP="AFTER INSERT" FONTE_FB="as&#013;&#010;begin&#013;&#010;  if (new.TipoMovCaixa = 1) then&#013;&#010;  begin&#013;&#010;    update FprContaSaldo&#013;&#010;       set ValorDeb = ValorDeb + new.ValorCaixa&#013;&#010;     where CODIGOESCRIT = new.CODIGOESCRIT&#013;&#010;       and CodigoConta = new.CodigoConta&#013;&#010;       and DataCaixa = new.DataCaixa;&#013;&#010;    if (row_count = 0) then&#013;&#010;    begin&#013;&#010;      insert into FprContaSaldo (CODIGOESCRIT,&#013;&#010;                                 CodigoConta,&#013;&#010;         DataCaixa,&#013;&#010;         ValorDeb,&#013;&#010;         ValorCred)&#013;&#010;       values (new.CODIGOESCRIT,&#013;&#010;         new.CodigoConta,&#013;&#010;         new.DataCaixa,&#013;&#010;         new.ValorCaixa,&#013;&#010;         0);&#013;&#010;    end&#013;&#010;  end&#013;&#010;  if (new.TipoMovCaixa = -1) then&#013;&#010;  begin&#013;&#010;    update FprContaSaldo&#013;&#010;       set ValorCred = ValorCred + new.ValorCaixa&#013;&#010;     where CODIGOESCRIT = new.CODIGOESCRIT&#013;&#010;       and CodigoConta = new.CodigoConta&#013;&#010;       and DataCaixa = new.DataCaixa;&#013;&#010;    if (row_count = 0) then&#013;&#010;    begin&#013;&#010;      insert into FprContaSaldo (CODIGOESCRIT,&#013;&#010;                                 CodigoConta,&#013;&#010;         DataCaixa,&#013;&#010;         ValorDeb,&#013;&#010;         ValorCred)&#013;&#010;       values (new.CODIGOESCRIT,&#013;&#010;         new.CodigoConta,&#013;&#010;         new.DataCaixa,&#013;&#010;         0,&#013;&#010;         new.ValorCaixa);&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="FPRCAIXAAU" TAB="FPRCAIXA" TIP="AFTER UPDATE" FONTE_FB="as&#013;&#010;  declare variable aAtualizaSaldo smallint;&#013;&#010;begin&#013;&#010;  aAtualizaSaldo = 0;&#013;&#010;  if (new.CODIGOESCRIT &lt;&gt; old.CODIGOESCRIT) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.DataCaixa &lt;&gt; old.DataCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.CodigoConta &lt;&gt; old.CodigoConta) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.ValorCaixa &lt;&gt; old.ValorCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.TipoMovCaixa &lt;&gt; old.TipoMovCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  if (aAtualizaSaldo = 1) then&#013;&#010;  begin&#013;&#010;    if (new.TipoMovCaixa = 1) then&#013;&#010;    begin&#013;&#010;      update FprContaSaldo&#013;&#010;         set ValorDeb = ValorDeb + new.ValorCaixa&#013;&#010;       where CODIGOESCRIT = new.CODIGOESCRIT&#013;&#010;         and CodigoConta = new.CodigoConta&#013;&#010;         and DataCaixa = new.DataCaixa;&#013;&#010;      if (row_count = 0) then &#013;&#010;      begin&#013;&#010;        insert into FprContaSaldo (CODIGOESCRIT,&#013;&#010;                              CodigoConta,&#013;&#010;                              DataCaixa,&#013;&#010;                              ValorDeb,&#013;&#010;                              ValorCred)&#013;&#010;                      values (new.CODIGOESCRIT,&#013;&#010;                              new.CodigoConta,&#013;&#010;                              new.DataCaixa,&#013;&#010;                              new.ValorCaixa,&#013;&#010;                              0);&#013;&#010;      end&#013;&#010;    end&#013;&#010;    if (new.TipoMovCaixa = -1) then&#013;&#010;    begin&#013;&#010;      update FprContaSaldo&#013;&#010;         set ValorCred = ValorCred + new.ValorCaixa&#013;&#010;       where CODIGOESCRIT = new.CODIGOESCRIT&#013;&#010;         and CodigoConta = new.CodigoConta&#013;&#010;         and DataCaixa = new.DataCaixa;&#013;&#010;      if (row_count = 0) then &#013;&#010;      begin&#013;&#010;        insert into FprContaSaldo (CODIGOESCRIT,&#013;&#010;                              CodigoConta,&#013;&#010;                              DataCaixa,&#013;&#010;                              ValorDeb,&#013;&#010;                              ValorCred)&#013;&#010;                      values (new.CODIGOESCRIT,&#013;&#010;                              new.CodigoConta,&#013;&#010;                              new.DataCaixa,&#013;&#010;                              0,&#013;&#010;                              new.ValorCaixa);&#013;&#010;      end&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="FPRCAIXABD" TAB="FPRCAIXA" TIP="BEFORE DELETE" FONTE_FB="as&#013;&#010;begin&#013;&#010;  if (old.TipoMovCaixa = 1) then&#013;&#010;  begin&#013;&#010;    update FprContaSaldo&#013;&#010;       set ValorDeb = ValorDeb - old.ValorCaixa&#013;&#010;     where CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;       and CodigoConta = old.CodigoConta&#013;&#010;       and DataCaixa = old.DataCaixa;&#013;&#010;  end  &#013;&#010;  if (old.TipoMovCaixa = -1) then&#013;&#010;  begin&#013;&#010;    update FprContaSaldo&#013;&#010;       set ValorCred = ValorCred - old.ValorCaixa&#013;&#010;     where CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;       and CodigoConta = old.CodigoConta&#013;&#010;       and DataCaixa = old.DataCaixa;&#013;&#010;  end  &#013;&#010;end"/>
<ROW TRI_KEY="FPRCAIXABU" TAB="FPRCAIXA" TIP="BEFORE UPDATE" FONTE_FB="as&#013;&#010;  declare variable aAtualizaSaldo smallint;&#013;&#010;begin&#013;&#010;  aAtualizaSaldo = 0;&#013;&#010;  if (new.CODIGOESCRIT &lt;&gt; old.CODIGOESCRIT) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.DataCaixa &lt;&gt; old.DataCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.CodigoConta &lt;&gt; old.CodigoConta) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.ValorCaixa &lt;&gt; old.ValorCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  else if (new.TipoMovCaixa &lt;&gt; old.TipoMovCaixa) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;  if (aAtualizaSaldo = 1) then&#013;&#010;  begin&#013;&#010;    if (old.TipoMovCaixa = 1) then&#013;&#010;    begin&#013;&#010;      update FprContaSaldo&#013;&#010;         set ValorDeb = ValorDeb - old.ValorCaixa&#013;&#010;       where CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;         and CodigoConta = old.CodigoConta&#013;&#010;         and DataCaixa = old.DataCaixa;&#013;&#010;    end  &#013;&#010;    if (old.TipoMovCaixa = -1) then&#013;&#010;    begin&#013;&#010;      update FprContaSaldo&#013;&#010;         set ValorCred = ValorCred - old.ValorCaixa&#013;&#010;       where CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;         and CodigoConta = old.CodigoConta&#013;&#010;         and DataCaixa = old.DataCaixa;&#013;&#010;    end&#013;&#010;  end  &#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARAU" TAB="FPRCONTAPAGAR" TIP="AFTER UPDATE" FONTE_FB="AS&#013;&#010;  declare variable SomaValorBaixa Numeric(15,2);&#013;&#010;  declare variable ValorPagCab Numeric(15,2);&#013;&#010;begin&#013;&#010;  select coalesce(sum(FB.VALORBAIXA),0) from FPRCONTAPAGARBAIXA FB&#013;&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :SomaValorBaixa;&#013;&#010;&#013;&#010;  select coalesce(FC.VALORPAGCAB,0) from FPRCONTAPAGARCAB FC&#013;&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :ValorPagCab;&#013;&#010;&#013;&#010;  if (SomaValorBaixa &gt;= ValorPagCab) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if (SomaValorBaixa = 0) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXAAD" TAB="FPRCONTAPAGARBAIXA" TIP="AFTER DELETE" FONTE_FB="AS&#013;&#010;  declare variable Valor Numeric(15,2);&#013;&#010;  declare variable Saldo Numeric(15,2);&#013;&#010;  declare variable Status Integer;&#013;&#010;  declare variable SomaValorBaixa Numeric(15,2);&#013;&#010;  declare variable ValorPagCab Numeric(15,2);&#013;&#010;begin&#013;&#010; select&#013;&#010;    CP.VALORPAG,&#013;&#010;    CP.SALDOPAG&#013;&#010;  from FPRCONTAPAGAR CP&#013;&#010;  where CP.CODIGOESCRIT = OLD.CODIGOESCRIT&#013;&#010;    and CP.CODIGOPAGAR   = OLD.CODIGOPAGAR&#013;&#010;    and CP.CODIGOPAGARCAB = OLD.CODIGOPAGARCAB&#013;&#010;  into :Valor, Saldo;&#013;&#010;  if (Saldo = 0) then  /* Esta Quitada (Status 3)*/&#013;&#010;  begin&#013;&#010;    Status = 3;&#013;&#010;  end else&#013;&#010;  if (Valor = Saldo) then /* Esta Aberta (Status 1) */&#013;&#010;  begin&#013;&#010;    Status = 1;&#013;&#010;  end else /* Esta Parcial (Status 2) */&#013;&#010;  begin&#013;&#010;    Status = 2;&#013;&#010;  end&#013;&#010;  update FPRCONTAPAGAR set  SITUACAOPAG = :Status&#013;&#010;  where CODIGOESCRIT = OLD.CODIGOESCRIT&#013;&#010;    and CODIGOPAGAR = OLD.CODIGOPAGAR&#013;&#010;    and CODIGOPAGARCAB = OLD.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  select coalesce(sum(FB.VALORBAIXA), 0) from FPRCONTAPAGARBAIXA FB&#013;&#010;  WHERE FB.codigoescrit = old.CODIGOESCRIT&#013;&#010;    and FB.CODIGOPAGARCAB = old.CODIGOPAGARCAB&#013;&#010;    into :SomaValorBaixa;&#013;&#010;&#013;&#010;  select coalesce(FC.VALORPAGCAB, 0) from FPRCONTAPAGARCAB FC&#013;&#010;  WHERE FC.codigoescrit = old.CODIGOESCRIT&#013;&#010;    and FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB&#013;&#010;    into :ValorPagCab;&#013;&#010;&#013;&#010;  if (SomaValorBaixa &gt;= ValorPagCab) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#013;&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#013;&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if (SomaValorBaixa = 0) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#013;&#010;    WHERE FC.CODIGOESCRIT = old.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = old.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXAAI" TAB="FPRCONTAPAGARBAIXA" TIP="AFTER INSERT" FONTE_FB="AS&#013;&#010;  declare variable Valor Numeric(15,2);&#013;&#010;  declare variable Saldo Numeric(15,2);&#013;&#010;  declare variable Status Integer;&#013;&#010;  declare variable SomaValorBaixa Numeric(15,2);&#013;&#010;  declare variable ValorPagCab Numeric(15,2);&#013;&#010;begin&#013;&#010; select&#013;&#010;    CP.VALORPAG,&#013;&#010;    CP.SALDOPAG&#013;&#010;  from FPRCONTAPAGAR CP&#013;&#010;  where CP.CODIGOESCRIT  = NEW.CODIGOESCRIT&#013;&#010;    and CP.CODIGOPAGAR    = NEW.CODIGOPAGAR&#013;&#010;    and CP.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB&#013;&#010;  into :Valor, Saldo;&#013;&#010;  if (Saldo = 0) then  /* Esta Quitada (Status 3)*/&#013;&#010;  begin&#013;&#010;    Status = 3;&#013;&#010;  end else&#013;&#010;  if (Valor = Saldo) then /* Esta Aberta (Status 1) */&#013;&#010;  begin&#013;&#010;    Status = 1;&#013;&#010;  end else /* Esta Parcial (Status 2) */&#013;&#010;  begin&#013;&#010;    Status = 2;&#013;&#010;  end&#013;&#010;  update FPRCONTAPAGAR set  SITUACAOPAG = :Status&#013;&#010;  where CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and CODIGOPAGAR   = NEW.CODIGOPAGAR&#013;&#010;    and CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  select coalesce(sum(FB.VALORBAIXA), 0) from FPRCONTAPAGARBAIXA FB&#013;&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :SomaValorBaixa;&#013;&#010;&#013;&#010;  select coalesce(FC.VALORPAGCAB, 0) from FPRCONTAPAGARCAB FC&#013;&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :ValorPagCab;&#013;&#010;&#013;&#010;  if (SomaValorBaixa &gt;= ValorPagCab) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if (SomaValorBaixa = 0) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXAAU" TAB="FPRCONTAPAGARBAIXA" TIP="AFTER UPDATE" FONTE_FB="AS&#013;&#010;  declare variable Valor Numeric(15,2);&#013;&#010;  declare variable Saldo Numeric(15,2);&#013;&#010;  declare variable Status Integer;&#013;&#010;  declare variable SomaValorBaixa Numeric(15,2);&#013;&#010;  declare variable ValorPagCab Numeric(15,2);&#013;&#010;begin&#013;&#010; select&#013;&#010;    CP.VALORPAG,&#013;&#010;    CP.SALDOPAG&#013;&#010;  from FPRCONTAPAGAR CP&#013;&#010;  where CP.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and CP.CODIGOPAGAR   = NEW.CODIGOPAGAR&#013;&#010;    and CP.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB&#013;&#010;  into :Valor, Saldo;&#013;&#010;  if (Saldo = 0) then  /* Esta Quitada (Status 3)*/&#013;&#010;  begin&#013;&#010;    Status = 3;&#013;&#010;  end else&#013;&#010;  if (Valor = Saldo) then /* Esta Aberta (Status 1) */&#013;&#010;  begin&#013;&#010;    Status = 1;&#013;&#010;  end else /* Esta Parcial (Status 2) */&#013;&#010;  begin&#013;&#010;    Status = 2;&#013;&#010;  end&#013;&#010;  update FPRCONTAPAGAR set  SITUACAOPAG = :Status&#013;&#010;  where CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and CODIGOPAGAR   = NEW.CODIGOPAGAR&#013;&#010;    and CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  select coalesce(sum(FB.VALORBAIXA), 0) from FPRCONTAPAGARBAIXA FB&#013;&#010;  WHERE FB.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FB.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :SomaValorBaixa;&#013;&#010;&#013;&#010;  select coalesce(FC.VALORPAGCAB, 0) from FPRCONTAPAGARCAB FC&#013;&#010;  WHERE FC.codigoescrit = new.CODIGOESCRIT&#013;&#010;    and FC.CODIGOPAGARCAB = new.CODIGOPAGARCAB&#013;&#010;    into :ValorPagCab;&#013;&#010;&#013;&#010;  if (SomaValorBaixa &gt;= ValorPagCab) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 3&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if ((SomaValorBaixa &gt; 0) and (SomaValorBaixa &lt; ValorPagCab)) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 2&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      and FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;&#013;&#010;  if (SomaValorBaixa = 0) then&#013;&#010;    update FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;      AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXABD" TAB="FPRCONTAPAGARBAIXA" TIP="BEFORE DELETE" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  update FPRCONTAPAGAR set&#013;&#010;    FPRCONTAPAGAR.SALDOPAG = FPRCONTAPAGAR.SALDOPAG + OLD.VALORBAIXA&#013;&#010;  where FPRCONTAPAGAR.CODIGOESCRIT = OLD.CODIGOESCRIT&#013;&#010;    and FPRCONTAPAGAR.CODIGOPAGAR   = OLD.CODIGOPAGAR&#013;&#010;    and CODIGOPAGARCAB = OLD.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXABI" TAB="FPRCONTAPAGARBAIXA" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  update FPRCONTAPAGAR set&#013;&#010;    FPRCONTAPAGAR.SALDOPAG = FPRCONTAPAGAR.SALDOPAG - NEW.VALORBAIXA&#013;&#010;  where FPRCONTAPAGAR.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and FPRCONTAPAGAR.CODIGOPAGAR   = NEW.CODIGOPAGAR&#013;&#010;    and FPRCONTAPAGAR.CODIGOPAGARCAB   = NEW.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARBAIXABU" TAB="FPRCONTAPAGARBAIXA" TIP="BEFORE UPDATE" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  update FPRCONTAPAGAR set&#013;&#010;    FPRCONTAPAGAR.SALDOPAG = FPRCONTAPAGAR.SALDOPAG - (NEW.VALORBAIXA - OLD.VALORBAIXA)&#013;&#010;  where FPRCONTAPAGAR.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    and FPRCONTAPAGAR.CODIGOPAGAR = NEW.CODIGOPAGAR&#013;&#010;    and FPRCONTAPAGAR.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FPRCONTAPAGARCABAI" TAB="FPRCONTAPAGARCAB" TIP="AFTER INSERT" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  UPDATE FPRCONTAPAGARCAB FC SET SITUACAOPAG = 1&#013;&#010;    WHERE FC.CODIGOESCRIT = NEW.CODIGOESCRIT&#013;&#010;    AND FC.CODIGOPAGARCAB = NEW.CODIGOPAGARCAB;&#013;&#010;end"/>
<ROW TRI_KEY="FUNCPERCALCULOBD" TAB="FUNCPERCALCULO" TIP="BEFORE DELETE" FONTE_FB="AS &#010;BEGIN &#010; &#010;END"/>
<ROW TRI_KEY="HISTORICOALTERACAOESOCIALBI" TAB="HISTORICOALTERACAOESOCIAL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.SEQ is null) then&#013;&#010;    new.SEQ = GEN_ID(GEN_HISTORICOALTERACAOESOCIAL, 1);&#013;&#010;  else&#013;&#010;    if (new.SEQ &gt; GEN_ID(GEN_HISTORICOALTERACAOESOCIAL, 0)) then&#013;&#010;      i = GEN_ID(GEN_HISTORICOALTERACAOESOCIAL, new.SEQ - GEN_ID(GEN_HISTORICOALTERACAOESOCIAL, 0));&#013;&#010;end"/>
<ROW TRI_KEY="ICMSESESTOQCOMBUSTBI" TAB="ICMSESESTOQCOMBUST" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i integer;&#013;&#010;begin&#013;&#010;  if (new.IDESTOQCOMBUST is null) then&#013;&#010;    new.IDESTOQCOMBUST = GEN_ID(GEN_IDESTOQCOMBUST, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.IDESTOQCOMBUST &gt; GEN_ID(GEN_IDESTOQCOMBUST, 0)) then&#013;&#010;      i = GEN_ID(GEN_IDESTOQCOMBUST, new.IDESTOQCOMBUST - GEN_ID(GEN_IDESTOQCOMBUST, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="ICMSESTOTALCOMBUSTBI" TAB="ICMSESTOTALCOMBUST" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.IDTOTALCOMBUST is null) then&#013;&#010;    new.IDTOTALCOMBUST = GEN_ID(GEN_IDTOTALCOMBUST, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.IDTOTALCOMBUST &gt; GEN_ID(GEN_IDTOTALCOMBUST, 0)) then&#013;&#010;      i = GEN_ID(GEN_IDTOTALCOMBUST, new.IDTOTALCOMBUST - GEN_ID(GEN_IDTOTALCOMBUST, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="IMPLSALDOCTBAIAU" TAB="IMPLSALDOCTB" TIP="AFTER INSERT OR UPDATE" FONTE_FB="as&#013;&#010;  declare variable aContaCtbDeb numeric(10,0);&#013;&#010;  declare variable aContaCtbCred numeric(10,0);&#013;&#010;begin&#013;&#010;  if (new.NaturezaSaldo in (1, -1)) then&#013;&#010;  begin&#013;&#010;    aContaCtbDeb  = null;&#013;&#010;    aContaCtbCred = null;&#013;&#010;&#013;&#010;    if (new.NaturezaSaldo = 1) then&#013;&#010;      aContaCtbDeb  = new.ContaCtb;&#013;&#010;    else&#013;&#010;      aContaCtbCred = new.ContaCtb;&#013;&#010;&#013;&#010;    if (new.CodigoMoeda = 0/*Real*/) then&#013;&#010;    begin&#013;&#010;      execute procedure TOTALIZARSALDOCTB(new.CodigoEmpresa,&#013;&#010;                                          new.CodigoEstab,&#013;&#010;                                          :aContaCtbDeb,&#013;&#010;                                          :aContaCtbCred,&#013;&#010;                                          new.DataSaldo,&#013;&#010;                                          new.TipoLancamento,&#013;&#010;                                          new.ValorSaldo);&#013;&#010;    end&#013;&#010;    else&#013;&#010;    begin&#013;&#010;      execute procedure TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa,&#013;&#010;                                               new.CodigoEstab,&#013;&#010;                                               :aContaCtbDeb,&#013;&#010;                                               :aContaCtbCred,&#013;&#010;                                               new.DataSaldo,&#013;&#010;                                               new.TipoLancamento,&#013;&#010;                                               new.ValorSaldo,&#013;&#010;                                               new.CodigoMoeda);&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="IMPLSALDOCTBBI" TAB="IMPLSALDOCTB" TIP="BEFORE INSERT" FONTE_FB="as&#013;&#010;begin&#013;&#010;  if (new.TipoLancamento is null) then&#013;&#010;    new.TipoLancamento = &apos;LN&apos;;&#013;&#010;end"/>
<ROW TRI_KEY="IMPLSALDOCTBBUBD" TAB="IMPLSALDOCTB" TIP="BEFORE UPDATE OR DELETE" FONTE_FB="as&#013;&#010;  declare variable aContaCtbDeb numeric(10,0);&#013;&#010;  declare variable aContaCtbCred numeric(10,0);&#013;&#010;begin&#013;&#010;  if (old.NaturezaSaldo in (1, -1)) then&#013;&#010;  begin&#013;&#010;    aContaCtbDeb  = null;&#013;&#010;    aContaCtbCred = null;&#013;&#010;&#013;&#010;    if (old.NaturezaSaldo = 1) then&#013;&#010;      aContaCtbDeb  = old.ContaCtb;&#013;&#010;    else&#013;&#010;      aContaCtbCred = old.ContaCtb;&#013;&#010;&#013;&#010;    if (old.CodigoMoeda = 0/*Real*/) then&#013;&#010;    begin&#013;&#010;      execute procedure SUBTRAIRSALDOCTB(old.CodigoEmpresa,&#013;&#010;                                         old.CodigoEstab,&#013;&#010;                                         :aContaCtbDeb,&#013;&#010;                                         :aContaCtbCred,&#013;&#010;                                         old.DataSaldo,&#013;&#010;                                         old.TipoLancamento,&#013;&#010;                                         old.ValorSaldo);&#013;&#010;    end&#013;&#010;    else&#013;&#010;    begin&#013;&#010;      execute procedure SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa,&#013;&#010;                                              old.CodigoEstab,&#013;&#010;                                              :aContaCtbDeb,&#013;&#010;                                              :aContaCtbCred,&#013;&#010;                                              old.DataSaldo,&#013;&#010;                                              old.TipoLancamento,&#013;&#010;                                              old.ValorSaldo,&#013;&#010;                                              old.CodigoMoeda);&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
<ROW TRI_KEY="JOBAGENDABI" TAB="JOBAGENDA" TIP="BEFORE INSERT" FONTE_FB="AS&#010;DECLARE VARIABLE TMP DECIMAL(18,0);&#010;BEGIN&#010;  IF (NEW.CODIGOJOBAGENDA IS NULL) THEN&#010;    NEW.CODIGOJOBAGENDA = GEN_ID(GENJOBAGENDA, 1);&#010;  ELSE&#010;  BEGIN&#010;    TMP = GEN_ID(GENJOBAGENDA, 0);&#010;    IF (TMP &lt; NEW.CODIGOJOBAGENDA) THEN&#010;      TMP = GEN_ID(GENJOBAGENDA, NEW.CODIGOJOBAGENDA - TMP);&#010;  END&#010;END"/>
<ROW TRI_KEY="JOBBUILDBI" TAB="JOBBUILD" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOBUILD IS NULL) THEN&#013;&#010;    NEW.CODIGOBUILD = GEN_ID(GEN_JOBBUILD, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_JOBBUILD, 0);&#013;&#010;    if (tmp &lt; new.CODIGOBUILD) then&#013;&#010;      tmp = GEN_ID(GEN_JOBBUILD, new.CODIGOBUILD-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="JOBCONFIGURACAOBI" TAB="JOBCONFIGURACAO" TIP="BEFORE INSERT" FONTE_FB="AS&#010;DECLARE VARIABLE TMP DECIMAL(18,0);&#010;BEGIN&#010;  IF (NEW.CODIGOJOBCFG IS NULL) THEN&#010;    NEW.CODIGOJOBCFG = GEN_ID(GENJOBCONFIGURACAO, 1);&#010;  ELSE&#010;  BEGIN&#010;    TMP = GEN_ID(GENJOBCONFIGURACAO, 0);&#010;    IF (TMP &lt; NEW.CODIGOJOBCFG) THEN&#010;      TMP = GEN_ID(GENJOBCONFIGURACAO, NEW.CODIGOJOBCFG - TMP);&#010;  END&#010;END"/>
<ROW TRI_KEY="JOBPARAMETROBI" TAB="JOBPARAMETRO" TIP="BEFORE INSERT" FONTE_FB="AS&#010;DECLARE VARIABLE TMP DECIMAL(18,0);&#010;BEGIN&#010;  IF (NEW.CODIGOJOBPARAMETRO IS NULL) THEN&#010;    NEW.CODIGOJOBPARAMETRO = GEN_ID(GENJOBPARAMETRO, 1);&#010;  ELSE&#010;  BEGIN&#010;    TMP = GEN_ID(GENJOBPARAMETRO, 0);&#010;    IF (TMP &lt; NEW.CODIGOJOBPARAMETRO) THEN&#010;      TMP = GEN_ID(GENJOBPARAMETRO, NEW.CODIGOJOBPARAMETRO - TMP);&#010;  END&#010;END"/>
<ROW TRI_KEY="LCTOATIVDIFERENCEXCLBI" TAB="LCTOATIVDIFERENCEXCL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.IDLCTOATIVEXCL is null) then&#013;&#010;    new.IDLCTOATIVEXCL = GEN_ID(GEN_IDLCTOATIVDIFEXCL, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.IDLCTOATIVEXCL &gt; GEN_ID(GEN_IDLCTOATIVDIFEXCL, 0)) then&#013;&#010;      i = GEN_ID(GEN_IDLCTOATIVDIFEXCL, new.IDLCTOATIVEXCL - GEN_ID(GEN_IDLCTOATIVDIFEXCL, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBAI" TAB="LCTOCTB" TIP="AFTER INSERT" FONTE_FB="as&#013;&#010;begin&#013;&#010;  execute procedure TOTALIZARSALDOCTB(new.CodigoEmpresa,&#013;&#010;                                      new.CodigoEstab,&#013;&#010;                                      new.ContaCtbDeb,&#013;&#010;                                      new.ContaCtbCred,&#013;&#010;                                      new.DataLctoCtb,&#013;&#010;                                      new.TipoLancamento,&#013;&#010;                                      new.ValorLctoCtb);&#013;&#010;&#013;&#010;  execute procedure TOTALIZARSALDOCTBHIST(new.CodigoEmpresa,&#013;&#010;                                          new.CodigoEstab,&#013;&#010;                                          new.ContaCtbDeb,&#013;&#010;                                          new.ContaCtbCred,&#013;&#010;                                          new.DataLctoCtb,&#013;&#010;                                          new.TipoLancamento,&#013;&#010;                                          new.CodigoHistCtb,&#013;&#010;                                          new.ValorLctoCtb);&#013;&#010;&#013;&#010;  execute procedure TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa,&#013;&#010;                                           new.CodigoEstab,&#013;&#010;                                           new.ContaCtbDeb,&#013;&#010;                                           new.ContaCtbCred,&#013;&#010;                                           new.DataLctoCtb,&#013;&#010;                                           new.TipoLancamento,&#013;&#010;                                           new.ValorLctoMoeda,&#013;&#010;                                           null);&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBAU" TAB="LCTOCTB" TIP="AFTER UPDATE" FONTE_FB="as&#013;&#010;  declare variable aAtualizaSaldo smallint;&#013;&#010;begin&#013;&#010;  aAtualizaSaldo = 0;&#013;&#010;  if ((new.CodigoEmpresa             &lt;&gt; old.CodigoEmpresa)            or&#013;&#010;      (new.CodigoEstab               &lt;&gt; old.CodigoEstab)              or&#013;&#010;      (new.DataLctoCtb               &lt;&gt; old.DataLctoCtb)              or&#013;&#010;      (new.TipoLancamento            &lt;&gt; old.TipoLancamento)           or&#013;&#010;      (coalesce(new.ContaCtbDeb, 0)  &lt;&gt; coalesce(old.ContaCtbDeb, 0)) or&#013;&#010;      (coalesce(new.ContaCtbCred, 0) &lt;&gt; coalesce(old.ContaCtbCred, 0))) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb)) then&#013;&#010;    execute procedure TOTALIZARSALDOCTB(new.CodigoEmpresa,&#013;&#010;                                        new.CodigoEstab,&#013;&#010;                                        new.ContaCtbDeb,&#013;&#010;                                        new.ContaCtbCred,&#013;&#010;                                        new.DataLctoCtb,&#013;&#010;                                        new.TipoLancamento,&#013;&#010;                                        new.ValorLctoCtb);&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or&#013;&#010;      (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb) or&#013;&#010;      (coalesce(new.CodigoHistCtb, 0) &lt;&gt; coalesce(old.CodigoHistCtb, 0))) then&#013;&#010;    execute procedure TOTALIZARSALDOCTBHIST(new.CodigoEmpresa,&#013;&#010;                                            new.CodigoEstab,&#013;&#010;                                            new.ContaCtbDeb,&#013;&#010;                                            new.ContaCtbCred,&#013;&#010;                                            new.DataLctoCtb,&#013;&#010;                                            new.TipoLancamento,&#013;&#010;                                            new.CodigoHistCtb,&#013;&#010;                                            new.ValorLctoCtb);&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or (coalesce(new.ValorLctoMoeda, 0) &lt;&gt; coalesce(old.ValorLctoMoeda, 0))) then&#013;&#010;      execute procedure TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa,&#013;&#010;                                               new.CodigoEstab,&#013;&#010;                                               new.ContaCtbDeb,&#013;&#010;                                               new.ContaCtbCred,&#013;&#010;                                               new.DataLctoCtb,&#013;&#010;                                               new.TipoLancamento,&#013;&#010;                                               new.ValorLctoMoeda,&#013;&#010;                                               null);&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBBD" TAB="LCTOCTB" TIP="BEFORE DELETE" FONTE_FB="as&#013;&#010;begin&#013;&#010;  execute procedure SUBTRAIRSALDOCTB(old.CodigoEmpresa,&#013;&#010;                                     old.CodigoEstab,&#013;&#010;                                     old.ContaCtbDeb,&#013;&#010;                                     old.ContaCtbCred,&#013;&#010;                                     old.DataLctoCtb,&#013;&#010;                                     old.TipoLancamento,&#013;&#010;                                     old.ValorLctoCtb);&#013;&#010;&#013;&#010;  execute procedure SUBTRAIRSALDOCTBHIST(old.CodigoEmpresa,&#013;&#010;                                         old.CodigoEstab,&#013;&#010;                                         old.ContaCtbDeb,&#013;&#010;                                         old.ContaCtbCred,&#013;&#010;                                         old.DataLctoCtb,&#013;&#010;                                         old.TipoLancamento,&#013;&#010;                                         old.CodigoHistCtb,&#013;&#010;                                         old.ValorLctoCtb);&#013;&#010;&#013;&#010;  execute procedure SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa,&#013;&#010;                                          old.CodigoEstab,&#013;&#010;                                          old.ContaCtbDeb,&#013;&#010;                                          old.ContaCtbCred,&#013;&#010;                                          old.DataLctoCtb,&#013;&#010;                                          old.TipoLancamento,&#013;&#010;                                          old.ValorLctoMoeda,&#013;&#010;                                          null);&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBBI" TAB="LCTOCTB" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;begin&#013;&#010;  if ((new.TipoLancamento is null) or (not(new.TipoLancamento in (&apos;LN&apos;, &apos;LS&apos;, &apos;LF&apos;)))) then&#013;&#010;    new.TipoLancamento = &apos;LN&apos;;&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBBICHAVE" TAB="LCTOCTB" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp integer;&#013;&#010;DECLARE VARIABLE nomegen VARCHAR(100);&#013;&#010;BEGIN&#013;&#010;  nomegen = &apos;DYN_GENCHAVELCTOCTB_&apos;||New.CODIGOEMPRESA;&#013;&#010;  IF (NEW.CHAVELCTOCTB IS NULL) THEN&#013;&#010;  BEGIN&#013;&#010;    execute STATEMENT &apos;select GEN_ID(&apos;||nomegen||&apos;, 1) from RDB$DATABASE&apos; into tmp;&#013;&#010;    NEW.CHAVELCTOCTB = tmp;&#013;&#010;  END&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    execute STATEMENT &apos;select GEN_ID(&apos;||nomegen||&apos;, 0) from RDB$DATABASE&apos; into tmp;&#013;&#010;    if (NEW.CHAVELCTOCTB &gt; tmp) then&#013;&#010;    BEGIN&#013;&#010;      tmp = NEW.CHAVELCTOCTB - tmp;&#013;&#010;      execute STATEMENT &apos;select GEN_ID(&apos;||nomegen||&apos;, &apos;||tmp||&apos;) from RDB$DATABASE&apos; into tmp;&#013;&#010;    END&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="LCTOCTBBU" TAB="LCTOCTB" TIP="BEFORE UPDATE" FONTE_FB="as&#013;&#010;  declare variable aAtualizaSaldo smallint;&#013;&#010;begin&#013;&#010;  aAtualizaSaldo = 0;&#013;&#010;  if ((new.CodigoEmpresa             &lt;&gt; old.CodigoEmpresa)            or&#013;&#010;      (new.CodigoEstab               &lt;&gt; old.CodigoEstab)              or&#013;&#010;      (new.DataLctoCtb               &lt;&gt; old.DataLctoCtb)              or&#013;&#010;      (new.TipoLancamento            &lt;&gt; old.TipoLancamento)           or&#013;&#010;      (coalesce(new.ContaCtbDeb, 0)  &lt;&gt; coalesce(old.ContaCtbDeb, 0)) or&#013;&#010;      (coalesce(new.ContaCtbCred, 0) &lt;&gt; coalesce(old.ContaCtbCred, 0))) then&#013;&#010;    aAtualizaSaldo = 1;&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb)) then&#013;&#010;    execute procedure SUBTRAIRSALDOCTB(old.CodigoEmpresa,&#013;&#010;                                       old.CodigoEstab,&#013;&#010;                                       old.ContaCtbDeb,&#013;&#010;                                       old.ContaCtbCred,&#013;&#010;                                       old.DataLctoCtb,&#013;&#010;                                       old.TipoLancamento,&#013;&#010;                                       old.ValorLctoCtb);&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or&#013;&#010;      (new.ValorLctoCtb &lt;&gt; old.ValorLctoCtb) or&#013;&#010;      (coalesce(new.CodigoHistCtb, 0) &lt;&gt; coalesce(old.CodigoHistCtb, 0)))  then&#013;&#010;    execute procedure SUBTRAIRSALDOCTBHIST(old.CodigoEmpresa,&#013;&#010;                                           old.CodigoEstab,&#013;&#010;                                           old.ContaCtbDeb,&#013;&#010;                                           old.ContaCtbCred,&#013;&#010;                                           old.DataLctoCtb,&#013;&#010;                                           old.TipoLancamento,&#013;&#010;                                           old.CodigoHistCtb,&#013;&#010;                                           old.ValorLctoCtb);&#013;&#010;&#013;&#010;  if ((aAtualizaSaldo = 1) or (coalesce(new.ValorLctoMoeda, 0) &lt;&gt; coalesce(old.ValorLctoMoeda, 0))) then&#013;&#010;    execute procedure SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa,&#013;&#010;                                            old.CodigoEstab,&#013;&#010;                                            old.ContaCtbDeb,&#013;&#010;                                            old.ContaCtbCred,&#013;&#010;                                            old.DataLctoCtb,&#013;&#010;                                            old.TipoLancamento,&#013;&#010;                                            old.ValorLctoMoeda,&#013;&#010;                                            null);&#013;&#010;end"/>
<ROW TRI_KEY="LCTOCTBEXCLUIDOBI" TAB="LCTOCTBEXCLUIDO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.IDLCTOCTBEXCL is null) then&#013;&#010;    new.IDLCTOCTBEXCL = GEN_ID(GEN_IDLCTOCTBEXCL, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.IDLCTOCTBEXCL &gt; GEN_ID(GEN_IDLCTOCTBEXCL, 0)) then&#013;&#010;      i = GEN_ID(GEN_IDLCTOCTBEXCL, new.IDLCTOCTBEXCL - GEN_ID(GEN_IDLCTOCTBEXCL, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="LCTODOCUMENTOFISCALBI" TAB="LCTODOCUMENTOFISCAL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGODOCUMENTOFISCAL IS NULL) THEN&#013;&#010;    NEW.CODIGODOCUMENTOFISCAL = GEN_ID(GEN_CODIGODOCUMENTOFISCAL, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_CODIGODOCUMENTOFISCAL, 0);&#013;&#010;    IF (tmp &lt; NEW.CODIGODOCUMENTOFISCAL) THEN&#013;&#010;      tmp = GEN_ID(GEN_CODIGODOCUMENTOFISCAL, NEW.CODIGODOCUMENTOFISCAL-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="LCTOFISENTBI" TAB="LCTOFISENT" TIP="BEFORE INSERT" FONTE_FB="AS &#010;DECLARE VARIABLE ACTUAL_ID Numeric(14,0);&#010;DECLARE VARIABLE DIFERENCA VARCHAR(20);&#010;BEGIN &#010;  if (new.CHAVELCTOFISENT is null) then&#010;    execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISENT_&apos;||new.CODIGOEMPRESA||&apos;,1) from RDB$DATABASE&apos; into new.CHAVELCTOFISENT;&#010;  else&#010;  begin&#010;    execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISENT_&apos;||new.CODIGOEMPRESA||&apos;,0) from RDB$DATABASE&apos; into :ACTUAL_ID;&#010;    if (new.CHAVELCTOFISENT &gt; ACTUAL_ID) then&#010;    begin&#010;      DIFERENCA = new.CHAVELCTOFISENT - ACTUAL_ID;&#010;      execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISENT_&apos;||new.CODIGOEMPRESA||&apos;,&apos;||:DIFERENCA||&apos;) from RDB$DATABASE&apos; into :ACTUAL_ID;&#010;    end&#010;  end&#010;end"/>
<ROW TRI_KEY="LCTOFISSAIBI" TAB="LCTOFISSAI" TIP="BEFORE INSERT" FONTE_FB="AS &#010;DECLARE VARIABLE ACTUAL_ID Numeric(14,0);&#010;DECLARE VARIABLE DIFERENCA VARCHAR(20);&#010;BEGIN &#010;  if (new.CHAVELCTOFISSAI is null) then&#010;    execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISSAI_&apos;||new.CODIGOEMPRESA||&apos;,1) from RDB$DATABASE&apos; into new.CHAVELCTOFISSAI;&#010;  else&#010;  begin&#010;    execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISSAI_&apos;||new.CODIGOEMPRESA||&apos;,0) from RDB$DATABASE&apos; into :ACTUAL_ID;&#010;    if (new.CHAVELCTOFISSAI &gt; ACTUAL_ID) then&#010;    begin&#010;      DIFERENCA = new.CHAVELCTOFISSAI - ACTUAL_ID;&#010;      execute statement &apos;select GEN_ID(DYN_GENCHAVELCTOFISSAI_&apos;||new.CODIGOEMPRESA||&apos;,&apos;||:DIFERENCA||&apos;) from RDB$DATABASE&apos; into :ACTUAL_ID;&#010;    end&#010;  end&#010;end"/>
<ROW TRI_KEY="LCTOGEREXCLUIDOBI" TAB="LCTOGEREXCLUIDO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.IDLCTOGEREXCL is null) then&#013;&#010;    new.IDLCTOGEREXCL = GEN_ID(GEN_IDLCTOGEREXCL, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.IDLCTOGEREXCL &gt; GEN_ID(GEN_IDLCTOGEREXCL, 0)) then&#013;&#010;      i = GEN_ID(GEN_IDLCTOGEREXCL, new.IDLCTOGEREXCL - GEN_ID(GEN_IDLCTOGEREXCL, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="LOGGERALBI" TAB="LOGGERAL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i INTEGER;&#013;&#010;begin&#013;&#010;  if (new.IDLOG is null) then&#013;&#010;    new.IDLOG = GEN_ID(GENLOG, 1);&#013;&#010;  else&#013;&#010;    if (new.IDLOG &gt; GEN_ID(GENLOG, 0)) then&#013;&#010;      i = GEN_ID( GENLOG, new.IDLOG - GEN_ID( GENLOG, 0 ) );&#013;&#010;&#013;&#010;  if (new.DATAHORAINICIO is null) then&#013;&#010;    new.DATAHORAINICIO = current_timestamp;&#013;&#010;&#013;&#010;end"/>
<ROW TRI_KEY="PATBEMBI" TAB="PATBEM" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.CODIGOBEM is null) then&#013;&#010;    new.CODIGOBEM = GEN_ID(GEN_CODIGOBEM, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CODIGOBEM &gt; GEN_ID(GEN_CODIGOBEM, 0)) then&#013;&#010;      i = GEN_ID(GEN_CODIGOBEM, new.CODIGOBEM - GEN_ID(GEN_CODIGOBEM, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="PATBEMCONTACONTABILBI" TAB="PATBEMCONTACONTABIL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.CODIGOBEMCONTACONTABIL is null) then&#013;&#010;    new.CODIGOBEMCONTACONTABIL = GEN_ID(GEN_CODIGOBEMCONTACONTABIL, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CODIGOBEMCONTACONTABIL &gt; GEN_ID(GEN_CODIGOBEMCONTACONTABIL, 0)) then&#013;&#010;      i = GEN_ID(GEN_CODIGOBEMCONTACONTABIL, new.CODIGOBEMCONTACONTABIL - GEN_ID(GEN_CODIGOBEMCONTACONTABIL, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="PATCFGBEMBI" TAB="PATCFGBEM" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;begin&#013;&#010;  if (new.CODIGOCFGBEM is null) then&#013;&#010;    new.CODIGOCFGBEM = GEN_ID(GEN_CODIGOCFGBEM, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CODIGOCFGBEM &gt; GEN_ID(GEN_CODIGOCFGBEM, 0)) then&#013;&#010;      i = GEN_ID(GEN_CODIGOCFGBEM, new.CODIGOCFGBEM - GEN_ID(GEN_CODIGOCFGBEM, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="PATENCCONTACONTABILBI" TAB="PATENCCONTACONTABIL" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOENCCONTACONTABIL IS NULL) THEN&#013;&#010;    NEW.CODIGOENCCONTACONTABIL = GEN_ID(GEN_CODIGOENCCONTACONTABIL, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_CODIGOENCCONTACONTABIL, 0);&#013;&#010;    IF (tmp &lt; NEW.CODIGOENCCONTACONTABIL) THEN&#013;&#010;      tmp = GEN_ID(GEN_CODIGOENCCONTACONTABIL, NEW.CODIGOENCCONTACONTABIL-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="PATGRUPOBI" TAB="PATGRUPO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOGRUPO IS NULL) THEN&#013;&#010;    NEW.CODIGOGRUPO = GEN_ID(GEN_CODIGOGRUPO, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_CODIGOGRUPO, 0);&#013;&#010;    IF (tmp &lt; NEW.CODIGOGRUPO) THEN&#013;&#010;      tmp = GEN_ID(GEN_CODIGOGRUPO, NEW.CODIGOGRUPO-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="PATGRUPODETALHEBI" TAB="PATGRUPODETALHE" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGODETALHE IS NULL) THEN&#013;&#010;    NEW.CODIGODETALHE = GEN_ID(GEN_CODIGODETALHE, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_CODIGODETALHE, 0);&#013;&#010;    IF (tmp &lt; NEW.CODIGODETALHE) THEN&#013;&#010;      tmp = GEN_ID(GEN_CODIGODETALHE, NEW.CODIGODETALHE-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="PATHISTORICOCONVERSAOBI" TAB="PATHISTORICOCONVERSAO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#013;&#010;BEGIN&#013;&#010;  IF (NEW.CODIGOHISTORICOCONVERSAO IS NULL) THEN&#013;&#010;    NEW.CODIGOHISTORICOCONVERSAO = GEN_ID(GEN_CODIGOHISTORICOCONVERSAO, 1);&#013;&#010;  ELSE&#013;&#010;  BEGIN&#013;&#010;    tmp = GEN_ID(GEN_CODIGOHISTORICOCONVERSAO, 0);&#013;&#010;    IF (tmp &lt; NEW.CODIGOHISTORICOCONVERSAO) THEN&#013;&#010;      tmp = GEN_ID(GEN_CODIGOHISTORICOCONVERSAO, NEW.CODIGOHISTORICOCONVERSAO-tmp);&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="PESSOABI" TAB="PESSOA" TIP="BEFORE INSERT" FONTE_FB="AS&#010;DECLARE VARIABLE i Numeric(14,0);&#010;BEGIN&#010;  if (new.CODIGOPESSOA is null) then&#010;    new.CODIGOPESSOA = GEN_ID(GEN_CODIGOPESSOA, 1);/**/&#010;  else&#010;    if (new.CODIGOPESSOA &gt; GEN_ID(GEN_CODIGOPESSOA, 0)) then&#010;      i = GEN_ID(GEN_CODIGOPESSOA, new.CODIGOPESSOA - GEN_ID(GEN_CODIGOPESSOA, 0));/**/&#010;END"/>
<ROW TRI_KEY="PRODUTOSPEDFIS0205" TAB="PRODUTO" TIP="AFTER UPDATE" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE VALORLOG VARCHAR(120);&#013;&#010;BEGIN&#013;&#010;  IF (OLD.REFERENPRODUTO &lt;&gt; NEW.REFERENPRODUTO) THEN&#013;&#010;  BEGIN&#013;&#010;&#013;&#010;    SELECT VLRANTERIOR&#013;&#010;    FROM SPEDFIS0205 S&#013;&#010;    WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;    AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#013;&#010;    AND NUMCAMPO = 2&#013;&#010;    AND DATAALTER = CURRENT_DATE INTO VALORLOG;&#013;&#010;&#013;&#010;    IF (ROW_COUNT = 0) THEN&#013;&#010;      INSERT INTO SPEDFIS0205 (CODIGOEMPRESA, CODIGOPRODUTO, DATAALTER, NUMCAMPO, VLRANTERIOR, DATAINI)&#013;&#010;      VALUES (NEW.CODIGOEMPRESA, NEW.CODIGOPRODUTO, CURRENT_DATE, 2, OLD.REFERENPRODUTO,&#013;&#010;      (SELECT MAX(DATAALTER) FROM SPEDFIS0205 WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;       AND CODIGOPRODUTO = NEW.CODIGOPRODUTO AND NUMCAMPO = 2));&#013;&#010;    ELSE&#013;&#010;&#013;&#010;    IF (VALORLOG = NEW.REFERENPRODUTO) THEN&#013;&#010;      DELETE FROM SPEDFIS0205 S&#013;&#010;      WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;      AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#013;&#010;      AND NUMCAMPO = 2&#013;&#010;      AND DATAALTER = CURRENT_DATE;&#013;&#010;  END&#013;&#010;&#013;&#010;  IF (OLD.DESCRPRODUTO &lt;&gt; NEW.DESCRPRODUTO) THEN&#013;&#010;  BEGIN&#013;&#010;&#013;&#010;    SELECT VLRANTERIOR&#013;&#010;    FROM SPEDFIS0205 S&#013;&#010;    WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;    AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#013;&#010;    AND NUMCAMPO = 3&#013;&#010;    AND DATAALTER = CURRENT_DATE INTO VALORLOG;&#013;&#010;&#013;&#010;    IF (ROW_COUNT = 0) THEN&#013;&#010;      INSERT INTO SPEDFIS0205 (CODIGOEMPRESA, CODIGOPRODUTO, DATAALTER, NUMCAMPO, VLRANTERIOR, DATAINI)&#013;&#010;      VALUES (NEW.CODIGOEMPRESA, NEW.CODIGOPRODUTO, CURRENT_DATE, 3, OLD.DESCRPRODUTO,&#013;&#010;      (SELECT MAX(DATAALTER) FROM SPEDFIS0205 WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;       AND CODIGOPRODUTO = NEW.CODIGOPRODUTO AND NUMCAMPO = 3));&#013;&#010;    ELSE&#013;&#010;&#013;&#010;    IF (VALORLOG = NEW.DESCRPRODUTO) THEN&#013;&#010;      DELETE FROM SPEDFIS0205 S&#013;&#010;      WHERE CODIGOEMPRESA = NEW.CODIGOEMPRESA&#013;&#010;      AND CODIGOPRODUTO = NEW.CODIGOPRODUTO&#013;&#010;      AND NUMCAMPO = 3&#013;&#010;      AND DATAALTER = CURRENT_DATE;&#013;&#010;  END&#013;&#010;END"/>
<ROW TRI_KEY="QUIUPUBLICACAOBI" TAB="QUIUPUBLICACAO" TIP="BEFORE INSERT" FONTE_FB="AS&#010;DECLARE VARIABLE tmp DECIMAL(18,0);&#010;BEGIN&#010;  IF (NEW.CODIGOQUIUPUBLICACAO IS NULL) THEN&#010;    NEW.CODIGOQUIUPUBLICACAO = GEN_ID(GENQUIUPUBLICACAO, 1);&#010;  ELSE&#010;  BEGIN&#010;    tmp = GEN_ID(GENQUIUPUBLICACAO, 0);&#010;    if (tmp &lt; new.CODIGOQUIUPUBLICACAO) then&#010;      tmp = GEN_ID(GENQUIUPUBLICACAO, new.CODIGOQUIUPUBLICACAO-tmp);&#010;  END&#010;END"/>
<ROW TRI_KEY="RECIBOFERIASBD" TAB="RECIBOFERIAS" TIP="BEFORE DELETE" FONTE_FB="AS &#010;BEGIN &#010; &#010;END"/>
<ROW TRI_KEY="SEGMENTOCESTBI" TAB="SEGMENTOCEST" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i SMALLINT;&#013;&#010;begin&#013;&#010;  if (new.CODIGOSEGMENTOCEST is null) then&#013;&#010;    new.CODIGOSEGMENTOCEST = GEN_ID(GEN_CODIGOSEGMENTOCEST, 1);/**/&#013;&#010;  else&#013;&#010;    if (new.CODIGOSEGMENTOCEST &gt; GEN_ID(GEN_CODIGOSEGMENTOCEST, 0)) then&#013;&#010;      i = GEN_ID(GEN_CODIGOSEGMENTOCEST, new.CODIGOSEGMENTOCEST - GEN_ID(GEN_CODIGOSEGMENTOCEST, 0));/**/&#013;&#010;end"/>
<ROW TRI_KEY="TLAGENDACONFIGFUNC" TAB="LEANAGENDACONFIGFUNC" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then NEW.ID = GEN_ID(GLAGENDACONFIGURACAOFUNC, 1);&#013;&#010;END"/>
<ROW TRI_KEY="TLAGENDACONFIGFUNCACESSO" TAB="LEANAGENDACONFIGFUNCACESSO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then NEW.ID = GEN_ID(GLAGENDACONFIGFUNCACESSO, 1);&#013;&#010;END"/>
<ROW TRI_KEY="TLAGENDACONFIGURACAO" TAB="LEANAGENDACONFIGURACAO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then NEW.ID = GEN_ID(GLAGENDACONFIGURACAO, 1);&#013;&#010;END"/>
<ROW TRI_KEY="TLAMBITOTIPOS" TAB="LEANAMBITOTIPOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLAMBITOTIPOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLAMBITOTIPOS, 0)) then&#013;&#010;  i = GEN_ID(GLAMBITOTIPOS, new.ID - GEN_ID(GLAMBITOTIPOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLARQUIVOS" TAB="LEANARQUIVOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLARQUIVOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLARQUIVOS, 0)) then&#013;&#010;  i = GEN_ID(GLARQUIVOS, new.ID - GEN_ID(GLARQUIVOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLATIVIDADEOCORRENCIAS" TAB="LEANATIVIDADEOCORRENCIAS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLATIVIDADEOCORRENCIAS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLATIVIDADEOCORRENCIAS, 0)) then&#013;&#010;  i = GEN_ID(GLATIVIDADEOCORRENCIAS, new.ID - GEN_ID(GLATIVIDADEOCORRENCIAS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLATIVIDADES" TAB="LEANATIVIDADES" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLATIVIDADES, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLATIVIDADES, 0)) then&#013;&#010;  i = GEN_ID(GLATIVIDADES, new.ID - GEN_ID(GLATIVIDADES, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLATIVIDADETIPOS" TAB="LEANATIVIDADETIPOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLATIVIDADETIPOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLATIVIDADETIPOS, 0)) then&#013;&#010;  i = GEN_ID(GLATIVIDADETIPOS, new.ID - GEN_ID(GLATIVIDADETIPOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLCONFIGURACAO" TAB="LEANCONFIGURACAO" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLCONFIGURACAO, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLCONFIGURACAO, 0)) then&#013;&#010;  i = GEN_ID(GLCONFIGURACAO, new.ID - GEN_ID(GLCONFIGURACAO, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLDEPARTAMENTOS" TAB="LEANDEPARTAMENTOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLDEPARTAMENTOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLDEPARTAMENTOS, 0)) then&#013;&#010;  i = GEN_ID(GLDEPARTAMENTOS, new.ID - GEN_ID(GLDEPARTAMENTOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLESCRITORIOSETTING" TAB="LEANESCRITORIOSETTING" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLESCRITORIOSETTING, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLESCRITORIOSETTING, 0)) then&#013;&#010;  i = GEN_ID(GLESCRITORIOSETTING, new.ID - GEN_ID(GLESCRITORIOSETTING, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLFLUXOS" TAB="LEANFLUXOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLFLUXOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLFLUXOS, 0)) then&#013;&#010;  i = GEN_ID(GLFLUXOS, new.ID - GEN_ID(GLFLUXOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLGRUPOS" TAB="LEANGRUPOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLGRUPOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLGRUPOS, 0)) then&#013;&#010;  i = GEN_ID(GLGRUPOS, new.ID - GEN_ID(GLGRUPOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLOCORRENCIAHISTORICOS" TAB="LEANOCORRENCIAHISTORICOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLOCORRENCIAHISTORICOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLOCORRENCIAHISTORICOS, 0)) then&#013;&#010;  i = GEN_ID(GLOCORRENCIAHISTORICOS, new.ID - GEN_ID(GLOCORRENCIAHISTORICOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLPROCEDIMENTOS" TAB="LEANPROCEDIMENTOS" TIP="BEFORE INSERT" FONTE_FB="AS&#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN&#013;&#010;if (NEW.ID is NULL) then &#013;&#010; NEW.ID = GEN_ID(GLPROCEDIMENTOS, 1);&#013;&#010;else&#013;&#010; if (new.ID &gt; GEN_ID(GLPROCEDIMENTOS, 0)) then&#013;&#010;  i = GEN_ID(GLPROCEDIMENTOS, new.ID - GEN_ID(GLPROCEDIMENTOS, 0));&#013;&#010;END"/>
<ROW TRI_KEY="TLQUESTORMENU" TAB="LEANQUESTORMENU" TIP="BEFORE INSERT" FONTE_FB="AS &#013;&#010;DECLARE VARIABLE i Numeric(14,0);&#013;&#010;BEGIN &#013;&#010;if (NEW.ID is NULL) then &#013;&#010;NEW.ID = GEN_ID(GLQUESTORMENU, 1);&#013;&#010;else&#013;&#010;if (new.ID &gt; GEN_ID(GLQUESTORMENU, 0)) then&#013;&#010;i = GEN_ID(GLQUESTORMENU, new.ID - GEN_ID(GLQUESTORMENU, 0));&#013;&#010;END"/>
<ROW TRI_KEY="ZERAMENTOCTBMOEDAAIAU" TAB="ZERAMENTOCTBMOEDA" TIP="AFTER INSERT OR UPDATE" FONTE_FB="as&#013;&#010;begin&#013;&#010;  execute procedure TOTALIZARSALDOCTBMOEDA(new.CodigoEmpresa,&#013;&#010;                                           new.CodigoEstab,&#013;&#010;                                           new.ContaCtbDeb,&#013;&#010;                                           new.ContaCtbCred,&#013;&#010;                                           new.DataZeramento,&#013;&#010;                                           new.TipoLancamento,&#013;&#010;                                           new.ValorZeramento,&#013;&#010;                                           null);&#013;&#010;end"/>
<ROW TRI_KEY="ZERAMENTOCTBMOEDABUBD" TAB="ZERAMENTOCTBMOEDA" TIP="BEFORE UPDATE OR DELETE" FONTE_FB="as&#013;&#010;begin&#013;&#010;  execute procedure SUBTRAIRSALDOCTBMOEDA(old.CodigoEmpresa,&#013;&#010;                                          old.CodigoEstab,&#013;&#010;                                          old.ContaCtbDeb,&#013;&#010;                                          old.ContaCtbCred,&#013;&#010;                                          old.DataZeramento,&#013;&#010;                                          old.TipoLancamento,&#013;&#010;                                          old.ValorZeramento,&#013;&#010;                                          null);&#013;&#010;end"/>
</ROWDATA>
</DATAPACKET>
