Veja o tutorial em Vídeo:
Ao gerar uma nota de saída o sistema faz o calculo total das mercadorias diferente do total da nota

Na emissão da nota o sistema também leva o total das mercadorias, onde o mesmo deveria levar o total da nota.

Para correção do erro, baixe a Correção de Arredondamento de Centavos.rar e faça os passos a seguir:
- Extraia as 4 sqls que estão no arquivo
- Vá até o IBExpert e no CTRL+F12 rode as mesmas na sequência
01_SPI_TRUNC_2.sql
SET TERM ^ ;
CREATE OR ALTER procedure SPI_TRUNC_2 (
VALOR numeric(15,5))
returns (
RESULT numeric(15,2))
as
declare variable INTEIRO integer;
declare variable FRAC numeric(15,5);
declare variable STR varchar(20);
declare variable pos integer;
begin
str = cast(valor as varchar(20));
pos = position('.' in str);
if (pos = 0) then
pos = position(',' in str);
if (pos = 0) then
begin
result = cast(valor as numeric(15,2));
suspend;
end
else
begin
str = substring(str from 1 for pos - 1);
inteiro = cast(str as integer);
--inteiro = cast(valor as integer);
frac = valor - inteiro;
str = cast(frac as varchar(20));
str = substring(str from 1 for 4);
frac = cast(str as numeric(15,2));
result = inteiro + frac;
suspend;
end
end^
SET TERM ; ^
02_A02ANFSV_BI1.sql
SET TERM ^ ;
CREATE OR ALTER trigger a02anfsv_bi1 for a02anfsv
active before insert position 1
AS
declare variable codcfo integer;
declare variable xser varchar(3);
declare variable parencerrante char(1);
BEGIN
if (current_user <> 'REPLICATOR') then
BEGIN
IF ((NEW.nvtotal IS NULL) OR (NEW.nvtotal = 0)) THEN
NEW.nvtotal = NEW.nvqtd * NEW.nvunit;
IF (NEW.nvitem IS NULL) THEN
NEW.nvitem = 0;
IF (NEW.nvitem = 0) THEN
BEGIN
SELECT MAX(nvitem)+1 FROM a02anfsv
WHERE nvemp = NEW.nvemp AND nvnfseq = NEW.nvnfseq
INTO NEW.nvitem;
IF (NEW.nvitem IS NULL) THEN
NEW.nvitem = 1;
END
SELECT a02amerc.menome, a02apre.mepven
FROM a02amerc
LEFT JOIN a02apre ON a02apre.mecod = a02amerc.mecod
WHERE a02amerc.mecod = NEW.nvcodm AND a02apre.meemp = NEW.nvemp
INTO NEW.nvnmerc, NEW.nvprctab;
select nfoper, nfser from a02anfcl where
nfemp = new.nvemp and nfseq = new.nvnfseq
into :codcfo, :xser;
if (:xser = 'CX') then
begin
select parencerrante from sisapar where parcod = new.nvemp into :parencerrante;
if (:parencerrante = 'R') then
exception ex_naopermitido;
end
if (new.nvcfo is null) then
new.nvcfo = :codcfo;
select result from spi_trunc_2(new.nvtotal) into new.nvtotal;
--new.nvtotal = cast(new.nvtotal * 100 as numeric(15,2)) / 100;
END
END^
SET TERM ; ^
03_A02ANFSV_BU0.sql
SET TERM ^ ;
CREATE OR ALTER trigger a02anfsv_bu0 for a02anfsv
active before update position 0
as
begin
new.NVDTALTERACAO = cast('NOW' as date);
if (new.NVACRE is null) then
new.NVACRE = 0;
if (new.NVDESC is null) then
new.NVDESC = 0;
if (new.NVSIT is null) then
new.NVSIT = 'A';
if ((new.NVTOTAL is null) or (new.NVTOTAL = 0)) then
new.NVTOTAL = new.NVQTD * new.NVUNIT;
if ((old.NVCODM <> new.NVCODM) or (new.nvnmerc is null)) then
begin
select A02AMERC.MENOME, A02APRE.MEPVEN
from A02AMERC
left join A02APRE on A02APRE.MECOD = A02AMERC.MECOD
where A02AMERC.MECOD = new.NVCODM and
A02APRE.MEEMP = new.NVEMP
into new.NVNMERC, new.NVPRCTAB;
end
if ((NEW.nvencerrante IS NULL) AND (NEW.nvabaseq IS NOT NULL)) then
BEGIN
SELECT ABAENCERRANTE FROM A02AABA
WHERE ABAEMP = NEW.nvemp AND ABASEQ = NEW.nvabaseq
INTO NEW.nvencerrante;
END
select result from spi_trunc_2(new.nvtotal) into new.nvtotal;
-- new.nvtotal = cast(new.nvtotal * 100 as numeric(15,2)) / 100;
END^
SET TERM ; ^
RODAR NO F12:
04_Corrigir Erro Arredondamento.sql
update a02anfsv a set
nvtotal = (select result from spi_trunc_2(nvqtd * nvunit))
where a.nvemp = :Empresa
and a.nvnfseq in (select nf.nfseq from a02anfcl nf
where cast(nf.nfemis as date) between :DataIni and :DataFim
and nf.nfemp = :Empresa)
Ao executar as sql gere a nota novamente
Se o erro persistir, contate um facilitador.
Tags: Correção de arredondamento de centavos em notas , arredeondamente de notas, arredondamento de centavos, diferença de centavos na nota, nota com diferença de centavos, total da mercadoria difere do total da nota, total da mercadoria diferente do total da nota, total da nota difere do total da mercadoria, total da nota diferente do total da mercadoria

0 comentários:
Postar um comentário