abank 0.4.9 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/abank/big.rb +20 -12
- data/lib/abank/version.rb +1 -1
- data/lib/abank.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89ef46f10e2a27d3ec0b07cec44c409b5ccc8657becb08c797c3593ac0c34d01
|
4
|
+
data.tar.gz: bee920d33a78383e41b836326bc0d18e32ea5040fa3580f7fe6d0abfd59779b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
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.
|
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}.
|
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
|
-
|
72
|
+
stp("call #{BD}.uct()")
|
75
73
|
puts("MOVIMENTOS CLASSIFICADOS #{bqnrs}")
|
76
|
-
@ctlct = sql("select
|
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}.
|
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
|
-
|
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}.
|
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
|
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
|
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
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(
|
58
|
+
Big.new().re_atualiza
|
60
59
|
end
|
61
60
|
|
62
61
|
desc 'work', 'carrega/apaga dados da folha calculo'
|