abank 0.7.1 → 0.7.2
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 +4 -4
- data/Gemfile.lock +4 -4
- data/lib/abank/big.rb +10 -10
- data/lib/abank/folha.rb +24 -19
- data/lib/abank/version.rb +1 -1
- 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: 18f8a44c8a32fc138ee5184b0bab2b57608041f74960cba12061cd4e00294e21
|
4
|
+
data.tar.gz: a0278c5241cbed5417f1be08bf7fe0c9f7dd3957c6e059866d5eec2fd5f1512d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad0df9fa07cbacf1e63bf02863d912ce4ebbe963ae3dece73c3d5f61ff07552d848f6625891d7a600452ddc97faf8a816bc69a61099380c359b5f4b0d13ff9f8
|
7
|
+
data.tar.gz: bcb08fcba8e4299d3e87d35cc814c5bda1781c98e0f866fba9f4f9017e5ae33e45c307380747f8916d9ab3565c160f84aad3c6056b15183e60ffc9ffba5bbe1c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
abank (0.7.
|
4
|
+
abank (0.7.2)
|
5
5
|
google-cloud-bigquery
|
6
6
|
roo
|
7
7
|
thor
|
@@ -80,7 +80,7 @@ GEM
|
|
80
80
|
faraday (>= 1.0, < 3.a)
|
81
81
|
google-cloud-errors (1.5.0)
|
82
82
|
google-logging-utils (0.1.0)
|
83
|
-
googleauth (1.
|
83
|
+
googleauth (1.14.0)
|
84
84
|
faraday (>= 1.0, < 3.a)
|
85
85
|
google-cloud-env (~> 2.2)
|
86
86
|
google-logging-utils (~> 0.1)
|
@@ -107,10 +107,10 @@ GEM
|
|
107
107
|
mutex_m (0.3.0)
|
108
108
|
net-http (0.6.0)
|
109
109
|
uri
|
110
|
-
nokogiri (1.18.
|
110
|
+
nokogiri (1.18.4)
|
111
111
|
mini_portile2 (~> 2.8.2)
|
112
112
|
racc (~> 1.4)
|
113
|
-
nokogiri (1.18.
|
113
|
+
nokogiri (1.18.4-x86_64-linux-gnu)
|
114
114
|
racc (~> 1.4)
|
115
115
|
observer (0.1.2)
|
116
116
|
os (1.1.4)
|
data/lib/abank/big.rb
CHANGED
@@ -41,14 +41,14 @@ module Abank
|
|
41
41
|
# @return [Big] acesso a base dados abank no bigquery
|
42
42
|
def mv_delete
|
43
43
|
@ctlct = []
|
44
|
-
return self if mvkys.empty? &&
|
44
|
+
return self if mvkys.empty? && contadel.zero?
|
45
45
|
|
46
46
|
# obtem lista contratos arrendamento associados aos movimentos a apagar
|
47
47
|
@ctlct =
|
48
|
-
if
|
48
|
+
if contadel.zero?
|
49
49
|
sql("select distinct ct from #{BD}.gmr where ky IN UNNEST(@kys)", kys: mvkys)
|
50
50
|
else
|
51
|
-
sql("select distinct ct from #{BD}.gmr where nc=@nc", nc:
|
51
|
+
sql("select distinct ct from #{BD}.gmr where nc=@nc", nc: contadel)
|
52
52
|
end
|
53
53
|
re_apaga
|
54
54
|
mv_delete_dml
|
@@ -125,16 +125,16 @@ module Abank
|
|
125
125
|
|
126
126
|
private
|
127
127
|
|
128
|
-
# @return [Integer] numero conta movimentos apagar
|
129
|
-
def docnt
|
130
|
-
@docnt ||= opcao[:n] > 3 ? opcao[:n] : 0
|
131
|
-
end
|
132
|
-
|
133
128
|
# @return [Google::Cloud::Bigquery] API bigquery
|
134
129
|
def bqapi
|
135
130
|
@bqapi ||= Google::Cloud::Bigquery.new
|
136
131
|
end
|
137
132
|
|
133
|
+
# @return [Integer] numero conta apagar movimentos
|
134
|
+
def contadel
|
135
|
+
@contadel ||= opcao[:n] > 3 ? opcao[:n] : 0
|
136
|
+
end
|
137
|
+
|
138
138
|
# @return [String] movimentos a apagar (keysin.mv)
|
139
139
|
def mvkys
|
140
140
|
@mvkys ||= opcao[:k].to_s.scan(/[-+]?\d+/).map(&:to_i)
|
@@ -215,10 +215,10 @@ module Abank
|
|
215
215
|
|
216
216
|
# apaga movimentos no bigquery
|
217
217
|
def mv_delete_dml
|
218
|
-
if
|
218
|
+
if contadel.zero?
|
219
219
|
dml("delete from #{BD}.mv where #{BD}.ky(dl,dv,ds,vl,nc,ex) IN UNNEST(@kys)", kys: mvkys)
|
220
220
|
else
|
221
|
-
dml("delete from #{BD}.mv where nc=@nc", nc:
|
221
|
+
dml("delete from #{BD}.mv where nc=@nc", nc: contadel)
|
222
222
|
end
|
223
223
|
puts("MOVIMENTOS APAGADOS #{bqnrs}")
|
224
224
|
end
|
data/lib/abank/folha.rb
CHANGED
@@ -35,7 +35,7 @@ module Abank
|
|
35
35
|
|
36
36
|
# carrega/mostra folha calculo
|
37
37
|
def processa_xls
|
38
|
-
puts("\n#{
|
38
|
+
puts("\n#{opcao[:f]}")
|
39
39
|
mvs = sql("select * from #{BD}.gmv where nc=@nc", nc: conta).group_by { |m| [m[:dl], m[:vl].to_f] }
|
40
40
|
folha.sheet(0).parse(header_search: ['Data Lanc.', 'Data Valor', 'Descrição', 'Valor']) do |r|
|
41
41
|
next unless valid?(r.values)
|
@@ -60,37 +60,47 @@ module Abank
|
|
60
60
|
|
61
61
|
private
|
62
62
|
|
63
|
-
# @return [Roo::Excelx] folha
|
63
|
+
# @return [Roo::Excelx] folha a processar
|
64
64
|
def folha
|
65
65
|
@folha ||= Roo::Spreadsheet.open(opcao[:f])
|
66
66
|
rescue StandardError
|
67
67
|
raise("Erro ao abrir a folha de cálculo: #{opcao[:f]}")
|
68
68
|
end
|
69
69
|
|
70
|
-
# @return [Integer]
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
opcao[:f].match?(/card/i) ? 2 : 1
|
70
|
+
# @return [Integer] multiplicador valores
|
71
|
+
def sig
|
72
|
+
@sig ||= cartao? ? -1 : 1
|
75
73
|
end
|
76
74
|
|
77
75
|
# @example
|
78
|
-
# mov*.xlsx
|
79
|
-
# movCard*.xlsx
|
80
|
-
# opcao[:n]
|
81
|
-
# opcao[:n]
|
82
|
-
# @return [Integer] numero conta
|
76
|
+
# mov*.xlsx 1 --> corrente
|
77
|
+
# movCard*.xlsx 2 --> cartao
|
78
|
+
# opcao[:n] 3 --> cash
|
79
|
+
# opcao[:n] n --> outras
|
80
|
+
# @return [Integer] numero conta
|
83
81
|
def conta
|
84
82
|
@conta ||= fconta
|
85
83
|
end
|
86
84
|
|
85
|
+
# @return [Boolean] folha cartao credito
|
86
|
+
def cartao?
|
87
|
+
opcao[:f].match?(/card/i)
|
88
|
+
end
|
89
|
+
|
90
|
+
# @return [Integer] obter numero conta
|
91
|
+
def fconta
|
92
|
+
return opcao[:n] if opcao[:n] > 2
|
93
|
+
|
94
|
+
cartao? ? 2 : 1
|
95
|
+
end
|
96
|
+
|
87
97
|
# @param [Array] row folha calculo em processamento
|
88
98
|
# @return [Boolean] linha com valores correctos para processar?
|
89
99
|
def valid?(row)
|
90
100
|
return false unless row[0].is_a?(Date) && row[1].is_a?(Date)
|
91
101
|
|
92
102
|
row[2] = row[2].to_s.strip.gsub("'", '').gsub('\\', '') # Descrição
|
93
|
-
row[3] = row[3].to_f *
|
103
|
+
row[3] = row[3].to_f * sig # Valor
|
94
104
|
@rowfc = row
|
95
105
|
true
|
96
106
|
rescue StandardError => e
|
@@ -105,7 +115,7 @@ module Abank
|
|
105
115
|
|
106
116
|
# @return [String] novo texto base formatado para display
|
107
117
|
def lnexi
|
108
|
-
@mvvls << "('#{rowfc[0].iso8601}','#{dvc.iso8601}','#{rowfc[2]}',#{rowfc[3]},#{conta},#{dvc.year},#{dvc.month}
|
118
|
+
@mvvls << "('#{rowfc[0].iso8601}','#{dvc.iso8601}','#{rowfc[2]}',#{rowfc[3]},#{conta},#{dvc.year},#{dvc.month},#{ctc},null,null)"
|
109
119
|
"#{lbase} NOVO"
|
110
120
|
end
|
111
121
|
|
@@ -143,10 +153,5 @@ module Abank
|
|
143
153
|
cmv = opcao[:g].to_s
|
144
154
|
cmv.empty? ? 'null' : "'#{cmv}'"
|
145
155
|
end
|
146
|
-
|
147
|
-
# @return [String] tipo movimento c[redito] ou d[ebito]
|
148
|
-
def tpc
|
149
|
-
rowfc[3].positive? ? 'c' : 'd'
|
150
|
-
end
|
151
156
|
end
|
152
157
|
end
|
data/lib/abank/version.rb
CHANGED