abank 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a59c02ce2b0191c7352505afee9cc70a9cb089e13f8eff6bdb9fadd8033b71c
4
- data.tar.gz: c010bc3136f075a8323403b147e064cfc4b34e3eacb38a71fddb88b84f5204eb
3
+ metadata.gz: aab432e51be128ae3bf7ba50a5dadcacad1e940b0d36fa0cf04cdf15e255be19
4
+ data.tar.gz: 968c78583abbff5c4dc5a0286e31c6d9278270af322ec2f86a045f8b776356fb
5
5
  SHA512:
6
- metadata.gz: 174bdd47142b4344abafeadff04c89a8cbea380d508667ba68ea27c602d98eb10a5920972fd017058e6f260712519b4e2d952ff3cdf854f893b9fffd79ee4e33
7
- data.tar.gz: f62757b9667bfbcdfe8efbf85083d6bc2cd1351af83e8b3f7307fff9b4cffd13feff922242fdb0e23db1fdce25704dac89f88ba00f8123819302c31fed8fbc0c
6
+ metadata.gz: b2f25e773fc986695bd318c8938168bd01ff27dd44c2799afd653428886fbe6c08b0dde2e8a520fe63d386caf9ad730a67979faf677512c9e03404a161448020
7
+ data.tar.gz: 8dee5c630c47155bb4478b5f0f7d2c6963e716a186db8ec31f11d86c194693e8167c09b09054f22f66910519e7d3fabd53d093ad71efaa5567fc4816cb448d34
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abank (0.2.0)
4
+ abank (0.2.1)
5
5
  google-cloud-bigquery
6
6
  roo
7
7
  thor
@@ -72,7 +72,7 @@ GEM
72
72
  multi_json (~> 1.10)
73
73
  thor (1.0.1)
74
74
  uber (0.1.0)
75
- yard (0.9.24)
75
+ yard (0.9.25)
76
76
 
77
77
  PLATFORMS
78
78
  ruby
data/lib/abank.rb CHANGED
@@ -18,6 +18,8 @@ module Abank
18
18
  desc: 'Onde procurar folhas calculo'
19
19
  option :x, banner: 'EXT', default: '.xlsx',
20
20
  desc: 'Extensao das folhas calculo'
21
+ option :n, banner: 'NUM', type: :numeric, default: 0,
22
+ desc: 'Correcao dias para data valor'
21
23
  option :s, type: :boolean, default: false,
22
24
  desc: 'apaga linha similar no bigquery'
23
25
  option :e, type: :boolean, default: false,
@@ -27,8 +29,7 @@ module Abank
27
29
  # processa folha calculo
28
30
  def load
29
31
  Dir.glob("#{options[:d]}/*#{options[:x]}").sort.each do |f|
30
- Bigquery.new(f, { s: options[:s], e: options[:e],
31
- m: options[:m], i: true }).processa
32
+ Bigquery.new(f, load_ops).processa
32
33
  end
33
34
  end
34
35
 
@@ -50,6 +51,14 @@ module Abank
50
51
  Bigquery.new.classifica
51
52
  end
52
53
 
54
+ no_commands do
55
+ # @return [Hash] ops opcoes trabalho com linhas para load
56
+ def load_ops
57
+ { s: options[:s], e: options[:e],
58
+ m: options[:m], i: true, n: options[:n] }
59
+ end
60
+ end
61
+
53
62
  default_task :mostra
54
63
  end
55
64
  end
@@ -12,7 +12,7 @@ module Abank
12
12
  attr_reader :apibq
13
13
  # @return [Roo::Excelx] folha calculo a processar
14
14
  attr_reader :folha
15
- # @return [Hash<Symbol, Boolean>] opcoes trabalho com linhas
15
+ # @return [Hash] opcoes trabalho com linhas
16
16
  attr_reader :linha
17
17
  # @return [Integer] numero conta
18
18
  attr_reader :conta
@@ -25,14 +25,16 @@ module Abank
25
25
  attr_reader :sql
26
26
 
27
27
  # @param [String] xls folha calculo para processar
28
- # @param [Hash<Symbol, Boolean>] ops opcoes trabalho com linhas
28
+ # @param [Hash] ops opcoes trabalho com linhas
29
29
  # @option ops [Boolean] :s (false) apaga linha similar?
30
30
  # @option ops [Boolean] :e (false) apaga linha igual?
31
31
  # @option ops [Boolean] :m (false) apaga linhas existencia multipla?
32
32
  # @option ops [Boolean] :i (false) insere linha nova?
33
+ # @option ops [Numeric] :n (0) numero dias correcao para data valor
33
34
  # @return [Bigquery] acesso folhas calculo activobank
34
35
  # & correspondente bigquery dataset
35
- def initialize(xls = '', ops = { s: false, e: false, m: false, i: false })
36
+ def initialize(xls = '', ops = { s: false, e: false, m: false,
37
+ i: false, n: 0 })
36
38
  # usa env GOOGLE_APPLICATION_CREDENTIALS para obter credentials
37
39
  # @see https://cloud.google.com/bigquery/docs/authentication/getting-started
38
40
  @apibq = Google::Cloud::Bigquery.new
@@ -93,10 +95,15 @@ module Abank
93
95
  return 1 unless linha[:i]
94
96
 
95
97
  dml('insert hernanilr.ab.mv(dl,dv,ds,vl,nc,ano,mes,ct,tp) VALUES(' \
96
- "'#{row[0].strftime(DF)}','#{row[1].strftime(DF)}','#{row[2]}'" +
98
+ "'#{row[0].strftime(DF)}','#{data_valor.strftime(DF)}','#{row[2]}'" +
97
99
  str_insert1)
98
100
  end
99
101
 
102
+ # @return [Date] data valor corrigida
103
+ def data_valor
104
+ row[1] + linha[:n].to_i
105
+ end
106
+
100
107
  # @return [String] campos extra da linha bigquery
101
108
  def str_insert1
102
109
  ",#{row[3]},#{conta}" + str_insert2
@@ -104,7 +111,8 @@ module Abank
104
111
 
105
112
  # @return [String] campos calculados da linha bigquery
106
113
  def str_insert2
107
- ",#{row[1].year},#{row[1].month},null,'#{row[3].positive? ? 'c' : 'd'}')"
114
+ ",#{data_valor.year},#{data_valor.month},null," \
115
+ "'#{row[3].positive? ? 'c' : 'd'}')"
108
116
  end
109
117
 
110
118
  # @return [Integer] numero linhas apagadas
data/lib/abank/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abank
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-03 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler