abank 0.4.6 → 0.4.8

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: de10c87be621e35389199acb7ffd3d3cab6108d47e6a4567843498676aa9d406
4
- data.tar.gz: 6522e24a538f2614e149c528e51c136bc4d382e048fedf613ee6c1a2c2a5e5a5
3
+ metadata.gz: a0c532723fa1fdbba391b26c59f6f48348ae894aa3d77e78f8157e48130b868a
4
+ data.tar.gz: b29c85587e6369483bb98c31df0ae3a37dbd3f136b1cd7b86f96d627b7a577d4
5
5
  SHA512:
6
- metadata.gz: ec9e2dccd22fa3a0a1516354069564f6794a678a0cb918d96e28e27bade10435cfe19b42a8795d54a58bf12be331c67427673e7d5bdfe2ed1211997e62e69f87
7
- data.tar.gz: 0ff5bbc6dad1e8bebed8fd0b29dd3a3b3e4ac4f3387e1ae93c8553b7cd6ab01c403bc032dfb3f4c5f741237375a5f20b83af75b9fcba3656dca4e7ea34bb6b66
6
+ metadata.gz: 38b7dc65b7c119aba2f8ca470ed690cabfbf778b5a5d295686194ede2d5327cc58fce5b2e3724ac23f1800aff307ac48829eee23474d64ef05e8712afcb0d88f
7
+ data.tar.gz: 6e6815d2d870ed30711671d6d6aae45cc86ed93c17d6cb054af9e196a8bc6ccb76f3d0074172133d116e338326375df707517da850a59fa652ebbff0eb5550e7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- abank (0.4.6)
4
+ abank (0.4.8)
5
5
  google-cloud-bigquery
6
6
  roo
7
7
  thor
@@ -16,7 +16,7 @@ GEM
16
16
  base64 (0.2.0)
17
17
  benchmark (0.4.0)
18
18
  bigdecimal (3.1.9)
19
- concurrent-ruby (1.3.4)
19
+ concurrent-ruby (1.3.5)
20
20
  declarative (0.0.20)
21
21
  diff-lcs (1.5.1)
22
22
  dry-configurable (1.3.0)
@@ -57,7 +57,7 @@ GEM
57
57
  net-http (>= 0.5.0)
58
58
  google-apis-bigquery_v2 (0.83.0)
59
59
  google-apis-core (>= 0.15.0, < 2.a)
60
- google-apis-core (0.15.1)
60
+ google-apis-core (0.16.0)
61
61
  addressable (~> 2.5, >= 2.5.1)
62
62
  googleauth (~> 1.9)
63
63
  httpclient (>= 2.8.3, < 3.a)
data/lib/abank/big.rb CHANGED
@@ -54,7 +54,7 @@ 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 #{ky_mv} in(#{mvkys}) and substr(ct,1,1)='r'")
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'")
58
58
 
59
59
  # apaga todas as rendas dos contratos arrendamento associados aos movimentos a apagar
60
60
  opcao[:t] = true unless ctlct.empty?
@@ -65,23 +65,18 @@ module Abank
65
65
 
66
66
  # apaga movimentos no bigquery
67
67
  def mv_delete_dml
68
- dml("delete from #{BD}.mv where #{ky_mv} in(#{mvkys})")
68
+ dml("delete from #{BD}.mv where #{BD}.ky(dl,dv,ds,vl,nc) in(#{mvkys})")
69
69
  puts("MOVIMENTOS APAGADOS #{bqnrs}")
70
70
  end
71
71
 
72
72
  # (see CLI#tag)
73
73
  def mv_classifica
74
- dml("update #{BD}.mv set mv.ct=tt.nct from (select * from #{BD}.cl) as tt where #{ky_mv}=tt.ky")
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")
75
75
  puts("MOVIMENTOS CLASSIFICADOS #{bqnrs}")
76
76
  @ctlct = sql("select distinct ct from #{BD}.re") if bqnrs.positive?
77
77
  self
78
78
  end
79
79
 
80
- # @return [String] expressao sql da chave de movimentos
81
- def ky_mv
82
- 'FARM_FINGERPRINT(CONCAT(CAST(mv.nc as STRING),mv.ds,CAST(mv.dl as STRING),CAST(mv.vl as STRING)))'
83
- end
84
-
85
80
  # (see CLI#criact)
86
81
  def ct_cria
87
82
  unless ct_existe?
@@ -119,6 +114,7 @@ module Abank
119
114
  ctlct.map! do |ctr|
120
115
  opcao[:c] = ctr[:ct]
121
116
  lre = sql(sql_last_re)[0]
117
+ lre[:dl] += -1 if lre[:cnt] == 0
122
118
  ctr.merge(lre, mv: sql(sql_novo_mv(lre[:dl])))
123
119
  end
124
120
  self
@@ -152,13 +148,13 @@ module Abank
152
148
  # @return [String] sql para obter ultima renda do contrato arrendamento
153
149
  def sql_last_re
154
150
  'select r1.ct,r0.dl dc,r1.ano,r1.cnt,r1.dl,CAST(REGEXP_EXTRACT(r1.ct,r"\d+") as numeric)/100 vr '\
155
- "from #{BD}.re r1 join hernanilr.ab.re r0 on (r0.ct=r1.ct and r0.cnt=0 and r1.cnt>0)"\
156
- " where r1.ct='#{opcao[:c]}' order by ano desc,cnt desc limit 1"
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"
157
153
  end
158
154
 
159
155
  # @return [String] sql para obter movimentos novos (depois da ultima renda do contrato arrendamento)
160
156
  def sql_novo_mv(mdl)
161
- "select dl,vl from #{BD}.mv where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by dl,dv"
157
+ "select dl,vl from #{BD}.mvgem where ct='#{opcao[:c]}' and dl>='#{(mdl + 1).strftime(DF)}' order by dl,dv"
162
158
  end
163
159
 
164
160
  # @return [String] sql para obter dados do inicio contrato arrendamento
@@ -225,7 +221,7 @@ module Abank
225
221
  def re_proximos_dados
226
222
  # valor renda paga retirada do movimento
227
223
  re_atual_mv[:vl] -= re_atual[:vr]
228
- dre = cnt.zero? ? Date.new(ano, 1, 1) : Date.new(ano, cnt, 1) >> 1
224
+ dre = cnt.zero? ? Date.new(re_atual[:dc].year, re_atual[:dc].month, 1) : Date.new(ano, cnt, 1) >> 1
229
225
  re_atual.merge!(ano: dre.year, cnt: dre.month)
230
226
  end
231
227
 
@@ -262,7 +258,7 @@ module Abank
262
258
 
263
259
  # @return [Integer] dias atraso/antecipo neste pagamento renda
264
260
  def dias
265
- re_atual_mv[:dl].mjd - (Date.new(ano, cnt, 1) >> (re_atual[:dc].month - 1)).mjd
261
+ re_atual_mv[:dl].mjd - Date.new(ano, cnt, 1).mjd
266
262
  end
267
263
 
268
264
  # @param [String] cmd comando a executar
data/lib/abank/folha.rb CHANGED
@@ -147,7 +147,7 @@ module Abank
147
147
 
148
148
  # @return [String] sql para movimentos no bigquery
149
149
  def sql_existe_mv
150
- "select *,#{ky_mv} as ky from #{BD}.mv where nc=#{conta} and dl='#{rowfc[0].strftime(DF)}' and vl=#{rowfc[3]}"
150
+ "select *,#{BD}.ky(dl,dv,ds,vl,nc) ky from #{BD}.mv where nc=#{conta} and dl='#{rowfc[0].strftime(DF)}' and vl=#{rowfc[3]}"
151
151
  end
152
152
 
153
153
  # obtem movimento (values.mv) para inserir
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.6'
4
+ VERSION = '0.4.8'
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.4.6
4
+ version: 0.4.8
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-14 00:00:00.000000000 Z
11
+ date: 2025-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler