abank 0.7.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b52d3129983933c52306acea70fdfc2c1104038080b554456a4d8ac1e89406f5
4
- data.tar.gz: 73ebaaa2457f7166cdb4f455534a6d8ff3554c78b7106bbb140efdfb145a96a6
3
+ metadata.gz: 5cdbf5848f71477ac0335fce39e8b98eec16ec5fbf0cce20d71d45100759779d
4
+ data.tar.gz: 0ca9a3cd18bbe22522695bb6de305bb238c5f9bf9166e8f3b1a8bf65258a58c3
5
5
  SHA512:
6
- metadata.gz: ecd45604e88d0cf0aed881117b8865f5cb73baf7bafda6b4f33f35000b1807f106d3ebcd2f949f86009e89adca82fc53147e42e56b20b02361871385338df6ab
7
- data.tar.gz: 44903880f6ebb27932ba21eaa1baebcd6df49af6fa0bddfb2e45a36cc646b6b996bd8fb06c2cf598a42956a3f734b14f075b1b817df05cfeafbc22a3814e8cbc
6
+ metadata.gz: e613799e22925d9ab3af9ff414c6a5b66e8d37f4deb56c2a86cadd032a4ae62bb3fee6e4ec62c54490b9dd8f3626f54dd5407272aa9796354010b149e014acff
7
+ data.tar.gz: cb51cb9d37401a738ac8a83b294f24e48bc7a89ea06dc885d4b72ca5ddd09a05d521a049d878456e48880ffeb80303daf10c44eb0fa537e392e214667b69f4f1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abank (0.7.0)
4
+ abank (0.7.1)
5
5
  google-cloud-bigquery
6
6
  roo
7
7
  thor
@@ -75,7 +75,8 @@ GEM
75
75
  google-cloud-core (1.8.0)
76
76
  google-cloud-env (>= 1.0, < 3.a)
77
77
  google-cloud-errors (~> 1.0)
78
- google-cloud-env (2.2.1)
78
+ google-cloud-env (2.2.2)
79
+ base64 (~> 0.2)
79
80
  faraday (>= 1.0, < 3.a)
80
81
  google-cloud-errors (1.5.0)
81
82
  google-logging-utils (0.1.0)
@@ -142,7 +143,7 @@ GEM
142
143
  roo (2.10.1)
143
144
  nokogiri (~> 1)
144
145
  rubyzip (>= 1.3.0, < 3.0.0)
145
- rubocop (1.73.2)
146
+ rubocop (1.74.0)
146
147
  json (~> 2.3)
147
148
  language_server-protocol (~> 3.17.0.2)
148
149
  lint_roller (~> 1.1.0)
@@ -213,4 +214,4 @@ DEPENDENCIES
213
214
  yard
214
215
 
215
216
  BUNDLED WITH
216
- 2.6.3
217
+ 2.6.5
data/lib/abank/big.rb CHANGED
@@ -17,6 +17,7 @@ module Abank
17
17
  # acesso a base dados abank no bigquery
18
18
  # @param [Thor::CoreExt::HashWithIndifferentAccess] opcoes trabalho
19
19
  # @option opcoes [String] :k ('') movimentos a apagar (keysin.mv)
20
+ # @option opcoes [Integer] :n (0) conta apagar movimentos >3 outras (mv)
20
21
  # @option opcoes [String] :c ('') id contrato arrendamento (re)
21
22
  # @option opcoes [String] :d ('') data inicio contrato arrendamento (re)
22
23
  # @option opcoes [Boolean] :t (false) trabalha todas as rendas? (re)
@@ -40,10 +41,15 @@ module Abank
40
41
  # @return [Big] acesso a base dados abank no bigquery
41
42
  def mv_delete
42
43
  @ctlct = []
43
- return self if mvkys.empty?
44
+ return self if mvkys.empty? && docnt.zero?
44
45
 
45
46
  # obtem lista contratos arrendamento associados aos movimentos a apagar
46
- @ctlct = sql("select distinct ct from #{BD}.gmr where ky IN UNNEST(@kys)", kys: mvkys)
47
+ @ctlct =
48
+ if docnt.zero?
49
+ sql("select distinct ct from #{BD}.gmr where ky IN UNNEST(@kys)", kys: mvkys)
50
+ else
51
+ sql("select distinct ct from #{BD}.gmr where nc=@nc", nc: docnt)
52
+ end
47
53
  re_apaga
48
54
  mv_delete_dml
49
55
  self
@@ -92,7 +98,7 @@ module Abank
92
98
  opcao[:c] = ctr[:ct]
93
99
  lre = sql("select * from #{BD}.glr where ct=@ct order by ano desc,cnt desc limit 1", ct: opcao[:c]).first
94
100
  lre[:dl] -= 1 if lre[:cnt].zero?
95
- ctr.merge(lre, mv: sql("select * from #{BD}.gmn where ct=@ct and dl>=@ud order by 1,2", ct: opcao[:c], ud: lre[:dl] + 1))
101
+ ctr.merge(lre, mv: sql("select * from #{BD}.gmr where ct=@ct and dv>=@ud order by 1,2", ct: opcao[:c], ud: lre[:dl] + 1))
96
102
  end
97
103
  self
98
104
  end
@@ -119,6 +125,11 @@ module Abank
119
125
 
120
126
  private
121
127
 
128
+ # @return [Integer] numero conta movimentos apagar
129
+ def docnt
130
+ @docnt ||= opcao[:n] > 3 ? opcao[:n] : 0
131
+ end
132
+
122
133
  # @return [Google::Cloud::Bigquery] API bigquery
123
134
  def bqapi
124
135
  @bqapi ||= Google::Cloud::Bigquery.new
@@ -204,7 +215,11 @@ module Abank
204
215
 
205
216
  # apaga movimentos no bigquery
206
217
  def mv_delete_dml
207
- dml("delete from #{BD}.mv where #{BD}.ky(dl,dv,ds,vl,nc,ex) IN UNNEST(@kys)", kys: mvkys)
218
+ if docnt.zero?
219
+ dml("delete from #{BD}.mv where #{BD}.ky(dl,dv,ds,vl,nc,ex) IN UNNEST(@kys)", kys: mvkys)
220
+ else
221
+ dml("delete from #{BD}.mv where nc=@nc", nc: docnt)
222
+ end
208
223
  puts("MOVIMENTOS APAGADOS #{bqnrs}")
209
224
  end
210
225
 
data/lib/abank/folha.rb CHANGED
@@ -15,11 +15,21 @@ module Abank
15
15
  # @option opcoes [Boolean] :s (false) apaga movimento similar? (mv)
16
16
  # @option opcoes [Boolean] :e (false) apaga movimento igual? (mv)
17
17
  # @option opcoes [Boolean] :i (false) insere movimento novo? (mv)
18
+ # @option opcoes [Integer] :n (0) conta dos movimentos (mv)
18
19
  # @option opcoes [String] :v ('') data valor movimentos (mv)
19
20
  # @option opcoes [String] :g ('') classificacao movimentos (mv)
20
21
  def initialize(opcoes = {})
21
22
  super
22
- @opcao = opcao.merge(s: opcoes.fetch(:s, false), e: opcoes.fetch(:e, false), i: opcoes.fetch(:i, false), v: opcoes.fetch(:v, ''), g: opcoes.fetch(:g, ''), k: +'', f: opcoes[:f])
23
+ @opcao = opcao.merge(
24
+ s: opcoes.fetch(:s, false),
25
+ e: opcoes.fetch(:e, false),
26
+ i: opcoes.fetch(:i, false),
27
+ n: opcoes.fetch(:n, 0),
28
+ v: opcoes.fetch(:v, ''),
29
+ g: opcoes.fetch(:g, ''),
30
+ k: +'',
31
+ f: opcoes[:f]
32
+ )
23
33
  @mvvls = []
24
34
  end
25
35
 
@@ -43,6 +53,8 @@ module Abank
43
53
  end
44
54
  return unless opcao[:i]
45
55
 
56
+ # para nao apagar movimentos duma conta, por aqui somente com keys opcao[:k]
57
+ opcao[:n] = 0
46
58
  mv_delete.mv_insert.ct_dados.re_insert
47
59
  end
48
60
 
@@ -55,12 +67,21 @@ module Abank
55
67
  raise("Erro ao abrir a folha de cálculo: #{opcao[:f]}")
56
68
  end
57
69
 
70
+ # @return [Integer] obter numero conta a partir das opcoes
71
+ def fconta
72
+ return opcao[:n] if opcao[:n] > 2
73
+
74
+ opcao[:f].match?(/card/i) ? 2 : 1
75
+ end
76
+
58
77
  # @example
59
78
  # mov*.xlsx --> 1 --> conta-corrente
60
79
  # movCard*.xlsx --> 2 --> conta-cartao
80
+ # opcao[:n] --> 3 --> conta-cash
81
+ # opcao[:n] --> n --> conta-outras
61
82
  # @return [Integer] numero conta associado a folha calculo
62
83
  def conta
63
- @conta ||= opcao[:f].match?(/card/i) ? 2 : 1
84
+ @conta ||= fconta
64
85
  end
65
86
 
66
87
  # @param [Array] row folha calculo em processamento
@@ -69,7 +90,7 @@ module Abank
69
90
  return false unless row[0].is_a?(Date) && row[1].is_a?(Date)
70
91
 
71
92
  row[2] = row[2].to_s.strip.gsub("'", '').gsub('\\', '') # Descrição
72
- row[3] = row[3].to_f * (conta == 1 ? 1 : -1) # Valor
93
+ row[3] = row[3].to_f * (conta == 2 ? -1 : 1) # Valor
73
94
  @rowfc = row
74
95
  true
75
96
  rescue StandardError => e
@@ -111,10 +132,9 @@ module Abank
111
132
 
112
133
  # @return [Date] data valor corrigida
113
134
  def dvc
114
- dvl = opcao[:v].to_s
115
- dvl.empty? ? rowfc[1] : Date.parse(dvl)
135
+ d = opcao[:v].to_s
136
+ d.empty? ? rowfc[1] : Date.parse(d)
116
137
  rescue ArgumentError
117
- puts("Invalid date format in #{opcao[:v].inspect}")
118
138
  rowfc[1]
119
139
  end
120
140
 
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.7.0'
4
+ VERSION = '0.7.1'
5
5
  end
data/lib/abank.rb CHANGED
@@ -18,8 +18,9 @@ module Abank
18
18
  Big.new(options.to_h).mv_classifica.ct_dados.re_insert
19
19
  end
20
20
 
21
- desc 'apagamv', 'apaga movimentos'
22
- option :k, banner: 'KEY[,KEY...]', required: true, desc: 'keys movimentos a apagar'
21
+ desc 'apagamv', 'apaga movimentos keys|conta'
22
+ option :k, banner: 'KEY[,KEY...]', default: '', desc: 'keys movimentos apagar'
23
+ option :n, banner: 'CONTA', type: :numeric, default: 0, desc: 'conta movimentos apagar (>3 outras)'
23
24
  # apaga movimentos
24
25
  def apagamv
25
26
  Big.new(options.transform_keys(&:to_sym)).mv_delete.ct_dados.re_insert
@@ -60,7 +61,8 @@ module Abank
60
61
  desc 'work', 'carrega/apaga dados da folha calculo'
61
62
  option :s, type: :boolean, default: false, desc: 'apaga movimento similar (=data,=valor,<>descricao)'
62
63
  option :e, type: :boolean, default: false, desc: 'apaga movimento igual'
63
- option :v, banner: 'DATA', default: '', desc: 'data valor para movimentos a carregar'
64
+ option :n, banner: 'CONTA', type: :numeric, default: 0, desc: 'conta destino (0 auto,1 corrente,2 cartao,3 chash,> outras)'
65
+ option :v, banner: 'DATA', default: '', desc: 'data lancamento para movimentos a carregar'
64
66
  option :g, banner: 'TAG', default: '', desc: 'classificacao para movimentos a carregar'
65
67
  # carrega/apaga dados da folha calculo
66
68
  def work
@@ -70,10 +72,11 @@ module Abank
70
72
  end
71
73
 
72
74
  desc 'show', 'mostra dados da folha calculo'
75
+ option :n, banner: 'CONTA', type: :numeric, default: 0, desc: 'conta destino (0 auto,1 corrente,2 cartao,3 chash,> outras)'
73
76
  # mostra folha calculo
74
77
  def show
75
78
  Dir.glob("#{DR}/*.xlsx").each do |file|
76
- Folha.new(options.merge(f: file)).processa_xls
79
+ Folha.new(options.transform_keys(&:to_sym).merge(f: file)).processa_xls
77
80
  end
78
81
  end
79
82
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-12 00:00:00.000000000 Z
10
+ date: 2025-03-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
199
  requirements: []
200
- rubygems_version: 3.6.3
200
+ rubygems_version: 3.6.5
201
201
  specification_version: 4
202
202
  summary: Arquiva movimentos conta-corrente, conta-cartao do activobank no bigquery.
203
203
  test_files: []