pais_legacy 2.5.1 → 2.6.1
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/lib/pais_legacy/version.rb +1 -1
- data/lib/pais_legacy.rb +83 -32
- 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"
|
@@ -12,11 +14,51 @@ module PaisLegacy
|
|
12
14
|
class Error < StandardError; end
|
13
15
|
|
14
16
|
class Pais
|
15
|
-
SERVER="192.168.200.4"
|
17
|
+
#SERVER="192.168.200.4"
|
18
|
+
SERVER="pais.com.au"
|
16
19
|
SUSPENSE_ACCOUNT=1599
|
17
20
|
CLEARING_ACCOUNT=5199
|
18
21
|
TB_DIRECT_ACCOUNT=8999
|
19
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
|
+
|
20
62
|
# --------------------------------------------------------------------------------
|
21
63
|
# Client
|
22
64
|
# --------------------------------------------------------------------------------
|
@@ -29,7 +71,7 @@ module PaisLegacy
|
|
29
71
|
end
|
30
72
|
|
31
73
|
def self.clfi_read(client=nil)
|
32
|
-
out
|
74
|
+
out=execute_ssh_command(clfi_read_cmd(client.to_s))
|
33
75
|
JSON.parse(out)
|
34
76
|
end
|
35
77
|
|
@@ -45,7 +87,9 @@ module PaisLegacy
|
|
45
87
|
end
|
46
88
|
|
47
89
|
def self.glfi_read(ledger=nil)
|
48
|
-
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
|
+
|
49
93
|
JSON.parse(out)
|
50
94
|
end
|
51
95
|
|
@@ -57,7 +101,7 @@ module PaisLegacy
|
|
57
101
|
end
|
58
102
|
|
59
103
|
def self.glch_read(ledger)
|
60
|
-
# out
|
104
|
+
# out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
61
105
|
# out.
|
62
106
|
# split("\n").
|
63
107
|
# map{|line| line.split(",")}.
|
@@ -66,7 +110,8 @@ module PaisLegacy
|
|
66
110
|
end
|
67
111
|
|
68
112
|
def self.glch_read_all(ledger)
|
69
|
-
|
113
|
+
puts glch_read_cmd(ledger.to_s)
|
114
|
+
out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
70
115
|
JSON.parse(out)
|
71
116
|
end
|
72
117
|
|
@@ -75,15 +120,17 @@ module PaisLegacy
|
|
75
120
|
def self.raw(params,program="rdefi00a")
|
76
121
|
params = params.gsub(" "," \\")
|
77
122
|
|
78
|
-
cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
79
|
-
|
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)
|
80
127
|
[out]
|
81
128
|
end
|
82
129
|
|
83
130
|
def self.raw_zsh(params,program="rdefi00a")
|
84
131
|
params = params.gsub(" "," \\")
|
85
132
|
|
86
|
-
cmd = 'zsh -c "'+ fglgo("rptrun") +'
|
133
|
+
cmd = 'zsh -c "'+ fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' "'
|
87
134
|
stdout, stderr, status_=Open3.capture3(cmd)
|
88
135
|
[stdout]
|
89
136
|
end
|
@@ -99,7 +146,7 @@ module PaisLegacy
|
|
99
146
|
date_to = Date.parse("30/06/#{date_to.year}")
|
100
147
|
date_from = Date.parse("01/07/#{date_to.year - 1}")
|
101
148
|
|
102
|
-
cmd =
|
149
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \2 \1 \2 \3 \4 \5 \{{date_from}} \{{date_to}} \' '
|
103
150
|
.gsub("{{program}}",program)
|
104
151
|
.gsub("{{printer}}","SCREEN")
|
105
152
|
.gsub("{{ccode}}","T1")
|
@@ -111,7 +158,7 @@ module PaisLegacy
|
|
111
158
|
.gsub("{{report_type}}","1")
|
112
159
|
.gsub("{{subaccs}}","N")
|
113
160
|
|
114
|
-
out
|
161
|
+
out=execute_ssh_command(cmd)
|
115
162
|
[out]
|
116
163
|
end
|
117
164
|
|
@@ -125,7 +172,7 @@ module PaisLegacy
|
|
125
172
|
program="rglch01a"
|
126
173
|
end
|
127
174
|
|
128
|
-
cmd =
|
175
|
+
cmd = fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \{{account_from}} \{{account_to}} \{{date}}\ \1 \N\' '
|
129
176
|
.gsub("{{program}}",program)
|
130
177
|
.gsub("{{printer}}","SCREEN")
|
131
178
|
.gsub("{{ccode}}","T1")
|
@@ -136,7 +183,7 @@ module PaisLegacy
|
|
136
183
|
.gsub("{{report_type}}","1")
|
137
184
|
.gsub("{{subaccs}}","N")
|
138
185
|
|
139
|
-
out
|
186
|
+
out=execute_ssh_command(cmd)
|
140
187
|
|
141
188
|
# if from and to
|
142
189
|
# out.split("\n").each_with_index do |line,index|
|
@@ -216,7 +263,11 @@ module PaisLegacy
|
|
216
263
|
end
|
217
264
|
|
218
265
|
def self.pais_api(file,ledger,options="")
|
219
|
-
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}}'
|
220
271
|
.gsub("{{ccode}}","T1")
|
221
272
|
.gsub("{{ledger}}",ledger.to_s)
|
222
273
|
.gsub("{{options}}",options)
|
@@ -227,18 +278,18 @@ module PaisLegacy
|
|
227
278
|
end
|
228
279
|
|
229
280
|
def self.lasttrnno_read(ledger)
|
230
|
-
out
|
281
|
+
out=execute_ssh_command(lasttrnno_read_cmd(ledger.to_s))
|
231
282
|
out.strip
|
232
283
|
end
|
233
284
|
|
234
285
|
def self.gltr_read_all(ledger,start_date,end_date)
|
235
|
-
cmd=
|
286
|
+
cmd=fglgo("gltr_read") + ' {{ccode}} {{ledger}} {{start_date}} {{end_date}}'
|
236
287
|
.gsub("{{ccode}}","T1")
|
237
288
|
.gsub("{{ledger}}",ledger.to_s)
|
238
289
|
.gsub("{{start_date}}",start_date)
|
239
290
|
.gsub("{{end_date}}",end_date)
|
240
291
|
|
241
|
-
out
|
292
|
+
out=execute_ssh_command(cmd)
|
242
293
|
JSON.parse(out)
|
243
294
|
end
|
244
295
|
|
@@ -258,7 +309,7 @@ module PaisLegacy
|
|
258
309
|
# Example of P&L for ledger 336 with 2 periods
|
259
310
|
# '\SCREEN \T1 \336 \spar \N \2 \1 \Y \3 \4 \5 \N \01/07/2021 \30/06/2022 \N \ALL \ALL \N \2'
|
260
311
|
def self.rptrun(ledger,date_to,from="0001",to="9999",program="rglch01a")
|
261
|
-
|
312
|
+
fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \{{account_from}} \{{account_to}} \1 \{{report_type}} \{{subaccs}} \{{date}}\' N'
|
262
313
|
.gsub("{{program}}",program)
|
263
314
|
.gsub("{{printer}}","SCREEN")
|
264
315
|
.gsub("{{ccode}}","T1")
|
@@ -287,7 +338,7 @@ module PaisLegacy
|
|
287
338
|
end
|
288
339
|
|
289
340
|
def self.common_ledger_date(cmd,ledger,end_date)
|
290
|
-
cmd=
|
341
|
+
cmd=fglgo(cmd) + ' {{ccode}} {{ledger}} {{end_date}}'
|
291
342
|
.gsub("{{ccode}}","T1")
|
292
343
|
.gsub("{{ledger}}",ledger.to_s)
|
293
344
|
.gsub("{{end_date}}",end_date)
|
@@ -308,13 +359,13 @@ module PaisLegacy
|
|
308
359
|
# Invoice related
|
309
360
|
# --------------------------------------------------------------------------------
|
310
361
|
def legacy_import_invoices(ledger,date)
|
311
|
-
cmd=PaisLegacy::Pais.
|
362
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}}'
|
312
363
|
.gsub("{{ccode}}","T1")
|
313
364
|
.gsub("{{ledger}}",ledger.to_s)
|
314
365
|
.gsub("{{date}}",date)
|
315
366
|
|
316
367
|
puts cmd
|
317
|
-
out
|
368
|
+
out=execute_ssh_command(cmd)
|
318
369
|
out.delete!("\\\\")
|
319
370
|
begin
|
320
371
|
out = JSON.parse(out)
|
@@ -331,7 +382,7 @@ module PaisLegacy
|
|
331
382
|
|
332
383
|
date = Date.parse(date).strftime("%d/%m/%Y")
|
333
384
|
|
334
|
-
cmd=PaisLegacy::Pais.
|
385
|
+
cmd=PaisLegacy::Pais.fglgo("invo_read") + ' {{ccode}} {{ledger}} {{date}} {{inv_no}} {{client}}'
|
335
386
|
.gsub("{{ccode}}","T1")
|
336
387
|
.gsub("{{ledger}}",ledger.to_s)
|
337
388
|
.gsub("{{date}}",date)
|
@@ -339,7 +390,7 @@ module PaisLegacy
|
|
339
390
|
.gsub("{{client}}",client)
|
340
391
|
|
341
392
|
puts cmd
|
342
|
-
out
|
393
|
+
out=execute_ssh_command(cmd)
|
343
394
|
|
344
395
|
begin
|
345
396
|
out = JSON.parse(out)
|
@@ -365,21 +416,21 @@ module PaisLegacy
|
|
365
416
|
# --------------------------------------------------------------------------------
|
366
417
|
|
367
418
|
def self.table_indexes_cmd(table)
|
368
|
-
|
419
|
+
fglgo("db") + ' indexes'
|
369
420
|
end
|
370
421
|
|
371
422
|
def self.table_indexes(table)
|
372
|
-
out
|
423
|
+
out=execute_ssh_command(table_indexes_cmd(table))
|
373
424
|
out.split("\n").select{|i| i =~ /^#{table}_/}
|
374
425
|
end
|
375
426
|
|
376
427
|
def self.table_schema_cmd(table)
|
377
|
-
|
428
|
+
fglgo("db") + ' schema {{table}}'
|
378
429
|
.gsub("{{table}}",table)
|
379
430
|
end
|
380
431
|
|
381
432
|
def self.table_schema_raw(table)
|
382
|
-
out
|
433
|
+
out=execute_ssh_command(table_schema_cmd(table))
|
383
434
|
out.split("\n")
|
384
435
|
end
|
385
436
|
|
@@ -391,12 +442,12 @@ module PaisLegacy
|
|
391
442
|
end
|
392
443
|
|
393
444
|
def self.table_data_cmd(table)
|
394
|
-
|
445
|
+
fglgo("db") + ' data {{table}}'
|
395
446
|
.gsub("{{table}}",table)
|
396
447
|
end
|
397
448
|
|
398
449
|
def self.table_data_raw(table)
|
399
|
-
out
|
450
|
+
out=execute_ssh_command(table_data_cmd(table))
|
400
451
|
out.split("\n")
|
401
452
|
end
|
402
453
|
|
@@ -415,20 +466,20 @@ module PaisLegacy
|
|
415
466
|
end
|
416
467
|
|
417
468
|
def self.table_unload_cmd(table)
|
418
|
-
|
469
|
+
fglgo("db") + ' unload {{table}}'
|
419
470
|
.gsub("{{table}}",table)
|
420
471
|
end
|
421
472
|
|
422
473
|
def self.table_unload(table)
|
423
|
-
out
|
474
|
+
out=execute_ssh_command(table_unload_cmd(table))
|
424
475
|
end
|
425
476
|
|
426
477
|
def self.tables_cmd
|
427
|
-
|
478
|
+
fglgo("db") + ' tables'
|
428
479
|
end
|
429
480
|
|
430
481
|
def self.tables
|
431
|
-
out
|
482
|
+
out=execute_ssh_command(tables_cmd)
|
432
483
|
out.split("\n")
|
433
484
|
end
|
434
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.
|
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-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|