cnab2ofx 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+
2
+ cnab2ofx
3
+ ========
4
+
5
+ **cnab2ofx** é script simples em [Ruby][1] que serve para converter extratos bancários no formato CNAB240 para o formato ofx.
6
+ A Unicred emite extratos nesse formato.
7
+
8
+ [CNAB240][2] é o formato padrão da [FEBRABAN][3] (Federação Brasileira de Bancos) utilizado para gerar extratos dentre outras transações bancárias.
9
+ [OFX][4] é a sigla do "Open Financial Exchange" e é o que permite a importação de extratos bancários para softwares como o [GnuCash][5], [Microsoft Money][6] e [Quicken][7].
10
+
11
+ **Uso:**
12
+
13
+ cnab2ofx [extrato_cnab240] > [arquivo_ofx]
14
+
15
+ ---------------------------------------
16
+
17
+ cnab2ofx
18
+ ========
19
+ [**English**]
20
+
21
+ **cnab2ofx** is a simple [Ruby][1] script that can be used to convert from CNAB240 to ofx.
22
+
23
+ [CNAB240][2] is a brazilian account statement format by [FEBRABAN][3] (Brazilian Bank Federation).
24
+ [OFX][4] stands for Open Financial Exchange and can be used to allow financial softwares as [GnuCash][5], [Microsoft Money][6] and [Quicken][7] to import bank statemnts.
25
+
26
+ **Usage:**
27
+
28
+ cnab2ofx [cnab240_bank_statement_file] > [ofx_output_file]
29
+
30
+
31
+ [1]: http://ruby-lang.org/ "Ruby Language"
32
+ [2]: http://www.febraban.org.br/Acervo1.asp?id_texto=717&id_pagina=173 "CNAB240"
33
+ [3]: http://www.febraban.org.br "Febraban"
34
+ [4]: http://www.ofx.net/ "Open Financial Exchange"
35
+ [5]: http://www.gnucash.org/ "GnuCash - Free Accounting Software"
36
+ [6]: http://support.microsoft.com/kb/2118008 "Microsoft Money"
37
+ [7]: http://quicken.intuit.com/ "Quicken"
data/bin/cnab2ofx ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ #encoding:utf-8
3
+
4
+ ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+
6
+ require 'yaml'
7
+ require 'pp'
8
+ require 'date'
9
+ require 'erb'
10
+ require 'cnab240_helper.rb'
11
+ pp $LOAD_PATH
12
+ require 'cnab2ofx'
13
+
14
+ CONFIG_DIR = File.join ROOT_DIR, 'lib/cnab2ofx/cnab240'
15
+ VIEW_DIR = File.join ROOT_DIR, 'view'
16
+
17
+ if ARGV[0].nil?
18
+ puts "Usage: cnab2ofx [cnab240_input_file] > [ofx_output_file]"
19
+ else
20
+ filename = ARGV[0]
21
+ cnab240 = CNAB240.new(filename)
22
+ puts cnab240.to_ofx
23
+ end
data/cnab2ofx.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "cnab2ofx"
3
+ s.version = "0.0.4"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.authors = ["Abinoam Praxedes Marques Junior"]
6
+ s.email = ["abinoam@gmail.com"]
7
+ s.homepage = "https://bitbucket.org/abinoam/cnab2ofx"
8
+ s.summary = "CNAB240 to ofx conversion script"
9
+ s.description = "A small and simple script that can be used to convert CNAB240 to ofx financial formats"
10
+ s.rubyforge_project = s.name
11
+
12
+ s.required_rubygems_version = ">= 1.3.6"
13
+ s.required_ruby_version = ">= 1.9.2"
14
+
15
+ # If you have runtime dependencies, add them here
16
+ # s.add_runtime_dependency "other", "~> 1.2"
17
+
18
+ # If you have development dependencies, add them here
19
+ # s.add_development_dependency "another", "= 0.9"
20
+
21
+ # The list of files to be contained in the gem
22
+ s.files = `git ls-files`.split("\n")
23
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
24
+ # s.extensions = `git ls-files ext/extconf.rb`.split("\n")
25
+
26
+ s.require_paths = ['lib', 'helper']
27
+
28
+ # For C extensions
29
+ # s.extensions = "ext/extconf.rb"
30
+
31
+ s.post_install_message = "\nA sample generated CNAB240 file is provided at 'test' directory.\n\n"
32
+ end
@@ -0,0 +1,20 @@
1
+ module CNAB240Helper
2
+
3
+ module StringHelper
4
+
5
+ def trim_lzeroes
6
+ self.sub(/^0+/,"")
7
+ rescue ArgumentError => e
8
+ i = self.encode("utf-8", "iso-8859-1") # Brazilian encoding used by some banks
9
+ i.sub(/^0+/,"")
10
+ i.encode("iso-8859-1", "utf-8")
11
+ end
12
+
13
+ def date_convert(from, to)
14
+ from_date = DateTime.strptime(self,from) # Import from 'from' DateTime format
15
+ to_date = from_date.strftime(to) # Export to 'to' DateTime format
16
+ end
17
+
18
+ end
19
+
20
+ end
data/lib/cnab2ofx.rb ADDED
@@ -0,0 +1,132 @@
1
+ #encoding:utf-8
2
+
3
+ #TODO: Solve the encoding problem
4
+
5
+ class String
6
+ include CNAB240Helper::StringHelper
7
+ end
8
+
9
+ class CNAB240
10
+
11
+ attr_reader :cnab240, :dtserver, :dtstart, :dtend,
12
+ :org, :fid, :bankid, :branchid, :acctid,
13
+ :balamt, :dtasof, :transactions
14
+
15
+ def initialize(filename)
16
+ @filename = filename
17
+ @cnab240 = parse
18
+ @dtserver = get_dtserver
19
+ @dtstart = get_dtstart
20
+ @dtend = get_dtend
21
+ @org = @fid = get_org
22
+ @bankid = get_bankid
23
+ @branchid = get_branchid
24
+ @acctid = get_acctid
25
+ @balamt = get_balamt
26
+ @dtasof = get_dtasof
27
+ @transactions = get_transactions
28
+ end
29
+
30
+ def to_ofx
31
+ ERB.new(File.read(File.join(VIEW_DIR, "extrato.ofx.erb"))).result(binding)
32
+ end
33
+
34
+ private
35
+
36
+ def str_decode_with_headers(str, headers)
37
+ raise ArgumentError, "str.size should be 240 for CNAB240 but it's #{str.size}" if str.size != 240
38
+ str = str.dup
39
+ headers.each_with_object({}) do |(k,v), hsh|
40
+ hsh[k.to_sym] = str.slice!(0,v)
41
+ end
42
+ end
43
+
44
+ def parse
45
+
46
+ f = File.open(@filename)
47
+
48
+ lines = {}
49
+
50
+ lines[:header_de_arquivo],
51
+ lines[:header_de_lote],
52
+ *lines[:detalhe_segmento_e],
53
+ lines[:trailer_de_lote],
54
+ lines[:trailer_de_arquivo] = f.readlines
55
+
56
+ lines.each_with_index.with_object({}) do |((k,v), i), hsh| #|(k,v), i, hsh|
57
+ file_index = "%03d" % i
58
+ fields_headers = YAML.load_file (File.join(CONFIG_DIR, "#{file_index}_registro_#{k}.yaml"))
59
+ case v
60
+ when String
61
+ hsh[k] = str_decode_with_headers(v.chomp, fields_headers)
62
+ when Array
63
+ hsh[k] = v.map {|line| str_decode_with_headers(line.chomp, fields_headers) }
64
+ else
65
+ raise ArgumentError, "v (line) should be Array or String but it is #{v.class} "
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+ def get_dtserver
72
+ cnab_date_string = @cnab240[:header_de_arquivo][:data_arquivo]+@cnab240[:header_de_arquivo][:hora_arquivo]
73
+ cnab_date_string.date_convert "%d%m%Y%H%M%S", "%Y%m%d%H%M%S"
74
+ end
75
+
76
+ def get_dtstart
77
+ cnab_date_string = @cnab240[:header_de_lote][:data_saldo_inicial]
78
+ cnab_date_string.date_convert "%d%m%Y", "%Y%m%d"
79
+ end
80
+
81
+ def get_dtend
82
+ cnab_date_string = @cnab240[:trailer_de_lote][:data_saldo_final]
83
+ cnab_date_string.date_convert "%d%m%Y", "%Y%m%d"
84
+ end
85
+
86
+ alias get_dtasof get_dtend
87
+
88
+ def get_org
89
+ @org = @fid = @cnab240[:header_de_arquivo][:nome_banco].strip
90
+ end
91
+
92
+ alias get_fid get_org
93
+
94
+ def get_bankid
95
+ @cnab240[:header_de_arquivo][:banco].trim_lzeroes
96
+ end
97
+
98
+ def get_branchid
99
+ @cnab240[:header_de_arquivo][:agência].trim_lzeroes + "-" +
100
+ @cnab240[:header_de_arquivo][:agência_dv].trim_lzeroes
101
+ end
102
+
103
+ def get_acctid
104
+ @cnab240[:header_de_arquivo][:conta_corrente].trim_lzeroes + "-" +
105
+ @cnab240[:header_de_arquivo][:conta_corrente_dv].trim_lzeroes
106
+ end
107
+
108
+ def get_balamt
109
+ @cnab240[:trailer_de_lote][:valor_saldo_final].to_f / 100
110
+ end
111
+
112
+ def get_transactions
113
+ t = @cnab240[:detalhe_segmento_e].map do |t|
114
+ hash = Hash.new
115
+ hash[:dtposted] = t[:data_lançamento].date_convert("%d%m%Y", "%Y%m%d")
116
+ hash[:trnamt] = (t[:valor_lançamento].to_f / 100).to_s
117
+ if t[:tipo_lançamento] == "D" # (D)ebit = Débito
118
+ hash[:trnamt] = "-"+hash[:trnamt]
119
+ end
120
+ hash[:checknum] = checknum(t)
121
+ hash[:fitid] = "20" + hash[:checknum]
122
+ hash[:memo] = t[:desc_histórico].strip.trim_lzeroes + " - " + t[:num_documento].strip.trim_lzeroes
123
+ hash
124
+ end
125
+ end
126
+
127
+ def checknum(t)
128
+ t[:data_lançamento].date_convert("%d%m%Y", "%y%m%d") + #31122013 -> 131231
129
+ t[:valor_lançamento][-8,8] +
130
+ (t[:desc_histórico]+t[:num_documento]).unpack("C*").reduce(:+).to_s
131
+ end
132
+ end
@@ -0,0 +1,24 @@
1
+ banco: 3 # (1..3) Código do Banco na Compensação
2
+ lote: 4 # (4..7) Lote de Serviço
3
+ registro: 1 # (8..8) Tipo de Registro
4
+ reservado_04_5: 9 # (9..17) Uso Exclusivo FEBRABAN / CNAB
5
+ emp_tipo_insc: 1 # (18..18) Tipo de Inscrição da Empresa
6
+ emp_num_insc: 14 # (19..32) Número de Inscrição da Empresa
7
+ conv_banco: 20 # (33..52) Código do Convênio no Banco
8
+ agência: 5 # (53..57) Agência Mantenedora da Conta
9
+ agência_dv: 1 # (58..58) Dígito Verificador da Agência
10
+ conta_corrente: 12 # (59..70) Número da Conta Corrente
11
+ conta_corrente_dv: 1 # (71..71) Dígito Verificador da Conta
12
+ ag_conta_dv: 1 # (72..72) Dígito Verificador da Ag/Conta
13
+ nome: 30 # (73..102) Nome da Empresa
14
+ nome_banco: 30 # (103..132) Nome do Banco
15
+ reservado_15_0: 10 # (133..142) Uso Exclusivo FEBRABAN / CNAB
16
+ cód_remessa: 1 # (143..143) Código Remessa / Retorno
17
+ data_arquivo: 8 # (144..151) Data de Geração do Arquivo
18
+ hora_arquivo: 6 # (152..157) Hora de Geração do Arquivo
19
+ num_seq_arquivo: 6 # (158..163) Número Seqüencial do Arquivo
20
+ num_versão_layout: 3 # (164..166) No da Versão do Layout do Arquivo
21
+ densidade_grav_arquivo: 5 # (167..171) Densidade de Gravação do Arquivo
22
+ reservado_banco: 20 # (172..191) Para Uso Reservado do Banco
23
+ reservado_empresa: 20 # (192..211) Para Uso Reservado da Empresa
24
+ reservado_24_0: 29 # (212..240) Uso Exclusivo FEBRABAN / CNAB
@@ -0,0 +1,26 @@
1
+ banco: 3 # (1..3) ... Código do Banco na Compensação
2
+ lote: 4 # (4..7) ... Lote de Serviço
3
+ registro: 1 # (8..8) ... Tipo de Registro
4
+ operação: 1 # (9..9) ... Tipo da Operação
5
+ serviço: 2 # (10..11) . Tipo de Serviço
6
+ forma: 2 # (12..13) . Forma de Lançamento
7
+ layout: 3 # (14..16) . Nº da Versão do Layout do Lote
8
+ reservado_08_1: 1 # (17..17) . Uso Exclusivo FEBRABAN/CNAB
9
+ emp_tipo_insc: 1 # (18..18) . Tipo de Inscrição da Empresa
10
+ emp_num_insc: 14 # (19..32) . Número de Inscrição da Empresa
11
+ conv_banco: 20 # (33..52) . Código do Convênio no Banco
12
+ agência: 5 # (53..57) . Agência Mantenedora da Conta
13
+ agência_dv: 1 # (58..58) . Dígito Verificador da Agência
14
+ conta_corrente: 12 # (59..70) . Número da Conta Corrente
15
+ conta_corrente_dv: 1 # (71..71) . Dígito Verificador da Conta
16
+ ag_conta_dv: 1 # (72..72) . Dígito Verificador da Ag/Conta
17
+ nome: 30 # (73..102) Nome da Empresa
18
+ reservado_18_1: 40 # (103..142) Uso Exclusivo da FEBRABAN/CNAB
19
+ data_saldo_inicial: 8 # (143..150) Data do Saldo Inicial
20
+ saldo_inicial: 18 # (151..168) Valor do Saldo Inicial
21
+ situação_saldo_inicial: 1 # (169..169) Situação do Saldo Inicial
22
+ posição_saldo_inicial: 1 # (170..170) Posição do Saldo Inicial
23
+ moeda: 3 # (171..173) Moeda Referenciada no Extrato
24
+ sequência: 5 # (174..178) Número de Seqüência do Extrato
25
+ reservado_25_1: 62 # (179..240) Uso Exclusivo FEBRABAN/CNAB
26
+
@@ -0,0 +1,29 @@
1
+ banco: 3 # (1..3) Código no Banco da Compensação
2
+ lote: 4 # (4..7) Lote de Serviço
3
+ registro: 1 # (8..8) Tipo de Registro
4
+ num_registro: 5 # (9..13) Nº Seqüencial do Registro no Lote
5
+ segmento: 1 # (14..14) Código Segmento do Reg. Detalhe
6
+ reservado_06_3: 3 # (15..17) Uso Exclusivo FEBRABAN/CNAB
7
+ emp_tipo_insc: 1 # (18..18) Tipo de Inscrição da Empresa
8
+ emp_num_insc: 14 # (19..32) Número de Inscrição da Empresa
9
+ conv_banco: 20 # (33..52) Código do Convênio no Banco
10
+ agência: 5 # (53..57) Agência Mantenedora da Conta
11
+ agência_dv: 1 # (58..58) Dígito Verificador da Agência
12
+ conta_corrente: 12 # (59..70) Número da Conta Corrente
13
+ conta_corrente_dv: 1 # (71..71) Dígito Verificador da Conta
14
+ ag_conta_dv: 1 # (72..72) Dígito Verificador da Ag/Conta
15
+ nome: 30 # (73..102) Nome da Empresa
16
+ reservado_18_1: 6 # (103..108) Uso Exclusivo da FEBRABAN/CNAB
17
+ natureza: 3 # (109..111) Natureza do Lançamento
18
+ tipo_complemento: 2 # (112..113) Tipo do Complemento Lançamento
19
+ complemento: 20 # (114..133) Complemento do Lançamento
20
+ isenção_cpmf: 1 # (134..134) Identificação de Isenção do CPMF
21
+ data_contábil: 8 # (135..142) Data Contábil
22
+ data_lançamento: 8 # (143..150) Data do Lançamento
23
+ valor_lançamento: 18 # (151..168) Valor do Lançamento
24
+ tipo_lançamento: 1 # (169..169) Tipo Lançamento: Valor a Déb./Créd.
25
+ categoria_lançamento: 3 # (170..172) Categoria do Lançamento
26
+ cód_histórico: 4 # (173..176) Código Histórico no Banco
27
+ desc_histórico: 25 # (177..201) Descrição Histórico Lcto. no Banco
28
+ num_documento: 39 # (202..240) Número Documento/Complemento
29
+
@@ -0,0 +1,24 @@
1
+ banco: 3 # (1..3) Código do Banco na Compensação
2
+ lote: 4 # (4..7) Lote de Serviço
3
+ registro: 1 # (8..8) Tipo de Registro
4
+ reservado_04_5: 9 # (9..17) Uso Exclusivo da FEBRABAN/CNAB
5
+ emp_tipo_insc: 1 # (18..18) Tipo de Inscrição da Empresa
6
+ emp_num_insc: 14 # (19..32) Número de Inscrição da Empresa
7
+ conv_banco: 20 # (33..52) Código do Convênio no Banco
8
+ agência: 5 # (53..57) Agência Mantenedora da Conta
9
+ agência_dv: 1 # (58..58) Dígito Verificador da Agência
10
+ conta_corrente: 12 # (59..70) Número da Conta Corrente
11
+ conta_corrente_dv: 1 # (71..71) Dígito Verificador da Conta
12
+ ag_conta_dv: 1 # (72..72) Dígito Verificador da Ag/Conta
13
+ reservado_13_5: 16 # (73..88) Uso Exclusivo da FEBRABAN/CNAB
14
+ saldo_bloqueado_acima_24h: 18 # (89..106) Saldo Bloqueado Acima 24 horas
15
+ limite_conta: 18 # (107..124) Limite da Conta
16
+ saldo_bloqueado_até_24h: 18 # (125..142) Saldo Bloqueado até 24 Horas
17
+ data_saldo_final: 8 # (143..150) Data do Saldo Final
18
+ valor_saldo_final: 18 # (151..168) Valor do Saldo Final
19
+ situação_saldo_final: 1 # (169..169) Situação do Saldo Final
20
+ status_saldo_final: 1 # (170..170) Posição do Saldo Final
21
+ qtd_reg_lote: 6 # (171..176) Quantidade de Registros do Lote
22
+ débitos_valor: 18 # (177..194) Somatória dos Valores a Débito
23
+ créditos_valor: 18 # (195..212) Somatória dos Valores a Crédito
24
+ reservado_24_5: 28 # (213..240) Uso Exclusivo da FEBRABAN/CNAB
@@ -0,0 +1,8 @@
1
+ banco: 3 # (1..3) Código do Banco na Compensação
2
+ lote: 4 # (4..7) Lote de Serviço
3
+ registro: 1 # (8..8) Tipo de Registro
4
+ reservado_04_9: 9 # (9..17) Uso Exclusivo FEBRABAN/CNAB
5
+ qtd_lotes: 6 # (18..23) Quantidade de Lotes do Arquivo
6
+ qtd_registros: 6 # (24..29) Quantidade de Registros do Arquivo
7
+ qtd_contas: 6 # (30..35) Qtde de Contas p/ Conc. (Lotes)
8
+ reservado_08_9: 205 # (36..240) Uso Exclusivo FEBRABAN/CNAB
@@ -0,0 +1,15 @@
1
+ 11200000 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TALUNICRED MATO GROSSO 208042013112245000001060
2
+ 11200021E0440032 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 01032013000000000001084871CFBRL000001
3
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N0703201307032013000000000000020000D1010010CHQ COMPENSADO 000000000033
4
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N1103201311032013000000000000040000D1200186DEBITO DOC CAMARADA CAM
5
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N1103201311032013000000000000001100D1050069TAR REMESSA DE DOC 016600000883
6
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N1103201311032013000000000000017886D1040019DEBITO CORR. BANCARIO CONTA 2013
7
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N1103201311032013000000000000062619D1040019DEBITO CORR. BANCARIO CONTA 013 03
8
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N1103201311032013000000000000014136D1040021PAGTO DE TITULOS CONTA2013 03
9
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 S1103201311032013000000000000004200D1170150INTEGRALIZACAO DE CAPITAL099200001435
10
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N2103201321032013000000000000022100D1010010CHQ COMPENSADO 000000000034
11
+ 1120002300000E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N2503201325032013000000000000000115D1040090SEGURO PRESTAMISTA 14420
12
+ 1120002300001E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 N2803201328032013000000000000017632D1170089DEBITO TRANSFER ALA BALA LAL
13
+ 1120002300001E 111222333444 000000000000001360150987650000000123456 FULANO DE TAL DOS ANZOIS E TAL 0111298765 S2803201328032013000000000000597569C2170882CREDITO PRODUCAO LAL ALAB ALA
14
+ 11200025 111222333444 000000000000001360150987650000000123456 00000000000000000000000000000000000500000000000000000031032013000000000001482652CF000013000000000000000000000000000000000000
15
+ 11299999 000002000015000002
@@ -0,0 +1,63 @@
1
+ OFXHEADER:100
2
+ DATA:OFXSGML
3
+ VERSION:102
4
+ SECURITY:NONE
5
+ ENCODING:USASCII
6
+ CHARSET:1252
7
+ COMPRESSION:NONE
8
+ OLDFILEUID:NONE
9
+ NEWFILEUID:NONE
10
+
11
+ <OFX>
12
+ <SIGNONMSGSRSV1>
13
+ <SONRS>
14
+ <STATUS>
15
+ <CODE>0
16
+ <SEVERITY>INFO
17
+ </STATUS>
18
+ <DTSERVER><%=@dtserver%>
19
+ <LANGUAGE>POR
20
+ <FI>
21
+ <ORG><%=@org%>
22
+ <FID><%=@fid%>
23
+ </FI>
24
+ </SONRS>
25
+ </SIGNONMSGSRSV1>
26
+ <BANKMSGSRSV1>
27
+ <STMTTRNRS>
28
+ <TRNUID>1
29
+ <STATUS>
30
+ <CODE>0
31
+ <SEVERITY>INFO
32
+ </STATUS>
33
+ <STMTRS>
34
+ <CURDEF>BRL
35
+ <BANKACCTFROM>
36
+ <BANKID><%=@bankid%>
37
+ <BRANCHID><%=@branchid%>
38
+ <ACCTID><%=@acctid%>
39
+ <ACCTTYPE>CHECKING
40
+ </BANKACCTFROM>
41
+ <BANKTRANLIST>
42
+ <DTSTART><%=@dtstart%>
43
+ <DTEND><%=@dtend%>
44
+ <% @transactions.each do |t| %>
45
+ <STMTTRN>
46
+ <TRNTYPE>OTHER
47
+ <DTPOSTED><%=t[:dtposted]%>
48
+ <TRNAMT><%=t[:trnamt]%>
49
+ <FITID><%=t[:fitid] %>
50
+ <CHECKNUM><%=t[:checknum] %>
51
+ <PAYEEID>0
52
+ <MEMO><%=t[:memo]%>
53
+ </STMTTRN>
54
+ <% end %>
55
+ </BANKTRANLIST>
56
+ <LEDGERBAL>
57
+ <BALAMT><%=@balamt%>
58
+ <DTASOF><%=@dtasof%>
59
+ </LEDGERBAL>
60
+ </STMTRS>
61
+ </STMTTRNRS>
62
+ </BANKMSGSRSV1>
63
+ </OFX>
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cnab2ofx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Abinoam Praxedes Marques Junior
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A small and simple script that can be used to convert CNAB240 to ofx
15
+ financial formats
16
+ email:
17
+ - abinoam@gmail.com
18
+ executables:
19
+ - cnab2ofx
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - Gemfile
24
+ - README.md
25
+ - bin/cnab2ofx
26
+ - cnab2ofx.gemspec
27
+ - helpers/cnab240_helper.rb
28
+ - lib/cnab2ofx.rb
29
+ - lib/cnab2ofx/cnab240/000_registro_header_de_arquivo.yaml
30
+ - lib/cnab2ofx/cnab240/001_registro_header_de_lote.yaml
31
+ - lib/cnab2ofx/cnab240/002_registro_detalhe_segmento_e.yaml
32
+ - lib/cnab2ofx/cnab240/003_registro_trailer_de_lote.yaml
33
+ - lib/cnab2ofx/cnab240/004_registro_trailer_de_arquivo.yaml
34
+ - test/modelo.teste.cnab240
35
+ - view/extrato.ofx.erb
36
+ homepage: https://bitbucket.org/abinoam/cnab2ofx
37
+ licenses: []
38
+ post_install_message: ! '
39
+
40
+ A sample generated CNAB240 file is provided at ''test'' directory.
41
+
42
+
43
+ '
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ - helper
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.9.2
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: 1.3.6
60
+ requirements: []
61
+ rubyforge_project: cnab2ofx
62
+ rubygems_version: 1.8.24
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: CNAB240 to ofx conversion script
66
+ test_files: []