pais_legacy 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pais_legacy/version.rb +1 -1
- data/lib/pais_legacy.rb +81 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f69175d350cb7e66382799b7fe36e26161394599e0060abb5139019ddfd165
|
4
|
+
data.tar.gz: 900892b5404050052d8e3963f3e31be6c0ea843ccd6ab27b289ac19ef0c36ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02f01d3ffd046c32215fde925367e8aee9b59f844c018e515fed8646cd25c225ba66272a125d100d88d1c900b55620f15e0506a58a18a3cbbdc1f35715d4230a
|
7
|
+
data.tar.gz: 7d3aff622d67f4a4f44cfc159513733303aa7997542420c718ea86a33b615d0b2413d8d84e1d97a12e1dbb6d7a24d89fb0b8ffa9b8dfc3fdbe9fb2cac8a855ad
|
data/lib/pais_legacy/version.rb
CHANGED
data/lib/pais_legacy.rb
CHANGED
@@ -4,6 +4,8 @@ require 'date'
|
|
4
4
|
require 'json' # Output
|
5
5
|
require "open3" # File I/O
|
6
6
|
require 'pastel' # TTY Color
|
7
|
+
require 'net/ssh'
|
8
|
+
require 'byebug'
|
7
9
|
|
8
10
|
require_relative "pais_legacy/trial_balance"
|
9
11
|
require_relative "pais_legacy/version"
|
@@ -18,6 +20,45 @@ module PaisLegacy
|
|
18
20
|
CLEARING_ACCOUNT=5199
|
19
21
|
TB_DIRECT_ACCOUNT=8999
|
20
22
|
|
23
|
+
def self.execute_ssh_command(command)
|
24
|
+
output = ""
|
25
|
+
|
26
|
+
# Start an SSH session
|
27
|
+
Net::SSH.start(SERVER) do |ssh|
|
28
|
+
# Open a new SSH channel
|
29
|
+
ssh.open_channel do |channel|
|
30
|
+
# Request a pseudo-tty
|
31
|
+
channel.request_pty do |ch, success|
|
32
|
+
raise "Could not obtain pty" unless success
|
33
|
+
|
34
|
+
# Execute the command
|
35
|
+
ch.exec(command) do |ch, success|
|
36
|
+
raise "Could not execute command" unless success
|
37
|
+
|
38
|
+
# Collect the data received from the command's standard output
|
39
|
+
ch.on_data do |c, data|
|
40
|
+
output += data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Collect the data received from the command's standard error
|
44
|
+
ch.on_extended_data do |c, type, data|
|
45
|
+
output += "stderr: #{data}"
|
46
|
+
end
|
47
|
+
|
48
|
+
ch.on_close do
|
49
|
+
puts "Command execution finished"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Keep the session open until the command execution is finished
|
56
|
+
ssh.loop
|
57
|
+
end
|
58
|
+
|
59
|
+
output
|
60
|
+
end
|
61
|
+
|
21
62
|
# --------------------------------------------------------------------------------
|
22
63
|
# Client
|
23
64
|
# --------------------------------------------------------------------------------
|
@@ -30,7 +71,7 @@ module PaisLegacy
|
|
30
71
|
end
|
31
72
|
|
32
73
|
def self.clfi_read(client=nil)
|
33
|
-
out
|
74
|
+
out=execute_ssh_command(clfi_read_cmd(client.to_s))
|
34
75
|
JSON.parse(out)
|
35
76
|
end
|
36
77
|
|
@@ -46,7 +87,9 @@ module PaisLegacy
|
|
46
87
|
end
|
47
88
|
|
48
89
|
def self.glfi_read(ledger=nil)
|
49
|
-
out,
|
90
|
+
# out,stderr,status=Open3.capture2(glfi_read_cmd(ledger.to_s))
|
91
|
+
out=execute_ssh_command(glfi_read_cmd(ledger.to_s))
|
92
|
+
|
50
93
|
JSON.parse(out)
|
51
94
|
end
|
52
95
|
|
@@ -58,7 +101,7 @@ module PaisLegacy
|
|
58
101
|
end
|
59
102
|
|
60
103
|
def self.glch_read(ledger)
|
61
|
-
# out
|
104
|
+
# out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
62
105
|
# out.
|
63
106
|
# split("\n").
|
64
107
|
# map{|line| line.split(",")}.
|
@@ -67,7 +110,8 @@ module PaisLegacy
|
|
67
110
|
end
|
68
111
|
|
69
112
|
def self.glch_read_all(ledger)
|
70
|
-
|
113
|
+
puts glch_read_cmd(ledger.to_s)
|
114
|
+
out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
71
115
|
JSON.parse(out)
|
72
116
|
end
|
73
117
|
|
@@ -76,15 +120,17 @@ module PaisLegacy
|
|
76
120
|
def self.raw(params,program="rdefi00a")
|
77
121
|
params = params.gsub(" "," \\")
|
78
122
|
|
79
|
-
cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
80
|
-
|
123
|
+
# cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
124
|
+
cmd = fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' '
|
125
|
+
|
126
|
+
out=execute_ssh_command(cmd)
|
81
127
|
[out]
|
82
128
|
end
|
83
129
|
|
84
130
|
def self.raw_zsh(params,program="rdefi00a")
|
85
131
|
params = params.gsub(" "," \\")
|
86
132
|
|
87
|
-
cmd = 'zsh -c "'+ fglgo("rptrun") +'
|
133
|
+
cmd = 'zsh -c "'+ fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' "'
|
88
134
|
stdout, stderr, status_=Open3.capture3(cmd)
|
89
135
|
[stdout]
|
90
136
|
end
|
@@ -100,7 +146,7 @@ module PaisLegacy
|
|
100
146
|
date_to = Date.parse("30/06/#{date_to.year}")
|
101
147
|
date_from = Date.parse("01/07/#{date_to.year - 1}")
|
102
148
|
|
103
|
-
cmd =
|
149
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \2 \1 \2 \3 \4 \5 \{{date_from}} \{{date_to}} \' '
|
104
150
|
.gsub("{{program}}",program)
|
105
151
|
.gsub("{{printer}}","SCREEN")
|
106
152
|
.gsub("{{ccode}}","T1")
|
@@ -112,7 +158,7 @@ module PaisLegacy
|
|
112
158
|
.gsub("{{report_type}}","1")
|
113
159
|
.gsub("{{subaccs}}","N")
|
114
160
|
|
115
|
-
out
|
161
|
+
out=execute_ssh_command(cmd)
|
116
162
|
[out]
|
117
163
|
end
|
118
164
|
|
@@ -126,7 +172,7 @@ module PaisLegacy
|
|
126
172
|
program="rglch01a"
|
127
173
|
end
|
128
174
|
|
129
|
-
cmd =
|
175
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \{{account_from}} \{{account_to}} \{{date}}\ \1 \N\' '
|
130
176
|
.gsub("{{program}}",program)
|
131
177
|
.gsub("{{printer}}","SCREEN")
|
132
178
|
.gsub("{{ccode}}","T1")
|
@@ -137,7 +183,7 @@ module PaisLegacy
|
|
137
183
|
.gsub("{{report_type}}","1")
|
138
184
|
.gsub("{{subaccs}}","N")
|
139
185
|
|
140
|
-
out
|
186
|
+
out=execute_ssh_command(cmd)
|
141
187
|
|
142
188
|
# if from and to
|
143
189
|
# out.split("\n").each_with_index do |line,index|
|
@@ -217,7 +263,11 @@ module PaisLegacy
|
|
217
263
|
end
|
218
264
|
|
219
265
|
def self.pais_api(file,ledger,options="")
|
220
|
-
ssh + ' "bash -c \"' + fglgo(file) + ' {{ccode}} {{ledger}} {{options}}\""'
|
266
|
+
# ssh + ' "bash -c \"' + fglgo(file) + ' {{ccode}} {{ledger}} {{options}}\""'
|
267
|
+
# .gsub("{{ccode}}","T1")
|
268
|
+
# .gsub("{{ledger}}",ledger.to_s)
|
269
|
+
# .gsub("{{options}}",options)
|
270
|
+
fglgo(file) + ' {{ccode}} {{ledger}} {{options}}'
|
221
271
|
.gsub("{{ccode}}","T1")
|
222
272
|
.gsub("{{ledger}}",ledger.to_s)
|
223
273
|
.gsub("{{options}}",options)
|
@@ -228,18 +278,18 @@ module PaisLegacy
|
|
228
278
|
end
|
229
279
|
|
230
280
|
def self.lasttrnno_read(ledger)
|
231
|
-
out
|
281
|
+
out=execute_ssh_command(lasttrnno_read_cmd(ledger.to_s))
|
232
282
|
out.strip
|
233
283
|
end
|
234
284
|
|
235
285
|
def self.gltr_read_all(ledger,start_date,end_date)
|
236
|
-
cmd=
|
286
|
+
cmd=fglgo("gltr_read") + ' {{ccode}} {{ledger}} {{start_date}} {{end_date}}'
|
237
287
|
.gsub("{{ccode}}","T1")
|
238
288
|
.gsub("{{ledger}}",ledger.to_s)
|
239
289
|
.gsub("{{start_date}}",start_date)
|
240
290
|
.gsub("{{end_date}}",end_date)
|
241
291
|
|
242
|
-
out
|
292
|
+
out=execute_ssh_command(cmd)
|
243
293
|
JSON.parse(out)
|
244
294
|
end
|
245
295
|
|
@@ -259,7 +309,7 @@ module PaisLegacy
|
|
259
309
|
# Example of P&L for ledger 336 with 2 periods
|
260
310
|
# '\SCREEN \T1 \336 \spar \N \2 \1 \Y \3 \4 \5 \N \01/07/2021 \30/06/2022 \N \ALL \ALL \N \2'
|
261
311
|
def self.rptrun(ledger,date_to,from="0001",to="9999",program="rglch01a")
|
262
|
-
|
312
|
+
fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \{{account_from}} \{{account_to}} \1 \{{report_type}} \{{subaccs}} \{{date}}\' N'
|
263
313
|
.gsub("{{program}}",program)
|
264
314
|
.gsub("{{printer}}","SCREEN")
|
265
315
|
.gsub("{{ccode}}","T1")
|
@@ -288,7 +338,7 @@ module PaisLegacy
|
|
288
338
|
end
|
289
339
|
|
290
340
|
def self.common_ledger_date(cmd,ledger,end_date)
|
291
|
-
cmd=
|
341
|
+
cmd=fglgo(cmd) + ' {{ccode}} {{ledger}} {{end_date}}'
|
292
342
|
.gsub("{{ccode}}","T1")
|
293
343
|
.gsub("{{ledger}}",ledger.to_s)
|
294
344
|
.gsub("{{end_date}}",end_date)
|
@@ -309,13 +359,13 @@ module PaisLegacy
|
|
309
359
|
# Invoice related
|
310
360
|
# --------------------------------------------------------------------------------
|
311
361
|
def legacy_import_invoices(ledger,date)
|
312
|
-
cmd=PaisLegacy::Pais.
|
362
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}}'
|
313
363
|
.gsub("{{ccode}}","T1")
|
314
364
|
.gsub("{{ledger}}",ledger.to_s)
|
315
365
|
.gsub("{{date}}",date)
|
316
366
|
|
317
367
|
puts cmd
|
318
|
-
out
|
368
|
+
out=execute_ssh_command(cmd)
|
319
369
|
out.delete!("\\\\")
|
320
370
|
begin
|
321
371
|
out = JSON.parse(out)
|
@@ -332,7 +382,7 @@ module PaisLegacy
|
|
332
382
|
|
333
383
|
date = Date.parse(date).strftime("%d/%m/%Y")
|
334
384
|
|
335
|
-
cmd=PaisLegacy::Pais.
|
385
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}} {{inv_no}} {{client}}'
|
336
386
|
.gsub("{{ccode}}","T1")
|
337
387
|
.gsub("{{ledger}}",ledger.to_s)
|
338
388
|
.gsub("{{date}}",date)
|
@@ -340,7 +390,7 @@ module PaisLegacy
|
|
340
390
|
.gsub("{{client}}",client)
|
341
391
|
|
342
392
|
puts cmd
|
343
|
-
out
|
393
|
+
out=execute_ssh_command(cmd)
|
344
394
|
|
345
395
|
begin
|
346
396
|
out = JSON.parse(out)
|
@@ -366,21 +416,21 @@ module PaisLegacy
|
|
366
416
|
# --------------------------------------------------------------------------------
|
367
417
|
|
368
418
|
def self.table_indexes_cmd(table)
|
369
|
-
|
419
|
+
fglgo("db") + ' indexes'
|
370
420
|
end
|
371
421
|
|
372
422
|
def self.table_indexes(table)
|
373
|
-
out
|
423
|
+
out=execute_ssh_command(table_indexes_cmd(table))
|
374
424
|
out.split("\n").select{|i| i =~ /^#{table}_/}
|
375
425
|
end
|
376
426
|
|
377
427
|
def self.table_schema_cmd(table)
|
378
|
-
|
428
|
+
fglgo("db") + ' schema {{table}}'
|
379
429
|
.gsub("{{table}}",table)
|
380
430
|
end
|
381
431
|
|
382
432
|
def self.table_schema_raw(table)
|
383
|
-
out
|
433
|
+
out=execute_ssh_command(table_schema_cmd(table))
|
384
434
|
out.split("\n")
|
385
435
|
end
|
386
436
|
|
@@ -392,12 +442,12 @@ module PaisLegacy
|
|
392
442
|
end
|
393
443
|
|
394
444
|
def self.table_data_cmd(table)
|
395
|
-
|
445
|
+
fglgo("db") + ' data {{table}}'
|
396
446
|
.gsub("{{table}}",table)
|
397
447
|
end
|
398
448
|
|
399
449
|
def self.table_data_raw(table)
|
400
|
-
out
|
450
|
+
out=execute_ssh_command(table_data_cmd(table))
|
401
451
|
out.split("\n")
|
402
452
|
end
|
403
453
|
|
@@ -416,20 +466,20 @@ module PaisLegacy
|
|
416
466
|
end
|
417
467
|
|
418
468
|
def self.table_unload_cmd(table)
|
419
|
-
|
469
|
+
fglgo("db") + ' unload {{table}}'
|
420
470
|
.gsub("{{table}}",table)
|
421
471
|
end
|
422
472
|
|
423
473
|
def self.table_unload(table)
|
424
|
-
out
|
474
|
+
out=execute_ssh_command(table_unload_cmd(table))
|
425
475
|
end
|
426
476
|
|
427
477
|
def self.tables_cmd
|
428
|
-
|
478
|
+
fglgo("db") + ' tables'
|
429
479
|
end
|
430
480
|
|
431
481
|
def self.tables
|
432
|
-
out
|
482
|
+
out=execute_ssh_command(tables_cmd)
|
433
483
|
out.split("\n")
|
434
484
|
end
|
435
485
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pais_legacy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|