A idéia é:
em 1, somar tudo que é 1xxxx
em 11, somar tudo que é 11xxxxx
em 1101, somar tudo que é 1101xxxx
mas não bateu
o dígito de controle é a posição 12, por isso substr( codigo, 1, 11 ) e mais o trim()
Soma não bate
Moderador: Moderadores
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Soma não bate
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Soma não bate
Resolvido.
Faltou filtrar somente conta analítica.
Faltou filtrar somente conta analítica.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Soma não bate
Código: Selecionar todos
CREATE PROCEDURE ze_ContabilExemploSintetica()
BEGIN
SELECT
jpctconta.idctconta,
TRIM( SUBSTR( jpctconta.cpcodigo, 1, 11 ) ) AS geral,
jpctconta.cpnome, SUM( b.saldo ) AS valor
FROM jpctconta
LEFT JOIN
( SELECT trim(SUBSTR(a.cpcodigo,1,11)) as analitica,
ze_ContabilSaldoAtual( a.idctconta, NOW() ) AS saldo
FROM jpctconta AS A
WHERE cptipo='A'
) AS b ON TRIM( SUBSTR( jpctconta.cpcodigo, 1, 11 ) ) = SUBSTR(b.analitica,1,LENGTH(TRIM( SUBSTR( jpctconta.cpcodigo, 1, 11 ) )) )
GROUP BY jpctconta.idctconta
HAVING valor != 0
ORDER BY geral;
END
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Soma não bate
Resolvi simplificar de vez:
Removi o dígito de controle e não precisa mais SUBSTR( xxx, 1, 11 )
E nas configurações em geral, passei a usar o Id.
Tudo mais simples assim.
Dando uma geral no aplicativo sem mexer em fonte Harbour kkkkk
Removi o dígito de controle e não precisa mais SUBSTR( xxx, 1, 11 )
E nas configurações em geral, passei a usar o Id.
Tudo mais simples assim.
Dando uma geral no aplicativo sem mexer em fonte Harbour kkkkk
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Soma não bate
Código: Selecionar todos
CREATE PROCEDURE ze_ContabilBalancete( nMes INT(11), nFechamento INT(11), nGrau INT(11 ), nZerado INT(11) )
BEGIN
SELECT
JPCTCONTA.IDCTCONTA,
JPCTCONTA.CPCODIGO,
JPCTCONTA.CPNOME, SUM( b.saldo ) AS valor
FROM JPCTCONTA
LEFT JOIN
( SELECT A.CPCODIGO as analitica,
ze_ContabilSaldoAtual( A.IDCTCONTA, NOW() ) AS saldo
FROM JPCTCONTA AS A
WHERE CPTIPO = 'A'
) AS b ON JPCTCONTA.CPCODIGO = SUBSTR( b.analitica, 1, LENGTH( JPCTCONTA.CPCODIGO ) )
GROUP BY JPCTCONTA.IDCTCONTA
HAVING valor != 0
ORDER BY geral;
END
É que comecei a ver que ia ter que fazer isso em tudo que é rotina... então assim simplifica todas.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/