pais_legacy 2.6.0 → 2.6.2
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 +84 -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: aa61d63746b222710a2eb2c0924b52ce25dca218dee63ba6d45f6b1ab75c6881
|
4
|
+
data.tar.gz: aededfd5890f10cff78f8172322985cbb207c5f8e143ed99157b58489624d2a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e9139de47550f1af4a450bc9bf15f17b7f53dd12d64f2650636eb381d41c6a4e779b4cb9500b0467c58940a1d9a57d680192b620e857a645b5f49055acb701
|
7
|
+
data.tar.gz: 035f50c5c12e7ca7625e1b56bb9a594b22d83abc346ac2a35c3cba71768b9fd1fa625b3aa3a409f53459f4ee0d89fcecf75a401fd3d8cbec0f24356ffb995956
|
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"
|
@@ -14,10 +16,52 @@ module PaisLegacy
|
|
14
16
|
class Pais
|
15
17
|
#SERVER="192.168.200.4"
|
16
18
|
SERVER="pais.com.au"
|
19
|
+
USER="map7"
|
20
|
+
KEY="/home/map7/.ssh/id_rsa"
|
21
|
+
|
17
22
|
SUSPENSE_ACCOUNT=1599
|
18
23
|
CLEARING_ACCOUNT=5199
|
19
24
|
TB_DIRECT_ACCOUNT=8999
|
20
25
|
|
26
|
+
def self.execute_ssh_command(command)
|
27
|
+
output = ""
|
28
|
+
|
29
|
+
# Start an SSH session
|
30
|
+
Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
|
31
|
+
# Open a new SSH channel
|
32
|
+
ssh.open_channel do |channel|
|
33
|
+
# Request a pseudo-tty
|
34
|
+
channel.request_pty do |ch, success|
|
35
|
+
raise "Could not obtain pty" unless success
|
36
|
+
|
37
|
+
# Execute the command
|
38
|
+
ch.exec(command) do |ch, success|
|
39
|
+
raise "Could not execute command" unless success
|
40
|
+
|
41
|
+
# Collect the data received from the command's standard output
|
42
|
+
ch.on_data do |c, data|
|
43
|
+
output += data
|
44
|
+
end
|
45
|
+
|
46
|
+
# Collect the data received from the command's standard error
|
47
|
+
ch.on_extended_data do |c, type, data|
|
48
|
+
output += "stderr: #{data}"
|
49
|
+
end
|
50
|
+
|
51
|
+
ch.on_close do
|
52
|
+
puts "Command execution finished"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Keep the session open until the command execution is finished
|
59
|
+
ssh.loop
|
60
|
+
end
|
61
|
+
|
62
|
+
output
|
63
|
+
end
|
64
|
+
|
21
65
|
# --------------------------------------------------------------------------------
|
22
66
|
# Client
|
23
67
|
# --------------------------------------------------------------------------------
|
@@ -30,7 +74,7 @@ module PaisLegacy
|
|
30
74
|
end
|
31
75
|
|
32
76
|
def self.clfi_read(client=nil)
|
33
|
-
out
|
77
|
+
out=execute_ssh_command(clfi_read_cmd(client.to_s))
|
34
78
|
JSON.parse(out)
|
35
79
|
end
|
36
80
|
|
@@ -46,7 +90,9 @@ module PaisLegacy
|
|
46
90
|
end
|
47
91
|
|
48
92
|
def self.glfi_read(ledger=nil)
|
49
|
-
out,
|
93
|
+
# out,stderr,status=Open3.capture2(glfi_read_cmd(ledger.to_s))
|
94
|
+
out=execute_ssh_command(glfi_read_cmd(ledger.to_s))
|
95
|
+
|
50
96
|
JSON.parse(out)
|
51
97
|
end
|
52
98
|
|
@@ -58,7 +104,7 @@ module PaisLegacy
|
|
58
104
|
end
|
59
105
|
|
60
106
|
def self.glch_read(ledger)
|
61
|
-
# out
|
107
|
+
# out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
62
108
|
# out.
|
63
109
|
# split("\n").
|
64
110
|
# map{|line| line.split(",")}.
|
@@ -67,7 +113,8 @@ module PaisLegacy
|
|
67
113
|
end
|
68
114
|
|
69
115
|
def self.glch_read_all(ledger)
|
70
|
-
|
116
|
+
puts glch_read_cmd(ledger.to_s)
|
117
|
+
out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
71
118
|
JSON.parse(out)
|
72
119
|
end
|
73
120
|
|
@@ -76,15 +123,17 @@ module PaisLegacy
|
|
76
123
|
def self.raw(params,program="rdefi00a")
|
77
124
|
params = params.gsub(" "," \\")
|
78
125
|
|
79
|
-
cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
80
|
-
|
126
|
+
# cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
127
|
+
cmd = fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' '
|
128
|
+
|
129
|
+
out=execute_ssh_command(cmd)
|
81
130
|
[out]
|
82
131
|
end
|
83
132
|
|
84
133
|
def self.raw_zsh(params,program="rdefi00a")
|
85
134
|
params = params.gsub(" "," \\")
|
86
135
|
|
87
|
-
cmd = 'zsh -c "'+ fglgo("rptrun") +'
|
136
|
+
cmd = 'zsh -c "'+ fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' "'
|
88
137
|
stdout, stderr, status_=Open3.capture3(cmd)
|
89
138
|
[stdout]
|
90
139
|
end
|
@@ -100,7 +149,7 @@ module PaisLegacy
|
|
100
149
|
date_to = Date.parse("30/06/#{date_to.year}")
|
101
150
|
date_from = Date.parse("01/07/#{date_to.year - 1}")
|
102
151
|
|
103
|
-
cmd =
|
152
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \2 \1 \2 \3 \4 \5 \{{date_from}} \{{date_to}} \' '
|
104
153
|
.gsub("{{program}}",program)
|
105
154
|
.gsub("{{printer}}","SCREEN")
|
106
155
|
.gsub("{{ccode}}","T1")
|
@@ -112,7 +161,7 @@ module PaisLegacy
|
|
112
161
|
.gsub("{{report_type}}","1")
|
113
162
|
.gsub("{{subaccs}}","N")
|
114
163
|
|
115
|
-
out
|
164
|
+
out=execute_ssh_command(cmd)
|
116
165
|
[out]
|
117
166
|
end
|
118
167
|
|
@@ -126,7 +175,7 @@ module PaisLegacy
|
|
126
175
|
program="rglch01a"
|
127
176
|
end
|
128
177
|
|
129
|
-
cmd =
|
178
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \{{account_from}} \{{account_to}} \{{date}}\ \1 \N\' '
|
130
179
|
.gsub("{{program}}",program)
|
131
180
|
.gsub("{{printer}}","SCREEN")
|
132
181
|
.gsub("{{ccode}}","T1")
|
@@ -137,7 +186,7 @@ module PaisLegacy
|
|
137
186
|
.gsub("{{report_type}}","1")
|
138
187
|
.gsub("{{subaccs}}","N")
|
139
188
|
|
140
|
-
out
|
189
|
+
out=execute_ssh_command(cmd)
|
141
190
|
|
142
191
|
# if from and to
|
143
192
|
# out.split("\n").each_with_index do |line,index|
|
@@ -217,7 +266,11 @@ module PaisLegacy
|
|
217
266
|
end
|
218
267
|
|
219
268
|
def self.pais_api(file,ledger,options="")
|
220
|
-
ssh + ' "bash -c \"' + fglgo(file) + ' {{ccode}} {{ledger}} {{options}}\""'
|
269
|
+
# ssh + ' "bash -c \"' + fglgo(file) + ' {{ccode}} {{ledger}} {{options}}\""'
|
270
|
+
# .gsub("{{ccode}}","T1")
|
271
|
+
# .gsub("{{ledger}}",ledger.to_s)
|
272
|
+
# .gsub("{{options}}",options)
|
273
|
+
fglgo(file) + ' {{ccode}} {{ledger}} {{options}}'
|
221
274
|
.gsub("{{ccode}}","T1")
|
222
275
|
.gsub("{{ledger}}",ledger.to_s)
|
223
276
|
.gsub("{{options}}",options)
|
@@ -228,18 +281,18 @@ module PaisLegacy
|
|
228
281
|
end
|
229
282
|
|
230
283
|
def self.lasttrnno_read(ledger)
|
231
|
-
out
|
284
|
+
out=execute_ssh_command(lasttrnno_read_cmd(ledger.to_s))
|
232
285
|
out.strip
|
233
286
|
end
|
234
287
|
|
235
288
|
def self.gltr_read_all(ledger,start_date,end_date)
|
236
|
-
cmd=
|
289
|
+
cmd=fglgo("gltr_read") + ' {{ccode}} {{ledger}} {{start_date}} {{end_date}}'
|
237
290
|
.gsub("{{ccode}}","T1")
|
238
291
|
.gsub("{{ledger}}",ledger.to_s)
|
239
292
|
.gsub("{{start_date}}",start_date)
|
240
293
|
.gsub("{{end_date}}",end_date)
|
241
294
|
|
242
|
-
out
|
295
|
+
out=execute_ssh_command(cmd)
|
243
296
|
JSON.parse(out)
|
244
297
|
end
|
245
298
|
|
@@ -259,7 +312,7 @@ module PaisLegacy
|
|
259
312
|
# Example of P&L for ledger 336 with 2 periods
|
260
313
|
# '\SCREEN \T1 \336 \spar \N \2 \1 \Y \3 \4 \5 \N \01/07/2021 \30/06/2022 \N \ALL \ALL \N \2'
|
261
314
|
def self.rptrun(ledger,date_to,from="0001",to="9999",program="rglch01a")
|
262
|
-
|
315
|
+
fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \{{account_from}} \{{account_to}} \1 \{{report_type}} \{{subaccs}} \{{date}}\' N'
|
263
316
|
.gsub("{{program}}",program)
|
264
317
|
.gsub("{{printer}}","SCREEN")
|
265
318
|
.gsub("{{ccode}}","T1")
|
@@ -288,7 +341,7 @@ module PaisLegacy
|
|
288
341
|
end
|
289
342
|
|
290
343
|
def self.common_ledger_date(cmd,ledger,end_date)
|
291
|
-
cmd=
|
344
|
+
cmd=fglgo(cmd) + ' {{ccode}} {{ledger}} {{end_date}}'
|
292
345
|
.gsub("{{ccode}}","T1")
|
293
346
|
.gsub("{{ledger}}",ledger.to_s)
|
294
347
|
.gsub("{{end_date}}",end_date)
|
@@ -309,13 +362,13 @@ module PaisLegacy
|
|
309
362
|
# Invoice related
|
310
363
|
# --------------------------------------------------------------------------------
|
311
364
|
def legacy_import_invoices(ledger,date)
|
312
|
-
cmd=PaisLegacy::Pais.
|
365
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}}'
|
313
366
|
.gsub("{{ccode}}","T1")
|
314
367
|
.gsub("{{ledger}}",ledger.to_s)
|
315
368
|
.gsub("{{date}}",date)
|
316
369
|
|
317
370
|
puts cmd
|
318
|
-
out
|
371
|
+
out=execute_ssh_command(cmd)
|
319
372
|
out.delete!("\\\\")
|
320
373
|
begin
|
321
374
|
out = JSON.parse(out)
|
@@ -332,7 +385,7 @@ module PaisLegacy
|
|
332
385
|
|
333
386
|
date = Date.parse(date).strftime("%d/%m/%Y")
|
334
387
|
|
335
|
-
cmd=PaisLegacy::Pais.
|
388
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}} {{inv_no}} {{client}}'
|
336
389
|
.gsub("{{ccode}}","T1")
|
337
390
|
.gsub("{{ledger}}",ledger.to_s)
|
338
391
|
.gsub("{{date}}",date)
|
@@ -340,7 +393,7 @@ module PaisLegacy
|
|
340
393
|
.gsub("{{client}}",client)
|
341
394
|
|
342
395
|
puts cmd
|
343
|
-
out
|
396
|
+
out=execute_ssh_command(cmd)
|
344
397
|
|
345
398
|
begin
|
346
399
|
out = JSON.parse(out)
|
@@ -366,21 +419,21 @@ module PaisLegacy
|
|
366
419
|
# --------------------------------------------------------------------------------
|
367
420
|
|
368
421
|
def self.table_indexes_cmd(table)
|
369
|
-
|
422
|
+
fglgo("db") + ' indexes'
|
370
423
|
end
|
371
424
|
|
372
425
|
def self.table_indexes(table)
|
373
|
-
out
|
426
|
+
out=execute_ssh_command(table_indexes_cmd(table))
|
374
427
|
out.split("\n").select{|i| i =~ /^#{table}_/}
|
375
428
|
end
|
376
429
|
|
377
430
|
def self.table_schema_cmd(table)
|
378
|
-
|
431
|
+
fglgo("db") + ' schema {{table}}'
|
379
432
|
.gsub("{{table}}",table)
|
380
433
|
end
|
381
434
|
|
382
435
|
def self.table_schema_raw(table)
|
383
|
-
out
|
436
|
+
out=execute_ssh_command(table_schema_cmd(table))
|
384
437
|
out.split("\n")
|
385
438
|
end
|
386
439
|
|
@@ -392,12 +445,12 @@ module PaisLegacy
|
|
392
445
|
end
|
393
446
|
|
394
447
|
def self.table_data_cmd(table)
|
395
|
-
|
448
|
+
fglgo("db") + ' data {{table}}'
|
396
449
|
.gsub("{{table}}",table)
|
397
450
|
end
|
398
451
|
|
399
452
|
def self.table_data_raw(table)
|
400
|
-
out
|
453
|
+
out=execute_ssh_command(table_data_cmd(table))
|
401
454
|
out.split("\n")
|
402
455
|
end
|
403
456
|
|
@@ -416,20 +469,20 @@ module PaisLegacy
|
|
416
469
|
end
|
417
470
|
|
418
471
|
def self.table_unload_cmd(table)
|
419
|
-
|
472
|
+
fglgo("db") + ' unload {{table}}'
|
420
473
|
.gsub("{{table}}",table)
|
421
474
|
end
|
422
475
|
|
423
476
|
def self.table_unload(table)
|
424
|
-
out
|
477
|
+
out=execute_ssh_command(table_unload_cmd(table))
|
425
478
|
end
|
426
479
|
|
427
480
|
def self.tables_cmd
|
428
|
-
|
481
|
+
fglgo("db") + ' tables'
|
429
482
|
end
|
430
483
|
|
431
484
|
def self.tables
|
432
|
-
out
|
485
|
+
out=execute_ssh_command(tables_cmd)
|
433
486
|
out.split("\n")
|
434
487
|
end
|
435
488
|
|
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.2
|
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
|