Jump to content
Fivewin Brasil

Wellington Vieira

Membros
  • Posts

    424
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Wellington Vieira

  1. Para renomear SEQUENCES no postgresql.. usa-se... ALTER TABLE [nome da tabela de sequencia a ser alterada] RENAME TO [novo nome da tabela de sequencia]; Pode testar o comando no PGADMIM... no Execute arbitrary SQL querys ou instruções de SQL arbritrária... wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  2. Para renomear SEQUENCES no postgresql.. usa-se... ALTER TABLE [nome da tabela de sequencia a ser alterada] RENAME TO [novo nome da tabela de sequencia]; Pode testar o comando no PGADMIM... no Execute arbitrary SQL querys ou instruções de SQL arbritrária... wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  3. No site da Receita Federal, abaixo: http://www1.receita.fazenda.gov.br/sistemas/efd-pis-cofins/exemplos-de-arquivos.htm wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  4. Uberlândia - Minas Gerais ( 37 anos ) wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  5. Utilizando a contrib - libhbpg .... do xharbour.. e a lib do postgresql libpq.lib, lembrando que: A libpq.lib que vem com o POSTGRESQL é para o microsoft visual C, entao nao funciona. Tem que fazer a seguinte operação: implib -a libpq.lib libpq.dll Criando assim uma nova lib no formato do borland... // Fazendo a conexao com o postgresql.......................................... oserver = "" cServer = alltrim(pServ) // exemplo: 127.0.0.1 e assim por diante.. cDatabase = alltrim(pdata) // exemplo: postgresql - nome do banco de dados. cUser = alltrim(pUser) // exemplo: postgre - nome do usuario. cPass = alltrim(pPass) // exemplo: teste - senha.. oServer := TPQServer():New(cServer, cDatabase, cUser, cPass) if oServer:NetErr() msgstop("erro de conexão com a base de dados!","Atenção") //oServer:Error() return nil endif // Criando bco de dados........................................................ if oServer:TableExists("rfontes") else cQuery := 'CREATE TABLE rfontes(' cQuery += 'fsqn serial primary key,' cQuery += 'fcod character(3),' cQuery += 'fhei Numeric(04,0),' cQuery += 'fwid Numeric(04,0),' cQuery += 'ffac Varchar(40))' oQuery := oServer:Query(cQuery) if oQuery:neterr() msgstop("Nao foi possível criar arquivo de fontes de cliente. O sistema sera finalizado.","ATENÇÃO") oServer:Destroy() return .t. endif oQuery:Destroy() endif // Gravando dados em uma tabela................................................ // variaveis.. memp = 1 ykdhm = "2011-04-01" nkncx = 1 msn = "n" cQuery := "insert into r111a0000(kemp,kdat,kncx,kfec)" cQuery += "values("+str(memp)+","+; "'"+ykdhm+"'"+","+; str(nkncx)+","+; "'"+"msn"+"'"+")" oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Erro na inclusão do caixa.","ATENÇÂO") //oQuery:error() endif oQuery:destroy() oServer:Commit() // Alterando dados em uma tabela............................................... // variaveis.. mtps = 1 madat = "2011-04-01" macon = "teste" memp = 1 // codigo da empresa a ser alterada.. cwQuery := "Update r50000000 set "+; "atps = " +alltrim(str(mtps))+ "," +; "adat = " +"'"+madat+"'"+ "," +; "acon = " +"'"+macon+"'"+; " where " + " aesq = " + alltrim(str(memp)) owQuery := oServer:Query(cwQuery) if owQuery:neterr() msgStop("Erro de rede em empresas.","ATENÇÂO") endif owQuery:destroy() oServer:Commit() // Excluindo dados em uma tabela............................................... // variavel mnsqn = 5 // codigo do registro a ser deletado.. cQuery := "delete from e50700000 where"+; " nsqn = " + alltrim(str(mnsqn)) oQuery := oServer:Query(cQuery) if oQuery:neterr() msgstop("Não foi possível realizar a operação de exclusão.","ATENÇÂO") endif oQuery:destroy() oServer:Commit() // Procurando ou fazendo uma selecao........................................... // variaveis.. ndtin = substr(dtos(date()),1,4)+"-"+substr(dtos(date()),5,2)+"-"+substr(dtos(date()),7,2) ndtfi = substr(dtos(date()),1,4)+"-"+substr(dtos(date()),5,2)+"-"+substr(dtos(date()),7,2) mbcol = 1 *** Localizando um ou varios registros em uma tabela... cQuery := "select n60500000.*,e40100000.bprd,e40100000.bcol,e40100000.bpag,n609a0000.*,n60900000.* from n60500000,e40100000,n609a0000,n60900000 where"+; " n60500000.ycdg = e40100000.bcdg and"+; " n60500000.ytam = n609a0000.tcdt and n60500000.ycor = n60900000.ccdc and" cQuery += " ystd is null" cQuery += " and bcol = " + alltrim(str(mbcol)) cQuery += " order by yprf asc, ydtm asc, ycdg asc, ytam asc, ycor asc;" oQuery := oServer:Query(cQuery) *** Fazendo um loop ate o fim da tabela.. do while ! oQuery:Eof() *** pegando os dados... yndc = oQuery:Fieldget(oQuery:Fieldpos('yndc')) // numero de documento ydtm = oQuery:Fieldget(oQuery:Fieldpos('ydtm')) // data do movimento ycdg = oQuery:Fieldget(oQuery:Fieldpos('ycdg')) // codigo do produto a ser produzido ycap = oQuery:Fieldget(oQuery:Fieldpos('ycap')) // codigo de acesso ao produto ytam = oQuery:Fieldget(oQuery:Fieldpos('ytam')) // tamanho ycor = oQuery:Fieldget(oQuery:Fieldpos('ycor')) // cor yprf = oQuery:Fieldget(oQuery:Fieldpos('yprf')) // profissional que produziu yqti = oQuery:Fieldget(oQuery:Fieldpos('yqti')) // quantidade tdta = oQuery:Fieldget(oQuery:Fieldpos('tdta')) // descricao.. ( G,GG,XG,P,M,) oQuery:Skip() end oQuery:destroy() // Localizando varios registros e enviando para um browse... cQuery := "select * from r50000000 "+; "order by aesq asc;" oQuery := oServer:Query(cQuery) xx = 0 esample := {} erec := {} DO WHILE ! oQuery:Eof() zaesq = oQuery:Fieldget(oQuery:Fieldpos('aesq')) zaden = oQuery:Fieldget(oQuery:Fieldpos('aden')) zacid = oQuery:Fieldget(oQuery:Fieldpos('acid')) aadd( esample,{str(zaesq),zaden,zacid}) aadd( erec,zaesq) oQuery:Skip() END oQuery:destroy() define brush obrush color mtela define dialog empresas title "Escolha a empresa" from 010,010 to 220,795 pixel brush oBrush transparent define font mtahoma name "Tahoma" size 5.5,13 define font ofont name 'MS Sans Serif' size 6,15 define font ofontl name "Courier" size 09,09 @ 05.5, 002 listbox oBrw fields esample[oBrw],esample[oBrw],; esample[oBrw]; headers "Cod.","Empresa","Cidade"; FIELDSIZES 050,500,300; size 385,100; pixel of empresas oBrw:nClrPane := {|| iif((oBrw:nat/2) = int(oBrw:nat/2),nRGB(207,226,207),nRGB(224,235,224)) } oBrw:nLineStyle := 2 oBrw:nClrForeHead := nRGB(207,226,207) oBrw:lCellStyle = .t. oBrw:lAutoSkip = .t. oBrw:SetArray(esample) oBrw:bGoTop = { || oBrw:nat := 1 } oBrw:bGoBottom = { || oBrw:nat := Eval( oBrw:bLogicLen ) } oBrw:bSkip = { | nWant, nOld | nOld := oBrw:nat, oBrw:nat += nWant,; oBrw:nat := Max( 1, Min( oBrw:nat, Eval( oBrw:bLogicLen ) ) ),; oBrw:nat - nOld } oBrw:bLogicLen = { || Len( esample ) } oBrw:cAlias = "Array" // Just put something oBrw:nClrBackHead := CLR_LG // Cor do Fundo do Cabe‡alho oBrw:nClrBackFocus := CLR_HB // Cor do Cursor Em Cima do Ötem oBrw:nClrForeFocus := CLR_AM // cor da letra da barra ativa activate dialog empresas center id=code>id=code>wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  6. Utilizando a contrib - libhbpg .... do xharbour.. e a lib do postgresql libpq.lib, lembrando que: A libpq.lib que vem com o POSTGRESQL é para o microsoft visual C, entao nao funciona. Tem que fazer a seguinte operação: implib -a libpq.lib libpq.dll Criando assim uma nova lib no formato do borland... // Fazendo a conexao com o postgresql.......................................... oserver = "" cServer = alltrim(pServ) // exemplo: 127.0.0.1 e assim por diante.. cDatabase = alltrim(pdata) // exemplo: postgresql - nome do banco de dados. cUser = alltrim(pUser) // exemplo: postgre - nome do usuario. cPass = alltrim(pPass) // exemplo: teste - senha.. oServer := TPQServer():New(cServer, cDatabase, cUser, cPass) if oServer:NetErr() msgstop("erro de conexão com a base de dados!","Atenção") //oServer:Error() return nil endif // Criando bco de dados........................................................ if oServer:TableExists("rfontes") else cQuery := 'CREATE TABLE rfontes(' cQuery += 'fsqn serial primary key,' cQuery += 'fcod character(3),' cQuery += 'fhei Numeric(04,0),' cQuery += 'fwid Numeric(04,0),' cQuery += 'ffac Varchar(40))' oQuery := oServer:Query(cQuery) if oQuery:neterr() msgstop("Nao foi possível criar arquivo de fontes de cliente. O sistema sera finalizado.","ATENÇÃO") oServer:Destroy() return .t. endif oQuery:Destroy() endif // Gravando dados em uma tabela................................................ // variaveis.. memp = 1 ykdhm = "2011-04-01" nkncx = 1 msn = "n" cQuery := "insert into r111a0000(kemp,kdat,kncx,kfec)" cQuery += "values("+str(memp)+","+; "'"+ykdhm+"'"+","+; str(nkncx)+","+; "'"+"msn"+"'"+")" oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Erro na inclusão do caixa.","ATENÇÂO") //oQuery:error() endif oQuery:destroy() oServer:Commit() // Alterando dados em uma tabela............................................... // variaveis.. mtps = 1 madat = "2011-04-01" macon = "teste" memp = 1 // codigo da empresa a ser alterada.. cwQuery := "Update r50000000 set "+; "atps = " +alltrim(str(mtps))+ "," +; "adat = " +"'"+madat+"'"+ "," +; "acon = " +"'"+macon+"'"+; " where " + " aesq = " + alltrim(str(memp)) owQuery := oServer:Query(cwQuery) if owQuery:neterr() msgStop("Erro de rede em empresas.","ATENÇÂO") endif owQuery:destroy() oServer:Commit() // Excluindo dados em uma tabela............................................... // variavel mnsqn = 5 // codigo do registro a ser deletado.. cQuery := "delete from e50700000 where"+; " nsqn = " + alltrim(str(mnsqn)) oQuery := oServer:Query(cQuery) if oQuery:neterr() msgstop("Não foi possível realizar a operação de exclusão.","ATENÇÂO") endif oQuery:destroy() oServer:Commit() // Procurando ou fazendo uma selecao........................................... // variaveis.. ndtin = substr(dtos(date()),1,4)+"-"+substr(dtos(date()),5,2)+"-"+substr(dtos(date()),7,2) ndtfi = substr(dtos(date()),1,4)+"-"+substr(dtos(date()),5,2)+"-"+substr(dtos(date()),7,2) mbcol = 1 *** Localizando um ou varios registros em uma tabela... cQuery := "select n60500000.*,e40100000.bprd,e40100000.bcol,e40100000.bpag,n609a0000.*,n60900000.* from n60500000,e40100000,n609a0000,n60900000 where"+; " n60500000.ycdg = e40100000.bcdg and"+; " n60500000.ytam = n609a0000.tcdt and n60500000.ycor = n60900000.ccdc and" cQuery += " ystd is null" cQuery += " and bcol = " + alltrim(str(mbcol)) cQuery += " order by yprf asc, ydtm asc, ycdg asc, ytam asc, ycor asc;" oQuery := oServer:Query(cQuery) *** Fazendo um loop ate o fim da tabela.. do while ! oQuery:Eof() *** pegando os dados... yndc = oQuery:Fieldget(oQuery:Fieldpos('yndc')) // numero de documento ydtm = oQuery:Fieldget(oQuery:Fieldpos('ydtm')) // data do movimento ycdg = oQuery:Fieldget(oQuery:Fieldpos('ycdg')) // codigo do produto a ser produzido ycap = oQuery:Fieldget(oQuery:Fieldpos('ycap')) // codigo de acesso ao produto ytam = oQuery:Fieldget(oQuery:Fieldpos('ytam')) // tamanho ycor = oQuery:Fieldget(oQuery:Fieldpos('ycor')) // cor yprf = oQuery:Fieldget(oQuery:Fieldpos('yprf')) // profissional que produziu yqti = oQuery:Fieldget(oQuery:Fieldpos('yqti')) // quantidade tdta = oQuery:Fieldget(oQuery:Fieldpos('tdta')) // descricao.. ( G,GG,XG,P,M,) oQuery:Skip() end oQuery:destroy() // Localizando varios registros e enviando para um browse... cQuery := "select * from r50000000 "+; "order by aesq asc;" oQuery := oServer:Query(cQuery) xx = 0 esample := {} erec := {} DO WHILE ! oQuery:Eof() zaesq = oQuery:Fieldget(oQuery:Fieldpos('aesq')) zaden = oQuery:Fieldget(oQuery:Fieldpos('aden')) zacid = oQuery:Fieldget(oQuery:Fieldpos('acid')) aadd( esample,{str(zaesq),zaden,zacid}) aadd( erec,zaesq) oQuery:Skip() END oQuery:destroy() define brush obrush color mtela define dialog empresas title "Escolha a empresa" from 010,010 to 220,795 pixel brush oBrush transparent define font mtahoma name "Tahoma" size 5.5,13 define font ofont name 'MS Sans Serif' size 6,15 define font ofontl name "Courier" size 09,09 @ 05.5, 002 listbox oBrw fields esample[oBrw],esample[oBrw],; esample[oBrw]; headers "Cod.","Empresa","Cidade"; FIELDSIZES 050,500,300; size 385,100; pixel of empresas oBrw:nClrPane := {|| iif((oBrw:nat/2) = int(oBrw:nat/2),nRGB(207,226,207),nRGB(224,235,224)) } oBrw:nLineStyle := 2 oBrw:nClrForeHead := nRGB(207,226,207) oBrw:lCellStyle = .t. oBrw:lAutoSkip = .t. oBrw:SetArray(esample) oBrw:bGoTop = { || oBrw:nat := 1 } oBrw:bGoBottom = { || oBrw:nat := Eval( oBrw:bLogicLen ) } oBrw:bSkip = { | nWant, nOld | nOld := oBrw:nat, oBrw:nat += nWant,; oBrw:nat := Max( 1, Min( oBrw:nat, Eval( oBrw:bLogicLen ) ) ),; oBrw:nat - nOld } oBrw:bLogicLen = { || Len( esample ) } oBrw:cAlias = "Array" // Just put something oBrw:nClrBackHead := CLR_LG // Cor do Fundo do Cabe‡alho oBrw:nClrBackFocus := CLR_HB // Cor do Cursor Em Cima do Ötem oBrw:nClrForeFocus := CLR_AM // cor da letra da barra ativa activate dialog empresas center id=code>id=code>wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  7. Bom dia, Alguem já emitiu NF-e para pessoa física (Estrangeiro) de outra nacionalidade, que não é exportação.., mas a pessoa física compra em uma loja aqui no Brasil, para seu próprio uso o produto. Como seria os campos de : Endereço - Seria o endereço onde ele reside no exterior ou o endereço onde ele esta hospedado no Brasil. Estado - Ex => Seria Ex, Exterior Bairro - Exterior => Seria Exterior ou o endereço no País onde ele reside.. Cidade - Exterior => Seria Exterior ou o endereço no País onde ele reside.. Cep - País - Seria o código do País onde ele reside, ou o Brasil pois ele estaria hospedado em algum hotel. CFOP - Qual seria. Obs. Lembrando que esta pessoa física, compra aqui no País e não sabe o dia que voltará ao seu país de origem.. podendo ser 02,03,04,05 meses aqui..., então não seria exportação e sim uma venda direta a uma pessoa física, que não tem CPF e nem RG, somente o Passaport.... wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  8. Bom dia, Alguem já emitiu NF-e para pessoa física (Estrangeiro) de outra nacionalidade, que não é exportação.., mas a pessoa física compra em uma loja aqui no Brasil, para seu próprio uso o produto. Como seria os campos de : Endereço - Seria o endereço onde ele reside no exterior ou o endereço onde ele esta hospedado no Brasil. Estado - Ex => Seria Ex, Exterior Bairro - Exterior => Seria Exterior ou o endereço no País onde ele reside.. Cidade - Exterior => Seria Exterior ou o endereço no País onde ele reside.. Cep - País - Seria o código do País onde ele reside, ou o Brasil pois ele estaria hospedado em algum hotel. CFOP - Qual seria. Obs. Lembrando que esta pessoa física, compra aqui no País e não sabe o dia que voltará ao seu país de origem.. podendo ser 02,03,04,05 meses aqui..., então não seria exportação e sim uma venda direta a uma pessoa física, que não tem CPF e nem RG, somente o Passaport.... wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  9. Boa tarde,, segue um exemplo, os dados foram substituídos por XXXX, então se for validar, deverá conter erros.., por isso é só um exemplo de como fica o XML simples nacional com permissão de credito <?xml version="1.0" encoding="UTF-8" ?> - - - 31 0000XXXX VENDA NO ESTADO 0 55 1 2803 2011-03-31 2011-03-31 1 3106200 1 1 3 2 1 0 4.0.1 - XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX - XXXXXXXXXX XXX XXXXXXXXXXXXXXX 3106200 BELO HORIZONTE MG XXXXXXXX XXXXXXXXXXXXX 1 - XXXXXXXXXXXXXX XXXXXXXXXXXXXX - XXXXXXXXXXXXXXXXX XXXXX XXXXXX 3131901 ITABIRITO MG XXXXXXXX XXXXXXXXXXXXX - - 000112 CL60VD - ACUMULADORES 85071090 5405 PC 2.0000 188.4500 376.90 PC 2.0000 188.4500 37.69 1 - - - 0 101 1.85 6.97 - - 07 - - 07 - - 000113 CL60VE - ACUMULADORES 85071090 5405 PC 2.0000 188.4500 376.90 PC 2.0000 188.4500 37.69 1 - - - 0 101 1.85 6.97 - - 07 - - 07 - - 0.00 0.00 0.00 0.00 753.80 0.00 0.00 75.38 0.00 0.00 0.00 0.00 0.00 678.42 - 1 - XXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX BELO HORIZONTE MG - 4 60.000 60.000 - Empresa optante pelo simples nacional.Permite aprov.de cred.de ICMS no valor 13,95 ref.aliq. 1,85 nos termos do art.23 da LC 123. - - - - eUOPFzaweTaeTa+6yJs+uaCNY/c= Ac+4MWp5rmm6zv3Vzb6GzWd657xotGsY3iECFAC3JYeoRdsjvCVOw+lcDXpi+6KbbUxzhmJ9zRz3ZL2430oP42om4Sk4KV9y9WVa+EjQqfPmVPvPbh6Fw+MpzhkSd0YaeElGRCTZUPyax/1TGJK2NaZSumgVRdnMZN8kl4ITkC4= - - MIIGKzCCBROgAwIBAgIIUufWKub9NKswDQYJKoZIhvcNAXXXXXXXXXXLMAkGA1UEBhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxKDAmBgNVBAMTH1NFUkFTQSBDZXJ0aWZpY2Fkb3JhIERpZ2l0YWwgdjEwHhcNMTEwMTI1MTE0ODI4WhcNMTIwMTI1MTE0ODI4WjCB4TELMAkGA1UEBhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxFDASBgNVBAsTCyhFTSBCUkFOQ08pMRgwFgYDVQQLEw8wMDAwMDEwMDE1NzY1NDQxFDASBgNVBAsTCyhFTSBCUkFOQ08pMRQwEgYDVQQLEwsoRU0gQlJBTkNPKTEUMBIGA1UECxMLKEVNIEJSQU5DTykxFDASBgNVBAsTCyhFTSBCUkFOQ08pMRQwEgYDVQQLEwsoRU0gQlJBTkNPKTEfMB0GA1UEAxMWQkFURVJJQVMgTkFDSU9OQUwgTFREQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsyHLDoDfbsmdy258hb05m+5TWdwqIKhhDEOwbQE91JX2IbEl8MzMDAFlAOP39CQQrC65LBNmJfcmdmemAdplXtYya5Wxpt7apQh+NCTC4Lzi8JVQHa5AMZKo3UD5YJM1nn1PYDD6IRgPq16nUov9L+xTWoS8tdONi/EoWxPnM1sCAwEAAaOCAv0wggL5MA4GA1UdDwEB/wQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwHwYDVR0jBBgwFoAUt2CoW/mypq4A7XTr1UrJlmhm9VwwgcAGA1UdEQSBuDCBtYEbQkFURVJJQVNOQUNJT05BTEBCT0wuQ09NLkJSoDgGBWBMAQMEoC8TLTAyMTAxOTUyMTQzNTEwMjE2OTEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMKAoBgVgTAEDAqAfEx1QQVVMTyBST0JFUlRPIFBJTlRPIE1BTEhFSVJPU6AZBgVXXXXXXXXXXw4xODExMDkxNjAwMDE2MKAXBgVgTAEDB6AOEwwwMDAwMDAwMDAwMDAwVwYDVR0gBFAwTjBMBgZgTAECAQYwQjBABggrBgEFBQcCARY0aHR0cDovL3d3dy5jZXJ0aWZpY2Fkb2RpZ2l0YWwuY29tLmJyL3JlcG9zaXRvcmlvL2RwYzCB8AYDVR0fBIHoMIHlMEmgR6BFhkNodHRwOi8vd3d3LmNlcnRpZmljYWRvZGlnaXRhbC5jb20uYnIvcmVwb3NpdG9yaW8vbGNyL3NlcmFzYWNkdjEuY3JsMEOgQaA/hj1odHRwOi8vbGNyLmNlcnRpZmljYWRvcy5jb20uYnIvcmVwb3NpdG9yaW8vbGNyL3NlcmFzYWNkdjEuY3JsMFOgUaBPhk1odHRwOi8vcmVwb3NpdG9yaW8uaWNwYnJhc2lsLmdvdi5ici9sY3IvU2VyYXNhL3JlcG9zaXRvcmlvL2xjci9zZXJhc2FjZHYxLmNybDCBlwYIKwYBBQUHAQEEgYowgYcwRwYIKwYBBQUHMAKGO2h0dHA6Ly93d3cuY2VydGlmaWNhZG9kaWdpdGFsLmNvbS5ici9jYWRlaWFzL3NlcmFzYWNkdjEucDdiMDwGCCsGAQUFBzABhjBodHRwOi8vb2NzcC5jZXJ0aWZpY2Fkb2RpZ2l0YWwuY29tLmJyL3NlcmFzYWNkdjEwDQYJKoZIhvcNAQEFBQADggEBADegGncHh8+vCS4RX/FXZKy3othRT142GmYK1UAIbVpZ79QvyQvIbEvudk4zumx1CHBYTzKVG53dJAUnNkAMnCZxWmxcJD6a42nZS9zxcrI9RrTfljpxNUMFJZQoKhlI8B6OIakOt/vwH8+HrJOA/czMKMA3MYzPiuBVmR8MXMAmkzDNrHbCdA7BA36GGijFPRqq5i8fRtj8VksqMb57MdVOaDBPYI5wwxTow3l8hhtQVI8q8pTZ+y8M8miBnnXYQQvI0rs3AIX1jLEiQ4R0icW/kweei4zj+OTTh3sZIXXXXXXXXXXURszecNTMew8VDFzfXXXXXXXXXXabdS+/S7s= id=code>id=code>wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  10. Boa Noite Os valores da apuração serão calculados automaticamente. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  11. Edvaldo, E da 1.10, realmente,, neste final de semana ou na próxima semana posto o da 2 geração.. assim que der.. ok.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  12. Quanto ao CFOP, correto.. Quanto ao CST eu faria assim,, é somente um exemplo para um sistema que tenha diferentes produtos com diferentes CST, no seu cadastro de produtos.. ex: SUPERMERCADO, Peças.. etc.. Tabela.. CST - 0.00.1 -> o ultimo digito é proprio do Sistema permitindo assim ter vários CST da mesma nomenclatura com situações diferentes. Descrição -> descrição do CST. Percentual -> Percentual da tributação na saída Isenta -> Se este CST é isento Aliquota diferenciada-> Se este CST usa uma aliquota diferenciada substituição tributaria -> Se este CST é uma substituição tributaria CFOP subs.trib. no estado CFOP subs.trib. fora do estado. ex(1): CST : 0.00.1 Descrição : Produto Tributado Integralmente Tributação Saída: 100,00% []Isenta Aliq.Diferenciada[ 0,00] []substituição Tributária CFOP Subs.Tributaria no Estado [ ] CFOP Subs.Tributaria fora do Estado[ ] Neste caso todo produto cadastrado com este tipo de CST, tera 100% do seu valor tributado pela aliq. de ICMS do estado para qual esta vendendo o produto. ex(2): Supondo que ha incentivo fiscal em redução na base de cálculo por parte de algum estado em algum produto e que este incentivo é de 25%,, então.. CST : 0.00.2 Descrição : Produto Trib. Integralmente c/red. base calculo Tributação Saída: 85,00% []Isenta Aliq.Diferenciada[ 0,00] []substituição Tributária CFOP Subs.Tributaria no Estado [ ] CFOP Subs.Tributaria fora do Estado[ ] Neste caso todo produto cadastrado com este tipo de CST, tera 85% do seu valor tributado pela aliq. de ICMS do estado para qual esta vendendo o produto, dentro ou fora do estado.. ex(3): Supondo que o produto é isento. CST : 0.40.1 Descrição : Isento Tributação Saída: 0,00% [X]Isenta Aliq.Diferenciada[ 0,00] []substituição Tributária CFOP Subs.Tributaria no Estado [ ] CFOP Subs.Tributaria fora do Estado[ ] Neste caso todo produto cadastrado com este tipo de CST, sera isento E assim por diante.... OBS: Eu coloco o CST com 4 digitos, pq,, assim eu posso variar o mesmo CST 0.00.1,0.00.2,0.003 e assim por diante, mas qdo ele for para a nota,, somente com 3 digitos.. OBS: No cadastro de produtos. vc, pode ter dois campos.. CST dentro do estado e CST fora do estado.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  13. Lembrando ainda, que no caso acima. conforme a consistência do registro E110, no ato da geração do SPEED, não permitir que se gere os valores de ICMS e ICMS/ST na entradas, somente as suas respectivas bases de cálculo.. OBS. Este layout do manual do Speed, ainda como está não esta totalmente 100%, acredito que muita coisa nele ainda mudará. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  14. Bom dia, Sim esta em funcionamento de janeiro/2011, lembrando que este é um exemplo pois a forma de geração dos dados no Speed, dependerá do tipo de empresa que esta gerando. O registro E110 - Apuração do ICMS - Operações próprias é obrigatório, mas os dados em seu conteúdo, depende exclusivamente do tipo de empresa e operações que ela exerce. No exemplo acima: A empresa é REGIME NORMAL, que compra produtos com Substituição Tributária - CST 010, ou seja paga na fonte, e revende os produtos em CST 060, não tendo assim destaque de ICMS, ou seja a empresa é substituído. Então o registro E110, como é obrigatório neste caso ficará todo zerado. (lembrando ainda que esta empresa no caso ainda tem certos incentivos do governo) para os produtos que comercializa. MAS ISSO DEPENDERà DO TIPO DE EMPRESA QUE ESTA GERANDO O SPEED, DEPENDENDO ASSIM DOS MOLDES FISCAIS DA EMPRESA.. obs.. E olha que são muitas as variações de empresa para empresa,, esse é o BRASIL,, infelizmente... wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  15. Bom dia, CFOP - Código Fiscal de Operação e Prestação, que são códigos numéricos que identificam: * Naturezas das operações de circulação de mercadorias; * Prestações de serviços de transportes intermunicipal e interestadual; * Serviços de Comunicação. É permitida a inclusão de operações enquadradas em diferentes códigos fiscais numa mesma nota fiscal, hipótese em que estes serão indicados no campo “CFOP†no quadro “Emitente†e no quadro “Dados do Produtoâ€, na linha correspondente a cada item, após a descrição do produto. Obs.- Nos meus softwares eu faço assim, qdo vou emitir a NF, peço apenas um CFOP e o repito para todos os produtos. Caso seja necessário mudar um CFOP de um produto permito que altere o CFOP do(s) produto(s) na própria Nota ou pedido, pois se vc, cadastrar o CFOP na tabela de produtos, vc, terá um CFOP fixo. Sabendo que se eu vendar para dentro do estado é um CFOP, para fora do Estado é outro CFOP, REmessa é outro CFOP, Manifesto é outro CFOP e assim por diante. Então não acho prático vc,, cadastrar o CFOP na tabela de produtos.. Acredito que o melhor é criar uma tabela de CFOP e toda a vez que emitir a nota pedir o CFOP Geral, e permitir que se mude o CFOP de cada produto na nota ou pedido, qdo isso se fizer necessário. É apenas uma observação. Ao contrário do CST, que esse sim,, vc,, pode ter no seu cadastro de produto.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  16. #include "FiveWin.ch" #include "common.ch" #include "postgres.ch" #include "Folder.ch" #include "report.ch" #include "barcode.ch" //#include "vget.ch" //#include "vbtnbmp.ch" #Define clr_vermelho nRGB( 127, 058, 017 ) #define btn_width 12 #define btn_height 10 function spedfiscal() define brush obrush color mtela DEFINE BITMAP otpContador FILENAME "spedfiscal.bmp" define dialog spedfis title "EFD - Escrituracao Fiscal Digital" from 010,010 to 438,790 pixel brush oBrush define font mtahoma name "Tahoma" size 5.5,13 define font mtahoma1 name "Tahoma" size 08,22 define font oFont name 'MS Sans Serif' size 6,15 define font ofontL name "Courier" size 11,11 mbldg = 0 mblvs = space(03) // versÆo do layout mfinl = "Remessa do arquivo original" afinl = {"Remessa do arquivo original","Remessa do arquivo substituto"} mperf = "B - Perfil B" aperf = {"A - Perfil A","B - Perfil B","C - Perfil C"} mindi = "1 - Outros" aindi = {"0 - Industrial ou equiparado a industrial","1 - Outros"} mdtin = ctod("") mdtfi = ctod("") minvt = .f. // para os registros de entrada que foram lancados no sistema.......... mbaseCalculoICMS = .t. mvaloICMSentrada = .t. mbaseCalculoICMSSt = .t. mvaloICMSStentrada = .t. mvalorIPI = .t. finvt = "" ainvt = {} cQuery := "select * from n60300000 where"+; " wemp = " + alltrim(str(memp))+; " and wstd = " + "'"+"I"+"'"+; " order by wndc asc;" oQuery := oServer:Query(cQuery) aadd(ainvt,space(06)) DO WHILE ! oQuery:Eof() nwstd = oQuery:Fieldget(oQuery:Fieldpos('wstd')) if !empty(nwstd) nwndc = oQuery:Fieldget(oQuery:Fieldpos('wndc')) if empty(ainvt) aadd(ainvt,nwndc) else msn = "N" for tt = 1 to len(ainvt) if alltrim(nwndc) = alltrim(ainvt[tt]) msn = "S" exit endif next if msn = "N" aadd(ainvt,nwndc) endif endif endif oQuery:Skip() END oQuery:destroy() @ 35.5,002 say "Versao do leiaute Ato Cotepe" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 035 ,100 get oblvs var mblvs picture "@!" font mtahoma size 016,9 of spedfis color mcolorCA,mcolorCB pixel @ 50,002 say "Finalidade do arquivo Magnetico" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 60,002 combobox ofinl var mfinl items afinl font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 75,002 say "Perfil de apresentacao do arquivo fiscal" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 85,002 combobox operf var mperf items aperf font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 100,002 say "Indicador do tipo de atividade" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 110,002 combobox oindi var mindi items aindi font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 125, 002 say "Período a ser gerado" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 135, 002 say "Data inicial:" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 135, 040 get odtin var mdtin font mtahoma size 32,9 of spedfis color mcolorCA,mcolorCB pixel @ 145, 002 say "Data final:" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 145, 040 get odtfi var mdtfi font mtahoma size 32,9 of spedfis color mcolorCA,mcolorCB pixel @ 165,002 checkbox oinvt var minvt prompt "&Gerar o inventario"; font mtahoma colors mcolorAA,mcolorAB size 64, 11 of spedfis pixel @ 178,002 combobox oinvt var finvt items ainvt font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel when iif(minvt = .t.,.t.,.f.) @ 050,265 say "Registro a serem gerados para a Entrada" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 060,265 checkbox obaseCalculoICMS var mbaseCalculoICMS prompt "Com base de calculo do ICMS"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 070,265 checkbox ovaloICMSentrada var mvaloICMSentrada prompt "Com valor de ICMS "; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 080,265 checkbox obaseCalculoICMSSt var mbaseCalculoICMSSt prompt "Com base de calculo do ICMS ST"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 090,265 checkbox ovaloICMSStentrada var mvaloICMSStentrada prompt "Com valor de ICMS ST"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 100,265 checkbox ovalorIPI var mvalorIPI prompt "Com valor de IPI"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 200,004 button orombut0 prompt "Gerar " size 040,12 font oFont OF spedfis pixel action ( gera_efd_fiscal() ) @ 200,047 button orombut1 prompt "Contador" size 040,12 font oFont OF spedfis pixel action ( contador() ) @ 200,090 button orombut2 prompt "Inventario" size 040,12 font oFont OF spedfis pixel action ( n6030008(1) ) @ 200,133 button orombut3 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,176 button orombut4 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,219 button orombut5 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,262 button orombut6 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,305 button orombut7 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,348 button orombut8 prompt "Sair " size 040,12 font oFont OF spedfis pixel action ( spedfis:end() ) activate dialog spedfis center on Init ( busca_gera_efd_fiscal() ) on Paint ( WndBoxIn(spedfis:Hdc, 064, 001, 066, 790) ,; WndBoxIn(spedfis:Hdc, 391, 001, 393, 790) ,; sayBitmapContador() ) return nil function sayBitmapContador() spedfis:SayBitmap( (((spedfis:nTop+spedfis:nbottom)/2)-190) -(otpContador:nHeight()/2),((spedfis:nLeft+spedfis:nRight)/2)-(otpContador:nWidth()/2),otpContador,otpContador:nWidth(),otpContador:nHeight()) return nil function busca_gera_efd_fiscal() cQuery := "select * from r20200000"+; " order by bldg asc;" oQuery := oServer:Query(cQuery) mbldg = 0 mblvs = space(03) // versÆo do layout DO WHILE ! oQuery:Eof() mbldg = oQuery:Fieldget(oQuery:Fieldpos('bldg')) if !empty(mbldg) mblvs = oQuery:Fieldget(oQuery:Fieldpos('blvs')) oblvs:ctext := mblvs endif oQuery:Skip() END oQuery:destroy() return nil // Geracao do arquivo magnetico do EFD - Escritura‡Æo Fiscal Digital............ function gera_efd_fiscal() if empty(mblvs) msgstop("Versao do leiaute nao informado.","Atencao") return nil endif if empty(mdtin) msgstop("Data inicial nao foi informada.","Atencao") return nil endif if empty(mdtfi) msgstop("Data final nao foi informada.","Atencao") return nil endif if mbldg = 0 cQuery := "insert into r20200000(blvs)" cQuery += "values("+"'"+mblvs+"'"+")" oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Não foi possível realizar a inclusão.","ATENÇÃO") //oQuery:error() endif oQuery:destroy() oServer:Commit() else cQuery := "Update r20200000 set "+; "blvs = " + "'"+mblvs+"'"+; " where " + " bldg = " + alltrim(str(mbldg)) oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Não foi possível realizar a alteração.","ATENÇÃO") //oQuery:error() endif oQuery:destroy() oServer:Commit() endif // validacoes a serem consideradas para emissao do sped fiscal........ if empty(zaden) msgstop("Razao social do contribuinte vazio.","Atencao") return nil endif if empty(zaest) msgstop("Estado do contribuinte vazio.","Atencao") return nil endif if empty(zaies) msgstop("Inscricao Estadual do contribuinte vazio.","Atencao") return nil endif if empty(zaibg) msgstop("Codigo do municipio do IBGE do contribuinte vazio.","Atencao") return nil endif if empty(zatf1) msgstop("Numero do telefone do contribuinte vazio.","Atencao") return nil endif if empty(zatfx) msgstop("Numero do fax do contribuinte vazio.","Atencao") return nil endif // verifica os dados do contador ..................................... cQuery := "select * from r20100000"+; " order by ctnm asc;" oQuery := oServer:Query(cQuery) mctdg = 0 DO WHILE ! oQuery:Eof() mctdg = oQuery:Fieldget(oQuery:Fieldpos('ctdg')) if !empty(mctdg) mctnm = oQuery:Fieldget(oQuery:Fieldpos('ctnm')) mctcf = oQuery:Fieldget(oQuery:Fieldpos('ctcf')) mctrc = oQuery:Fieldget(oQuery:Fieldpos('ctrc')) mctpj = oQuery:Fieldget(oQuery:Fieldpos('ctpj')) mctcp = oQuery:Fieldget(oQuery:Fieldpos('ctcp')) mctlg = oQuery:Fieldget(oQuery:Fieldpos('ctlg')) mctnr = oQuery:Fieldget(oQuery:Fieldpos('ctnr')) mctdc = oQuery:Fieldget(oQuery:Fieldpos('ctdc')) mctbr = oQuery:Fieldget(oQuery:Fieldpos('ctbr')) mcttf = oQuery:Fieldget(oQuery:Fieldpos('cttf')) mctfx = oQuery:Fieldget(oQuery:Fieldpos('ctfx')) mctml = oQuery:Fieldget(oQuery:Fieldpos('ctml')) maibg = oQuery:Fieldget(oQuery:Fieldpos('ctbg')) endif oQuery:Skip() END oQuery:destroy() if empty(mctdg) msgstop("Preencha os dados do contabilista.","Atencao") return nil endif // comeca a geracao do arquivo do sped fiscal ........................ cDirXML = "spedfiscal-" + substr(dtos(mdtin),5,2) + "-" + substr(dtos(mdtin),1,4) + ".txt" Bloco0totallinhas = 0 BlocoCtotallinhas = 0 BlocoDtotallinhas = 0 BlocoEtotallinhas = 0 BlocoGtotallinhas = 0 BlocoHtotallinhas = 0 Bloco1totallinhas = 0 Bloco9totallinhas = 0 mreg0000 = 0 mreg0001 = 0 mreg0005 = 0 mreg0100 = 0 mreg0150 = 0 mreg0190 = 0 mreg0200 = 0 mreg0400 = 0 mreg0990 = 0 mregC001 = 0 mregC100 = 0 mregC170 = 0 mregC190 = 0 mregC990 = 0 mregD001 = 0 mregD990 = 0 mregE001 = 0 mregE100 = 0 mregE110 = 0 //mregE200 = 0 //mregE210 = 0 mregE990 = 0 mregG001 = 0 mregG990 = 0 mregH001 = 0 mregH005 = 0 mregH010 = 0 mregH990 = 0 mreg1001 = 0 mreg1990 = 0 mreg9001 = 0 mreg9900 = 0 mreg9990 = 0 mreg9999 = 0 campoE = {} mtotalICMS = 0 mtotalICMSst = 0 lh := 0 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. // B L O C O 0 // registro 0000...................................................... mlinha = "|" + "0000" + "|" + mblvs + "|" + iif(mfinl = "Remessa do arquivo original","0","1") +; "|" + substr(dtos(mdtin),7,2) + substr(dtos(mdtin),5,2) + substr(dtos(mdtin),1,4) +; "|" + substr(dtos(mdtfi),7,2) + substr(dtos(mdtfi),5,2) + substr(dtos(mdtfi),1,4) +; "|" + alltrim(zaden) + "|" + zandn + "|" + "|" + zaest + "|" + alltrim(substr(zaies,1,14)) +; "|" + alltrim(substr(zaibg,1,7)) + "|" + "|" + "|"+; iif(mperf = "A - Perfil A","A",iif(mperf = "B - Perfil B","B","C")) + "|"+; iif(mindi = "1 - Outros","1","0") + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0000 // registro 0001...................................................... mlinha = "|" + "0001" + "|" + "0" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0001 // registro 0005...................................................... // obs.. para o nome fantasia depois ver um modo de pegar alguns dados // do nome da empresa.. mlinha = "|" + "0005" + "|" + substr(zaden,1,17) + "|" + zacep + "|" + alltrim(zaend) +; "|" + alltrim(str(zanro)) + "|" + alltrim(zacpl) + "|" + alltrim(zabai)+; "|" + alltrim(zatf1) + "|" + alltrim(zatfx) + "|" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0005 // registro 0100 mlinha = "|" + "0100" + "|" + alltrim(mctnm) + "|" + alltrim(mctcf) + "|" +; alltrim(mctrc) + "|" + alltrim(mctpj) + "|" + mctcp + "|" +; alltrim(mctlg) + "|" + alltrim(mctnr) + "|" + alltrim(mctdc) +; "|" + alltrim(mctbr) + "|" + mcttf + "|" + mctfx + "|" + ; alltrim(mctml) + "|" + maibg + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0100 // registro 0150 // para clientes...................................................... acliautorizada := {} aprodutosusado := {} aunidadeusadas := {} acfoputilizado := {} // se for utilizar o inventario....................................... if minvt = .t. finvt = alltrim(finvt) if !empty(finvt) ntotv = 0 cQuery := "select * from n60300000 where"+; " wemp = " + alltrim(str(memp))+; " and wndc = " + "'"+alltrim(finvt)+"'"+; " and wstd = " + "'"+"I"+"'"+; " order by wndc asc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() nwstd = oQuery:Fieldget(oQuery:Fieldpos('wstd')) if !empty(nwstd) if nwstd != "I" oQuery:Skip() loop endif iwbcf = oQuery:Fieldget(oQuery:Fieldpos('wbcf')) // codigo normal iwqit = oQuery:Fieldget(oQuery:Fieldpos('wqit')) // quantidade a ser fabricada iwvlr = oQuery:Fieldget(oQuery:Fieldpos('wvlr')) // valor.. ntotv = ntotv + ( iwqit * iwvlr ) wQuery := "select * from e40100000 where" wQuery += " bcdg = " + "'"+alltrim(iwbcf)+"'" wQuery += " order by bcdg asc;" owQuery := oServer:Query(wQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) nqund = alltrim(nqund) nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) nqcap = owQuery:Fieldget(owQuery:Fieldpos('bcap')) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para produtos que estao usados no inventario........... if empty(aprodutosusado) aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) else msn = "S" for tt = 1 to len(aprodutosusado) if aprodutosusado[tt,1] = nqnpc msn = "N" exit endif next if msn = "S" aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) endif endif endif oQuery:Skip() END oQuery:destroy() endif endif nsaidas := nentradas := 0 ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) if mdtin = mdtfi cQuery := "select * from f50900000 where"+; " p035 = " + "'"+ndtin+"'" else cQuery := "select * from f50900000 where"+; " p035 >= " + "'"+ndtin+"'" + " and"+; " p035 <= " + "'"+ndtfi+"'" endif cQuery += " order by p035 desc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) p051 = oQuery:Fieldget(oQuery:Fieldpos('p051')) p094 = oQuery:Fieldget(oQuery:Fieldpos('p094')) // Entrada ou Saida.. nsta = oQuery:Fieldget(oQuery:Fieldpos('pstu')) // Situacao da nota mp016 = oQuery:Fieldget(oQuery:Fieldpos('p016')) // numero do pedido ou romaneio.. mp016 = alltrim(mp016) nrnop = oQuery:Fieldget(oQuery:Fieldpos('p062')) np062 = oQuery:Fieldget(oQuery:Fieldpos('p062')) np062 = alltrim(substr(np062,1,4)) nrdno = "" cqQuery := "select * from f51100000 "+; "where rnop = " + alltrim(nrnop)+; " order by rnop asc;" oqQuery := oServer:Query(cqQuery) nrdno = oqQuery:Fieldget(oqQuery:Fieldpos('rdno')) oqQuery:destroy() if empty(pasq) oQuery:Skip() loop endif if nsta != 5 if nsta = 6 if empty(acliautorizada) aadd(acliautorizada,p051) else msn = "S" for tt = 1 to len(acliautorizada) if acliautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(acliautorizada,p051) endif endif endif oQuery:Skip() loop endif if empty(acliautorizada) aadd(acliautorizada,p051) else msn = "S" for tt = 1 to len(acliautorizada) if acliautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(acliautorizada,p051) endif endif if p094 = "S" ++nsaidas elseif p094 = "E" ++nentradas endif // acrescenta os cfops.. usados nas saidas e entradas.............. //if empt(acfoputilizado) // aadd(acfoputilizado,{np062,nrdno}) //else // msn = "S" // for tt = 1 to len(acfoputilizado) // if acfoputilizado[tt,1] = np062 // msn = "N" // exit // endif // next // if msn = "S" // aadd(acfoputilizado,{np062,nrdno}) // endif //endif // Detalha os produtos e seus impostos................................ czQuery := "select * from f51000000 where"+; " qnpd = " + "'"+mp016+"'"+; " order by qnpd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para os produtos que foram usados nas transacoes............. //if empty(aprodutosusado) // aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) //else // msn = "S" // for tt = 1 to len(aprodutosusado) // if aprodutosusado[tt,1] = nqnpc // msn = "N" // exit // endif // next // if msn = "S" // aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) // endif //endif ozQuery:Skip() END ozQuery:destroy() oQuery:Skip() END oQuery:destroy() for tt = 1 to len(acliautorizada) cQuery := "select * from r20000000 where "+; "acdc = " + alltrim(str(val(acliautorizada[tt]))) cQuery += " order by acdc asc;" oQuery := oServer:Query(cQuery) ncod_part = oQuery:Fieldget(oQuery:Fieldpos('acdc')) ncod_part = alltrim(str(ncod_part)) nnome = oQuery:Fieldget(oQuery:Fieldpos('anrs')) nnome = alltrim(nnome) ncod_pais = "01058" napfj = oQuery:Fieldget(oQuery:Fieldpos('apfj')) if napfj = "F" ncnpj = "" ncnpf = oQuery:Fieldget(oQuery:Fieldpos('andn')) else ncnpj = oQuery:Fieldget(oQuery:Fieldpos('andn')) ncnpf = "" endif nie = oQuery:Fieldget(oQuery:Fieldpos('andl')) nie = alltrim(substr(nie,1,14)) ncod_mun = oQuery:Fieldget(oQuery:Fieldpos('aibg')) ncod_mun = substr(ncod_mun,1,7) nsuframa = "" nend = oQuery:Fieldget(oQuery:Fieldpos('aend')) nend = alltrim(nend) nnum = oQuery:Fieldget(oQuery:Fieldpos('anro')) nnum = alltrim(nnum) ncompl = oQuery:Fieldget(oQuery:Fieldpos('acmp')) ncompl = alltrim(ncompl) nbairro = oQuery:Fieldget(oQuery:Fieldpos('abai')) nbairro = alltrim(nbairro) mlinha = "|" + "0150" + "|" + ncod_part + "|" + nnome + "|" + ncod_pais +; "|" + ncnpj + "|" + ncnpf + "|" + nie + "|" + ncod_mun +; "|" + nsuframa + "|" + nend + "|" + nnum + "|" + ncompl+; "|" + nbairro + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0150 next // para fornecedores.................................................. aforautorizada := {} ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) if mdtin = mdtfi cQuery := "select * from f60900000 where"+; " pent = " + "'"+ndtin+"'" else cQuery := "select * from f60900000 where"+; " pent >= " + "'"+ndtin+"'" + " and"+; " pent <= " + "'"+ndtfi+"'" endif cQuery += " order by pent desc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) p051 = oQuery:Fieldget(oQuery:Fieldpos('pclf')) p051 = alltrim(strzero(p051,5)) mpncd = oQuery:Fieldget(oQuery:Fieldpos('pncd')) p094 = "E" nrnop = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) nrnop = alltrim(str(nrnop)) np062 = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) np062 = alltrim(str(np062)) nrdno = "" cqQuery := "select * from f51100000 "+; "where substr(rnop,1,4) = " + alltrim(nrnop)+; " order by rnop asc;" oqQuery := oServer:Query(cqQuery) nrdno = oqQuery:Fieldget(oqQuery:Fieldpos('rdno')) oqQuery:destroy() if empty(pasq) oQuery:Skip() loop endif if empty(aforautorizada) aadd(aforautorizada,p051) else msn = "S" for tt = 1 to len(aforautorizada) if aforautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(aforautorizada,p051) endif endif ++nentradas // acrescenta os cfops.. usados nas saidas e entradas.............. if empt(acfoputilizado) aadd(acfoputilizado,{np062,nrdno}) else msn = "S" for tt = 1 to len(acfoputilizado) if acfoputilizado[tt,1] = np062 msn = "N" exit endif next if msn = "S" aadd(acfoputilizado,{np062,nrdno}) endif endif // Detalha os produtos e seus impostos................................ czQuery := "select * from f61000000 where"+; " qncd = " + alltrim(str(mpncd))+; " order by qncd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para os produtos que foram usados nas transacoes............. if empty(aprodutosusado) aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) else msn = "S" for tt = 1 to len(aprodutosusado) if aprodutosusado[tt,1] = nqnpc msn = "N" exit endif next if msn = "S" aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) endif endif ozQuery:Skip() END ozQuery:destroy() oQuery:Skip() END oQuery:destroy() for tt = 1 to len(aforautorizada) cQuery := "select * from r10000000 where "+; "acdg = " + alltrim(str(val(aforautorizada[tt]))) cQuery += " order by acdg asc;" oQuery := oServer:Query(cQuery) ncod_part = oQuery:Fieldget(oQuery:Fieldpos('acdg')) ncod_part = "FOR-" + alltrim(str(ncod_part)) nnome = oQuery:Fieldget(oQuery:Fieldpos('anrs')) nnome = alltrim(nnome) ncod_pais = "01058" napfj = oQuery:Fieldget(oQuery:Fieldpos('andn')) napfj = alltrim(napfj) if len(napfj) <= 11 ncnpj = "" ncnpf = oQuery:Fieldget(oQuery:Fieldpos('andn')) else ncnpj = oQuery:Fieldget(oQuery:Fieldpos('andn')) ncnpf = "" endif nie = oQuery:Fieldget(oQuery:Fieldpos('andl')) nie = alltrim(substr(nie,1,14)) ncod_mun = oQuery:Fieldget(oQuery:Fieldpos('aibg')) ncod_mun = substr(ncod_mun,1,7) nsuframa = "" nend = oQuery:Fieldget(oQuery:Fieldpos('aend')) nend = alltrim(nend) nnum = oQuery:Fieldget(oQuery:Fieldpos('anro')) nnum = alltrim(nnum) ncompl = "" nbairro = oQuery:Fieldget(oQuery:Fieldpos('abai')) nbairro = alltrim(nbairro) mlinha = "|" + "0150" + "|" + ncod_part + "|" + nnome + "|" + ncod_pais +; "|" + ncnpj + "|" + ncnpf + "|" + nie + "|" + ncod_mun +; "|" + nsuframa + "|" + nend + "|" + nnum + "|" + ncompl+; "|" + nbairro + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0150 next // registro 0190 for tt = 1 to len(aunidadeusadas) mlinha = "|" + "0190" + "|" + aunidadeusadas[tt,1] + "|" + aunidadeusadas[tt,2] + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0190 next // registro 0200 for tt = 1 to len(aprodutosusado) mlinha = "|" + "0200" + "|" + aprodutosusado[tt,1] + "|" + aprodutosusado[tt,2]; + "|" + aprodutosusado[tt,3] + "|" + aprodutosusado[tt,4]; + "|" + aprodutosusado[tt,5] + "|" + aprodutosusado[tt,6]; + "|" + aprodutosusado[tt,7] + "|" + aprodutosusado[tt,8]; + "|" + aprodutosusado[tt,9] + "|" + aprodutosusado[tt,10]; + "|" + aprodutosusado[tt,11] + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0200 next // registro 0400 for tt = 1 to len(acfoputilizado) mlinha = "|" + "0400" + "|" + acfoputilizado[tt,1] + "|" + alltrim(acfoputilizado[tt,2]) + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0400 next // registro 0990 ++Bloco0totallinhas ++mreg0990 mlinha = "|" + "0990" + "|" + alltrim(str(Bloco0totallinhas)) + "|" + CRLF oPrn:Say(lh,000,mlinha) // B L O C O C if nsaidas = 0 .and. nentradas = 0 // registro c001 mlinha = "|" + "C001" + "|" + "1" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC001 // registro c990 ++BlocoCtotallinhas ++mregC990 mlinha = "|" + "C990" + "|" + alltrim(str(BlocoCtotallinhas)) + CRLF oPrn:Say(lh,000,mlinha) else mlinha = "|" + "C001" + "|" + "0" + "|"+ CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC001 // registro c001 // Notas fiscais eletronica de saida e entrada emissao propria ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) for pt = 1 to 2 if pt = 1 ntipodenota = "S" elseif pt = 2 ntipodenota = "E" endif if mdtin = mdtfi cQuery := "select * from f50900000 where"+; " p035 = " + "'"+ndtin+"'" else cQuery := "select * from f50900000 where"+; " p035 >= " + "'"+ndtin+"'" + " and"+; " p035 <= " + "'"+ndtfi+"'" endif cQuery += " and p094 = " + "'"+ntipodenota+"'" cQuery += " order by p034 asc;" oQuery := oServer:Query(cQuery) pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) if !empty(pasq) DO WHILE ! oQuery:Eof() psql = oQuery:Fieldget(oQuery:Fieldpos('pasq')) pstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) // Situacao da nota p016 = oQuery:Fieldget(oQuery:Fieldpos('p016')) // numero do pedido p051 = oQuery:Fieldget(oQuery:Fieldpos('p051')) // codigo do cliente psnf = oQuery:Fieldget(oQuery:Fieldpos('psnf')) // serie da nota fiscal p034 = oQuery:Fieldget(oQuery:Fieldpos('p034')) // numero da nota fiscal pchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // chave de acesso da nota fiscal eletronica p035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) // data de emissao p033 = oQuery:Fieldget(oQuery:Fieldpos('p033')) // data de saida p026 = oQuery:Fieldget(oQuery:Fieldpos('p026')) // valor do documento p089 = oQuery:Fieldget(oQuery:Fieldpos('p089')) // tipo de pagamento p024 = oQuery:Fieldget(oQuery:Fieldpos('p024')) // valor total dos produtos p069 = oQuery:Fieldget(oQuery:Fieldpos('p069')) // frete p021 = oQuery:Fieldget(oQuery:Fieldpos('p021')) // valor do frete p022 = oQuery:Fieldget(oQuery:Fieldpos('p022')) // valor do seguro p063 = oQuery:Fieldget(oQuery:Fieldpos('p063')) // outras despesas e acessorios p053 = oQuery:Fieldget(oQuery:Fieldpos('p053')) // base de calculo p054 = oQuery:Fieldget(oQuery:Fieldpos('p054')) // valor do icms. p055 = oQuery:Fieldget(oQuery:Fieldpos('p055')) p056 = oQuery:Fieldget(oQuery:Fieldpos('p056')) p025 = oQuery:Fieldget(oQuery:Fieldpos('p025')) if pstu < 5 oQuery:Skip() loop endif ind_oper = iif(ntipodenota = "S","1","0") ind_emit = "0" if pstu = 6 cod_part = "" else cod_part = alltrim(str(val(p051))) endif cod_mod = "55" if pstu = 6 cod_sit = "02" else cod_sit = "00" endif ser = alltrim(psnf) num_doc = alltrim(str(val(p034))) chv_nfe = alltrim(pchv) if pstu = 6 dt_doc = "" dt_e_s = "" vl_doc = "" ind_pgto = "" vl_desc = "" vl_abat_nt = "" vl_merc = "" ind_frt = "" vl_frt = "" vl_seg = "" vl_out_da = "" vl_bc_icms = "" vl_icms = "" vl_bc_icmsst = "" vl_icms_st = "" vl_ipi = "" vl_pis = "" vl_cofins = "" vl_pis_st = "" vl_cofins_st = "" else dt_doc = substr(dtos(p035),7,2) + substr(dtos(p035),5,2) + substr(dtos(p035),1,4) if empty(p033) dt_e_s = "" else dt_e_s = substr(dtos(p033),7,2) + substr(dtos(p033),5,2) + substr(dtos(p033),1,4) endif vl_doc = alltrim(transform(p026,"@e 999999999.99")) if p089 = "0" ind_pgto = "0" elseif p089 = "1" ind_pgto = "1" elseif p089 = "2" ind_pgto = "9" endif vl_desc = "0,00" vl_abat_nt = "0,00" vl_merc = alltrim(transform(p024,"@e 999999999.99")) ind_frt = iif(p069 = "1","1","2") vl_frt = iif(!empty(p021),alltrim(transform(p021,"@e 999999999.99")),"0,00") vl_seg = iif(!empty(p022),alltrim(transform(p022,"@e 999999999.99")),"0,00") vl_out_da = iif(!empty(p063),alltrim(transform(p063,"@e 999999999.99")),"0,00") vl_bc_icms = iif(!empty(p053),alltrim(transform(p053,"@e 999999999.99")),"0,00") vl_icms = iif(!empty(p054),alltrim(transform(p054,"@e 999999999.99")),"0,00") vl_bc_icmsst = iif(!empty(p055),alltrim(transform(p055,"@e 999999999.99")),"0,00") vl_icms_st = iif(!empty(p056),alltrim(transform(p056,"@e 999999999.99")),"0,00") vl_ipi = iif(!empty(p025),alltrim(transform(p025,"@e 999999999.99")),"0,00") vl_pis = "0,00" vl_cofins = "0,00" vl_pis_st = "0,00" vl_cofins_st = "0,00" endif mlinha = "|" + "C100" + "|" + ind_oper + "|" + ind_emit; + "|" + cod_part + "|" + cod_mod + "|" + cod_sit; + "|" + ser + "|" + num_doc + "|" + chv_nfe; + "|" + dt_doc + "|" + dt_e_s + "|" + vl_doc; + "|" + ind_pgto + "|" + vl_desc + "|" + vl_abat_nt; + "|" + vl_merc + "|" + ind_frt + "|" + vl_frt; + "|" + vl_seg + "|" + vl_out_da + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st; + "|" + vl_ipi + "|" + vl_pis + "|" + vl_cofins; + "|" + vl_pis_st + "|" + vl_cofins_st + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC100 if pstu = 6 else // obs.. o array abaixo sera usado quando a operacao // tiver cst, cfop e icms diferenciados.. rc190:= {} // array para o registro c190 czQuery := "select * from f51000000 where"+; " qnpd = " + "'"+p016+"'"+; " order by qnpd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto nqcfo = ozQuery:Fieldget(ozQuery:Fieldpos('qcfo')) // cfop nqqtd = ozQuery:Fieldget(ozQuery:Fieldpos('qqtd')) // quantidade nquni = ozQuery:Fieldget(ozQuery:Fieldpos('quni')) // unidade nqvru = ozQuery:Fieldget(ozQuery:Fieldpos('qvru')) // valor unitario nqvti = ozQuery:Fieldget(ozQuery:Fieldpos('qvti')) // valor total nqvti = iif(!empty(nqvti),alltrim(transform(nqvti,"@e 999999999.99")),"0,00") nqcst = ozQuery:Fieldget(ozQuery:Fieldpos('qcst')) // situacao tributaria nqbci = ozQuery:Fieldget(ozQuery:Fieldpos('qbci')) // base de calculo do i.c.m nqbci = iif(!empty(nqbci),alltrim(transform(nqbci,"@e 999999999.99")),"0,00") nqaic = ozQuery:Fieldget(ozQuery:Fieldpos('qaic')) // aliquota de icm nqvic = ozQuery:Fieldget(ozQuery:Fieldpos('qvic')) // valor do icm nqvic = iif(!empty(nqvic),alltrim(transform(nqvic,"@e 999999999.99")),"0,00") nqisn = ozQuery:Fieldget(ozQuery:Fieldpos('qisn')) // isento nqtrs = ozQuery:Fieldget(ozQuery:Fieldpos('qtrs')) // tributacao na saida nqadc = ozQuery:Fieldget(ozQuery:Fieldpos('qadc')) // classificacao fiscal nqads = ozQuery:Fieldget(ozQuery:Fieldpos('qads')) // aliquota diferenciada //cwQuery := "select * from e40100000 where "+; // "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" //owQuery := oServer:Query(cwQuery) //nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a //nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto //nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto //nqund = alltrim(nqund) //owQuery:destroy() // //cyQuery := "select * from e40200000 where "+; // "cemp = " + alltrim(str(memp)) +; // " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" //oyQuery := oServer:Query(cyQuery) //nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) //nqcdcl = substr(alltrim(nqcdcl),1,8) //oyQuery:destroy() ozQuery:Skip() END ozQuery:destroy() mlinha = "|" + "C190" + "|" + substr(nqcst,1,3) + "|" +; substr(nqcfo,1,4) + "|" + iif(!empty(nqaic),alltrim(transform(nqaic,"@e 999.99")),"0,00"); + "|" + vl_doc + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st + "|"; + "0,00" + "|" + "0,00" + "|" + "" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC190 endif oQuery:Skip() END endif oQuery:destroy() next // Notas fisciais de entrada ... Lancamento manual................. if mdtin = mdtfi cQuery := "select * from f60900000 where"+; " pent = " + "'"+ndtin+"'" else cQuery := "select * from f60900000 where"+; " pent >= " + "'"+ndtin+"'" + " and"+; " pent <= " + "'"+ndtfi+"'" endif cQuery += " order by pemi asc;" oQuery := oServer:Query(cQuery) pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) if !empty(pasq) DO WHILE ! oQuery:Eof() psql = oQuery:Fieldget(oQuery:Fieldpos('pasq')) mpncd = oQuery:Fieldget(oQuery:Fieldpos('pncd')) p051 = oQuery:Fieldget(oQuery:Fieldpos('pclf')) // codigo do fornecedor p051 = "FOR-" + alltrim(str(p051)) nNatureza = "" p062 = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) p062 = alltrim(str(p062)) for tt = 1 to len(acfoputilizado) if acfoputilizado[tt,1] = p062 nNatureza = acfoputilizado[tt,2] exit endif next psnf = oQuery:Fieldget(oQuery:Fieldpos('pser')) // serie da nota fiscal p034 = oQuery:Fieldget(oQuery:Fieldpos('pnur')) // numero da nota fiscal p034 = alltrim(str(p034)) pchv = "" // chave de acesso da nota fiscal eletronica p035 = oQuery:Fieldget(oQuery:Fieldpos('pemi')) // data de emissao p033 = oQuery:Fieldget(oQuery:Fieldpos('pemi')) // data de saida p089 = oQuery:Fieldget(oQuery:Fieldpos('pprz')) // tipo de pagamento p089 = iif(p089 = .t.,"1","0" ) mntmv = oQuery:Fieldget(oQuery:Fieldpos('ptmv')) // verifica se movimenta o estoque............................... cwQuery := "select * from e40700000 where "+; "lcmv = " + alltrim(str(mntmv)) cwQuery += " order by lcmv asc;" owQuery := oServer:Query(cwQuery) nlmve = owQuery:Fieldget(owQuery:Fieldpos('lmve')) owQuery:destroy() nlmve = iif(nlmve = .t.,"y","n") pest = oQuery:Fieldget(oQuery:Fieldpos('pest')) // estado da federacao ptnf = oQuery:Fieldget(oQuery:Fieldpos('ptnf')) // total da nota if mbaseCalculoICMS = .t. pbas = oQuery:Fieldget(oQuery:Fieldpos('pbas')) // total da base else pbas = 0 endif if mvaloICMSentrada = .t. picm = oQuery:Fieldget(oQuery:Fieldpos('picm')) // total do icms else picm = 0 endif pist = oQuery:Fieldget(oQuery:Fieldpos('pist')) // total do isento pout = oQuery:Fieldget(oQuery:Fieldpos('pout')) // total outros if mvalorIPI = .t. pipi = oQuery:Fieldget(oQuery:Fieldpos('pipi')) // total ipi else pipi = 0 endif ptpr = oQuery:Fieldget(oQuery:Fieldpos('ptpr')) // total dos produtos pfre = oQuery:Fieldget(oQuery:Fieldpos('pfre')) // total frete pseg = oQuery:Fieldget(oQuery:Fieldpos('pseg')) // total seguro palq = oQuery:Fieldget(oQuery:Fieldpos('palq')) // aliquota icms pdes = oQuery:Fieldget(oQuery:Fieldpos('pdes')) // despesa if mbaseCalculoICMSSt pbst = oQuery:Fieldget(oQuery:Fieldpos('pbst')) // base substituicao else pbst = 0 endif if mvaloICMSStentrada = .t. pict = oQuery:Fieldget(oQuery:Fieldpos('pict')) // icms substituicao else pict = 0 endif ind_oper = "0" ind_emit = "1" cod_part = p051 cod_mod = "55" cod_sit = "00" ser = alltrim(psnf) num_doc = p034 chv_nfe = pchv dt_doc = substr(dtos(p035),7,2) + substr(dtos(p035),5,2) + substr(dtos(p035),1,4) if empty(p033) dt_e_s = "" else dt_e_s = substr(dtos(p033),7,2) + substr(dtos(p033),5,2) + substr(dtos(p033),1,4) endif vl_doc = alltrim(transform(ptnf,"@e 999999999.99")) if p089 = "0" ind_pgto = "0" elseif p089 = "1" ind_pgto = "1" elseif p089 = "2" ind_pgto = "9" endif vl_desc = "0,00" vl_abat_nt = "0,00" vl_merc = alltrim(transform(ptpr,"@e 999999999.99")) ind_frt = "1" vl_frt = iif(!empty(pfre),alltrim(transform(pfre,"@e 999999999.99")),"0,00") vl_seg = iif(!empty(pseg),alltrim(transform(pseg,"@e 999999999.99")),"0,00") vl_out_da = iif(!empty(pout),alltrim(transform(pout,"@e 999999999.99")),"0,00") vl_bc_icms = iif(!empty(pbas),alltrim(transform(pbas,"@e 999999999.99")),"0,00") vl_icms = iif(!empty(picm),alltrim(transform(picm,"@e 999999999.99")),"0,00") vl_bc_icmsst = iif(!empty(pbst),alltrim(transform(pbst,"@e 999999999.99")),"0,00") vl_icms_st = iif(!empty(pict),alltrim(transform(pict,"@e 999999999.99")),"0,00") vl_ipi = iif(!empty(pipi),alltrim(transform(pipi,"@e 999999999.99")),"0,00") vl_pis = "0,00" vl_cofins = "0,00" vl_pis_st = "0,00" vl_cofins_st = "0,00" //mtotalICMS = mtotalICMS + picm //mtotalICMSst = mtotalICMSst + pict // verifica se gera o campo E100 e o E200.................... //if pict > 0 if empty(campoE) aadd(campoE,pest) else msn = "S" for tt = 1 to len(campoE) if campoE[tt] = pest msn = "N" exit endif next if msn = "S" aadd(campoE,pest) endif endif //endif mlinha = "|" + "C100" + "|" + ind_oper + "|" + ind_emit; + "|" + cod_part + "|" + cod_mod + "|" + cod_sit; + "|" + ser + "|" + num_doc + "|" + chv_nfe; + "|" + dt_doc + "|" + dt_e_s + "|" + vl_doc; + "|" + ind_pgto + "|" + vl_desc + "|" + vl_abat_nt; + "|" + vl_merc + "|" + ind_frt + "|" + vl_frt; + "|" + vl_seg + "|" + vl_out_da + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st; + "|" + vl_ipi + "|" + vl_pis + "|" + vl_cofins; + "|" + vl_pis_st + "|" + vl_cofins_st + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC100 // obs.. o array abaixo sera usado quando a operacao // tiver cst, cfop e icms diferenciados.. rc190:= {} // array para o registro c190 czQuery := "select * from f61000000 where"+; " qncd = " + alltrim(str(mpncd))+; " order by qncd asc;" ozQuery := oServer:Query(czQuery) num_item = 1 DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto nqcfo = ozQuery:Fieldget(ozQuery:Fieldpos('qcfo')) // cfop nqqtd = ozQuery:Fieldget(ozQuery:Fieldpos('qqtd')) // quantidade nquni = ozQuery:Fieldget(ozQuery:Fieldpos('quni')) // unidade nqvru = ozQuery:Fieldget(ozQuery:Fieldpos('qvru')) // valor unitario nqvti = ozQuery:Fieldget(ozQuery:Fieldpos('qvti')) // valor total nqvti = iif(!empty(nqvti),alltrim(transform(nqvti,"@e 999999999.99")),"0,00") nqcst = ozQuery:Fieldget(ozQuery:Fieldpos('qcst')) // situacao tributaria if mbaseCalculoICMS nqbci = ozQuery:Fieldget(ozQuery:Fieldpos('qbci')) // base de calculo do i.c.m nqbci = iif(!empty(nqbci),alltrim(transform(nqbci,"@e 999999999.99")),"0,00") else nqbci = "0,00" endif nqaic = ozQuery:Fieldget(ozQuery:Fieldpos('qaic')) // aliquota de icm nqaic = iif(!empty(nqaic),alltrim(transform(nqaic,"@e 999999999.99")),"0,00") if mvaloICMSentrada = .t. nqvic = ozQuery:Fieldget(ozQuery:Fieldpos('qvic')) // valor do icm nqvic = iif(!empty(nqvic),alltrim(transform(nqvic,"@e 999999999.99")),"0,00") else nqvic = "0,00" endif nqisn = ozQuery:Fieldget(ozQuery:Fieldpos('qisn')) // isento nqtrs = ozQuery:Fieldget(ozQuery:Fieldpos('qtrs')) // tributacao na saida if mbaseCalculoICMSSt = .t. nqbcs = ozQuery:Fieldget(ozQuery:Fieldpos('qbcs')) // base de substituicao nqbcs = iif(!empty(nqbcs),alltrim(transform(nqbcs,"@e 999999999.99")),"0,00") else nqbcs = "0,00" endif if mvaloICMSStentrada = .t. nqvcs = ozQuery:Fieldget(ozQuery:Fieldpos('qvcs')) // valor da substituicao nqvcs = iif(!empty(nqbcs),alltrim(transform(nqvcs,"@e 999999999.99")),"0,00") else nqvcs = "0,00" endif nqaip = ozQuery:Fieldget(ozQuery:Fieldpos('qaip')) // aliquota do ipi nqaip = iif(!empty(nqaip),alltrim(transform(nqaip,"@e 999999999.99")),"0,00") if mvalorIPI = .t. nqipi = ozQuery:Fieldget(ozQuery:Fieldpos('qipi')) // valor do ipi nqipi = iif(!empty(nqipi),alltrim(transform(nqipi,"@e 999999999.99")),"0,00") else nqipi = "0,00" endif nqadc = ozQuery:Fieldget(ozQuery:Fieldpos('qadc')) // classificacao fiscal nqads = ozQuery:Fieldget(ozQuery:Fieldpos('qads')) // aliquota diferenciada cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() //cyQuery := "select * from e40200000 where "+; // "cemp = " + alltrim(str(memp)) +; // " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" //oyQuery := oServer:Query(cyQuery) //nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) //nqcdcl = substr(alltrim(nqcdcl),1,8) //oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif cwQuery := "select * from r50000000 where "+; "aesq = " + alltrim(str(memp)) +" order by aesq asc;" owQuery := oServer:Query(cwQuery) paest = owQuery:Fieldget(owQuery:Fieldpos('aest')) owQuery:destroy() cwQuery := "select * from f50300000 where "+; "cses = " + "'"+upper(paest)+"'" cwQuery += " order by cses asc;" owQuery := oServer:Query(cwQuery) maliq = owQuery:Fieldget(owQuery:Fieldpos('caic')) maliq = iif(!empty(maliq),alltrim(transform(maliq,"@e 999999999.99")),"0,00") owQuery:dest
  17. #include "FiveWin.ch" #include "common.ch" #include "postgres.ch" #include "Folder.ch" #include "report.ch" #include "barcode.ch" //#include "vget.ch" //#include "vbtnbmp.ch" #Define clr_vermelho nRGB( 127, 058, 017 ) #define btn_width 12 #define btn_height 10 function spedfiscal() define brush obrush color mtela DEFINE BITMAP otpContador FILENAME "spedfiscal.bmp" define dialog spedfis title "EFD - Escrituracao Fiscal Digital" from 010,010 to 438,790 pixel brush oBrush define font mtahoma name "Tahoma" size 5.5,13 define font mtahoma1 name "Tahoma" size 08,22 define font oFont name 'MS Sans Serif' size 6,15 define font ofontL name "Courier" size 11,11 mbldg = 0 mblvs = space(03) // versÆo do layout mfinl = "Remessa do arquivo original" afinl = {"Remessa do arquivo original","Remessa do arquivo substituto"} mperf = "B - Perfil B" aperf = {"A - Perfil A","B - Perfil B","C - Perfil C"} mindi = "1 - Outros" aindi = {"0 - Industrial ou equiparado a industrial","1 - Outros"} mdtin = ctod("") mdtfi = ctod("") minvt = .f. // para os registros de entrada que foram lancados no sistema.......... mbaseCalculoICMS = .t. mvaloICMSentrada = .t. mbaseCalculoICMSSt = .t. mvaloICMSStentrada = .t. mvalorIPI = .t. finvt = "" ainvt = {} cQuery := "select * from n60300000 where"+; " wemp = " + alltrim(str(memp))+; " and wstd = " + "'"+"I"+"'"+; " order by wndc asc;" oQuery := oServer:Query(cQuery) aadd(ainvt,space(06)) DO WHILE ! oQuery:Eof() nwstd = oQuery:Fieldget(oQuery:Fieldpos('wstd')) if !empty(nwstd) nwndc = oQuery:Fieldget(oQuery:Fieldpos('wndc')) if empty(ainvt) aadd(ainvt,nwndc) else msn = "N" for tt = 1 to len(ainvt) if alltrim(nwndc) = alltrim(ainvt[tt]) msn = "S" exit endif next if msn = "N" aadd(ainvt,nwndc) endif endif endif oQuery:Skip() END oQuery:destroy() @ 35.5,002 say "Versao do leiaute Ato Cotepe" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 035 ,100 get oblvs var mblvs picture "@!" font mtahoma size 016,9 of spedfis color mcolorCA,mcolorCB pixel @ 50,002 say "Finalidade do arquivo Magnetico" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 60,002 combobox ofinl var mfinl items afinl font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 75,002 say "Perfil de apresentacao do arquivo fiscal" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 85,002 combobox operf var mperf items aperf font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 100,002 say "Indicador do tipo de atividade" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 110,002 combobox oindi var mindi items aindi font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel @ 125, 002 say "Período a ser gerado" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 135, 002 say "Data inicial:" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 135, 040 get odtin var mdtin font mtahoma size 32,9 of spedfis color mcolorCA,mcolorCB pixel @ 145, 002 say "Data final:" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 145, 040 get odtfi var mdtfi font mtahoma size 32,9 of spedfis color mcolorCA,mcolorCB pixel @ 165,002 checkbox oinvt var minvt prompt "&Gerar o inventario"; font mtahoma colors mcolorAA,mcolorAB size 64, 11 of spedfis pixel @ 178,002 combobox oinvt var finvt items ainvt font mtahoma size 250,90 of spedfis color mcolorCA,mcolorCB pixel when iif(minvt = .t.,.t.,.f.) @ 050,265 say "Registro a serem gerados para a Entrada" of spedfis font mtahoma color mcolorAA,mcolorAB pixel @ 060,265 checkbox obaseCalculoICMS var mbaseCalculoICMS prompt "Com base de calculo do ICMS"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 070,265 checkbox ovaloICMSentrada var mvaloICMSentrada prompt "Com valor de ICMS "; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 080,265 checkbox obaseCalculoICMSSt var mbaseCalculoICMSSt prompt "Com base de calculo do ICMS ST"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 090,265 checkbox ovaloICMSStentrada var mvaloICMSStentrada prompt "Com valor de ICMS ST"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 100,265 checkbox ovalorIPI var mvalorIPI prompt "Com valor de IPI"; font mtahoma colors mcolorAA,mcolorAB size 100, 11 of spedfis pixel @ 200,004 button orombut0 prompt "Gerar " size 040,12 font oFont OF spedfis pixel action ( gera_efd_fiscal() ) @ 200,047 button orombut1 prompt "Contador" size 040,12 font oFont OF spedfis pixel action ( contador() ) @ 200,090 button orombut2 prompt "Inventario" size 040,12 font oFont OF spedfis pixel action ( n6030008(1) ) @ 200,133 button orombut3 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,176 button orombut4 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,219 button orombut5 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,262 button orombut6 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,305 button orombut7 prompt "" size 040,12 font oFont OF spedfis pixel @ 200,348 button orombut8 prompt "Sair " size 040,12 font oFont OF spedfis pixel action ( spedfis:end() ) activate dialog spedfis center on Init ( busca_gera_efd_fiscal() ) on Paint ( WndBoxIn(spedfis:Hdc, 064, 001, 066, 790) ,; WndBoxIn(spedfis:Hdc, 391, 001, 393, 790) ,; sayBitmapContador() ) return nil function sayBitmapContador() spedfis:SayBitmap( (((spedfis:nTop+spedfis:nbottom)/2)-190) -(otpContador:nHeight()/2),((spedfis:nLeft+spedfis:nRight)/2)-(otpContador:nWidth()/2),otpContador,otpContador:nWidth(),otpContador:nHeight()) return nil function busca_gera_efd_fiscal() cQuery := "select * from r20200000"+; " order by bldg asc;" oQuery := oServer:Query(cQuery) mbldg = 0 mblvs = space(03) // versÆo do layout DO WHILE ! oQuery:Eof() mbldg = oQuery:Fieldget(oQuery:Fieldpos('bldg')) if !empty(mbldg) mblvs = oQuery:Fieldget(oQuery:Fieldpos('blvs')) oblvs:ctext := mblvs endif oQuery:Skip() END oQuery:destroy() return nil // Geracao do arquivo magnetico do EFD - Escritura‡Æo Fiscal Digital............ function gera_efd_fiscal() if empty(mblvs) msgstop("Versao do leiaute nao informado.","Atencao") return nil endif if empty(mdtin) msgstop("Data inicial nao foi informada.","Atencao") return nil endif if empty(mdtfi) msgstop("Data final nao foi informada.","Atencao") return nil endif if mbldg = 0 cQuery := "insert into r20200000(blvs)" cQuery += "values("+"'"+mblvs+"'"+")" oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Não foi possível realizar a inclusão.","ATENÇÃO") //oQuery:error() endif oQuery:destroy() oServer:Commit() else cQuery := "Update r20200000 set "+; "blvs = " + "'"+mblvs+"'"+; " where " + " bldg = " + alltrim(str(mbldg)) oQuery := oServer:Query(cQuery) if oQuery:neterr() msgStop("Não foi possível realizar a alteração.","ATENÇÃO") //oQuery:error() endif oQuery:destroy() oServer:Commit() endif // validacoes a serem consideradas para emissao do sped fiscal........ if empty(zaden) msgstop("Razao social do contribuinte vazio.","Atencao") return nil endif if empty(zaest) msgstop("Estado do contribuinte vazio.","Atencao") return nil endif if empty(zaies) msgstop("Inscricao Estadual do contribuinte vazio.","Atencao") return nil endif if empty(zaibg) msgstop("Codigo do municipio do IBGE do contribuinte vazio.","Atencao") return nil endif if empty(zatf1) msgstop("Numero do telefone do contribuinte vazio.","Atencao") return nil endif if empty(zatfx) msgstop("Numero do fax do contribuinte vazio.","Atencao") return nil endif // verifica os dados do contador ..................................... cQuery := "select * from r20100000"+; " order by ctnm asc;" oQuery := oServer:Query(cQuery) mctdg = 0 DO WHILE ! oQuery:Eof() mctdg = oQuery:Fieldget(oQuery:Fieldpos('ctdg')) if !empty(mctdg) mctnm = oQuery:Fieldget(oQuery:Fieldpos('ctnm')) mctcf = oQuery:Fieldget(oQuery:Fieldpos('ctcf')) mctrc = oQuery:Fieldget(oQuery:Fieldpos('ctrc')) mctpj = oQuery:Fieldget(oQuery:Fieldpos('ctpj')) mctcp = oQuery:Fieldget(oQuery:Fieldpos('ctcp')) mctlg = oQuery:Fieldget(oQuery:Fieldpos('ctlg')) mctnr = oQuery:Fieldget(oQuery:Fieldpos('ctnr')) mctdc = oQuery:Fieldget(oQuery:Fieldpos('ctdc')) mctbr = oQuery:Fieldget(oQuery:Fieldpos('ctbr')) mcttf = oQuery:Fieldget(oQuery:Fieldpos('cttf')) mctfx = oQuery:Fieldget(oQuery:Fieldpos('ctfx')) mctml = oQuery:Fieldget(oQuery:Fieldpos('ctml')) maibg = oQuery:Fieldget(oQuery:Fieldpos('ctbg')) endif oQuery:Skip() END oQuery:destroy() if empty(mctdg) msgstop("Preencha os dados do contabilista.","Atencao") return nil endif // comeca a geracao do arquivo do sped fiscal ........................ cDirXML = "spedfiscal-" + substr(dtos(mdtin),5,2) + "-" + substr(dtos(mdtin),1,4) + ".txt" Bloco0totallinhas = 0 BlocoCtotallinhas = 0 BlocoDtotallinhas = 0 BlocoEtotallinhas = 0 BlocoGtotallinhas = 0 BlocoHtotallinhas = 0 Bloco1totallinhas = 0 Bloco9totallinhas = 0 mreg0000 = 0 mreg0001 = 0 mreg0005 = 0 mreg0100 = 0 mreg0150 = 0 mreg0190 = 0 mreg0200 = 0 mreg0400 = 0 mreg0990 = 0 mregC001 = 0 mregC100 = 0 mregC170 = 0 mregC190 = 0 mregC990 = 0 mregD001 = 0 mregD990 = 0 mregE001 = 0 mregE100 = 0 mregE110 = 0 //mregE200 = 0 //mregE210 = 0 mregE990 = 0 mregG001 = 0 mregG990 = 0 mregH001 = 0 mregH005 = 0 mregH010 = 0 mregH990 = 0 mreg1001 = 0 mreg1990 = 0 mreg9001 = 0 mreg9900 = 0 mreg9990 = 0 mreg9999 = 0 campoE = {} mtotalICMS = 0 mtotalICMSst = 0 lh := 0 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. // B L O C O 0 // registro 0000...................................................... mlinha = "|" + "0000" + "|" + mblvs + "|" + iif(mfinl = "Remessa do arquivo original","0","1") +; "|" + substr(dtos(mdtin),7,2) + substr(dtos(mdtin),5,2) + substr(dtos(mdtin),1,4) +; "|" + substr(dtos(mdtfi),7,2) + substr(dtos(mdtfi),5,2) + substr(dtos(mdtfi),1,4) +; "|" + alltrim(zaden) + "|" + zandn + "|" + "|" + zaest + "|" + alltrim(substr(zaies,1,14)) +; "|" + alltrim(substr(zaibg,1,7)) + "|" + "|" + "|"+; iif(mperf = "A - Perfil A","A",iif(mperf = "B - Perfil B","B","C")) + "|"+; iif(mindi = "1 - Outros","1","0") + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0000 // registro 0001...................................................... mlinha = "|" + "0001" + "|" + "0" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0001 // registro 0005...................................................... // obs.. para o nome fantasia depois ver um modo de pegar alguns dados // do nome da empresa.. mlinha = "|" + "0005" + "|" + substr(zaden,1,17) + "|" + zacep + "|" + alltrim(zaend) +; "|" + alltrim(str(zanro)) + "|" + alltrim(zacpl) + "|" + alltrim(zabai)+; "|" + alltrim(zatf1) + "|" + alltrim(zatfx) + "|" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0005 // registro 0100 mlinha = "|" + "0100" + "|" + alltrim(mctnm) + "|" + alltrim(mctcf) + "|" +; alltrim(mctrc) + "|" + alltrim(mctpj) + "|" + mctcp + "|" +; alltrim(mctlg) + "|" + alltrim(mctnr) + "|" + alltrim(mctdc) +; "|" + alltrim(mctbr) + "|" + mcttf + "|" + mctfx + "|" + ; alltrim(mctml) + "|" + maibg + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0100 // registro 0150 // para clientes...................................................... acliautorizada := {} aprodutosusado := {} aunidadeusadas := {} acfoputilizado := {} // se for utilizar o inventario....................................... if minvt = .t. finvt = alltrim(finvt) if !empty(finvt) ntotv = 0 cQuery := "select * from n60300000 where"+; " wemp = " + alltrim(str(memp))+; " and wndc = " + "'"+alltrim(finvt)+"'"+; " and wstd = " + "'"+"I"+"'"+; " order by wndc asc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() nwstd = oQuery:Fieldget(oQuery:Fieldpos('wstd')) if !empty(nwstd) if nwstd != "I" oQuery:Skip() loop endif iwbcf = oQuery:Fieldget(oQuery:Fieldpos('wbcf')) // codigo normal iwqit = oQuery:Fieldget(oQuery:Fieldpos('wqit')) // quantidade a ser fabricada iwvlr = oQuery:Fieldget(oQuery:Fieldpos('wvlr')) // valor.. ntotv = ntotv + ( iwqit * iwvlr ) wQuery := "select * from e40100000 where" wQuery += " bcdg = " + "'"+alltrim(iwbcf)+"'" wQuery += " order by bcdg asc;" owQuery := oServer:Query(wQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) nqund = alltrim(nqund) nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) nqcap = owQuery:Fieldget(owQuery:Fieldpos('bcap')) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para produtos que estao usados no inventario........... if empty(aprodutosusado) aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) else msn = "S" for tt = 1 to len(aprodutosusado) if aprodutosusado[tt,1] = nqnpc msn = "N" exit endif next if msn = "S" aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) endif endif endif oQuery:Skip() END oQuery:destroy() endif endif nsaidas := nentradas := 0 ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) if mdtin = mdtfi cQuery := "select * from f50900000 where"+; " p035 = " + "'"+ndtin+"'" else cQuery := "select * from f50900000 where"+; " p035 >= " + "'"+ndtin+"'" + " and"+; " p035 <= " + "'"+ndtfi+"'" endif cQuery += " order by p035 desc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) p051 = oQuery:Fieldget(oQuery:Fieldpos('p051')) p094 = oQuery:Fieldget(oQuery:Fieldpos('p094')) // Entrada ou Saida.. nsta = oQuery:Fieldget(oQuery:Fieldpos('pstu')) // Situacao da nota mp016 = oQuery:Fieldget(oQuery:Fieldpos('p016')) // numero do pedido ou romaneio.. mp016 = alltrim(mp016) nrnop = oQuery:Fieldget(oQuery:Fieldpos('p062')) np062 = oQuery:Fieldget(oQuery:Fieldpos('p062')) np062 = alltrim(substr(np062,1,4)) nrdno = "" cqQuery := "select * from f51100000 "+; "where rnop = " + alltrim(nrnop)+; " order by rnop asc;" oqQuery := oServer:Query(cqQuery) nrdno = oqQuery:Fieldget(oqQuery:Fieldpos('rdno')) oqQuery:destroy() if empty(pasq) oQuery:Skip() loop endif if nsta != 5 if nsta = 6 if empty(acliautorizada) aadd(acliautorizada,p051) else msn = "S" for tt = 1 to len(acliautorizada) if acliautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(acliautorizada,p051) endif endif endif oQuery:Skip() loop endif if empty(acliautorizada) aadd(acliautorizada,p051) else msn = "S" for tt = 1 to len(acliautorizada) if acliautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(acliautorizada,p051) endif endif if p094 = "S" ++nsaidas elseif p094 = "E" ++nentradas endif // acrescenta os cfops.. usados nas saidas e entradas.............. //if empt(acfoputilizado) // aadd(acfoputilizado,{np062,nrdno}) //else // msn = "S" // for tt = 1 to len(acfoputilizado) // if acfoputilizado[tt,1] = np062 // msn = "N" // exit // endif // next // if msn = "S" // aadd(acfoputilizado,{np062,nrdno}) // endif //endif // Detalha os produtos e seus impostos................................ czQuery := "select * from f51000000 where"+; " qnpd = " + "'"+mp016+"'"+; " order by qnpd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para os produtos que foram usados nas transacoes............. //if empty(aprodutosusado) // aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) //else // msn = "S" // for tt = 1 to len(aprodutosusado) // if aprodutosusado[tt,1] = nqnpc // msn = "N" // exit // endif // next // if msn = "S" // aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) // endif //endif ozQuery:Skip() END ozQuery:destroy() oQuery:Skip() END oQuery:destroy() for tt = 1 to len(acliautorizada) cQuery := "select * from r20000000 where "+; "acdc = " + alltrim(str(val(acliautorizada[tt]))) cQuery += " order by acdc asc;" oQuery := oServer:Query(cQuery) ncod_part = oQuery:Fieldget(oQuery:Fieldpos('acdc')) ncod_part = alltrim(str(ncod_part)) nnome = oQuery:Fieldget(oQuery:Fieldpos('anrs')) nnome = alltrim(nnome) ncod_pais = "01058" napfj = oQuery:Fieldget(oQuery:Fieldpos('apfj')) if napfj = "F" ncnpj = "" ncnpf = oQuery:Fieldget(oQuery:Fieldpos('andn')) else ncnpj = oQuery:Fieldget(oQuery:Fieldpos('andn')) ncnpf = "" endif nie = oQuery:Fieldget(oQuery:Fieldpos('andl')) nie = alltrim(substr(nie,1,14)) ncod_mun = oQuery:Fieldget(oQuery:Fieldpos('aibg')) ncod_mun = substr(ncod_mun,1,7) nsuframa = "" nend = oQuery:Fieldget(oQuery:Fieldpos('aend')) nend = alltrim(nend) nnum = oQuery:Fieldget(oQuery:Fieldpos('anro')) nnum = alltrim(nnum) ncompl = oQuery:Fieldget(oQuery:Fieldpos('acmp')) ncompl = alltrim(ncompl) nbairro = oQuery:Fieldget(oQuery:Fieldpos('abai')) nbairro = alltrim(nbairro) mlinha = "|" + "0150" + "|" + ncod_part + "|" + nnome + "|" + ncod_pais +; "|" + ncnpj + "|" + ncnpf + "|" + nie + "|" + ncod_mun +; "|" + nsuframa + "|" + nend + "|" + nnum + "|" + ncompl+; "|" + nbairro + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0150 next // para fornecedores.................................................. aforautorizada := {} ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) if mdtin = mdtfi cQuery := "select * from f60900000 where"+; " pent = " + "'"+ndtin+"'" else cQuery := "select * from f60900000 where"+; " pent >= " + "'"+ndtin+"'" + " and"+; " pent <= " + "'"+ndtfi+"'" endif cQuery += " order by pent desc;" oQuery := oServer:Query(cQuery) DO WHILE ! oQuery:Eof() pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) p051 = oQuery:Fieldget(oQuery:Fieldpos('pclf')) p051 = alltrim(strzero(p051,5)) mpncd = oQuery:Fieldget(oQuery:Fieldpos('pncd')) p094 = "E" nrnop = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) nrnop = alltrim(str(nrnop)) np062 = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) np062 = alltrim(str(np062)) nrdno = "" cqQuery := "select * from f51100000 "+; "where substr(rnop,1,4) = " + alltrim(nrnop)+; " order by rnop asc;" oqQuery := oServer:Query(cqQuery) nrdno = oqQuery:Fieldget(oqQuery:Fieldpos('rdno')) oqQuery:destroy() if empty(pasq) oQuery:Skip() loop endif if empty(aforautorizada) aadd(aforautorizada,p051) else msn = "S" for tt = 1 to len(aforautorizada) if aforautorizada[tt] = p051 msn = "N" exit endif next if msn = "S" aadd(aforautorizada,p051) endif endif ++nentradas // acrescenta os cfops.. usados nas saidas e entradas.............. if empt(acfoputilizado) aadd(acfoputilizado,{np062,nrdno}) else msn = "S" for tt = 1 to len(acfoputilizado) if acfoputilizado[tt,1] = np062 msn = "N" exit endif next if msn = "S" aadd(acfoputilizado,{np062,nrdno}) endif endif // Detalha os produtos e seus impostos................................ czQuery := "select * from f61000000 where"+; " qncd = " + alltrim(str(mpncd))+; " order by qncd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() cyQuery := "select * from e40200000 where "+; "cemp = " + alltrim(str(memp)) +; " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" oyQuery := oServer:Query(cyQuery) nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) nqcdcl = substr(alltrim(nqcdcl),1,8) oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif if empty(aunidadeusadas) aadd(aunidadeusadas,{ncdund,nqund}) else msn = "S" for tt = 1 to len(aunidadeusadas) if aunidadeusadas[tt,1] = ncdund msn = "N" exit endif next if msn = "S" aadd(aunidadeusadas,{ncdund,nqund}) endif endif // para os produtos que foram usados nas transacoes............. if empty(aprodutosusado) aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) else msn = "S" for tt = 1 to len(aprodutosusado) if aprodutosusado[tt,1] = nqnpc msn = "N" exit endif next if msn = "S" aadd(aprodutosusado,{nqnpc,alltrim(nqdpr),"","",ncdund,"00",nqcdcl,"","","",""}) endif endif ozQuery:Skip() END ozQuery:destroy() oQuery:Skip() END oQuery:destroy() for tt = 1 to len(aforautorizada) cQuery := "select * from r10000000 where "+; "acdg = " + alltrim(str(val(aforautorizada[tt]))) cQuery += " order by acdg asc;" oQuery := oServer:Query(cQuery) ncod_part = oQuery:Fieldget(oQuery:Fieldpos('acdg')) ncod_part = "FOR-" + alltrim(str(ncod_part)) nnome = oQuery:Fieldget(oQuery:Fieldpos('anrs')) nnome = alltrim(nnome) ncod_pais = "01058" napfj = oQuery:Fieldget(oQuery:Fieldpos('andn')) napfj = alltrim(napfj) if len(napfj) <= 11 ncnpj = "" ncnpf = oQuery:Fieldget(oQuery:Fieldpos('andn')) else ncnpj = oQuery:Fieldget(oQuery:Fieldpos('andn')) ncnpf = "" endif nie = oQuery:Fieldget(oQuery:Fieldpos('andl')) nie = alltrim(substr(nie,1,14)) ncod_mun = oQuery:Fieldget(oQuery:Fieldpos('aibg')) ncod_mun = substr(ncod_mun,1,7) nsuframa = "" nend = oQuery:Fieldget(oQuery:Fieldpos('aend')) nend = alltrim(nend) nnum = oQuery:Fieldget(oQuery:Fieldpos('anro')) nnum = alltrim(nnum) ncompl = "" nbairro = oQuery:Fieldget(oQuery:Fieldpos('abai')) nbairro = alltrim(nbairro) mlinha = "|" + "0150" + "|" + ncod_part + "|" + nnome + "|" + ncod_pais +; "|" + ncnpj + "|" + ncnpf + "|" + nie + "|" + ncod_mun +; "|" + nsuframa + "|" + nend + "|" + nnum + "|" + ncompl+; "|" + nbairro + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0150 next // registro 0190 for tt = 1 to len(aunidadeusadas) mlinha = "|" + "0190" + "|" + aunidadeusadas[tt,1] + "|" + aunidadeusadas[tt,2] + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0190 next // registro 0200 for tt = 1 to len(aprodutosusado) mlinha = "|" + "0200" + "|" + aprodutosusado[tt,1] + "|" + aprodutosusado[tt,2]; + "|" + aprodutosusado[tt,3] + "|" + aprodutosusado[tt,4]; + "|" + aprodutosusado[tt,5] + "|" + aprodutosusado[tt,6]; + "|" + aprodutosusado[tt,7] + "|" + aprodutosusado[tt,8]; + "|" + aprodutosusado[tt,9] + "|" + aprodutosusado[tt,10]; + "|" + aprodutosusado[tt,11] + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0200 next // registro 0400 for tt = 1 to len(acfoputilizado) mlinha = "|" + "0400" + "|" + acfoputilizado[tt,1] + "|" + alltrim(acfoputilizado[tt,2]) + "|" + CRLF oPrn:Say(lh,000,mlinha) ++Bloco0totallinhas ++mreg0400 next // registro 0990 ++Bloco0totallinhas ++mreg0990 mlinha = "|" + "0990" + "|" + alltrim(str(Bloco0totallinhas)) + "|" + CRLF oPrn:Say(lh,000,mlinha) // B L O C O C if nsaidas = 0 .and. nentradas = 0 // registro c001 mlinha = "|" + "C001" + "|" + "1" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC001 // registro c990 ++BlocoCtotallinhas ++mregC990 mlinha = "|" + "C990" + "|" + alltrim(str(BlocoCtotallinhas)) + CRLF oPrn:Say(lh,000,mlinha) else mlinha = "|" + "C001" + "|" + "0" + "|"+ CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC001 // registro c001 // Notas fiscais eletronica de saida e entrada emissao propria ndtin = substr(dtos(mdtin),1,4)+"-"+substr(dtos(mdtin),5,2)+"-"+substr(dtos(mdtin),7,2) ndtfi = substr(dtos(mdtfi),1,4)+"-"+substr(dtos(mdtfi),5,2)+"-"+substr(dtos(mdtfi),7,2) for pt = 1 to 2 if pt = 1 ntipodenota = "S" elseif pt = 2 ntipodenota = "E" endif if mdtin = mdtfi cQuery := "select * from f50900000 where"+; " p035 = " + "'"+ndtin+"'" else cQuery := "select * from f50900000 where"+; " p035 >= " + "'"+ndtin+"'" + " and"+; " p035 <= " + "'"+ndtfi+"'" endif cQuery += " and p094 = " + "'"+ntipodenota+"'" cQuery += " order by p034 asc;" oQuery := oServer:Query(cQuery) pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) if !empty(pasq) DO WHILE ! oQuery:Eof() psql = oQuery:Fieldget(oQuery:Fieldpos('pasq')) pstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) // Situacao da nota p016 = oQuery:Fieldget(oQuery:Fieldpos('p016')) // numero do pedido p051 = oQuery:Fieldget(oQuery:Fieldpos('p051')) // codigo do cliente psnf = oQuery:Fieldget(oQuery:Fieldpos('psnf')) // serie da nota fiscal p034 = oQuery:Fieldget(oQuery:Fieldpos('p034')) // numero da nota fiscal pchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // chave de acesso da nota fiscal eletronica p035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) // data de emissao p033 = oQuery:Fieldget(oQuery:Fieldpos('p033')) // data de saida p026 = oQuery:Fieldget(oQuery:Fieldpos('p026')) // valor do documento p089 = oQuery:Fieldget(oQuery:Fieldpos('p089')) // tipo de pagamento p024 = oQuery:Fieldget(oQuery:Fieldpos('p024')) // valor total dos produtos p069 = oQuery:Fieldget(oQuery:Fieldpos('p069')) // frete p021 = oQuery:Fieldget(oQuery:Fieldpos('p021')) // valor do frete p022 = oQuery:Fieldget(oQuery:Fieldpos('p022')) // valor do seguro p063 = oQuery:Fieldget(oQuery:Fieldpos('p063')) // outras despesas e acessorios p053 = oQuery:Fieldget(oQuery:Fieldpos('p053')) // base de calculo p054 = oQuery:Fieldget(oQuery:Fieldpos('p054')) // valor do icms. p055 = oQuery:Fieldget(oQuery:Fieldpos('p055')) p056 = oQuery:Fieldget(oQuery:Fieldpos('p056')) p025 = oQuery:Fieldget(oQuery:Fieldpos('p025')) if pstu < 5 oQuery:Skip() loop endif ind_oper = iif(ntipodenota = "S","1","0") ind_emit = "0" if pstu = 6 cod_part = "" else cod_part = alltrim(str(val(p051))) endif cod_mod = "55" if pstu = 6 cod_sit = "02" else cod_sit = "00" endif ser = alltrim(psnf) num_doc = alltrim(str(val(p034))) chv_nfe = alltrim(pchv) if pstu = 6 dt_doc = "" dt_e_s = "" vl_doc = "" ind_pgto = "" vl_desc = "" vl_abat_nt = "" vl_merc = "" ind_frt = "" vl_frt = "" vl_seg = "" vl_out_da = "" vl_bc_icms = "" vl_icms = "" vl_bc_icmsst = "" vl_icms_st = "" vl_ipi = "" vl_pis = "" vl_cofins = "" vl_pis_st = "" vl_cofins_st = "" else dt_doc = substr(dtos(p035),7,2) + substr(dtos(p035),5,2) + substr(dtos(p035),1,4) if empty(p033) dt_e_s = "" else dt_e_s = substr(dtos(p033),7,2) + substr(dtos(p033),5,2) + substr(dtos(p033),1,4) endif vl_doc = alltrim(transform(p026,"@e 999999999.99")) if p089 = "0" ind_pgto = "0" elseif p089 = "1" ind_pgto = "1" elseif p089 = "2" ind_pgto = "9" endif vl_desc = "0,00" vl_abat_nt = "0,00" vl_merc = alltrim(transform(p024,"@e 999999999.99")) ind_frt = iif(p069 = "1","1","2") vl_frt = iif(!empty(p021),alltrim(transform(p021,"@e 999999999.99")),"0,00") vl_seg = iif(!empty(p022),alltrim(transform(p022,"@e 999999999.99")),"0,00") vl_out_da = iif(!empty(p063),alltrim(transform(p063,"@e 999999999.99")),"0,00") vl_bc_icms = iif(!empty(p053),alltrim(transform(p053,"@e 999999999.99")),"0,00") vl_icms = iif(!empty(p054),alltrim(transform(p054,"@e 999999999.99")),"0,00") vl_bc_icmsst = iif(!empty(p055),alltrim(transform(p055,"@e 999999999.99")),"0,00") vl_icms_st = iif(!empty(p056),alltrim(transform(p056,"@e 999999999.99")),"0,00") vl_ipi = iif(!empty(p025),alltrim(transform(p025,"@e 999999999.99")),"0,00") vl_pis = "0,00" vl_cofins = "0,00" vl_pis_st = "0,00" vl_cofins_st = "0,00" endif mlinha = "|" + "C100" + "|" + ind_oper + "|" + ind_emit; + "|" + cod_part + "|" + cod_mod + "|" + cod_sit; + "|" + ser + "|" + num_doc + "|" + chv_nfe; + "|" + dt_doc + "|" + dt_e_s + "|" + vl_doc; + "|" + ind_pgto + "|" + vl_desc + "|" + vl_abat_nt; + "|" + vl_merc + "|" + ind_frt + "|" + vl_frt; + "|" + vl_seg + "|" + vl_out_da + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st; + "|" + vl_ipi + "|" + vl_pis + "|" + vl_cofins; + "|" + vl_pis_st + "|" + vl_cofins_st + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC100 if pstu = 6 else // obs.. o array abaixo sera usado quando a operacao // tiver cst, cfop e icms diferenciados.. rc190:= {} // array para o registro c190 czQuery := "select * from f51000000 where"+; " qnpd = " + "'"+p016+"'"+; " order by qnpd asc;" ozQuery := oServer:Query(czQuery) DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto nqcfo = ozQuery:Fieldget(ozQuery:Fieldpos('qcfo')) // cfop nqqtd = ozQuery:Fieldget(ozQuery:Fieldpos('qqtd')) // quantidade nquni = ozQuery:Fieldget(ozQuery:Fieldpos('quni')) // unidade nqvru = ozQuery:Fieldget(ozQuery:Fieldpos('qvru')) // valor unitario nqvti = ozQuery:Fieldget(ozQuery:Fieldpos('qvti')) // valor total nqvti = iif(!empty(nqvti),alltrim(transform(nqvti,"@e 999999999.99")),"0,00") nqcst = ozQuery:Fieldget(ozQuery:Fieldpos('qcst')) // situacao tributaria nqbci = ozQuery:Fieldget(ozQuery:Fieldpos('qbci')) // base de calculo do i.c.m nqbci = iif(!empty(nqbci),alltrim(transform(nqbci,"@e 999999999.99")),"0,00") nqaic = ozQuery:Fieldget(ozQuery:Fieldpos('qaic')) // aliquota de icm nqvic = ozQuery:Fieldget(ozQuery:Fieldpos('qvic')) // valor do icm nqvic = iif(!empty(nqvic),alltrim(transform(nqvic,"@e 999999999.99")),"0,00") nqisn = ozQuery:Fieldget(ozQuery:Fieldpos('qisn')) // isento nqtrs = ozQuery:Fieldget(ozQuery:Fieldpos('qtrs')) // tributacao na saida nqadc = ozQuery:Fieldget(ozQuery:Fieldpos('qadc')) // classificacao fiscal nqads = ozQuery:Fieldget(ozQuery:Fieldpos('qads')) // aliquota diferenciada //cwQuery := "select * from e40100000 where "+; // "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" //owQuery := oServer:Query(cwQuery) //nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a //nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto //nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto //nqund = alltrim(nqund) //owQuery:destroy() // //cyQuery := "select * from e40200000 where "+; // "cemp = " + alltrim(str(memp)) +; // " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" //oyQuery := oServer:Query(cyQuery) //nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) //nqcdcl = substr(alltrim(nqcdcl),1,8) //oyQuery:destroy() ozQuery:Skip() END ozQuery:destroy() mlinha = "|" + "C190" + "|" + substr(nqcst,1,3) + "|" +; substr(nqcfo,1,4) + "|" + iif(!empty(nqaic),alltrim(transform(nqaic,"@e 999.99")),"0,00"); + "|" + vl_doc + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st + "|"; + "0,00" + "|" + "0,00" + "|" + "" + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC190 endif oQuery:Skip() END endif oQuery:destroy() next // Notas fisciais de entrada ... Lancamento manual................. if mdtin = mdtfi cQuery := "select * from f60900000 where"+; " pent = " + "'"+ndtin+"'" else cQuery := "select * from f60900000 where"+; " pent >= " + "'"+ndtin+"'" + " and"+; " pent <= " + "'"+ndtfi+"'" endif cQuery += " order by pemi asc;" oQuery := oServer:Query(cQuery) pasq = oQuery:Fieldget(oQuery:Fieldpos('pasq')) if !empty(pasq) DO WHILE ! oQuery:Eof() psql = oQuery:Fieldget(oQuery:Fieldpos('pasq')) mpncd = oQuery:Fieldget(oQuery:Fieldpos('pncd')) p051 = oQuery:Fieldget(oQuery:Fieldpos('pclf')) // codigo do fornecedor p051 = "FOR-" + alltrim(str(p051)) nNatureza = "" p062 = oQuery:Fieldget(oQuery:Fieldpos('pcfo')) p062 = alltrim(str(p062)) for tt = 1 to len(acfoputilizado) if acfoputilizado[tt,1] = p062 nNatureza = acfoputilizado[tt,2] exit endif next psnf = oQuery:Fieldget(oQuery:Fieldpos('pser')) // serie da nota fiscal p034 = oQuery:Fieldget(oQuery:Fieldpos('pnur')) // numero da nota fiscal p034 = alltrim(str(p034)) pchv = "" // chave de acesso da nota fiscal eletronica p035 = oQuery:Fieldget(oQuery:Fieldpos('pemi')) // data de emissao p033 = oQuery:Fieldget(oQuery:Fieldpos('pemi')) // data de saida p089 = oQuery:Fieldget(oQuery:Fieldpos('pprz')) // tipo de pagamento p089 = iif(p089 = .t.,"1","0" ) mntmv = oQuery:Fieldget(oQuery:Fieldpos('ptmv')) // verifica se movimenta o estoque............................... cwQuery := "select * from e40700000 where "+; "lcmv = " + alltrim(str(mntmv)) cwQuery += " order by lcmv asc;" owQuery := oServer:Query(cwQuery) nlmve = owQuery:Fieldget(owQuery:Fieldpos('lmve')) owQuery:destroy() nlmve = iif(nlmve = .t.,"y","n") pest = oQuery:Fieldget(oQuery:Fieldpos('pest')) // estado da federacao ptnf = oQuery:Fieldget(oQuery:Fieldpos('ptnf')) // total da nota if mbaseCalculoICMS = .t. pbas = oQuery:Fieldget(oQuery:Fieldpos('pbas')) // total da base else pbas = 0 endif if mvaloICMSentrada = .t. picm = oQuery:Fieldget(oQuery:Fieldpos('picm')) // total do icms else picm = 0 endif pist = oQuery:Fieldget(oQuery:Fieldpos('pist')) // total do isento pout = oQuery:Fieldget(oQuery:Fieldpos('pout')) // total outros if mvalorIPI = .t. pipi = oQuery:Fieldget(oQuery:Fieldpos('pipi')) // total ipi else pipi = 0 endif ptpr = oQuery:Fieldget(oQuery:Fieldpos('ptpr')) // total dos produtos pfre = oQuery:Fieldget(oQuery:Fieldpos('pfre')) // total frete pseg = oQuery:Fieldget(oQuery:Fieldpos('pseg')) // total seguro palq = oQuery:Fieldget(oQuery:Fieldpos('palq')) // aliquota icms pdes = oQuery:Fieldget(oQuery:Fieldpos('pdes')) // despesa if mbaseCalculoICMSSt pbst = oQuery:Fieldget(oQuery:Fieldpos('pbst')) // base substituicao else pbst = 0 endif if mvaloICMSStentrada = .t. pict = oQuery:Fieldget(oQuery:Fieldpos('pict')) // icms substituicao else pict = 0 endif ind_oper = "0" ind_emit = "1" cod_part = p051 cod_mod = "55" cod_sit = "00" ser = alltrim(psnf) num_doc = p034 chv_nfe = pchv dt_doc = substr(dtos(p035),7,2) + substr(dtos(p035),5,2) + substr(dtos(p035),1,4) if empty(p033) dt_e_s = "" else dt_e_s = substr(dtos(p033),7,2) + substr(dtos(p033),5,2) + substr(dtos(p033),1,4) endif vl_doc = alltrim(transform(ptnf,"@e 999999999.99")) if p089 = "0" ind_pgto = "0" elseif p089 = "1" ind_pgto = "1" elseif p089 = "2" ind_pgto = "9" endif vl_desc = "0,00" vl_abat_nt = "0,00" vl_merc = alltrim(transform(ptpr,"@e 999999999.99")) ind_frt = "1" vl_frt = iif(!empty(pfre),alltrim(transform(pfre,"@e 999999999.99")),"0,00") vl_seg = iif(!empty(pseg),alltrim(transform(pseg,"@e 999999999.99")),"0,00") vl_out_da = iif(!empty(pout),alltrim(transform(pout,"@e 999999999.99")),"0,00") vl_bc_icms = iif(!empty(pbas),alltrim(transform(pbas,"@e 999999999.99")),"0,00") vl_icms = iif(!empty(picm),alltrim(transform(picm,"@e 999999999.99")),"0,00") vl_bc_icmsst = iif(!empty(pbst),alltrim(transform(pbst,"@e 999999999.99")),"0,00") vl_icms_st = iif(!empty(pict),alltrim(transform(pict,"@e 999999999.99")),"0,00") vl_ipi = iif(!empty(pipi),alltrim(transform(pipi,"@e 999999999.99")),"0,00") vl_pis = "0,00" vl_cofins = "0,00" vl_pis_st = "0,00" vl_cofins_st = "0,00" //mtotalICMS = mtotalICMS + picm //mtotalICMSst = mtotalICMSst + pict // verifica se gera o campo E100 e o E200.................... //if pict > 0 if empty(campoE) aadd(campoE,pest) else msn = "S" for tt = 1 to len(campoE) if campoE[tt] = pest msn = "N" exit endif next if msn = "S" aadd(campoE,pest) endif endif //endif mlinha = "|" + "C100" + "|" + ind_oper + "|" + ind_emit; + "|" + cod_part + "|" + cod_mod + "|" + cod_sit; + "|" + ser + "|" + num_doc + "|" + chv_nfe; + "|" + dt_doc + "|" + dt_e_s + "|" + vl_doc; + "|" + ind_pgto + "|" + vl_desc + "|" + vl_abat_nt; + "|" + vl_merc + "|" + ind_frt + "|" + vl_frt; + "|" + vl_seg + "|" + vl_out_da + "|" + vl_bc_icms; + "|" + vl_icms + "|" + vl_bc_icmsst + "|" + vl_icms_st; + "|" + vl_ipi + "|" + vl_pis + "|" + vl_cofins; + "|" + vl_pis_st + "|" + vl_cofins_st + "|" + CRLF oPrn:Say(lh,000,mlinha) ++BlocoCtotallinhas ++mregC100 // obs.. o array abaixo sera usado quando a operacao // tiver cst, cfop e icms diferenciados.. rc190:= {} // array para o registro c190 czQuery := "select * from f61000000 where"+; " qncd = " + alltrim(str(mpncd))+; " order by qncd asc;" ozQuery := oServer:Query(czQuery) num_item = 1 DO WHILE !ozQuery:Eof() nqcap = ozQuery:Fieldget(ozQuery:Fieldpos('qcap')) // codigo de acesso ao produto nqcfo = ozQuery:Fieldget(ozQuery:Fieldpos('qcfo')) // cfop nqqtd = ozQuery:Fieldget(ozQuery:Fieldpos('qqtd')) // quantidade nquni = ozQuery:Fieldget(ozQuery:Fieldpos('quni')) // unidade nqvru = ozQuery:Fieldget(ozQuery:Fieldpos('qvru')) // valor unitario nqvti = ozQuery:Fieldget(ozQuery:Fieldpos('qvti')) // valor total nqvti = iif(!empty(nqvti),alltrim(transform(nqvti,"@e 999999999.99")),"0,00") nqcst = ozQuery:Fieldget(ozQuery:Fieldpos('qcst')) // situacao tributaria if mbaseCalculoICMS nqbci = ozQuery:Fieldget(ozQuery:Fieldpos('qbci')) // base de calculo do i.c.m nqbci = iif(!empty(nqbci),alltrim(transform(nqbci,"@e 999999999.99")),"0,00") else nqbci = "0,00" endif nqaic = ozQuery:Fieldget(ozQuery:Fieldpos('qaic')) // aliquota de icm nqaic = iif(!empty(nqaic),alltrim(transform(nqaic,"@e 999999999.99")),"0,00") if mvaloICMSentrada = .t. nqvic = ozQuery:Fieldget(ozQuery:Fieldpos('qvic')) // valor do icm nqvic = iif(!empty(nqvic),alltrim(transform(nqvic,"@e 999999999.99")),"0,00") else nqvic = "0,00" endif nqisn = ozQuery:Fieldget(ozQuery:Fieldpos('qisn')) // isento nqtrs = ozQuery:Fieldget(ozQuery:Fieldpos('qtrs')) // tributacao na saida if mbaseCalculoICMSSt = .t. nqbcs = ozQuery:Fieldget(ozQuery:Fieldpos('qbcs')) // base de substituicao nqbcs = iif(!empty(nqbcs),alltrim(transform(nqbcs,"@e 999999999.99")),"0,00") else nqbcs = "0,00" endif if mvaloICMSStentrada = .t. nqvcs = ozQuery:Fieldget(ozQuery:Fieldpos('qvcs')) // valor da substituicao nqvcs = iif(!empty(nqbcs),alltrim(transform(nqvcs,"@e 999999999.99")),"0,00") else nqvcs = "0,00" endif nqaip = ozQuery:Fieldget(ozQuery:Fieldpos('qaip')) // aliquota do ipi nqaip = iif(!empty(nqaip),alltrim(transform(nqaip,"@e 999999999.99")),"0,00") if mvalorIPI = .t. nqipi = ozQuery:Fieldget(ozQuery:Fieldpos('qipi')) // valor do ipi nqipi = iif(!empty(nqipi),alltrim(transform(nqipi,"@e 999999999.99")),"0,00") else nqipi = "0,00" endif nqadc = ozQuery:Fieldget(ozQuery:Fieldpos('qadc')) // classificacao fiscal nqads = ozQuery:Fieldget(ozQuery:Fieldpos('qads')) // aliquota diferenciada cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = alltrim(nqund) owQuery:destroy() //cyQuery := "select * from e40200000 where "+; // "cemp = " + alltrim(str(memp)) +; // " and ccap = " + alltrim(str(nqcap)) + " order by ccap asc;" //oyQuery := oServer:Query(cyQuery) //nqcdcl = oyQuery:Fieldget(oyQuery:Fieldpos('cdcl')) //nqcdcl = substr(alltrim(nqcdcl),1,8) //oyQuery:destroy() // para as unidades de medidas existentes no sistema............ if upper(nqund) = "PC" ncdund = "1" elseif upper(nqund) = "KG" ncdund = "2" elseif upper(nqund) = "MT" ncdund = "3" elseif upper(nqund) = "UN" ncdund = "4" elseif upper(nqund) = "UND" ncdund = "5" endif cwQuery := "select * from r50000000 where "+; "aesq = " + alltrim(str(memp)) +" order by aesq asc;" owQuery := oServer:Query(cwQuery) paest = owQuery:Fieldget(owQuery:Fieldpos('aest')) owQuery:destroy() cwQuery := "select * from f50300000 where "+; "cses = " + "'"+upper(paest)+"'" cwQuery += " order by cses asc;" owQuery := oServer:Query(cwQuery) maliq = owQuery:Fieldget(owQuery:Fieldpos('caic')) maliq = iif(!empty(maliq),alltrim(transform(maliq,"@e 999999999.99")),"0,00") owQuery:dest
  18. Um exemplo de criar arquivos XML, e fazendo a integração do ERP com o UNINFE,, enviando arquivos e recebendo arquivos XML e os lendo. Obs. Cada um faça de acordo com o sistema que possui.. ,, abaixo é um exemplo de como eu trato.. isso em um dos.. sistema que possuo... #include "FiveWin.ch" #include "common.ch" #include "postgres.ch" #include "Folder.ch" #include "report.ch" #include "Splitter.ch" #include "fileio.ch" #include "hbxml.ch" #define linebuff 1024 static lEof:=.F. // variavel que guarda o processo o estado do arquivo de nf-e ,, digitação,,validade e assinada, etc... // pstu - vazio... esta em digitacao.. // pstu - 1 validada e assinada.. // pstu - 3 lote gerado aguardando recibo.. // pstu - 4 recibo lido e gravado aguardando n§ de protocolo // pstu - 5 aprovada... // variaveis que guardam as pastas onde serão tratados os arquivos gerados e recebidos pelo UNINFE, que deverão estar // na aplicação ERP e também no UNINFE..,, POIS OS ARQUIVOS SERÃO GERADOS NESTAS PASTAS,, E PROCESSADAS PELO UNINFE,, // E OS RETORNOS VINDOS DO WEBSERVICE SERÃO GRAVADOS NAS PASTAS INFORMADAS E PROCESSADAS PELO SISTEMA ERP. //zaenv && VARIAVEL QUE GUARDA A pasta onde o xml a serem enviados individualmente para os Webservices //zalot && VARIAVEL QUE GUARDA A pasta onde o xml a serem enviados em lote para os webservices //zaret && VARIAVEL QUE GUARDA A pasta onde o xml de retorno dos webservices //zaaut && VARIAVEL QUE GUARDA A pasta onde o xml enviados, processados e autorizados nos webservices //zatbk && VARIAVEL QUE GUARDA A pasta onde o xml temporarios que apresentam erro na tentativa de envio: //zabkp && VARIAVEL QUE GUARDA A pasta onde o xml backup dos enviados //zavld && VARIAVEL QUE GUARDA A pasta onde o xml a serem somente validados. function fa110139(onotafis,objtipo) nNotafis = onotafis nobjtipo = objtipo if empty(zantf) msgstop("Tipo de nota fiscal ( IMPRESSA ) ou ( NF-E Nota Fiscal Eletronica ) nao informada no cadastro de empresa.","Atencao") return nil endif if zantf = 1 msgstop("Tipo de nota fiscal ( IMPRESSA) e nao (ELETRONICA).","Atencao") return nil endif if zantf = 2 if empty(zaibg) msgstop("Codigo do Municipio do IBGE da NF-e no cadastro de empresa vazio.","Atencao") return nil endif if empty(zambt) msgstop("Tipo de Ambiente da NF-e de producao ou homologacao no cadastro de empresa vazio.","Atencao") return nil endif if empty(zafnd) msgstop("Finalidade de emisao da NF-e Normal, Complementar ou Ajutos no cadastro de empresa esta vazio.","Atencao") return nil endif if empty(zasca) msgstop("Serie da NF-e em Contigencia esta vazio no cadastro de empresa.","Atencao") return nil endif if empty(zacrt) msgstop("Codigo do regime tributario esta vazio no cadastro de empresa.","Atencao") endif endif define brush obrush color rgb(255,239,214) define dialog nfeletronica title "Gerencia NF-E Nota(s) Fiscal(ais) Eletronica(s)" from 010,010 to 438,790 pixel brush oBrush define font mtahoma name "Tahoma" size 5.5,13 define font mtahoma1 name "Tahoma" size 08,22 define font oFont name 'MS Sans Serif' size 6,15 define font ofontL name "Courier" size 11,11 mdtin = date() mdtfi = date() asamplzNOTA = {""} arecNOTA = {} mnr = 0 // mumero da sequencia da nota no f509000000 paest = "" // estado do emitente pandn = "" // cnpj do emitente //mvalor = 0 @ 003, 001 say "Período " of nfeletronica font mtahoma color mcolorAA,mcolorAB pixel @ 003, 025 get odtin var mdtin font mtahoma size 28,9 of nfeletronica color mcolorCA,mcolorCB pixel @ 003, 055 say "A " of nfeletronica font mtahoma color mcolorAA,mcolorAB pixel @ 003, 065 get odtfi var mdtfi font mtahoma size 28,9 of nfeletronica color mcolorCA,mcolorCB pixel @ 001, 105 button oclicar0 prompt "Consultar" size 040,12 font oFont OF nfeletronica pixel action( enchenfeletronica() ) //@ 015, 047 say "Teste " of nfeletronica font mtahoma color mcolorAA,mcolorAB pixel //@ 015, 067 say ovalor var mvalor font mtahoma size 58,9 of nfeletronica color mcolorCA,mcolorCB pixel @ 045.5,002 listbox obrzNOTA fields asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],; asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],; asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],asamplzNOTA[obrzNOTA],; asamplzNOTA[obrzNOTA]; headers "","Serie","Numero","Emissao","Nome","CNPJ/CPF","UF","Tipo","Situacao","DanFe"; FIELDSIZES 20,30,100,50,200,110,30,050,105,20 on dblclick marca_nfe(); size 388,125; pixel of nfeletronica obrzNOTA:lCellStyle = .t. obrzNOTA:lAutoSkip = .t. obrzNOTA:SetArray(asamplzNOTA) obrzNOTA:bGoTop = { || obrzNOTA:nat := 1 } obrzNOTA:bGoBottom = { || obrzNOTA:nat := Eval( obrzNOTA:bLogicLen ) } obrzNOTA:bSkip = { | nWant, nOld | nOld := obrzNOTA:nat, obrzNOTA:nat += nWant,; obrzNOTA:nat := Max( 1, Min( obrzNOTA:nat, Eval( obrzNOTA:bLogicLen ) ) ),; obrzNOTA:nat - nOld } obrzNOTA:bLogicLen = { || Len( asamplzNOTA ) } obrzNOTA:cAlias = "Array" // Just put something obrzNOTA:SetFocus() obrzNOTA:Refresh() @ 200,004 button orombut0 prompt "Valida NF-e " size 040,12 font oFont OF nfeletronica pixel action ( valida_nfe() ) @ 200,047 button orombut1 prompt "Envia NF-e " size 040,12 font oFont OF nfeletronica pixel action ( envia_nfe() ) @ 200,090 button orombut2 prompt "Pendencia(s) " size 040,12 font oFont OF nfeletronica pixel action ( retorno_pendente_nfe() ) @ 200,133 button orombut3 prompt "Cancela Nf-e " size 040,12 font oFont OF nfeletronica pixel action ( cancela_nfe()) @ 200,176 button orombut4 prompt "Inutiliza Nro(s)" size 040,12 font oFont OF nfeletronica pixel when .f. @ 200,219 button orombut5 prompt " " size 040,12 font oFont OF nfeletronica pixel when .f. @ 200,262 button orombut6 prompt "Imprimir Danfe " size 040,12 font oFont OF nfeletronica pixel action ( imprime_danfe() ) @ 200,305 button orombut7 prompt "Cons. Servico " size 040,12 font oFont OF nfeletronica pixel action ( consulta_servico(1) ) @ 200,348 button orombut8 prompt "Sair " size 040,12 font oFont OF nfeletronica pixel action ( nfeletronica:end() ) activate dialog nfeletronica center on init( enchenfeletronica(nNotafis) ); on Paint ( WndBoxIn(nfeletronica:Hdc, 054, 001, 056, 790) ,; WndBoxIn(nfeletronica:Hdc, 349, 001, 351, 790) ,; WndBoxIn(nfeletronica:Hdc, 391, 001, 393, 790) ) //msginfo(zavrs) return nil // Funcao que verifica se chegou o arquivo da nota fiscal....................... function ver_arquivo_nfe_xml() cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npchv = alltrim(npchv) npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) np035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) ndata = substr(dtos(np035),5,2) + substr(dtos(np035),1,4) nprot = oQuery:Fieldget(oQuery:Fieldpos('prot')) oQuery:destroy() if npstu = 6 msgstop("Nota fiscal cancelada.","Atencao") return("S") endif cDirXML = reverso(alltrim(zaaut))+"\Autorizados\"+ndata+"\"+alltrim(npchv)+"-procNFE.xml" if file(cDirXML) //if empty(nprot) tprot = abrir_xml(cDirXML,"nProt") if empty(tprot) msgstop("Erro. Nao foi possivel ler o XML com o numero do protocolo gerado para esta nota fiscal.","Atencao") return("S") endif cQuery := "Update f50900000 set "+; "prot = " + "'"+tprot+"'"+","+; "pstu = " + "5"+; " where pasq = " + alltrim(str(mnr)) oQuery := oServer:Query(cQuery) oQuery:destroy() oServer:Commit() enchenfeletronica() //endif return("S") endif return("N") function imprime_danfe() public oDlgWait qq = ver_marcado_nota() if qq = "N" msgstop("Nenhuma nota fiscal foi marcada para a impressao.","Atencao") return nil endif nresp = fWait( "........* processando *........") cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npchv = alltrim(npchv) npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) nprec = oQuery:Fieldget(oQuery:Fieldpos('prec')) nprec = alltrim(nprec) nprot = oQuery:Fieldget(oQuery:Fieldpos('prot')) nprot = alltrim(nprot) np035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) ndata = substr(dtos(np035),5,2) + substr(dtos(np035),1,4) np091 = oQuery:Fieldget(oQuery:Fieldpos('p091')) oQuery:destroy() if empty(npstu) oDlgWait:end() msgstop("Esta nota nao foi validada.","Atencao") return nil endif if npstu <= 4 oDlgWait:end() msgstop("Esta nota nao foi autorizada.","Atencao") return nil endif if npstu = 5 cDirXML = reverso(alltrim(zaaut))+"\Autorizados\"+ndata+"\"+alltrim(npchv)+"-procNFE.xml" elseif npstu = 6 cDirXML = reverso(alltrim(zaaut))+"\Autorizados\"+ndata+"\"+alltrim(npchv)+"-procNFE.xml" endif //cCommand = "c:\unimake\uninfe\unidanfe.exe arquivo="+cDirXML+" edição=free configuração=RETRATO"+; // " logotipo=c:\unimake\uninfe\logonfe.jpg"+; // " visualizar=1 imprimir=0" // cCommand = "\sisau\unidanfe\unidanfe.exe arquivo="+cDirXML+" edição=free configuração=RETRATO"+; " logotipo=logonfe.jpg"+; " visualizar=1 imprimir=0" //cCommand = "\prg\necta\unidanfe\unidanfe.exe arquivo="+cDirXML+" edição=free configuração=RETRATO"+; // " logotipo=logonfe.jpg"+; // " visualizar=1 imprimir=0" //msgstop(cCommand) winexec(cCommand) oDlgWait:end() return nil // Cancela Nf-e......... function Cancela_nfe() public oDlgWait qq = ver_marcado_nota() if qq = "N" msgstop("Nenhuma nota fiscal foi marcada para a validacao.","Atencao") return nil endif nresp = fWait( "........* processando *........") if consulta_servico(2) == "N" oDlgWait:end() return nil endif cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npchv = alltrim(npchv) npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) nprec = oQuery:Fieldget(oQuery:Fieldpos('prec')) nprec = alltrim(nprec) nprot = oQuery:Fieldget(oQuery:Fieldpos('prot')) nprot = alltrim(nprot) np091 = oQuery:Fieldget(oQuery:Fieldpos('p091')) oQuery:destroy() // Verifica se a NF-e foi validada ou nao ............................. if empty(npstu) oDlgWait:end() msgstop("Esta nota nao foi validada.","Atencao") return nil endif if npstu != 5 oDlgWait:end() msgstop("Esta nota nao pode ser cancelada.","Atencao") return nil endif if empty(nprec) msgstop("Nao foi gerado o recibo desta nota fiscal. Envie a nota novamente.","Atencao") oDlgWait:end() return nill endif if empty(nprot) msgstop("Nao foi gerado o protocolo desta nota fiscal. Verifique pendencias ou envie a nota novamente.","Atencao") oDlgWait:end() return nill endif // Cria o motivo para o cancelamento.................................. DEFINE BRUSH oBrush COLOR rgb(255,239,214) define dialog teladialog title "Cancelamento" from 010,010 to 120,400 pixel brush oBrush //TRANSPARENT mtvcancelamento = "" @ 000,002 say "Informe o motivo do cancelamento" of teladialog font mtahoma color mcolorAA,mcolorAB pixel @ 010.5, 002 get otvcancelamento var mtvcancelamento memo size 142,37 of teladialog font mtahoma colors mcolorAA,mcolorCB pixel @ 020,150 BUTTON oteladialogbut6 prompt "&Confirmar" size 040,12 font oFont OF teladialog pixel action ( teladialog:end() ) activate dialog teladialog center if empty(mtvcancelamento) msgstop("Nao CANCELADO, poi e necessario informar o motivo do cancelamento.","Atencao") oDlgWait:end() return nil endif // Pedido de cancelamento da nf-e...................................... cDirXML = reverso(alltrim(zaenv))+"\"+alltrim(npchv)+"-ped-can.xml" // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" nAnte := zavrs zavrs := "1.07" endif lh := 00 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. mlinha = '<?xml version='+'"'+'1.0'+'"'+ ' encoding='+'"'+'UTF-8'+'"'+' ?>' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(zambt)+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+'CANCELAR'+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+npchv+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+nprot+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+mtvcancelamento+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' + alltrim(str(np091)) + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh oPrn:EndPage() oPrn:End() cDirXML = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-can.xml" cDirXME = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-can.err" msn = "N" nqte = 0 do while nqte < 100000 if file(cDirXML) msn = "S" exit endif if file(cDirXME) msn = "N" exit endif ++nqte enddo // tempo de espera de 7 segundos...................................... SysWait(7) if msn = "N" if file(cDirXME) // ler o arquivo no formato txt................................. csource = cDirXME nsource:=fopen("&csource",0) if ( nsource ) # -1 lEof:=.F. nn = 1 do while !lEof c :=p_readln(nSource,linebuff) if !lEof .and. c#chr(26) if nn = 1 cInfo := c ++nn else cInfo+=CRLF+c endif endif enddo endif fclose(nsource) msgstop(cInfo,"Atencao") ferase(cDirXME) else msgstop("Erro na geracao do arquivo de lote do UNINFE... Tente novamente..","Atencao") endif oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil elseif msn = "S" status = abrir_xml(cDirXML,"cStat") if empty(status) msgstop("Erro. Nao foi possivel ler o XML com o numero de lote gerado para esta nota fiscal.","Atencao") ferase(cDirXML) oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil endif if status != '101' motivo = abrir_xml(cDirXML,"xMotivo") msgstop(motivo,"Atencao") ferase(cDirXML) oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil else cQuery := "Update f50900000 set "+; "pstu = " + "6"+; " where pasq = " + alltrim(str(mnr)) oQuery := oServer:Query(cQuery) if oQuery:neterr() oQuery:destroy() oServer:Commit() ferase(cDirXML) msgStop("Não foi possível liberar o cancelamento para esta nota fiscal.","ATENÇÂO") oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil endif oQuery:destroy() oServer:Commit() enchenfeletronica() ferase(cDirXML) endif endif oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil // Pega o retorno pendente da nfe.............................................. function retorno_pendente_nfe() public oDlgWait qq = ver_marcado_nota() if qq = "N" msgstop("Nenhuma nota fiscal foi marcada para a validacao.","Atencao") return nil endif // Verifica se existe o arquivo para ser validado..................... if ver_arquivo_nfe_xml() = "S" return nil endif nresp = fWait( "........* processando *........") if consulta_servico(2) == "N" oDlgWait:end() return nil endif cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npchv = alltrim(npchv) npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) nprot = oQuery:Fieldget(oQuery:Fieldpos('prot')) nprot = alltrim(nprot) oQuery:destroy() // Verifica se a NF-e foi validada ou nao ............................. if empty(npstu) oDlgWait:end() msgstop("Esta nota nao foi validada.","Atencao") return nil endif //if npstu = 1 // oDlgWait:end() // msgstop("Esta nota precisa ser enviada primeiro.","Atencao") // return nil //endif // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" nAnte := zavrs zavrs := "1.07" endif cDirXML = reverso(alltrim(zaenv))+"\"+alltrim(npchv)+"-ped-sit.xml" lh := 00 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. mlinha = '<?xml version='+'"'+'1.0'+'"'+ ' encoding='+'"'+'UTF-8'+'"'+' ?>' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(zambt)+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+'CONSULTAR'+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+npchv+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh oPrn:EndPage() oPrn:End() cDirXML = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-sit.xml" cDirXME = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-sit.err" msn = "N" nqte = 0 do while nqte < 100000 if file(cDirXML) msn = "S" exit endif if file(cDirXME) msn = "N" exit endif ++nqte enddo // tempo de espera de 7 segundos...................................... SysWait(7) if msn = "N" if file(cDirXME) // ler o arquivo no formato txt................................. csource = cDirXME nsource:=fopen("&csource",0) if ( nsource ) # -1 lEof:=.F. nn = 1 do while !lEof c :=p_readln(nSource,linebuff) if !lEof .and. c#chr(26) if nn = 1 cInfo := c ++nn else cInfo+=CRLF+c endif endif enddo endif fclose(nsource) msgstop(cInfo,"Atencao") ferase(cDirXME) else msgstop("Erro na geracao do arquivo de lote do UNINFE... Tente novamente..","Atencao") endif oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil elseif msn = "S" status = abrir_xml(cDirXML,"cStat") if empty(status) msgstop("Erro. Nao foi possivel ler o XML com o numero de lote gerado para esta nota fiscal.","Atencao") ferase(cDirXML) oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil endif if status = '100' nprotocolo = abrir_xml(cDirXML,"nProt") cQuery := "Update f50900000 set "+; "prot = " + "'"+nprotocolo+"'"+","+; "pstu = " + "5"+; " where pasq = " + alltrim(str(mnr)) oQuery := oServer:Query(cQuery) if oQuery:neterr() oQuery:destroy() oServer:Commit() ferase(cDirXML) msgStop("Não foi possível gravar o numero do protocolo da NF-e no arquivo de notas.","ATENÇÂO") // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil endif oQuery:destroy() oServer:Commit() enchenfeletronica() ferase(cDirXML) else motivo = abrir_xml(cDirXML,"xMotivo") msgstop(motivo,"Atencao") ferase(cDirXML) oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil endif endif oDlgWait:end() // aqui muda de versao para acompanhar o uninfe....................... if alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" zavrs := nAnte endif return nil //Valida a nota fiscal eletronica.............................................. function valida_nfe() public oDlgWait qq = ver_marcado_nota() if qq = "N" msgstop("Nenhuma nota fiscal foi marcada para a validacao.","Atencao") return nil endif // Verifica se existe o arquivo para ser validado..................... if ver_arquivo_nfe_xml() = "S" return nil endif nresp = fWait( "........* processando *........") cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) np091 = oQuery:Fieldget(oQuery:Fieldpos('p091')) // normal ou contigencia np034 = oQuery:Fieldget(oQuery:Fieldpos('p034')) // numero da nota fiscal npsnf = oQuery:Fieldget(oQuery:Fieldpos('psnf')) // serie da nota fiscal np007 = oQuery:Fieldget(oQuery:Fieldpos('p007')) // CNPJ np035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) // data de emissao npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) oQuery:destroy() if np035 != date() oDlgWait:end() msgstop("A data de emissao desta nota foi dia: " + dtoc(np035),"Atencao") return nil endif if npstu > 1 oDlgWait:end() msgstop("Nota fiscal nao pode ser mais validade. Para isso sera preciso refazer a nota.","Atencao") return nil endif // Gera a chava da NFe para ser gravado no arquivo do sistema.......... cDirXML = reverso(alltrim(zaenv))+"\"+alltrim(str(mnr))+"-gerar-chave.xml" lh := 00 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. mlinha = '<?xml version=' + '"'+ '1.0' + '"' + ' encoding=' + '"' + 'UTF-8' + '"' + '?>' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + ver_estado() + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + alltrim(str(np091)) + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + alltrim(str(val(np034))) + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + alltrim(str(mnr)) + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + alltrim(npsnf) + '' oPrn:Say(lh,000,mlinha) ++lh ndata = substr(dtos(np035),3,2) + substr(dtos(np035),5,2) mlinha = ' ' + '' + ndata + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ' ' + '' + alltrim(pandn) + '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) oPrn:EndPage() oPrn:End() // Pega a chave da NF-e ou o erro da geracao da chave................. cDirXML = reverso(alltrim(zaret))+"\"+alltrim(str(mnr))+"-ret-gerar-chave.xml" cDirXME = reverso(alltrim(zaret))+"\"+alltrim(str(mnr))+"-ret-gerar-chave.err" msn = "N" nqte = 0 do while nqte < 100000 if file(cDirXML) msn = "S" exit endif if file(cDirXME) msn = "N" exit endif ++nqte enddo // tempo de espera de 7 segundos...................................... SysWait(7) if msn = "N" oDlgWait:end() msgstop("Erro. Tente novamente.","Atencao") ferase(cDirXME) return nil elseif msn = "S" nchave = abrir_xml(cDirXML,"chaveNFe") if empty(nchave) oDlgWait:end() msgstop("Erro. Nao foi possivel ler o XML com a chave, tente novamente.","Atencao") ferase(cDirXML) return nil endif cQuery := "Update f50900000 set "+; "pchv = " + "'"+nchave+"'"+; " where pasq = " + alltrim(str(mnr)) oQuery := oServer:Query(cQuery) if oQuery:neterr() oQuery:destroy() oServer:Commit() oDlgWait:end() ferase(cDirXML) msgStop("Não foi possível gravar a chave da NF-e no arquivo de notas.","ATENÇÂO") return nil endif oQuery:destroy() oServer:Commit() endif ferase(cDirXML) geraXMLNFe("V") // Faz o aguardo da validacao e assinatura... para informar o retorno.. cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) npchv = alltrim(npchv) oQuery:destroy() cDirXML = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-nfe-ret.xml" cDirErr = reverso(alltrim(zaret))+"\"+alltrim(npchv)+"-nfe-ret.err" machou = "N" do while .t. if file(cDirXML) machou = "X" exit endif if file(cDirErr) machou = "E" exit endif enddo // tempo de espera de 7 segundos...................................... SysWait(7) motivo = "" cstatus = '' if machou = "X" motivo = abrir_xml(cDirXML,"xMotivo") SysWait(3) cstatus = abrir_xml(cDirXML,"cStat") ferase(cDirXML) elseif machou = "E" motivo = abrir_xml(cDirErr,"xMotivo") ferase(cDirErr) endif oDlgWait:end() if !empty(motivo) msgstop(motivo,"Atencao") if machou = "X" if cstatus = '1' // grava o tipo de operacao efetuada que foi a validacao........... cQuery := "Update f50900000 set "+; "pstu = " + "1"+; " where pasq = " + alltrim(str(mnr)) oQuery := oServer:Query(cQuery) oQuery:destroy() oServer:Commit() ferase(cDirXML) enchenfeletronica() endif endif endif return nil //Funcao que envia a NF-e ..................................................... function envia_nfe() public oDlgWait qq = ver_marcado_nota() if qq = "N" msgstop("Nenhuma nota fiscal foi marcada para o envio.","Atencao") return nil endif // Verifica se existe o arquivo para ser validado..................... if ver_arquivo_nfe_xml() = "S" return nil endif nresp = fWait( "........* processando *........") if consulta_servico(2) == "N" oDlgWait:end() return nil endif cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npstu = oQuery:Fieldget(oQuery:Fieldpos('pstu')) oQuery:destroy() // Verifica se a NF-e foi validada ou nao ............................. if empty(npstu) oDlgWait:end() msgstop("Esta nota nao foi validada.","Atencao") return nil endif if npstu > 1 nsituacao = "" if empty(npstu) .or. npstu = 0 nsituacao = "Digitacao" elseif npstu = 1 nsituacao = "Validada e Assinada" elseif npstu = 3 nsituacao = "Aguardando recibo" elseif npstu = 4 nsituacao = "Aguardando protocolo" elseif npstu = 5 nsituacao = "Autorizada" elseif npstu = 6 nsituacao = "Cancelada" endif if msgnoyes("Esta nota esta " + nsituacao + " . Deseja realmente envia-la ?","") == .f. oDlgWait:end() return nil endif endif // gera o xml a ser enviado a Receita ................................. geraXMLNFe("E") // pega os retornos do xml ............................................ if retorno_nfe_lote() = "N" oDlgWait:end() return nil endif if retorno_nfe_recibo() = "N" oDlgWait:end() return nil endif if retorno_nfe_protocolo() = "N" oDlgWait:end() return nil endif oDlgWait:end() return nil // Funcao que gera o XML do recibo do lote enviado a SEFAZ..................... //function geraXMLrecibo() // B02_cUF = ver_estado() // // cQuery := "select * from f50900000 where"+; // " pasq = " + alltrim(str(mnr))+; // " order by pasq asc;" // oQuery := oServer:Query(cQuery) // npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. // npchv = alltrim(npchv) // nprec = oQuery:Fieldget(oQuery:Fieldpos('prec')) // nprec = alltrim(nprec) // mp091 = oQuery:Fieldget(oQuery:Fieldpos('p091')) // mp091 = alltrim(str(mp091)) // oQuery:destroy() // // cDirXML = reverso(alltrim(zaenv))+"\"+alltrim(nprec)+"-ped-rec.xml" // // lh := 00 // oPrn := TDosPrn():New(cDirXML) // oPrn:StartPage() // oPrn:lZeraBuffer:=.T. // // mlinha = '<?xml version=' + '"'+ '1.0' + '"' + ' encoding=' + '"' + 'UTF-8' + '"' + '?>' // oPrn:Say(lh,000,mlinha) // ++lh // mlinha = '' // oPrn:Say(lh,000,mlinha) // ++lh // // mlinha = ''+alltrim(zambt)+'' // oPrn:Say(lh,000,mlinha) // ++lh // // mlinha = ''+nprec+'' // oPrn:Say(lh,000,mlinha) // ++lh // // mlinha = ''+ver_estado()+'' // oPrn:Say(lh,000,mlinha) // ++lh // // mlinha = ''+ mp091 +'' // oPrn:Say(lh,000,mlinha) // ++lh // // mlinha = '' // oPrn:Say(lh,000,mlinha) // ++lh // oPrn:EndPage() // oPrn:End() //return nil // Funcao que gera o XML da nota fiscal eletronica............................. function geraXMLNFe(objet) B02_cUF = ver_estado() if alltrim(zavrs) = "2.00" B03_cNF = strzero(mnr,8) elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" B03_cNF = strzero(mnr,9) endif B06_mod = "55" cQuery := "select * from f50900000 where"+; " pasq = " + alltrim(str(mnr))+; " order by pasq asc;" oQuery := oServer:Query(cQuery) npchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // numero da nf-e .. npchv = alltrim(npchv) mp016 = oQuery:Fieldget(oQuery:Fieldpos('p016')) // numero do pedido ou romaneio.. mp016 = alltrim(mp016) mptip = oQuery:Fieldget(oQuery:Fieldpos('ptip')) // se romaneio ou pedido B04_natOP = oQuery:Fieldget(oQuery:Fieldpos('p048')) // natureza da operacao.. B04_natOP = alltrim(B04_natOP) B05_indPag = oQuery:Fieldget(oQuery:Fieldpos('p089')) // forma de pagamento B07_serie = oQuery:Fieldget(oQuery:Fieldpos('psnf')) // serie da nf-e. B07_serie = alltrim(B07_serie) B08_nNF = oQuery:Fieldget(oQuery:Fieldpos('p034')) // numero do documento fiscal B08_nNF = alltrim(str(val(B08_nNF))) mp035 = oQuery:Fieldget(oQuery:Fieldpos('p035')) // dt de emissao B09_dEmi = alltrim(str(year(mp035))) + "-" + substr(dtoc(mp035),4,2) + "-" + substr(dtoc(mp035),1,2) mp033 = oQuery:Fieldget(oQuery:Fieldpos('p033')) // dt de said if !empty(mp033) B10_dSaiEnt = alltrim(str(year(mp033))) + "-" + substr(dtoc(mp033),4,2) + "-" + substr(dtoc(mp033),1,2) endif B10a_hSaiEnt = oQuery:Fieldget(oQuery:Fieldpos('p065')) // Hora de saida ou entrada de mercadoria/Produto mp094 = oQuery:Fieldget(oQuery:Fieldpos('p094')) B11_tpNF = iif(mp094 = "S","1","0") // tipo de nota 0-entrada 1-saida B12_cMunFG = substr(zaibg,1,7) // municipio de ocorrencia do fato gerador numerico B21_tpImp = "1" // Formato de Impressao do DANFE. mp091 = oQuery:Fieldget(oQuery:Fieldpos('p091')) // Tipo de Emissao da Nf-e B22_tpEmis = alltrim(str(mp091)) mpchv = oQuery:Fieldget(oQuery:Fieldpos('pchv')) // Digito verificador da chave de acesso. B23_cDV = substr(alltrim(mpchv),44,1) B24_tpAmb = zambt // Identificacao do ambiente B25_finNFe = zafnd // finalidade da emissao B26_procEmi = "0" // Identificacao do processo de emissao da NF-e 0-emissao de NF-e com aplicativo do contribuinte B27_verProc = "4.0.1" // versao do processo de emissao da NF-e C02_CNPJ = alltrim(zandn) // CNPJ do emitente C02a_CPF = alltrim(zandn) // CPF do emitente C03_xNome = alltrim(zaden) // Razao social do emitente C03_xNome = trata_XML(C03_xNome) C04_xFant = "" // Nome fantasia if !empty(C04_xFant) C04_xFant = trata_XML(C04_xFant) endif C06_xLgr = alltrim(zaend) // Endereco do emitente C06_xLgr = trata_XML(C06_xLgr) C07_nro = alltrim(str(zanro)) // numero do endereco do emitente C08_xCpl = alltrim(zacpl) // complemento do endereco do emitente C08_xCpl = trata_XML(C08_xCpl) C09_xBairro = alltrim(zabai) // bairro do emitente C09_xBairro = trata_XML(c09_xBairro) C10_cMun = alltrim(zaibg) // Codigo do municipio no IBGE do emitente c11_xMun = alltrim(zacid) // Nome do municipio c11_xMun = trata_XML(c11_xMun) C12_UF = alltrim(zaest) // Estado do municipio do emitente C13_CEP = alltrim(zacep) // cep do emitente C14_cPais = "" // codigo do pais do emitente C15_xPais = "" // nome do pais do emitente C16_fone = "" C17_IE = alltrim(zaies) // Inscricao Estadual do Emitente C21_CRT = zacrt // codigo de regime tributario E02_CNPJ = oQuery:Fieldget(oQuery:Fieldpos('p007')) // CNPJ do destinatario E02_CNPJ = alltrim(E02_CNPJ) E03_CPF = oQuery:Fieldget(oQuery:Fieldpos('p007')) // CPF do destinatario E03_CPF = alltrim(E03_CPF) E04_xNome = oQuery:Fieldget(oQuery:Fieldpos('p001')) // Nome do destinatario E04_xNome = alltrim(E04_xNome) E04_xNome = trata_XML(E04_xNome) E06_xLgr = oQuery:Fieldget(oQuery:Fieldpos('p002')) // Logradouro do destinatario E06_xLgr = alltrim(E06_xLgr) E06_xLgr = trata_XML(E06_xLgr) E07_nro = oQuery:Fieldget(oQuery:Fieldpos('p02a')) // Numero do logradouro do destinatario E07_nro = alltrim(E07_nro) E08_xCpl = oQuery:Fieldget(oQuery:Fieldpos('p02b')) // Complemento do endereco if !empty(E08_xCpl) E08_xCpl = alltrim(E08_xCpl) E08_xCpl = trata_XML(E08_xCpl) endif E09_xBairro = oQuery:Fieldget(oQuery:Fieldpos('p003')) // Bairro do destinatario E09_xBairro = alltrim(E09_xBairro) E09_xBairro = trata_XML(E09_xBairro) E10_cMun = oQuery:Fieldget(oQuery:Fieldpos('p05a')) // Codigo do Municipio do destinatario no IBGE E10_cMun = alltrim(E10_cMun) E10_cMun = trata_XML(E10_cMun) E11_xMun = oQuery:Fieldget(oQuery:Fieldpos('p005')) // Nome do municipio do destinatario E11_xMun = alltrim(E11_xMun) E11_xMun = trata_XML(E11_xMun) E12_UF = oQuery:Fieldget(oQuery:Fieldpos('p006')) // Estado do destinatario E13_CEP = oQuery:Fieldget(oQuery:Fieldpos('p004')) // cep do destinatario. mp008 = oQuery:Fieldget(oQuery:Fieldpos('p008')) // inscricao ou rg mp08a = oQuery:Fieldget(oQuery:Fieldpos('p08a')) // tipo de documento E17_IE = iif(mp08a = 2,alltrim(substr(mp008,1,14)),iif(mp08a = 5,"ISENTO","")) np021 = oQuery:Fieldget(oQuery:Fieldpos('p021')) // valor do frete np022 = oQuery:Fieldget(oQuery:Fieldpos('p022')) // valor do seguro np024 = oQuery:Fieldget(oQuery:Fieldpos('p024')) // total dos produtos np025 = oQuery:Fieldget(oQuery:Fieldpos('p025')) // total do ipi np026 = oQuery:Fieldget(oQuery:Fieldpos('p026')) // total da nota np053 = oQuery:Fieldget(oQuery:Fieldpos('p053')) // base de calculo np054 = oQuery:Fieldget(oQuery:Fieldpos('p054')) // valor do icms. np055 = oQuery:Fieldget(oQuery:Fieldpos('p055')) // base calc. icm substit np056 = oQuery:Fieldget(oQuery:Fieldpos('p056')) // icms substituicao np063 = oQuery:Fieldget(oQuery:Fieldpos('p063')) // outras despesas e acessorios. np069 = oQuery:Fieldget(oQuery:Fieldpos('p069')) // modalidade de frete np010 = oQuery:Fieldget(oQuery:Fieldpos('p010')) // transportadora np010 = alltrim(np010) np010 = trata_XML(np010) np011 = oQuery:Fieldget(oQuery:Fieldpos('p011')) // endereco np011 = alltrim(np011) np011 = trata_XML(np011) np012 = oQuery:Fieldget(oQuery:Fieldpos('p012')) // bairro np012 = alltrim(np012) np012 = trata_XML(np012) np013 = oQuery:Fieldget(oQuery:Fieldpos('p013')) // municipio np013 = alltrim(np013) np013 = trata_XML(np013) np014 = oQuery:Fieldget(oQuery:Fieldpos('p014')) // estado np015 = oQuery:Fieldget(oQuery:Fieldpos('p015')) // placa do veiculo np015 = alltrim(np015) np066 = oQuery:Fieldget(oQuery:Fieldpos('p066')) // c.n.p.j. transportador np066 = alltrim(np066) np067 = oQuery:Fieldget(oQuery:Fieldpos('p067')) // insc. estadual transp. np067 = alltrim(np067) np068 = oQuery:Fieldget(oQuery:Fieldpos('p068')) // estado do veiculo np029 = oQuery:Fieldget(oQuery:Fieldpos('p029')) // quantidade np029 = alltrim(np029) np030 = oQuery:Fieldget(oQuery:Fieldpos('p030')) // especie np030 = alltrim(np030) np027 = oQuery:Fieldget(oQuery:Fieldpos('p027')) // marca np027 = alltrim(np027) np028 = oQuery:Fieldget(oQuery:Fieldpos('p028')) // numero np028 = alltrim(np028) np031 = oQuery:Fieldget(oQuery:Fieldpos('p031')) // peso liquido np031 = alltrim(np031) np032 = oQuery:Fieldget(oQuery:Fieldpos('p032')) // peso bruto np032 = alltrim(np032) np093 = oQuery:Fieldget(oQuery:Fieldpos('p093')) // informacao adicional ao contribuinte nprct = oQuery:Fieldget(oQuery:Fieldpos('prct')) // parcial ou total.. oQuery:destroy() if empty(npchv) msgstop("Nao foi possivel gerar a NF-e. Tente novamente.","Atenco") return nil endif if objet = "V" // gera na pasta a ser validada cDirXML = reverso(alltrim(zavld))+"\"+alltrim(npchv)+"-nfe.xml" elseif objet = "E" // gera na pasta a ser enviada e/ou aprovada.. cDirXML = reverso(alltrim(zaenv))+"\"+alltrim(npchv)+"-nfe.xml" endif lh := 00 oPrn := TDosPrn():New(cDirXML) oPrn:StartPage() oPrn:lZeraBuffer:=.T. mlinha = '<?xml version='+'"'+'1.0'+'"'+ ' encoding='+'"'+'UTF-8'+'"'+' ?>' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Identificacao da Nf-e ( Nota fiscal eletronica ) .................. mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B02_cUF+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B03_cNF+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B04_natOP+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B05_indPag+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B06_mod+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B07_serie+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B08_nNF+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B09_dEmi+'' oPrn:Say(lh,000,mlinha) ++lh if !empty(mp033) mlinha = ''+B10_dSaiEnt+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = ''+B11_tpNF+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B12_cMunFG+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B21_tpImp+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B22_tpEmis+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B23_cDV+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B24_tpAmb+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B25_finNFe+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B26_procEmi+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+B27_verProc+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Identificacao do emitente da nota fiscal eletronica................. mlinha = '' oPrn:Say(lh,000,mlinha) ++lh if len(alltrim(zandn)) > 11 mlinha = ''+C02_CNPJ+'' oPrn:Say(lh,000,mlinha) ++lh else mlinha = ''+C02a_CPF+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = ''+C03_xNome+'' oPrn:Say(lh,000,mlinha) ++lh // Endereco do Emitente................................................ mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C06_xLgr+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C07_nro+'' oPrn:Say(lh,000,mlinha) ++lh if !empty(C08_xCpl) mlinha = ''+C08_xCpl+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = ''+C09_xBairro+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C10_cMun+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+c11_xMun+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C12_UF+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C13_CEP+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+C17_IE+'' oPrn:Say(lh,000,mlinha) ++lh // somente para versao 2.00........................................... if alltrim(zavrs) = "2.00" mlinha = ''+C21_CRT+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Identificacao do Destinatario da Nf-e.............................. mlinha = '' oPrn:Say(lh,000,mlinha) ++lh if len(alltrim(E02_CNPJ)) > 11 mlinha = ''+E02_CNPJ+'' oPrn:Say(lh,000,mlinha) ++lh else mlinha = ''+E03_CPF+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = ''+E04_xNome+'' oPrn:Say(lh,000,mlinha) ++lh // Dados do endereco do Destinatario................................... mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+E06_xLgr+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+E07_nro+'' oPrn:Say(lh,000,mlinha) ++lh if !empty(E08_xCpl) mlinha = ''+E08_xCpl+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = ''+E09_xBairro+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+E10_cMun+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+E11_xMun+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+E12_UF+'' oPrn:Say(lh,000,mlinha) ++lh if !empty(E13_CEP) mlinha = ''+alltrim(E13_CEP)+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = '' oPrn:Say(lh,000,mlinha) ++lh if empty(E17_IE) mlinha = ''+'' oPrn:Say(lh,000,mlinha) ++lh else mlinha = ''+E17_IE+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Detalha os produtos e seus impostos................................ cQuery := "select * from f51000000 where"+; " qemp = " + alltrim(str(memp))+; " and qnpd = " + "'"+mp016+"'"+; " and qtip = " + "'"+mptip+"'"+; " order by qnpd asc;" oQuery := oServer:Query(cQuery) nn = 1 DO WHILE !oQuery:Eof() nqcap = oQuery:Fieldget(oQuery:Fieldpos('qcap')) // codigo de acesso ao produto nqcfo = oQuery:Fieldget(oQuery:Fieldpos('qcfo')) // codigo fical de operacao nqqtd = oQuery:Fieldget(oQuery:Fieldpos('qqtd')) // quantidade do produto nquni = oQuery:Fieldget(oQuery:Fieldpos('quni')) // unidade do produto nqvru = oQuery:Fieldget(oQuery:Fieldpos('qvru')) // valor unitario nqvti = oQuery:Fieldget(oQuery:Fieldpos('qvti')) // valor total do item nqcst = oQuery:Fieldget(oQuery:Fieldpos('qcst')) // c.s.t. do produto nqbci = oQuery:Fieldget(oQuery:Fieldpos('qbci')) // base de calculo do i.c.m nqaic = oQuery:Fieldget(oQuery:Fieldpos('qaic')) // aliquota de icm nqvic = oQuery:Fieldget(oQuery:Fieldpos('qvic')) // valor do icm nqisn = oQuery:Fieldget(oQuery:Fieldpos('qisn')) // isento nqtrs = oQuery:Fieldget(oQuery:Fieldpos('qtrs')) // tributacao na saida nqadc = oQuery:Fieldget(oQuery:Fieldpos('qadc')) // classificacao fiscal nqads = oQuery:Fieldget(oQuery:Fieldpos('qads')) // aliquota diferenciada cwQuery := "select * from e40100000 where "+; "bcap = " + alltrim(str(nqcap)) + " order by bcap asc;" owQuery := oServer:Query(cwQuery) nqnpc = owQuery:Fieldget(owQuery:Fieldpos('bcdg')) // numero da pe‡a nbcdo = owQuery:Fieldget(owQuery:Fieldpos('bcdo')) nqdpr = owQuery:Fieldget(owQuery:Fieldpos('bprd')) // descricao do produto nqdpr = trata_XML(nqdpr) nqund = owQuery:Fieldget(owQuery:Fieldpos('bund')) // unidade do produto nqund = trata_xml(nqund) owQuery:destroy() mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Detalhamento dos dados do produto........................... mlinha = '' oPrn:Say(lh,000,mlinha) ++lh if empty(nprct) mlinha = ''+nqnpc+'' oPrn:Say(lh,000,mlinha) ++lh else if nprct = "T" mlinha = ''+nqnpc+'' oPrn:Say(lh,000,mlinha) ++lh elseif nprct = "P" mlinha = ''+alltrim(nbcdo)+'' oPrn:Say(lh,000,mlinha) ++lh else mlinha = ''+nqnpc+'' oPrn:Say(lh,000,mlinha) ++lh endif endif mlinha = ''+''+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(nqdpr)+'' oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" if !empty(nqadc) mlinha = ''+alltrim(substr(nqadc,1,8))+'' oPrn:Say(lh,000,mlinha) ++lh else mlinha = ''+'12345678'+'' oPrn:Say(lh,000,mlinha) ++lh endif elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" if !empty(nqadc) if alltrim(substr(nqadc,1,8)) != "99" mlinha = ''+alltrim(substr(nqadc,1,8))+'' oPrn:Say(lh,000,mlinha) ++lh endif endif endif mlinha = ''+substr(nqcfo,1,4)+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(nqund)+'' oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" mlinha = ''+alltrim(str(nqqtd,15,4))+'' elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" mlinha = ''+alltrim(str(nqqtd,12,4))+'' endif oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" mlinha = ''+alltrim(str(nqvru,15,4))+'' elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" mlinha = ''+alltrim(str(nqvru,16,4))+'' endif oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(str(nqvti,15,2))+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+''+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+alltrim(nqund)+'' oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" mlinha = ''+alltrim(str(nqqtd,15,4))+'' elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" mlinha = ''+alltrim(str(nqqtd,12,4))+'' endif oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" mlinha = ''+alltrim(str(nqvru,15,4))+'' elseif alltrim(zavrs) = "1.10" .or. alltrim(zavrs) = "1.07" mlinha = ''+alltrim(str(nqvru,16,4))+'' endif oPrn:Say(lh,000,mlinha) ++lh if alltrim(zavrs) = "2.00" mlinha = ''+'1'+'' oPrn:Say(lh,000,mlinha) ++lh endif mlinha = '' oPrn:Say(lh,000,mlinha) ++lh // Detalhamento dos imposto(s) do(s) produto(s)................. mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = '' oPrn:Say(lh,000,mlinha) ++lh if substr(nqcst,1,3) = "000" mlinha = '' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+'0'+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+'00'+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+'3'+'' oPrn:Say(lh,000,mlinha) ++lh mlinha = ''+iif(nqbci > 0,alltrim(str(nqbci,15,2)),"0.00")+'
  19. Esqueci,, tem esses manuais.. lá também.. Manual do Layout TXT-NF-e 2.0 - SEFAZ/SP (2.0.0) Manual do Layout TXT-NF-e - SEFAZ/SP (1.1.1) Modelos de Arquivos XML para NFe Layout 3.0.0 Modelos de Arquivos XML para NFe Layout 4.0.1 wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  20. Boa Tarde, Uma solução para quem esta começando com a NF-E, e não tem tempo ou conhecimento no momento para desenvolver sua própria ferramente de gerenciamento de nf-e, é o projeto UNINFE da Unimake softwares. http://www.unimake.com.br/uninfe/ Este projeto traz.. Aplicativo DANFEmon - Monitor do UniDANFe (1.1.9) Aplicativo DANFE View - Visualizador e gerenciador de Notas Fiscais Eletrônicas (2.1.15) Aplicativo UniCTe - Emissão do Conhecimento de Transporte Eletrônico / Integração ao ERP v1.1 Aplicativo UniDANFe 3.x - Emissão do Documento Auxiliar da Nota Fiscal Eletrônica (3.2.1) Aplicativo UniNFe - Emissão da Nota Fiscal Eletrônica / Integração ao ERP v2.2 Aplicativo UniNFe - Emissão da Nota Fiscal Eletrônica / Integração ao ERP v2.3 Aplicativo UniNFe - Emissão da Nota Fiscal Eletrônica / Integração ao ERP v3.1 p/lay-out 4.0.1 NF-e Artigo com informações sobre integração de softwares com a NFe Código fonte do aplicativo UniNFe e UniCTe, em C# (SourceForge) Manual de instalação, utilização e integração do UniCTe com sistemas ERP Manual de instalação, utilização e integração do UniNFe com sistemas ERP Manual de Utilização do Software UniDANFe 3.x A integração da aplicação em qualquer linguagem com o UNINFE E O UniDANFe é bem simples atraves de arquivo txt, seguindo o manual do uninfe, ou de acordo com o Manual de integração 4.0.1 (2.0) em XML. Vale a pena conferir. Eu utilizo há mais de 02(anos), e conheço uma grande quantidades de programadores que estão utilizando, até que as suas ferramentas de desenvolvimento próprio fiquem prontas. É free.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  21. Caros Colegas, Atuo em uma Indústria de Confecções na cidade de Uberlândia/MG, que tem lojas, e estão necessitando de um PDV FISCAL homologado em MG,SP e que tenha o TEF. Como não homologarei mais o que tenho, então a empresa quer adquirir o PDV FISCAL, para a(s) sua(s) loja(s). Obs. O sistema de PDV, fiscal tem que aceitar importação do sistema de retaguarda. como produtos,clientes etc. e gerar arquivo para exportação (txt,xml etc.), para ser importado para o retaguarda afim da geração de SINTEGRA, SPEED etc.. Favor se possivel enviar orçamento com valor unitário e com denominações técnicas do sistema,ou se tiver site para que possamos apreciar.. Enviar e-mail para : systemup@bol.com.br wellington_programador@hotmail.com... Aguardo.. Obrigado Favor se possível detalhar ou wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  22. Caros Colegas, Atuo em uma Indústria de Confecções na cidade de Uberlândia/MG, que tem lojas, e estão necessitando de um PDV FISCAL homologado em MG,SP e que tenha o TEF. Como não homologarei mais o que tenho, então a empresa quer adquirir o PDV FISCAL, para a(s) sua(s) loja(s). Obs. O sistema de PDV, fiscal tem que aceitar importação do sistema de retaguarda. como produtos,clientes etc. e gerar arquivo para exportação (txt,xml etc.), para ser importado para o retaguarda afim da geração de SINTEGRA, SPEED etc.. Favor se possivel enviar orçamento com valor unitário e com denominações técnicas do sistema,ou se tiver site para que possamos apreciar.. Enviar e-mail para : systemup@bol.com.br wellington_programador@hotmail.com... Aguardo.. Obrigado Favor se possível detalhar ou wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  23. Na SEFAZ de MG para usar a NF-e versão 2.0 aplicativo proprio ou não, se alguem tiver problemas, é decorrente que a mesma mudou os WSDL, que comparado aos de SP por exemplo, foge muito aos padrões. Recebi o seguinte e-mail da SEFAZ/MG. Prezado (a) Senhor (a), Conforme parecer da superintendência responsável, informamos que já detectamos as ocorrências de erro no aplicativo Emissor Gratuito versão 2.0.2, para versão 2.0 da NF-e. Informamos também que o erro já está sendo tratado pelos nossos técnicos de informática, mas ainda não há previsão de disponibilização da correção. Pedimos desculpas e solicitamos que aguarde. Atenciosamente, FALE CONOSCO - SEF Diretoria de Gestão do Atendimento ao Público Superintendência de Arrecadação e Informações Fiscais Tel.: 155 para todo o Estado de Minas Gerais; (31) 3303.7999 para outros estados e países. SE ALGUEM ESTIVER COM PROBLEMAS NA VERSÃO 2.0 EM MG, AJUDE-NOS A COBRAR UMA SOLUÇÃO JUNTO A SEFAZ/MG, POIS QTO MAIS GENTE, MAIS ELES TERÃO QUE NOS ATENDER. LEMBRANDO QUE EM MG, A 2.0 TEM SEU INICIO DECRETADO PARA 01/01/2011. OBRIGADO.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  24. Na SEFAZ de MG para usar a NF-e versão 2.0 aplicativo proprio ou não, se alguem tiver problemas, é decorrente que a mesma mudou os WSDL, que comparado aos de SP por exemplo, foge muito aos padrões. Recebi o seguinte e-mail da SEFAZ/MG. Prezado (a) Senhor (a), Conforme parecer da superintendência responsável, informamos que já detectamos as ocorrências de erro no aplicativo Emissor Gratuito versão 2.0.2, para versão 2.0 da NF-e. Informamos também que o erro já está sendo tratado pelos nossos técnicos de informática, mas ainda não há previsão de disponibilização da correção. Pedimos desculpas e solicitamos que aguarde. Atenciosamente, FALE CONOSCO - SEF Diretoria de Gestão do Atendimento ao Público Superintendência de Arrecadação e Informações Fiscais Tel.: 155 para todo o Estado de Minas Gerais; (31) 3303.7999 para outros estados e países. SE ALGUEM ESTIVER COM PROBLEMAS NA VERSÃO 2.0 EM MG, AJUDE-NOS A COBRAR UMA SOLUÇÃO JUNTO A SEFAZ/MG, POIS QTO MAIS GENTE, MAIS ELES TERÃO QUE NOS ATENDER. LEMBRANDO QUE EM MG, A 2.0 TEM SEU INICIO DECRETADO PARA 01/01/2011. OBRIGADO.. wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
  25. Bom dia, Alguem já testou este visual fivewin...?? visual http://visualfivewin.blogspot.com/ download http://rapidshare.com/files/371352100/jkide93x.zip wellington fwh/xharbour0.99.71 Bd. Postgresql Systemup@bol.com.br
×
×
  • Create New...