abank 0.4.9 → 0.5.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: 6226a5dfabceca906dc4184df86a56a73e0011bed42f585d32b6670611c45079
4
- data.tar.gz: 3553914f765583d647c71adfa780ec1c0d5cb82d374d19364be04401ab471aa4
3
+ metadata.gz: 3bc90d0c9f03e14c34aa29f1074c8bd7e2a121eb787ed59cb38d31924e451142
4
+ data.tar.gz: ced118cd77e31d81076ca49dc1e9dcb4818f6084f622a8e1421540f335bfc40d
5
5
  SHA512:
6
- metadata.gz: 1f5b4022cc832335806b74273b2ddc2a5201ed6cf42b0c19fc3c9993cc1c9903b7a33fa66a7e1eb1f29da6f1ed55b88dccef31a1904ce8c9e52501521c4cae51
7
- data.tar.gz: c78f07a0573bd68e4368ea4c5488812a1074c1c7857091199095faef8470db3c460501027f333ed25e65cff4deef03c916c07dcf7414d46b0698a8d12c5457dd
6
+ metadata.gz: 857c60ec90b359cebe6f52430a09f26dfeaecb749d7b821412b2c10cae48263951274030bd4309e5050fe8aa7f512cc337ea30788af63750d1f6cfdf035fd256
7
+ data.tar.gz: c2df0dcc9476ef6255ce86266c600c3dee53e4177570e15bdb9af906426063fe8a376b50dbf8d3ffed58d84fd805a2f329268ddb441852aee69284b00ccb7f40
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.1)
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}.gmr 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,10 @@ 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
+ @ctlct = []
73
+ stp("call #{BD}.uct()")
75
74
  puts("MOVIMENTOS CLASSIFICADOS #{bqnrs}")
76
- @ctlct = sql("select distinct ct from #{BD}.re") if bqnrs.positive?
75
+ @ctlct = sql("select ct from #{BD}.ca") if bqnrs.positive?
77
76
  self
78
77
  end
79
78
 
@@ -93,7 +92,7 @@ module Abank
93
92
  # @return [Boolean] contrato arrendamento ja existe sim/nao?
94
93
  def ct_existe?
95
94
  @ctlct = [{ ct: opcao[:c] }]
96
- vaz = sql("select ct from #{BD}.re where ct in(#{str_lc}) and cnt=0").empty?
95
+ vaz = sql("select ct from #{BD}.ca where ct in(#{str_lc})").empty?
97
96
  unless vaz
98
97
  @bqnrs = 1
99
98
  puts('CONTRATO JA EXISTE')
@@ -147,14 +146,12 @@ module Abank
147
146
 
148
147
  # @return [String] sql para obter ultima renda do contrato arrendamento
149
148
  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"
149
+ "select * from #{BD}.glr where ct='#{opcao[:c]}' order by ano desc,cnt desc limit 1"
153
150
  end
154
151
 
155
152
  # @return [String] sql para obter movimentos novos (depois da ultima renda do contrato arrendamento)
156
153
  def sql_novo_mv(mdl)
157
- "select * from #{BD}.mvgem where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by 1,2"
154
+ "select * from #{BD}.gmn where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by 1,2"
158
155
  end
159
156
 
160
157
  # @return [String] sql para obter dados do inicio contrato arrendamento
@@ -172,7 +169,7 @@ module Abank
172
169
  # (see CLI#recriare)
173
170
  def re_atualiza
174
171
  # [re]cria rendas novas/todas dos contratos ativos
175
- @ctlct = sql("select distinct ct from #{BD}.re")
172
+ @ctlct = sql("select ct from #{BD}.ca")
176
173
  re_apaga.ct_dados.re_insert
177
174
  end
178
175
 
@@ -192,7 +189,7 @@ module Abank
192
189
  #
193
190
  # @return [Big] acesso a base dados abank no bigquery
194
191
  def re_apaga
195
- return self if !opcao[:t] || ctlct.empty?
192
+ return self if ctlct.empty?
196
193
 
197
194
  # para nao apagar contrato arrendamento - somente as rendas
198
195
  opcao[:t] = false
@@ -293,5 +290,17 @@ module Abank
293
290
  rescue StandardError
294
291
  @bqnrs = 0
295
292
  end
293
+
294
+ # executa Stored Procedure (STP) with DML operations no bigquery
295
+ #
296
+ # @param (see job)
297
+ # @return [Integer] numero rows afetadas pelo STP
298
+ def stp(cmd)
299
+ # last command STP=SELECT @@row_count AS rows_affected;
300
+ # se job.failed? executa Integer(nil) => StandardError
301
+ @bqnrs = Integer(job(cmd).data.first[:rows_affected])
302
+ rescue StandardError
303
+ @bqnrs = 0
304
+ end
296
305
  end
297
306
  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.1'
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,14 +1,14 @@
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.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: 2025-01-16 00:00:00.000000000 Z
11
+ date: 2025-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler