Last active
December 19, 2015 00:19
-
-
Save ndrluis/5868027 to your computer and use it in GitHub Desktop.
Scripts para correções de arquivos do Sped Fiscal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Troca a CST dos registros C470/C490 de acordo com o CFOP | |
## | |
File.open(ARGV.first).each do |line| | |
row = line.split("|") | |
if row[1] == "C470" | |
row[7] = "060" if row[8] == "5656" | |
row[7] = "060" if row[8] == "5405" | |
row[7] = "000" if row[8] == "5102" | |
end | |
if row[1] == "C490" | |
row[2] = "060" if row[3] == "5656" | |
row[2] = "060" if row[3] == "5405" | |
row[2] = "000" if row[3] == "5102" | |
end | |
puts row.join("|") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Efetua correção da data do registro C405/C460 do Sped Fiscal de yyyymmdd para ddmmyyyy | |
# Remove a data do registro caso o Cupom fiscal esteja cancelado | |
## | |
File.open(ARGV.first).each do |line| | |
row = line.split("|") | |
row[2] = row[2][6..7] + row[2][4..5] + row[2][0..3] if row[1] == "C405" | |
if row[1] == "C460" | |
row[5] = row[5][6..7] + row[5][4..5] + row[5][0..3] unless row[5].empty? | |
row[5] = nil if row[3] == "02" | |
end | |
puts row.join("|") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment