cartolabco 1.0.0
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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +24 -0
- data/lib/bci.rb +32 -0
- data/lib/bci_xls.rb +54 -0
- data/lib/cartolabco.rb +11 -0
- data/lib/check_file.rb +11 -0
- data/lib/movimiento.rb +32 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cba96159942652e76cd93b457730439dd0f38e63ac9686f6dbb194aeaf7264df
|
4
|
+
data.tar.gz: c9383351d9ae7f2a537469911c63c4227958562f953c540e95bdb237cb88bd60
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a547e816be2d87e19efbb50a3d48c232a823c0c47ac8c4f98efa07f057809f1eb18a2a61d664183e1cfe7941e92c2b931588ed75f2f32171367ca9dd00f73344
|
7
|
+
data.tar.gz: a1cb0b1929b785eab51146ec3bea0f10e42919383c049604691b3b7b7f7a9135e4b9acce81945eaff1ec33355782fcb3133e94c3f15f3434fe5bb7b66696776c
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Alexis Astorga
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
[](https://github.com/aastorga123/cartola/blob/master/LICENSE) [](https://badge.fury.io/rb/cartolabco)
|
2
|
+
[](https://travis-ci.com/aastorga123/cartola)
|
3
|
+
|
4
|
+
## __Information__
|
5
|
+
|
6
|
+
Import file from banks to raise bank balance.
|
7
|
+
|
8
|
+
## How to use
|
9
|
+
|
10
|
+
Distributed in [RubyGems](https://rubygems.org/gems/cartolabco)
|
11
|
+
|
12
|
+
__Gemfile__
|
13
|
+
|
14
|
+
`gem 'cartolabco'`
|
15
|
+
|
16
|
+
__Install__
|
17
|
+
|
18
|
+
`gem install cartolabco`
|
19
|
+
|
20
|
+
## Contribute
|
21
|
+
just test your code before pull request, run
|
22
|
+
```console
|
23
|
+
$ bundle exec rake test
|
24
|
+
```
|
data/lib/bci.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class Bci
|
2
|
+
|
3
|
+
attr_reader :numero_cartola
|
4
|
+
attr_reader :desde
|
5
|
+
attr_reader :hasta
|
6
|
+
attr_reader :cuenta_corriente
|
7
|
+
attr_reader :movimientos
|
8
|
+
attr_reader :saldo_inicial
|
9
|
+
attr_reader :saldo_final
|
10
|
+
attr_reader :total_cargos
|
11
|
+
attr_reader :total_abonos
|
12
|
+
|
13
|
+
def initialize(
|
14
|
+
numero_cartola, desde, hasta, cuenta_corriente, movimientos,
|
15
|
+
saldo_inicial, saldo_final, total_cargos, total_abonos
|
16
|
+
)
|
17
|
+
@numero_cartola = numero_cartola
|
18
|
+
@desde = desde
|
19
|
+
@hasta = hasta
|
20
|
+
@cuenta_corriente = cuenta_corriente
|
21
|
+
@movimientos = movimientos
|
22
|
+
@saldo_inicial = saldo_inicial
|
23
|
+
@saldo_final = saldo_final
|
24
|
+
@total_cargos = total_cargos
|
25
|
+
@total_abonos = total_abonos
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_s
|
29
|
+
"numero_cartola: #{@numero_cartola}\ndesde:#{@desde}\nhasta:#{@hasta}\n" +
|
30
|
+
"cuenta_corriente:#{@cuenta_corriente}\nmovimientos:#{@movimientos}"
|
31
|
+
end
|
32
|
+
end
|
data/lib/bci_xls.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spreadsheet'
|
2
|
+
require 'bci'
|
3
|
+
require 'movimiento'
|
4
|
+
|
5
|
+
class BciXls
|
6
|
+
def initialize(file)
|
7
|
+
@file = file
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse
|
11
|
+
spreadsheet = Spreadsheet.open(@file.path)
|
12
|
+
book = spreadsheet.worksheet(0)
|
13
|
+
numero_cartola = book.rows[4][12].to_i
|
14
|
+
desde = book.rows[16][6].to_s[0..9]
|
15
|
+
hasta = book.rows[16][6].to_s[14..23]
|
16
|
+
cuenta_corriente = book.rows[7][6].to_s
|
17
|
+
movimientos = fill_list(book)
|
18
|
+
saldo_inicial = book.rows[22 + movimientos.size][3].to_f
|
19
|
+
saldo_final = book.rows[22 + movimientos.size][9].to_f
|
20
|
+
total_cargos = book.rows[22 + movimientos.size][5].to_f
|
21
|
+
total_abonos = book.rows[22 + movimientos.size][7].to_f
|
22
|
+
Bci.new(
|
23
|
+
numero_cartola,desde,hasta,cuenta_corriente,movimientos,
|
24
|
+
saldo_inicial, saldo_final, total_cargos, total_abonos
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def fill_list(book)
|
31
|
+
movimientos = Array.new
|
32
|
+
correlativo = 1
|
33
|
+
(20..book.rows.size).each do |index|
|
34
|
+
row = book.rows[index]
|
35
|
+
if row[0].to_s == 'Resumen del Periodo'
|
36
|
+
break
|
37
|
+
end
|
38
|
+
movimientos.push(
|
39
|
+
Movimiento.new(
|
40
|
+
row[0],
|
41
|
+
correlativo,
|
42
|
+
row[2],
|
43
|
+
row[1],
|
44
|
+
row[3].to_s[0..(row[3].to_s.size - 3)],
|
45
|
+
row[6],
|
46
|
+
row[7],
|
47
|
+
row[9]
|
48
|
+
)
|
49
|
+
)
|
50
|
+
correlativo = correlativo + 1
|
51
|
+
end
|
52
|
+
movimientos
|
53
|
+
end
|
54
|
+
end
|
data/lib/cartolabco.rb
ADDED
data/lib/check_file.rb
ADDED
data/lib/movimiento.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class Movimiento
|
2
|
+
|
3
|
+
attr_reader :fecha
|
4
|
+
attr_reader :correlativo
|
5
|
+
attr_reader :descripcion
|
6
|
+
attr_reader :sucursal
|
7
|
+
attr_reader :nro_documento
|
8
|
+
attr_reader :cargo
|
9
|
+
attr_reader :abono
|
10
|
+
attr_reader :saldo
|
11
|
+
|
12
|
+
def initialize(
|
13
|
+
fecha, correlativo, descripcion, sucursal,
|
14
|
+
nro_documento, cargo, abono, saldo
|
15
|
+
)
|
16
|
+
@fecha = fecha
|
17
|
+
@correlativo = correlativo
|
18
|
+
@descripcion = descripcion
|
19
|
+
@sucursal = sucursal
|
20
|
+
@nro_documento = nro_documento
|
21
|
+
@cargo = cargo
|
22
|
+
@abono = abono
|
23
|
+
@saldo = saldo
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"fecha: #{@fecha}\ncorrelativo: #{@correlativo}\n" +
|
28
|
+
"descripcion: #{@descripcion}\nsucursal: #{@sucursal}\n" +
|
29
|
+
"nro_documento: #{@nro_documento}\ncargo: #{@cargo}\nabono: #{@abono}" +
|
30
|
+
"saldo: #{@saldo}"
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cartolabco
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexis Astorga
|
8
|
+
- Braulio Lopez
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Generar Cartola
|
15
|
+
email:
|
16
|
+
- alexis.astorga.ti@gmail.com
|
17
|
+
- brauliop.3@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- lib/bci.rb
|
25
|
+
- lib/bci_xls.rb
|
26
|
+
- lib/cartolabco.rb
|
27
|
+
- lib/check_file.rb
|
28
|
+
- lib/movimiento.rb
|
29
|
+
homepage: http://rubygems.org/gems/cartolabco
|
30
|
+
licenses: []
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.7.6
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: gema cartola
|
52
|
+
test_files: []
|