abank 0.4.9 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6226a5dfabceca906dc4184df86a56a73e0011bed42f585d32b6670611c45079
4
- data.tar.gz: 3553914f765583d647c71adfa780ec1c0d5cb82d374d19364be04401ab471aa4
3
+ metadata.gz: 89ef46f10e2a27d3ec0b07cec44c409b5ccc8657becb08c797c3593ac0c34d01
4
+ data.tar.gz: bee920d33a78383e41b836326bc0d18e32ea5040fa3580f7fe6d0abfd59779b8
5
5
  SHA512:
6
- metadata.gz: 1f5b4022cc832335806b74273b2ddc2a5201ed6cf42b0c19fc3c9993cc1c9903b7a33fa66a7e1eb1f29da6f1ed55b88dccef31a1904ce8c9e52501521c4cae51
7
- data.tar.gz: c78f07a0573bd68e4368ea4c5488812a1074c1c7857091199095faef8470db3c460501027f333ed25e65cff4deef03c916c07dcf7414d46b0698a8d12c5457dd
6
+ metadata.gz: 62d1e5e44883182033f530ad970dda63f66cf72b0b3ae677a297ef8a8f73b02e9627ef6b125ad49dfc8382e6ad218bd95cf6659b8b166e8c1d16112878a3ba46
7
+ data.tar.gz: f64f197e84c2d49e80874771555da87d4af3a0f42b63e120024603a259fa1e9f065fee6eafc0be376a8190e6e361face9f26e57cb7393f0143b5813bc9239ac8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abank (0.4.9)
4
+ abank (0.5.0)
5
5
  google-cloud-bigquery
6
6
  roo
7
7
  thor
@@ -110,7 +110,7 @@ GEM
110
110
  racc (~> 1.4)
111
111
  os (1.1.4)
112
112
  parallel (1.26.3)
113
- parser (3.3.6.0)
113
+ parser (3.3.7.0)
114
114
  ast (~> 2.4.1)
115
115
  racc
116
116
  public_suffix (6.0.1)
data/lib/abank/big.rb CHANGED
@@ -54,10 +54,8 @@ module Abank
54
54
  @ctlct = []
55
55
  unless mvkys.empty?
56
56
  # obtem lista contratos arrendamento associados aos movimentos a apagar
57
- @ctlct = sql("select distinct ct from #{BD}.mv where #{BD}.ky(dl,dv,ds,vl,nc) in(#{mvkys}) and substr(ct,1,1)='r'")
57
+ @ctlct = sql("select distinct ct from #{BD}.gmc where #{BD}.ky(dl,dv,ds,vl,nc) in(#{mvkys})")
58
58
 
59
- # apaga todas as rendas dos contratos arrendamento associados aos movimentos a apagar
60
- opcao[:t] = true unless ctlct.empty?
61
59
  re_apaga.mv_delete_dml
62
60
  end
63
61
  self
@@ -71,9 +69,9 @@ module Abank
71
69
 
72
70
  # (see CLI#tag)
73
71
  def mv_classifica
74
- dml("update #{BD}.mv set mv.ct=tt.nct from (select * from #{BD}.cl) as tt where #{BD}.ky(mv.dl,mv.dv,mv.ds,mv.vl,mv.nc)=tt.ky")
72
+ stp("call #{BD}.uct()")
75
73
  puts("MOVIMENTOS CLASSIFICADOS #{bqnrs}")
76
- @ctlct = sql("select distinct ct from #{BD}.re") if bqnrs.positive?
74
+ @ctlct = sql("select ct from #{BD}.ca") if bqnrs.positive?
77
75
  self
78
76
  end
79
77
 
@@ -93,7 +91,7 @@ module Abank
93
91
  # @return [Boolean] contrato arrendamento ja existe sim/nao?
94
92
  def ct_existe?
95
93
  @ctlct = [{ ct: opcao[:c] }]
96
- vaz = sql("select ct from #{BD}.re where ct in(#{str_lc}) and cnt=0").empty?
94
+ vaz = sql("select ct from #{BD}.ca where ct in(#{str_lc})").empty?
97
95
  unless vaz
98
96
  @bqnrs = 1
99
97
  puts('CONTRATO JA EXISTE')
@@ -147,14 +145,12 @@ module Abank
147
145
 
148
146
  # @return [String] sql para obter ultima renda do contrato arrendamento
149
147
  def sql_last_re
150
- 'select r1.ct,r0.dl dc,r1.ano,r1.cnt,r1.dl,CAST(REGEXP_EXTRACT(r1.ct,r"\d+") as numeric)/100 vr '\
151
- "from #{BD}.re r1 join hernanilr.ab.re r0 on (r0.ct=r1.ct and r0.cnt=0)"\
152
- " where r1.ct='#{opcao[:c]}' order by r1.ano desc,r1.cnt desc limit 1"
148
+ "select * from #{BD}.glr where ct='#{opcao[:c]}' order by ano desc,cnt desc limit 1"
153
149
  end
154
150
 
155
151
  # @return [String] sql para obter movimentos novos (depois da ultima renda do contrato arrendamento)
156
152
  def sql_novo_mv(mdl)
157
- "select * from #{BD}.mvgem where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by 1,2"
153
+ "select * from #{BD}.gmv where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by 1,2"
158
154
  end
159
155
 
160
156
  # @return [String] sql para obter dados do inicio contrato arrendamento
@@ -172,7 +168,7 @@ module Abank
172
168
  # (see CLI#recriare)
173
169
  def re_atualiza
174
170
  # [re]cria rendas novas/todas dos contratos ativos
175
- @ctlct = sql("select distinct ct from #{BD}.re")
171
+ @ctlct = sql("select ct from #{BD}.ca")
176
172
  re_apaga.ct_dados.re_insert
177
173
  end
178
174
 
@@ -192,7 +188,7 @@ module Abank
192
188
  #
193
189
  # @return [Big] acesso a base dados abank no bigquery
194
190
  def re_apaga
195
- return self if !opcao[:t] || ctlct.empty?
191
+ return self if ctlct.empty?
196
192
 
197
193
  # para nao apagar contrato arrendamento - somente as rendas
198
194
  opcao[:t] = false
@@ -293,5 +289,17 @@ module Abank
293
289
  rescue StandardError
294
290
  @bqnrs = 0
295
291
  end
292
+
293
+ # executa Stored Procedure (STP) with DML operations no bigquery
294
+ #
295
+ # @param (see job)
296
+ # @return [Integer] numero rows afetadas pelo STP
297
+ def stp(cmd)
298
+ # last command STP=SELECT @@row_count AS rows_affected;
299
+ # se job.failed? executa Integer(nil) => StandardError
300
+ @bqnrs = Integer(job(cmd).data.first[:rows_affected])
301
+ rescue StandardError
302
+ @bqnrs = 0
303
+ end
296
304
  end
297
305
  end
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.4.9'
4
+ VERSION = '0.5.0'
5
5
  end
data/lib/abank.rb CHANGED
@@ -53,10 +53,9 @@ module Abank
53
53
  end
54
54
 
55
55
  desc 'recriare', 'atualiza rendas dos contratos ativos'
56
- option :t, type: :boolean, default: false, desc: 'atualiza todas as rendas?'
57
56
  # atualiza rendas dos contratos ativos
58
57
  def recriare
59
- Big.new(options.transform_keys(&:to_sym)).re_atualiza
58
+ Big.new().re_atualiza
60
59
  end
61
60
 
62
61
  desc 'work', 'carrega/apaga dados da folha calculo'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hernâni Rodrigues Vaz