<?xml version="1.0" standalone="yes"?>
  <DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="PRO_KEY" fieldtype="string.uni" required="true" WIDTH="256">
<PARAM Name="ORIGIN" Value="PRO_KEY" Roundtrip="True"/>
</FIELD>
<FIELD attrname="ID_KEY" fieldtype="i2" required="true">
<PARAM Name="ORIGIN" Value="ID_KEY" Roundtrip="True"/>
</FIELD>
<FIELD attrname="PROCEDURE_SOURCE" fieldtype="string.uni" WIDTH="8000">
<PARAM Name="ORIGIN" Value="PROCEDURE_SOURCE" Roundtrip="True"/>
</FIELD>
</FIELDS>
<PARAMS DEFAULT_ORDER="1 2"/>
</METADATA>
<ROWDATA>
<ROW PRO_KEY="add_months" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].[add_months] (  @datetime datetime,  @count integer ) RETURNS datetime AS BEGIN  DECLARE @ResultVar datetime  set @ResultVar = DATEADD(month, @count, @datetime)  RETURN @ResultVar END"/>
<ROW PRO_KEY="CARREGARMOEDAFUNCIONAL" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].CARREGARMOEDAFUNCIONAL ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pDataMoeda date ) RETURNS smallint AS BEGIN declare @aCodigoMoeda smallint set @aCodigoMoeda = (select CodigoMoeda from OPCAOMOEDAFUNCIONAL where CODIGOEMPRESA = @pCodigoEmpresa and CODIGOESTAB = @pCodigoEstab and DATAINICIAL &lt;= @pDataMoeda and (DATAFINAL &gt;= @pDataMoeda or DATAFINAL is null) ) if (@aCodigoMoeda is null) set @aCodigoMoeda = (select CodigoMoeda from OPCAOMOEDAFUNCIONAL where CODIGOEMPRESA = @pCodigoEmpresa and CODIGOESTAB = 1/*Matriz*/ and DATAINICIAL &lt;= @pDataMoeda and (DATAFINAL &gt;= @pDataMoeda or DATAFINAL is null) ) RETURN @aCodigoMoeda END"/>
<ROW PRO_KEY="DOCUMENTOACERTO" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].[DOCUMENTOACERTO] ( @PCODIGOESCRIT integer, @PCODIGOACERTO integer ) RETURNS varchar(1000) AS BEGIN  declare @DOCUMENTOS as varchar(1000)  declare @documento as varchar(10)  declare curDados cursor for   select distinct   case    when FCP.CodigoPagarCab &gt; 0 then cast(FCP.CodigoPagarCab as varchar(10))    when FCR.NUMERODCTOCR &lt;&gt; &apos;&apos; then FCR.NUMERODCTOCR    when FSN.SERIENS + cast(FSN.NUMERONS as varchar(10)) &lt;&gt; &apos;&apos; then FSN.SERIENS + cast(FSN.NUMERONS as varchar(10))    else &apos;&apos;   end Doc   from FPRACERTO AC   left join FPRACERTOCP FCP on FCP.CodigoEscrit = AC.CodigoEscrit and FCP.CodigoAcerto = AC.CodigoAcerto   left join FPRACERTOCXFINCR FCR on FCR.CodigoEscrit = AC.CodigoEscrit and FCR.CodigoAcerto = AC.CodigoAcerto   left join FPRACERTOCXFINSERVICONOTA FSN on FSN.CodigoEscrit = AC.CodigoEscrit and FSN.CodigoAcerto = AC.CodigoAcerto   where AC.CodigoEscrit = @PCODIGOESCRIT   and AC.CodigoAcerto = @PCODIGOACERTO   order by Doc SET @DOCUMENTOS = &apos;&apos;; open curDados; fetch next from curDados into @documento; WHILE @@FETCH_STATUS = 0 begin if (@DOCUMENTOS &lt;&gt; &apos;&apos;) SET @DOCUMENTOS = @DOCUMENTOS + &apos;;&apos;; SET @DOCUMENTOS = @DOCUMENTOS + @documento; fetch next from curDados into @documento; end close curDados; DEALLOCATE curDados; RETURN @DOCUMENTOS END"/>
<ROW PRO_KEY="EMAILSPESSOAFINANCEIRO" ID_KEY="1" PROCEDURE_SOURCE="create FUNCTION EMAILSPESSOAFINANCEIRO (  @PCODIGO integer ) RETURNS varchar(1000) AS BEGIN  declare @email as varchar(100)  declare @emails as varchar(1000)  declare curdados cursor for   select valor   from pessoacontato   where tipocontato in (7,8,9)   and codigopessoafin = @pcodigo   order by tipocontato desc, codigopessoacontato    SET @EMAILS = &apos;&apos; open curDados; fetch NEXT FROM curDados into @email; WHILE @@FETCH_STATUS = 0 BEGIN if (@EMAILS &lt;&gt; &apos;&apos;) SET @EMAILS = @EMAILS + &apos;;&apos;; SET @EMAILS = @EMAILS + @email; fetch NEXT FROM curDados into @email; end close curDados; DEALLOCATE curDados; return @EMAILS END"/>
<ROW PRO_KEY="EMAILSPESSOAFINANCEIRORPS" ID_KEY="1" PROCEDURE_SOURCE="create FUNCTION [dbo].[EMAILSPESSOAFINANCEIRORPS] ( @PCODIGO integer ) RETURNS varchar(1000) AS BEGIN   declare @email as varchar(100)   declare @emails as varchar(1000)   declare curdados cursor for select valor from pessoacontato    where tipocontato in (9) and codigopessoafin = @pcodigo    order by tipocontato desc, codigopessoacontato    SET @EMAILS = &apos;&apos; open curDados; fetch NEXT FROM curDados into @email; WHILE @@FETCH_STATUS = 0 BEGIN if (@EMAILS &lt;&gt; &apos;&apos;) SET @EMAILS = @EMAILS + &apos;;&apos;; SET @EMAILS = @EMAILS + @email; fetch NEXT FROM curDados into @email; end close curDados; DEALLOCATE curDados; return @EMAILS END;"/>
<ROW PRO_KEY="F_COLLATEBR" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION F_COLLATEBR ( @A varchar(256) ) RETURNS varchar(256) AS BEGIN SET @A = upper(@A) SET @A = replace(@A, CHAR(192), &apos;A&apos;) SET @A = replace(@A, CHAR(193), &apos;A&apos;) SET @A = replace(@A, CHAR(194), &apos;A&apos;) SET @A = replace(@A, CHAR(195), &apos;A&apos;) SET @A = replace(@A, CHAR(196), &apos;A&apos;) SET @A = replace(@A, CHAR(197), &apos;A&apos;) SET @A = replace(@A, CHAR(199), &apos;C&apos;) SET @A = replace(@A, CHAR(200), &apos;E&apos;) SET @A = replace(@A, CHAR(201), &apos;E&apos;) SET @A = replace(@A, CHAR(202), &apos;E&apos;) SET @A = replace(@A, CHAR(203), &apos;E&apos;) SET @A = replace(@A, CHAR(204), &apos;I&apos;) SET @A = replace(@A, CHAR(205), &apos;I&apos;) SET @A = replace(@A, CHAR(206), &apos;I&apos;) SET @A = replace(@A, CHAR(207), &apos;I&apos;) SET @A = replace(@A, CHAR(209), &apos;N&apos;) SET @A = replace(@A, CHAR(210), &apos;O&apos;) SET @A = replace(@A, CHAR(211), &apos;O&apos;) SET @A = replace(@A, CHAR(212), &apos;O&apos;) SET @A = replace(@A, CHAR(213), &apos;O&apos;) SET @A = replace(@A, CHAR(214), &apos;O&apos;) SET @A = replace(@A, CHAR(217), &apos;U&apos;) SET @A = replace(@A, CHAR(218), &apos;U&apos;) SET @A = replace(@A, CHAR(219), &apos;U&apos;) SET @A = replace(@A, CHAR(220), &apos;U&apos;) SET @A = replace(@A, CHAR(221), &apos;Y&apos;) SET @A = replace(@A, CHAR(224), &apos;A&apos;) SET @A = replace(@A, CHAR(225), &apos;A&apos;) SET @A = replace(@A, CHAR(226), &apos;A&apos;) SET @A = replace(@A, CHAR(227), &apos;A&apos;) SET @A = replace(@A, CHAR(228), &apos;A&apos;) SET @A = replace(@A, CHAR(229), &apos;A&apos;) SET @A = replace(@A, CHAR(231), &apos;C&apos;) SET @A = replace(@A, CHAR(232), &apos;E&apos;) SET @A = replace(@A, CHAR(233), &apos;E&apos;) SET @A = replace(@A, CHAR(234), &apos;E&apos;) SET @A = replace(@A, CHAR(235), &apos;E&apos;) SET @A = replace(@A, CHAR(236), &apos;I&apos;) SET @A = replace(@A, CHAR(237), &apos;I&apos;) SET @A = replace(@A, CHAR(238), &apos;I&apos;) SET @A = replace(@A, CHAR(239), &apos;I&apos;) SET @A = replace(@A, CHAR(241), &apos;N&apos;) SET @A = replace(@A, CHAR(242), &apos;O&apos;) SET @A = replace(@A, CHAR(243), &apos;O&apos;) SET @A = replace(@A, CHAR(244), &apos;O&apos;) SET @A = replace(@A, CHAR(245), &apos;O&apos;) SET @A = replace(@A, CHAR(246), &apos;O&apos;) SET @A = replace(@A, CHAR(249), &apos;U&apos;) SET @A = replace(@A, CHAR(250), &apos;U&apos;) SET @A = replace(@A, CHAR(251), &apos;U&apos;) SET @A = replace(@A, CHAR(252), &apos;U&apos;) SET @A = replace(@A, CHAR(253), &apos;Y&apos;) SET @A = replace(@A, CHAR(255), &apos;Y&apos;) RETURN @A END"/>
<ROW PRO_KEY="FORMATARDDDFONE" ID_KEY="1" PROCEDURE_SOURCE="create FUNCTION FORMATARDDDFONE (  @PNUMEROFONE varchar(100) ) RETURNS integer AS BEGIN  DECLARE @DDD as integer   if (substring(@PNUMEROFONE, 1, 1) = &apos;0&apos; and (Len(@PNUMEROFONE) = 9)) SET @DDD = null; else if (substring(@PNUMEROFONE, 1, 2) = &apos;00&apos;) SET @DDD = null; else if (Len(@PNUMEROFONE) = 8) SET @DDD = null; else if ((substring(@PNUMEROFONE, 1, 1) = &apos;0&apos;) and (Len(cast(substring(@PNUMEROFONE, 2, 2) as integer)) = 2)) SET @DDD = cast(substring(@PNUMEROFONE, 2, 2) as integer); else if ((Len(@PNUMEROFONE) = 9) and (substring(@PNUMEROFONE, 5, 1) &lt;&gt; &apos;.&apos;)) SET @DDD = cast(substring(@PNUMEROFONE, 1, 2) as integer); else if (substring(@PNUMEROFONE, 1, 1) = &apos;(&apos;) SET @DDD = cast(substring(@PNUMEROFONE, 2, 2) as integer); else if ((Len(@PNUMEROFONE) = 10) and (substring(@PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;) and (CHARINDEX(&apos;.&apos;, @PNUMEROFONE) = 0)) SET @DDD = cast(substring(@PNUMEROFONE, 1, 2) as integer); else SET @DDD = null;  RETURN @DDD; END"/>
<ROW PRO_KEY="FORMATARNUMEROFONE" ID_KEY="1" PROCEDURE_SOURCE="create FUNCTION [dbo].[FORMATARNUMEROFONE] ( @PNUMEROFONE varchar(100) ) RETURNS integer AS BEGIN  DECLARE @FONE as integer  SET @FONE = null  if (substring(@PNUMEROFONE, 1, 1) &lt;&gt; &apos;(&apos; and (substring(@PNUMEROFONE, 6, 1) = &apos;.&apos;) and (CHARINDEX(&apos;/&apos;, @PNUMEROFONE)=0))   SET @FONE = try_cast(substring(@PNUMEROFONE, 1, 5) + substring(@PNUMEROFONE, 7, 4) as integer);  else if (substring(@PNUMEROFONE, 1, 1) = &apos;(&apos; and (substring(@PNUMEROFONE, 11, 1) = &apos;.&apos;))   SET @FONE = try_cast(substring(@PNUMEROFONE, 6, 5) + substring(@PNUMEROFONE, 12, 4) as integer);  else if (substring(@PNUMEROFONE, 1, 1) = &apos;0&apos; and (Len(@PNUMEROFONE) = 9))   SET @FONE = try_cast(substring(@PNUMEROFONE, 2, 8) as integer);  else if (substring(@PNUMEROFONE, 1, 1) = &apos;0&apos; and (Len(@PNUMEROFONE) = 10))   SET @FONE = try_cast(substring(@PNUMEROFONE, 3, 8) as integer);  else if (substring(@PNUMEROFONE, 1, 1) = &apos;0&apos; and (Len(@PNUMEROFONE) = 11))   SET @FONE = try_cast(substring(@PNUMEROFONE, 3, 9) as integer);  else if (substring(@PNUMEROFONE, 1, 2) = &apos;00&apos;)   SET @FONE = try_cast(substring(@PNUMEROFONE, 3, Len(@PNUMEROFONE)-3) as integer);  else if ((Len(@PNUMEROFONE) = 9) and (substring(@PNUMEROFONE, 5, 1) &lt;&gt; &apos;.&apos;))   SET @FONE = try_cast(substring(@PNUMEROFONE, 3, 7) as integer);  else if ((Len(@PNUMEROFONE) = 9) and (substring(@PNUMEROFONE, 5, 1) = &apos;.&apos;))   SET @FONE = try_cast(substring(@PNUMEROFONE, 1, 4) + substring(@PNUMEROFONE, 6, 4) as integer);  else if (substring(@PNUMEROFONE, 1, 1) = &apos;(&apos; and (substring(@PNUMEROFONE, 10, 1) = &apos;.&apos;))   SET @FONE = try_cast(substring(@PNUMEROFONE, 6, 4) + substring(@PNUMEROFONE, 11, 4) as integer);  else if ((Len(@PNUMEROFONE) = 10) and (substring(@PNUMEROFONE, 1, 1) &lt;&gt; &apos;0&apos;))   SET @FONE = try_cast(substring(@PNUMEROFONE, 2, 9) as integer);  else   SET @FONE = try_cast(@PNUMEROFONE as integer);  RETURN @FONE END"/>
<ROW PRO_KEY="lpad" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].[lpad](@argvalue varchar(2000), @size int, @padstring varchar(1)) RETURNS varchar(2000) AS BEGIN return right(replicate(@padstring, @size) + @argvalue, @size) END"/>
<ROW PRO_KEY="substr" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].[substr]( @argvalue varchar(2000), @start int, @end int) RETURNS varchar(2000) AS BEGIN return substring(@argvalue, @start, @end - @start + 1) END"/>
<ROW PRO_KEY="SUBTRAIRSALDOBD" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOBD ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTB set ValorDeb = ValorDeb - @pValorDeb, ValorCred = ValorCred - @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @pDataSaldo and TipoLancamento = @pTipoLancamento; update SALDOCTBMENSAL set ValorDeb = ValorDeb - @pValorDeb, ValorCred = ValorCred - @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento; END"/>
<ROW PRO_KEY="SUBTRAIRSALDOBDHIST" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOBDHIST ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoHistCtb smallint, @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTBMENSALHIST set ValorDeb = ValorDeb - @pValorDeb, ValorCred = ValorCred - @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento and CodigoHistCtb = @pCodigoHistCtb; END"/>
<ROW PRO_KEY="SUBTRAIRSALDOBDMOEDA" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOBDMOEDA ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoMoeda smallint, @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTBMOEDA set ValorDeb = ValorDeb - @pValorDeb, ValorCred = ValorCred - @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @pDataSaldo and TipoLancamento = @pTipoLancamento and CodigoMoeda = @pCodigoMoeda; update SALDOCTBMOEDAMENSAL set ValorDeb = ValorDeb - @pValorDeb, ValorCred = ValorCred - @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento and CodigoMoeda = @pCodigoMoeda; END"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTB" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOCTB ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorSaldoCtb numeric(14, 2) ) AS BEGIN if (@pContaCtbDeb is not null) EXECUTE SUBTRAIRSALDOBD @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @pValorSaldoCtb, 0; if (@pContaCtbCred is not null) EXECUTE SUBTRAIRSALDOBD @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, 0, @pValorSaldoCtb; END"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTBHIST" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOCTBHIST ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoHistCtb smallint, @pValorSaldoCtb numeric(14, 2) ) AS BEGIN if (@pCodigoHistCtb is not null) begin if (@pContaCtbDeb is not null) EXECUTE SUBTRAIRSALDOBDHIST @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @pCodigoHistCtb, @pValorSaldoCtb, 0; if (@pContaCtbCred is not null) EXECUTE SUBTRAIRSALDOBDHIST @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, @pCodigoHistCtb, 0, @pValorSaldoCtb; end; END"/>
<ROW PRO_KEY="SUBTRAIRSALDOCTBMOEDA" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].SUBTRAIRSALDOCTBMOEDA ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorLctoMoeda numeric(14, 2), @pCodigoMoedaLcto smallint ) AS BEGIN declare @aMoedaFuncional smallint if (@pValorLctoMoeda is not null) begin set @aMoedaFuncional = @pCodigoMoedaLcto if (@aMoedaFuncional is null) select dbo.CARREGARMOEDAFUNCIONAL(@pCodigoEmpresa, @pCodigoEstab, @pDataSaldo) as aMoedaFuncional if (@aMoedaFuncional is not null) begin if (@pContaCtbDeb is not null) EXECUTE SUBTRAIRSALDOBDMOEDA @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @aMoedaFuncional, @pValorLctoMoeda, 0; if (@pContaCtbCred is not null) EXECUTE SUBTRAIRSALDOBDMOEDA @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, @aMoedaFuncional, 0, @pValorLctoMoeda; end end END"/>
<ROW PRO_KEY="TOTALIZARSALDOBD" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOBD ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTB set ValorDeb = ValorDeb + @pValorDeb, ValorCred = ValorCred + @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @pDataSaldo and TipoLancamento = @pTipoLancamento; if (@@rowcount = 0) insert into SALDOCTB (CodigoEmpresa, CodigoEstab, ContaCtb, DataSaldo, TipoLancamento, ValorDeb, ValorCred) values (@pCodigoEmpresa, @pCodigoEstab, @pContaCtb, @pDataSaldo, @pTipoLancamento, @pValorDeb, @pValorCred); update SALDOCTBMENSAL set ValorDeb = ValorDeb + @pValorDeb, ValorCred = ValorCred + @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento; if (@@rowcount = 0) insert into SALDOCTBMENSAL (CodigoEmpresa, CodigoEstab, ContaCtb, DataSaldo, TipoLancamento, ValorDeb, ValorCred) values (@pCodigoEmpresa, @pCodigoEstab, @pContaCtb, @aDataSaldoMensal, @pTipoLancamento, @pValorDeb, @pValorCred); END"/>
<ROW PRO_KEY="TOTALIZARSALDOBDHIST" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOBDHIST ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoHistCtb smallint, @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTBMENSALHIST set ValorDeb = ValorDeb + @pValorDeb, ValorCred = ValorCred + @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento and CodigoHistCtb = @pCodigoHistCtb; if (@@rowcount = 0) insert into SALDOCTBMENSALHIST (CodigoEmpresa, CodigoEstab, ContaCtb, DataSaldo, TipoLancamento, CodigoHistCtb, ValorDeb, ValorCred) values (@pCodigoEmpresa, @pCodigoEstab, @pContaCtb, @aDataSaldoMensal, @pTipoLancamento, @pCodigoHistCtb, @pValorDeb, @pValorCred); END"/>
<ROW PRO_KEY="TOTALIZARSALDOBDMOEDA" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOBDMOEDA ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtb numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoMoeda smallint, @pValorDeb numeric(14, 2), @pValorCred numeric(14, 2) ) AS BEGIN declare @aDataSaldoMensal date set @aDataSaldoMensal = (DATEFROMPARTS(YEAR(@pDataSaldo), MONTH(@pDataSaldo), 1)) update SALDOCTBMOEDA set ValorDeb = ValorDeb + @pValorDeb, ValorCred = ValorCred + @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @pDataSaldo and TipoLancamento = @pTipoLancamento and CodigoMoeda = @pCodigoMoeda; if (@@rowcount = 0) insert into SALDOCTBMOEDA (CodigoEmpresa, CodigoEstab, ContaCtb, DataSaldo, TipoLancamento, CodigoMoeda, ValorDeb, ValorCred) values (@pCodigoEmpresa, @pCodigoEstab, @pContaCtb, @pDataSaldo, @pTipoLancamento, @pCodigoMoeda, @pValorDeb, @pValorCred); update SALDOCTBMOEDAMENSAL set ValorDeb = ValorDeb + @pValorDeb, ValorCred = ValorCred + @pValorCred where CodigoEmpresa = @pCodigoEmpresa and CodigoEstab = @pCodigoEstab and ContaCtb = @pContaCtb and DataSaldo = @aDataSaldoMensal and TipoLancamento = @pTipoLancamento and CodigoMoeda = @pCodigoMoeda; if (@@rowcount = 0) insert into SALDOCTBMOEDAMENSAL (CodigoEmpresa, CodigoEstab, ContaCtb, DataSaldo, TipoLancamento, CodigoMoeda, ValorDeb, ValorCred) values (@pCodigoEmpresa, @pCodigoEstab, @pContaCtb, @aDataSaldoMensal, @pTipoLancamento, @pCodigoMoeda, @pValorDeb, @pValorCred); END"/>
<ROW PRO_KEY="TOTALIZARSALDOCTB" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOCTB ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorSaldoCtb numeric(14, 2) ) AS BEGIN if (@pContaCtbDeb is not null) EXECUTE TOTALIZARSALDOBD @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @pValorSaldoCtb, 0; if (@pContaCtbCred is not null) EXECUTE TOTALIZARSALDOBD @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, 0, @pValorSaldoCtb; END"/>
<ROW PRO_KEY="TOTALIZARSALDOCTBHIST" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOCTBHIST ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pCodigoHistCtb smallint, @pValorSaldoCtb numeric(14, 2) ) AS BEGIN if (@pCodigoHistCtb is not null) begin if (@pContaCtbDeb is not null) EXECUTE TOTALIZARSALDOBDHIST @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @pCodigoHistCtb, @pValorSaldoCtb, 0; if (@pContaCtbCred is not null) EXECUTE TOTALIZARSALDOBDHIST @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, @pCodigoHistCtb, 0, @pValorSaldoCtb; end END"/>
<ROW PRO_KEY="TOTALIZARSALDOCTBMOEDA" ID_KEY="1" PROCEDURE_SOURCE="CREATE PROCEDURE [dbo].TOTALIZARSALDOCTBMOEDA ( @pCodigoEmpresa smallint, @pCodigoEstab smallint, @pContaCtbDeb numeric(10), @pContaCtbCred numeric(10), @pDataSaldo date, @pTipoLancamento varchar(2), @pValorLctoMoeda numeric(14, 2), @pCodigoMoedaLcto smallint ) AS BEGIN declare @aMoedaFuncional smallint if (@pValorLctoMoeda is not null) begin set @aMoedaFuncional = @pCodigoMoedaLcto if (@aMoedaFuncional is null) select dbo.CARREGARMOEDAFUNCIONAL(@pCodigoEmpresa, @pCodigoEstab, @pDataSaldo) as aMoedaFuncional if (@aMoedaFuncional is not null) begin if (@pContaCtbDeb is not null) EXECUTE TOTALIZARSALDOBDMOEDA @pCodigoEmpresa, @pCodigoEstab, @pContaCtbDeb, @pDataSaldo, @pTipoLancamento, @aMoedaFuncional, @pValorLctoMoeda, 0; if (@pContaCtbCred is not null) EXECUTE TOTALIZARSALDOBDMOEDA @pCodigoEmpresa, @pCodigoEstab, @pContaCtbCred, @pDataSaldo, @pTipoLancamento, @aMoedaFuncional, 0, @pValorLctoMoeda; end end END"/>
<ROW PRO_KEY="trim" ID_KEY="1" PROCEDURE_SOURCE="CREATE FUNCTION [dbo].[trim](@argvalue varchar(2000)) RETURNS varchar(2000) AS BEGIN  return ltrim(rtrim(@argvalue)) END"/>
</ROWDATA>
</DATAPACKET>
