Jump to content
Seja Membro VIP - Remova Banners de Propagandas, Tenha Liberado Qualquer Download, Além de Acessos em Áreas Exclusivas!! ×

Recommended Posts


  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  39
  • Content Per Day:  0.01
  • Reputation:   2
  • Achievement Points:  327
  • Solved Content:  0
  • Days Won:  1
  • Status:  Offline

Posted

Pessoal, nao sei se vai ser de utilidade, mas coloco aqui uma consulta que pega, pelo numero do movimento (TMOV.NUMEROMOV) todos os itens dele e valida o codigo EAN, espero que ajude, caso a NFe seja rejeitada por codigo EAN invalido.



SELECT 
--TITMMOV.IDMOV,
--TMOV.NUMEROMOV,
--TMOV.DATAEMISSAO,
--TITMMOV.IDPRD,
TPRODUTO.CODIGOPRD,
TPRODUTO.NOMEFANTASIA,
TPRDCODIGO.CODIGO,


--VALIDAÇÃO DO CÓDIGO DE BARRAS
DIGITO_CADASTRADO=RIGHT(TPRDCODIGO.CODIGO,1),
DIGITO_CERTO= 10-(RIGHT(CAST(SUBSTRING(TPRDCODIGO.CODIGO,1,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,2,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,3,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,4,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,5,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,6,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,7,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,8,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,9,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,10,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,11,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,12,1) AS INT)*3),1)),


CASE 
WHEN RIGHT(TPRDCODIGO.CODIGO,1) <> (10-(RIGHT(CAST(SUBSTRING(TPRDCODIGO.CODIGO,1,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,2,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,3,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,4,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,5,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,6,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,7,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,8,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,9,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,10,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,11,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,12,1) AS INT)*3),1))) THEN 'ERRADO' END


SELECT 
	--TITMMOV.IDMOV,
	--TMOV.NUMEROMOV,
	--TMOV.DATAEMISSAO,
	--TITMMOV.IDPRD,
	TPRODUTO.CODIGOPRD,
	TPRODUTO.NOMEFANTASIA,
	TPRDCODIGO.CODIGO,
	
	--VALIDAÇÃO DO CÓDIGO DE BARRAS
	DIGITO_CADASTRADO=RIGHT(TPRDCODIGO.CODIGO,1),
	DIGITO_CERTO= 10-(RIGHT(CAST(SUBSTRING(TPRDCODIGO.CODIGO,1,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,2,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,3,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,4,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,5,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,6,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,7,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,8,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,9,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,10,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,11,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,12,1) AS INT)*3),1)),

	CASE 
	WHEN RIGHT(TPRDCODIGO.CODIGO,1) <> (10-(RIGHT(CAST(SUBSTRING(TPRDCODIGO.CODIGO,1,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,2,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,3,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,4,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,5,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,6,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,7,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,8,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,9,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,10,1) AS INT)*3)+CAST(SUBSTRING(TPRDCODIGO.CODIGO,11,1) AS INT)+(CAST(SUBSTRING(TPRDCODIGO.CODIGO,12,1) AS INT)*3),1))) THEN 'ERRADO' END

FROM
	TMOV
	INNER JOIN TITMMOV ON TITMMOV.IDMOV = TMOV.IDMOV
	INNER JOIN TPRODUTO ON TPRODUTO.IDPRD = TITMMOV.IDPRD
	LEFT JOIN TPRDCODIGO ON TPRDCODIGO.IDPRD = TPRODUTO.IDPRD
WHERE
	TMOV.NUMEROMOV='000096906'
	


FROM TMOV INNER JOIN TITMMOV ON TITMMOV.IDMOV = TMOV.IDMOV INNER JOIN TPRODUTO ON TPRODUTO.IDPRD = TITMMOV.IDPRD LEFT JOIN TPRDCODIGO ON TPRDCODIGO.IDPRD = TPRODUTO.IDPRD WHERE TMOV.NUMEROMOV='000096906'

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic


  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  133
  • Content Per Day:  0.03
  • Reputation:   5
  • Achievement Points:  979
  • Solved Content:  0
  • Days Won:  3
  • Status:  Offline
  • Age:  34

Posted

Isso aí cara!

Mais coisa pra ficar indexada no Google.

Valeu!

O ForumRM é eterno... esse seu conteúdo sempre estará aqui e no Google :EmoticonosMsN (85):

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.