<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="PRO_KEY" fieldtype="string.uni" SUBTYPE="FixedChar" WIDTH="62">
<PARAM Name="ORIGIN" Value="RDB$PROCEDURE_NAME" Roundtrip="True"/>
</FIELD>
<FIELD attrname="PROCEDURE_INPUTS" fieldtype="i2">
<PARAM Name="ORIGIN" Value="RDB$PROCEDURE_INPUTS" Roundtrip="True"/>
</FIELD>
<FIELD attrname="PROCEDURE_OUTPUTS" fieldtype="i4">
<PARAM Name="PROVFLAGS" Value="0" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="PROCEDURE_OUTPUTS" Roundtrip="True"/>
</FIELD>
<FIELD attrname="PROCEDURE_SOURCE" fieldtype="bin.hex" SUBTYPE="Text">
<PARAM Name="PROVFLAGS" Value="1" Type="i4" Roundtrip="True"/>
<PARAM Name="ORIGIN" Value="RDB$PROCEDURE_SOURCE" Roundtrip="True"/>
</FIELD>
</FIELDS>
<PARAMS DEFAULT_ORDER="1"/>
</METADATA>
<ROWDATA>
<ROW PRO_KEY="CARREGARMOEDAFUNCIONAL" PROCEDURE_INPUTS="3" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="begin&#013;&#010;  select CodigoMoeda&#013;&#010;   from OPCAOMOEDAFUNCIONAL&#013;&#010;  where CODIGOEMPRESA = :pCodigoEmpresa&#013;&#010;    and CODIGOESTAB = :pCodigoEstab&#013;&#010;    and DATAINICIAL &lt;= :pDataMoeda&#013;&#010;    and (DATAFINAL &gt;= :pDataMoeda or DATAFINAL is null)&#013;&#010;   into :CodigoMoeda;&#013;&#010;&#013;&#010;  if (:CodigoMoeda is null) then&#013;&#010;    select CodigoMoeda&#013;&#010;     from OPCAOMOEDAFUNCIONAL&#013;&#010;    where CODIGOEMPRESA = :pCodigoEmpresa&#013;&#010;      and CODIGOESTAB = 1/*Matriz*/&#013;&#010;      and DATAINICIAL &lt;= :pDataMoeda&#013;&#010;      and (DATAFINAL &gt;= :pDataMoeda or DATAFINAL is null)&#013;&#010;     into :CodigoMoeda;&#013;&#010;&#013;&#010;  suspend;&#013;&#010;end"/>
<ROW PRO_KEY="DOCUMENTOACERTO" PROCEDURE_INPUTS="2" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="declare variable documento varchar(10);&#013;&#010;begin&#013;&#010;  DOCUMENTOS = &apos;&apos;;&#013;&#010;  for select distinct &#013;&#010;    case&#013;&#010;      when FCP.CodigoPagarCab &gt; 0 then cast(FCP.CodigoPagarCab as varchar(10))&#013;&#010;      when FCR.NUMERODCTOCR &lt;&gt; &apos;&apos; then FCR.NUMERODCTOCR&#013;&#010;      when FSN.SERIENS || FSN.NUMERONS &lt;&gt; &apos;&apos; then FSN.SERIENS || FSN.NUMERONS  &#013;&#010;      else &apos;&apos; &#013;&#010;    end Doc&#013;&#010;    from FPRACERTO AC&#013;&#010;    left join FPRACERTOCP FCP on FCP.CodigoEscrit = AC.CodigoEscrit and FCP.CodigoAcerto = AC.CodigoAcerto&#013;&#010;    left join FPRACERTOCXFINCR FCR on FCR.CodigoEscrit = AC.CodigoEscrit and FCR.CodigoAcerto = AC.CodigoAcerto&#013;&#010;    left join FPRACERTOCXFINSERVICONOTA FSN on FSN.CodigoEscrit = AC.CodigoEscrit and FSN.CodigoAcerto = AC.CodigoAcerto&#013;&#010;    where AC.CodigoEscrit = :PCODIGOESCRIT&#013;&#010;    and AC.CodigoAcerto = :PCODIGOACERTO&#013;&#010;    order by Doc into :documento as cursor curDados do&#013;&#010;  begin&#013;&#010;    if (row_count = 0) then&#013;&#010;      leave;&#013;&#010;    if (DOCUMENTOS &lt;&gt; &apos;&apos;) then&#013;&#010;      DOCUMENTOS = :DOCUMENTOS || &apos;;&apos;;&#013;&#010;    DOCUMENTOS = :DOCUMENTOS || :documento;&#013;&#010;  end&#013;&#010;  suspend;&#013;&#010;end"/>
<ROW PRO_KEY="EMAILSPESSOAFINANCEIRO" PROCEDURE_INPUTS="1" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="declare variable email varchar(100);&#013;&#010;begin &#013;&#010;  EMAILS = &apos;&apos;; &#013;&#010;  for select valor &#013;&#010;    from pessoacontato &#013;&#010;    where tipocontato in (7,8,9) &#013;&#010;    and codigopessoafin = :pcodigo &#013;&#010;    order by tipocontato desc, codigopessoacontato &#013;&#010;    into :email as cursor curdados&#013;&#010;  do &#013;&#010;  begin &#013;&#010;    if (row_count = 0) then &#013;&#010;      leave; &#013;&#010;    if (EMAILS &lt;&gt; &apos;&apos;) then &#013;&#010;      EMAILS = :EMAILS || &apos;;&apos;; &#013;&#010;    EMAILS = :EMAILS || :email; &#013;&#010;  end &#013;&#010;  suspend; &#013;&#010;end"/>
<ROW PRO_KEY="EMAILSPESSOAFINANCEIRORPS" PROCEDURE_INPUTS="1" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="declare variable email varchar(100); &#013;&#010;declare variable curDados cursor for( &#013;&#010;  select Valor &#013;&#010;  from PessoaContato &#013;&#010;  where TipoContato in (9) &#013;&#010;  and CodigoPessoaFin = ? &#013;&#010;  order by CodigoPessoaContato); &#013;&#010;begin &#013;&#010;  EMAILS = &apos;&apos;; &#013;&#010;  open curDados; &#013;&#010;&#013;&#010;  while (1 = 1) do &#013;&#010;  begin &#013;&#010;    fetch curDados into :email; &#013;&#010;&#013;&#010;    if (row_count = 0) then &#013;&#010;      leave; &#013;&#010;&#013;&#010;    if (EMAILS &lt;&gt; &apos;&apos;) then &#013;&#010;      EMAILS = :EMAILS || &apos;;&apos;; &#013;&#010;&#013;&#010;    EMAILS = :EMAILS || :email; &#013;&#010;  end &#013;&#010;&#013;&#010;  suspend; &#013;&#010;  close curDados; &#013;&#010;end"/>
<ROW PRO_KEY="F_COLLATEBR" PROCEDURE_INPUTS="1" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE=" BEGIN Result = upper(a); Result = replace(Result, ASCII_CHAR (192), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (193), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (194), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (195), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (196), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (197), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (199), &apos;C&apos;); Result = replace(Result, ASCII_CHAR (200), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (201), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (202), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (203), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (204), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (205), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (206), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (207), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (209), &apos;N&apos;); Result = replace(Result, ASCII_CHAR (210), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (211), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (212), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (213), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (214), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (217), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (218), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (219), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (220), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (221), &apos;Y&apos;); Result = replace(Result, ASCII_CHAR (224), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (225), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (226), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (227), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (228), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (229), &apos;A&apos;); Result = replace(Result, ASCII_CHAR (231), &apos;C&apos;); Result = replace(Result, ASCII_CHAR (232), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (233), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (234), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (235), &apos;E&apos;); Result = replace(Result, ASCII_CHAR (236), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (237), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (238), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (239), &apos;I&apos;); Result = replace(Result, ASCII_CHAR (241), &apos;N&apos;); Result = replace(Result, ASCII_CHAR (242), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (243), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (244), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (245), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (246), &apos;O&apos;); Result = replace(Result, ASCII_CHAR (249), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (250), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (251), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (252), &apos;U&apos;); Result = replace(Result, ASCII_CHAR (253), &apos;Y&apos;); Result = replace(Result, ASCII_CHAR (255), &apos;Y&apos;); SUSPEND; END"/>
<ROW PRO_KEY="FORMATARDDDFONE" PROCEDURE_INPUTS="1" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="begin &#013;&#010;  if (SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos; and (StrLen(PNUMEROFONE) = 9)) then &#013;&#010;    DDD = null;  &#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 2) = &apos;00&apos;) then &#013;&#010;    DDD = null;&#013;&#010;  &#013;&#010;  else if (StrLen(PNUMEROFONE) = 8) then &#013;&#010;      DDD = null;&#013;&#010;  &#013;&#010;  else if ((SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos;) and (StrLen(cast(SubStr(PNUMEROFONE, 2, 3) as integer)) = 2)) then &#013;&#010;      DDD = cast(SubStr(PNUMEROFONE, 2, 3) as integer);  &#013;&#010;  &#013;&#010;  else if ((StrLen(PNUMEROFONE) = 9) and (SubStr(PNUMEROFONE, 5, 5) &lt;&gt; &apos;.&apos;)) then &#013;&#010;      DDD = cast(SubStr(PNUMEROFONE, 1, 2) as integer);  &#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;(&apos;) then &#013;&#010;      DDD = cast(SubStr(PNUMEROFONE, 2, 3) as integer);&#013;&#010;  &#013;&#010;  else if ((StrLen(PNUMEROFONE) = 10) and (SubStr(PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;) and (position(&apos;.&apos;, PNUMEROFONE) = 0)) then &#013;&#010;      DDD = cast(SubStr(PNUMEROFONE, 1, 2) as integer);  &#013;&#010;  &#013;&#010;  else  &#013;&#010;    DDD = null;&#013;&#010;    &#013;&#010;  suspend;&#013;&#010;&#013;&#010;  when any do&#013;&#010;    DDD = null;&#013;&#010;  &#013;&#010;end"/>
<ROW PRO_KEY="FORMATARNUMEROFONE" PROCEDURE_INPUTS="1" PROCEDURE_OUTPUTS="1" PROCEDURE_SOURCE="begin &#013;&#010;  FONE = null;&#013;&#010;&#013;&#010;  if (SubStr(PNUMEROFONE, 1, 1) &lt;&gt; &apos;(&apos; and (SubStr(PNUMEROFONE, 6, 6) = &apos;.&apos;) and (position(&apos;/&apos;, PNUMEROFONE)=0)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 1, 5) || SubStr(PNUMEROFONE, 7, 10)  as integer);&#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;(&apos; and (SubStr(PNUMEROFONE, 11, 11) = &apos;.&apos;)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 6, 10) || SubStr(PNUMEROFONE, 12, 15)  as integer);&#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos; and (StrLen(PNUMEROFONE) = 9)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 2, 9) as integer);   &#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos; and (StrLen(PNUMEROFONE) = 10)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 3, 10) as integer);   &#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;0&apos; and (StrLen(PNUMEROFONE) = 11)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 3, 11) as integer);  &#013;&#010;  &#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 2) = &apos;00&apos;) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 3, StrLen(PNUMEROFONE)) as integer);   &#013;&#010;    &#013;&#010;  else if ((StrLen(PNUMEROFONE) = 9) and (SubStr(PNUMEROFONE, 5, 5) &lt;&gt; &apos;.&apos;)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 3, 9) as integer);  &#013;&#010;&#013;&#010;  else if ((StrLen(PNUMEROFONE) = 9) and (SubStr(PNUMEROFONE, 5, 5) = &apos;.&apos;)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 1, 4) || SubStr(PNUMEROFONE, 6, 9)  as integer);  &#013;&#010;&#013;&#010;  else if (SubStr(PNUMEROFONE, 1, 1) = &apos;(&apos; and (SubStr(PNUMEROFONE, 10, 10) = &apos;.&apos;)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 6, 9) || SubStr(PNUMEROFONE, 11, 14)  as integer);&#013;&#010;&#013;&#010;  else if ((StrLen(PNUMEROFONE) = 10) and (SubStr(PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;)) then &#013;&#010;    FONE = cast(SubStr(PNUMEROFONE, 2, 10) as integer);&#013;&#010;&#013;&#010;  else &#013;&#010;    FONE = cast(PNUMEROFONE as integer);&#013;&#010;&#013;&#010;  suspend;&#013;&#010;&#013;&#010;  when any do&#013;&#010;    FONE = null;&#013;&#010;&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOBD" PROCEDURE_INPUTS="7" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTB&#013;&#010;     set ValorDeb  = ValorDeb  - :pValorDeb,&#013;&#010;         ValorCred = ValorCred - :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :pDataSaldo&#013;&#010;     and TipoLancamento = :pTipoLancamento;&#013;&#010;&#013;&#010;  update SALDOCTBMENSAL&#013;&#010;     set ValorDeb  = ValorDeb  - :pValorDeb,&#013;&#010;         ValorCred = ValorCred - :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento;&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOBDHIST" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTBMENSALHIST&#013;&#010;     set ValorDeb  = ValorDeb  - :pValorDeb,&#013;&#010;         ValorCred = ValorCred - :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoHistCtb  = :pCodigoHistCtb;&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOBDMOEDA" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTBMOEDA&#013;&#010;     set ValorDeb  = ValorDeb  - :pValorDeb,&#013;&#010;         ValorCred = ValorCred - :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :pDataSaldo&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoMoeda    = :pCodigoMoeda;&#013;&#010;&#013;&#010;  update SALDOCTBMOEDAMENSAL&#013;&#010;     set ValorDeb  = ValorDeb  - :pValorDeb,&#013;&#010;         ValorCred = ValorCred - :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoMoeda    = :pCodigoMoeda;&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTB" PROCEDURE_INPUTS="7" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="begin&#013;&#010;  if (:pContaCtbDeb is not null) then&#013;&#010;    execute procedure SUBTRAIRSALDOBD(:pCodigoEmpresa,&#013;&#010;                                      :pCodigoEstab,&#013;&#010;                                      :pContaCtbDeb,&#013;&#010;                                      :pDataSaldo,&#013;&#010;                                      :pTipoLancamento,&#013;&#010;                                      :pValorSaldoCtb,&#013;&#010;                                      0);&#013;&#010;  &#013;&#010;  if (:pContaCtbCred is not null) then&#013;&#010;    execute procedure SUBTRAIRSALDOBD(:pCodigoEmpresa,&#013;&#010;                                      :pCodigoEstab,&#013;&#010;                                      :pContaCtbCred,&#013;&#010;                                      :pDataSaldo,&#013;&#010;                                      :pTipoLancamento,&#013;&#010;                                      0,&#013;&#010;                                      :pValorSaldoCtb);&#013;&#010;&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTBHIST" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="begin&#013;&#010;  if (:pCodigoHistCtb is not null) then&#013;&#010;  begin&#013;&#010;    if (:pContaCtbDeb is not null) then&#013;&#010;      execute procedure SUBTRAIRSALDOBDHIST(:pCodigoEmpresa,&#013;&#010;                                            :pCodigoEstab,&#013;&#010;                                            :pContaCtbDeb,&#013;&#010;                                            :pDataSaldo,&#013;&#010;                                            :pTipoLancamento,&#013;&#010;                                            :pCodigoHistCtb,&#013;&#010;                                            :pValorSaldoCtb,&#013;&#010;                                            0);&#013;&#010;  &#013;&#010;    if (:pContaCtbCred is not null) then&#013;&#010;      execute procedure SUBTRAIRSALDOBDHIST(:pCodigoEmpresa,&#013;&#010;                                            :pCodigoEstab,&#013;&#010;                                            :pContaCtbCred,&#013;&#010;                                            :pDataSaldo,&#013;&#010;                                            :pTipoLancamento,&#013;&#010;                                            :pCodigoHistCtb,&#013;&#010;                                            0,&#013;&#010;                                            :pValorSaldoCtb);&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTBMOEDA" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable AMOEDAFUNCIONAL smallint;&#013;&#010;begin&#013;&#010;  if (:pValorLctoMoeda is not null) then&#013;&#010;  begin&#013;&#010;    aMoedaFuncional = :pCodigoMoedaLcto;&#013;&#010;&#013;&#010;    if (:aMoedaFuncional is null) then&#013;&#010;      select CODIGOMOEDA from CARREGARMOEDAFUNCIONAL(:pCodigoEmpresa, :pCodigoEstab, :pDataSaldo) into :aMoedaFuncional;&#013;&#010;&#013;&#010;    if (:aMoedaFuncional is not null) then&#013;&#010;    begin&#013;&#010;      if (:pContaCtbDeb is not null) then&#013;&#010;        execute procedure SUBTRAIRSALDOBDMOEDA(:pCodigoEmpresa,&#013;&#010;                                               :pCodigoEstab,&#013;&#010;                                               :pContaCtbDeb,&#013;&#010;                                               :pDataSaldo,&#013;&#010;                                               :pTipoLancamento,&#013;&#010;                                               :aMoedaFuncional,&#013;&#010;                                               :pValorLctoMoeda,&#013;&#010;                                               0);&#013;&#010;  &#013;&#010;      if (:pContaCtbCred is not null) then&#013;&#010;        execute procedure SUBTRAIRSALDOBDMOEDA(:pCodigoEmpresa,&#013;&#010;                                               :pCodigoEstab,&#013;&#010;                                               :pContaCtbCred,&#013;&#010;                                               :pDataSaldo,&#013;&#010;                                               :pTipoLancamento,&#013;&#010;                                               :aMoedaFuncional,&#013;&#010;                                               0,&#013;&#010;                                               :pValorLctoMoeda);&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOBD" PROCEDURE_INPUTS="7" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTB&#013;&#010;     set ValorDeb  = ValorDeb  + :pValorDeb,&#013;&#010;         ValorCred = ValorCred + :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :pDataSaldo&#013;&#010;     and TipoLancamento = :pTipoLancamento;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into SALDOCTB (CodigoEmpresa,&#013;&#010;                          CodigoEstab,&#013;&#010;                          ContaCtb,&#013;&#010;                          DataSaldo,&#013;&#010;                          TipoLancamento,&#013;&#010;                          ValorDeb,&#013;&#010;                          ValorCred)&#013;&#010;                  values (:pCodigoEmpresa,&#013;&#010;                          :pCodigoEstab,&#013;&#010;                          :pContaCtb,&#013;&#010;                          :pDataSaldo,&#013;&#010;                          :pTipoLancamento,&#013;&#010;                          :pValorDeb,&#013;&#010;                          :pValorCred);&#013;&#010;  end&#013;&#010;&#013;&#010;  update SALDOCTBMENSAL&#013;&#010;     set ValorDeb  = ValorDeb  + :pValorDeb,&#013;&#010;         ValorCred = ValorCred + :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into SALDOCTBMENSAL (CodigoEmpresa,&#013;&#010;                                CodigoEstab,&#013;&#010;                                ContaCtb,&#013;&#010;                                DataSaldo,&#013;&#010;                                TipoLancamento,&#013;&#010;                                ValorDeb,&#013;&#010;                                ValorCred)&#013;&#010;                        values (:pCodigoEmpresa,&#013;&#010;                                :pCodigoEstab,&#013;&#010;                                :pContaCtb,&#013;&#010;                                :aDataSaldoMensal,&#013;&#010;                                :pTipoLancamento,&#013;&#010;                                :pValorDeb,&#013;&#010;                                :pValorCred);&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOBDHIST" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTBMENSALHIST&#013;&#010;     set ValorDeb  = ValorDeb  + :pValorDeb,&#013;&#010;         ValorCred = ValorCred + :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoHistCtb  = :pCodigoHistCtb;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into SALDOCTBMENSALHIST (CodigoEmpresa,&#013;&#010;                                    CodigoEstab,&#013;&#010;                                    ContaCtb,&#013;&#010;                                    DataSaldo,&#013;&#010;                                    TipoLancamento,&#013;&#010;                                    CodigoHistCtb,&#013;&#010;                                    ValorDeb,&#013;&#010;                                    ValorCred)&#013;&#010;                            values (:pCodigoEmpresa,&#013;&#010;                                    :pCodigoEstab,&#013;&#010;                                    :pContaCtb,&#013;&#010;                                    :aDataSaldoMensal,&#013;&#010;                                    :pTipoLancamento,&#013;&#010;                                    :pCodigoHistCtb,&#013;&#010;                                    :pValorDeb,&#013;&#010;                                    :pValorCred);&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOBDMOEDA" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable ADATASALDOMENSAL date;&#013;&#010;begin&#013;&#010;  aDataSaldoMensal = CAST(&apos;1.&apos; ||EXTRACT(MONTH FROM :pDataSaldo) || &apos;.&apos; ||EXTRACT(YEAR FROM :pDataSaldo) AS DATE);&#013;&#010;&#013;&#010;  update SALDOCTBMOEDA&#013;&#010;     set ValorDeb  = ValorDeb  + :pValorDeb,&#013;&#010;         ValorCred = ValorCred + :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :pDataSaldo&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoMoeda    = :pCodigoMoeda;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into SALDOCTBMOEDA (CodigoEmpresa,&#013;&#010;                               CodigoEstab,&#013;&#010;                               ContaCtb,&#013;&#010;                               DataSaldo,&#013;&#010;                               TipoLancamento,&#013;&#010;                               CodigoMoeda,&#013;&#010;                               ValorDeb,&#013;&#010;                               ValorCred)&#013;&#010;                       values (:pCodigoEmpresa,&#013;&#010;                               :pCodigoEstab,&#013;&#010;                               :pContaCtb,&#013;&#010;                               :pDataSaldo,&#013;&#010;                               :pTipoLancamento,&#013;&#010;                               :pCodigoMoeda,&#013;&#010;                               :pValorDeb,&#013;&#010;                               :pValorCred);&#013;&#010;  end&#013;&#010;&#013;&#010;  update SALDOCTBMOEDAMENSAL&#013;&#010;     set ValorDeb  = ValorDeb  + :pValorDeb,&#013;&#010;         ValorCred = ValorCred + :pValorCred&#013;&#010;   where CodigoEmpresa  = :pCodigoEmpresa&#013;&#010;     and CodigoEstab    = :pCodigoEstab&#013;&#010;     and ContaCtb       = :pContaCtb&#013;&#010;     and DataSaldo      = :aDataSaldoMensal&#013;&#010;     and TipoLancamento = :pTipoLancamento&#013;&#010;     and CodigoMoeda    = :pCodigoMoeda;&#013;&#010;&#013;&#010;  if (row_count = 0) then&#013;&#010;  begin&#013;&#010;    insert into SALDOCTBMOEDAMENSAL (CodigoEmpresa,&#013;&#010;                                     CodigoEstab,&#013;&#010;                                     ContaCtb,&#013;&#010;                                     DataSaldo,&#013;&#010;                                     TipoLancamento,&#013;&#010;                                     CodigoMoeda,&#013;&#010;                                     ValorDeb,&#013;&#010;                                     ValorCred)&#013;&#010;                             values (:pCodigoEmpresa,&#013;&#010;                                     :pCodigoEstab,&#013;&#010;                                     :pContaCtb,&#013;&#010;                                     :aDataSaldoMensal,&#013;&#010;                                     :pTipoLancamento,&#013;&#010;                                     :pCodigoMoeda,&#013;&#010;                                     :pValorDeb,&#013;&#010;                                     :pValorCred);&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOCTB" PROCEDURE_INPUTS="7" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="begin&#013;&#010;  if (:pContaCtbDeb is not null) then&#013;&#010;    execute procedure TOTALIZARSALDOBD(:pCodigoEmpresa,&#013;&#010;                                       :pCodigoEstab,&#013;&#010;                                       :pContaCtbDeb,&#013;&#010;                                       :pDataSaldo,&#013;&#010;                                       :pTipoLancamento,&#013;&#010;                                       :pValorSaldoCtb,&#013;&#010;                                       0);&#013;&#010;&#013;&#010;  if (:pContaCtbCred is not null) then&#013;&#010;    execute procedure TOTALIZARSALDOBD(:pCodigoEmpresa,&#013;&#010;                                       :pCodigoEstab,&#013;&#010;                                       :pContaCtbCred,&#013;&#010;                                       :pDataSaldo,&#013;&#010;                                       :pTipoLancamento,&#013;&#010;                                       0,&#013;&#010;                                       :pValorSaldoCtb);&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOCTBHIST" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="begin&#013;&#010;  if (:pCodigoHistCtb is not null) then&#013;&#010;  begin&#013;&#010;    if (:pContaCtbDeb is not null) then&#013;&#010;      execute procedure TOTALIZARSALDOBDHIST(:pCodigoEmpresa,&#013;&#010;                                             :pCodigoEstab,&#013;&#010;                                             :pContaCtbDeb,&#013;&#010;                                             :pDataSaldo,&#013;&#010;                                             :pTipoLancamento,&#013;&#010;                                             :pCodigoHistCtb,&#013;&#010;                                             :pValorSaldoCtb,&#013;&#010;                                             0);&#013;&#010;&#013;&#010;    if (:pContaCtbCred is not null) then&#013;&#010;      execute procedure TOTALIZARSALDOBDHIST(:pCodigoEmpresa,&#013;&#010;                                             :pCodigoEstab,&#013;&#010;                                             :pContaCtbCred,&#013;&#010;                                             :pDataSaldo,&#013;&#010;                                             :pTipoLancamento,&#013;&#010;                                             :pCodigoHistCtb,&#013;&#010;                                             0,&#013;&#010;                                             :pValorSaldoCtb);&#013;&#010;  end&#013;&#010;end"/>
<ROW PRO_KEY="TOTALIZARSALDOCTBMOEDA" PROCEDURE_INPUTS="8" PROCEDURE_OUTPUTS="0" PROCEDURE_SOURCE="declare variable AMOEDAFUNCIONAL smallint;&#013;&#010;begin&#013;&#010;  if (:pValorLctoMoeda is not null) then&#013;&#010;  begin&#013;&#010;    aMoedaFuncional = :pCodigoMoedaLcto;&#013;&#010;    if (:aMoedaFuncional is null) then&#013;&#010;      select CODIGOMOEDA from CARREGARMOEDAFUNCIONAL(:pCodigoEmpresa, :pCodigoEstab, :pDataSaldo) into :aMoedaFuncional;&#013;&#010;&#013;&#010;    if (:aMoedaFuncional is not null) then&#013;&#010;    begin&#013;&#010;      if (:pContaCtbDeb is not null) then&#013;&#010;        execute procedure TOTALIZARSALDOBDMOEDA(:pCodigoEmpresa,&#013;&#010;                                                :pCodigoEstab,&#013;&#010;                                                :pContaCtbDeb,&#013;&#010;                                                :pDataSaldo,&#013;&#010;                                                :pTipoLancamento,&#013;&#010;                                                :aMoedaFuncional,&#013;&#010;                                                :pValorLctoMoeda,&#013;&#010;                                                0);&#013;&#010;&#013;&#010;      if (:pContaCtbCred is not null) then&#013;&#010;        execute procedure TOTALIZARSALDOBDMOEDA(:pCodigoEmpresa,&#013;&#010;                                                :pCodigoEstab,&#013;&#010;                                                :pContaCtbCred,&#013;&#010;                                                :pDataSaldo,&#013;&#010;                                                :pTipoLancamento,&#013;&#010;                                                :aMoedaFuncional,&#013;&#010;                                                0,&#013;&#010;                                                :pValorLctoMoeda);&#013;&#010;    end&#013;&#010;  end&#013;&#010;end"/>
</ROWDATA>
</DATAPACKET>
