pais_legacy 2.6.14 → 2.6.15
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 +27 -27
- 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: 01d00fd53c7be1c79d65281b584b0393d0a8557ef909cee4184548dd463e24ff
|
|
4
|
+
data.tar.gz: b1d83b4364eb008560c59fa526ba7fbeabe595fb5a7c8adb2ad05d965f2fd2f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a93e3969cb80889cef14a1ec588a6295b8b92543ef2d7ca3e1d6eccb1ec3f7766c086beacb2ca40caf4e442eb1c72fd96f1227680405e3849e00d5dc0a43a4d
|
|
7
|
+
data.tar.gz: 79baa5c6be105b11e83ca2ce2e2588db30b95c671295df430eb35879ecb7c24ba3c30b4b0b3aef543f916db3ca0cf71d98da3ab8538749d0ff6715af8e5c041a
|
data/lib/pais_legacy/version.rb
CHANGED
data/lib/pais_legacy.rb
CHANGED
|
@@ -21,7 +21,7 @@ module PaisLegacy
|
|
|
21
21
|
|
|
22
22
|
MAX_RETRIES = 5
|
|
23
23
|
RETRY_DELAY = 1 # seconds
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
SUSPENSE_ACCOUNT=1599
|
|
26
26
|
CLEARING_ACCOUNT=5199
|
|
27
27
|
TB_DIRECT_ACCOUNT=8999
|
|
@@ -29,13 +29,13 @@ module PaisLegacy
|
|
|
29
29
|
def execute_ssh_command(command)
|
|
30
30
|
PaisLegacy.execute_ssh_command(command)
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def self.execute_ssh_command(command)
|
|
34
34
|
output = ""
|
|
35
35
|
retries = 0
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
begin
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
# Start an SSH session
|
|
40
40
|
Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
|
|
41
41
|
# Open a new SSH channel
|
|
@@ -59,7 +59,7 @@ module PaisLegacy
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
ch.on_close do
|
|
62
|
-
puts "Command execution finished"
|
|
62
|
+
puts "Command execution finished" if ENV['DEBUG'] == 'true'
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
end
|
|
@@ -72,32 +72,32 @@ module PaisLegacy
|
|
|
72
72
|
rescue Net::SSH::ConnectionTimeout => e
|
|
73
73
|
retries += 1
|
|
74
74
|
if retries <= MAX_RETRIES
|
|
75
|
-
puts "Connection timed out, retrying (#{retries}/#{MAX_RETRIES})..."
|
|
75
|
+
puts "Connection timed out, retrying (#{retries}/#{MAX_RETRIES})..." if ENV['DEBUG'] == 'true'
|
|
76
76
|
sleep RETRY_DELAY
|
|
77
77
|
retry
|
|
78
78
|
else
|
|
79
|
-
puts "Max retries reached. Could not connect."
|
|
79
|
+
puts "Max retries reached. Could not connect." if ENV['DEBUG'] == 'true'
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
rescue Errno::ECONNRESET => e
|
|
83
83
|
retries += 1
|
|
84
84
|
if retries <= MAX_RETRIES
|
|
85
|
-
puts "Connection reset by peer, retrying (#{retries}/#{MAX_RETRIES})..."
|
|
85
|
+
puts "Connection reset by peer, retrying (#{retries}/#{MAX_RETRIES})..." if ENV['DEBUG'] == 'true'
|
|
86
86
|
sleep RETRY_DELAY
|
|
87
87
|
retry
|
|
88
88
|
else
|
|
89
|
-
puts "Max retries reached. Could not connect."
|
|
89
|
+
puts "Max retries reached. Could not connect." if ENV['DEBUG'] == 'true'
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
rescue StandardError => e
|
|
93
|
-
puts "An error occurred: #{e.message}"
|
|
93
|
+
puts "An error occurred: #{e.message}" if ENV['DEBUG'] == 'true'
|
|
94
94
|
end
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
output
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
# delegate :execute_ssh_command, to: :class
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
# --------------------------------------------------------------------------------
|
|
102
102
|
# Client
|
|
103
103
|
# --------------------------------------------------------------------------------
|
|
@@ -149,7 +149,7 @@ module PaisLegacy
|
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def self.glch_read_all(ledger)
|
|
152
|
-
puts glch_read_cmd(ledger.to_s)
|
|
152
|
+
puts glch_read_cmd(ledger.to_s) if ENV['DEBUG'] == 'true'
|
|
153
153
|
out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
|
154
154
|
JSON.parse(out)
|
|
155
155
|
end
|
|
@@ -173,7 +173,7 @@ module PaisLegacy
|
|
|
173
173
|
stdout, stderr, status_=Open3.capture3(cmd)
|
|
174
174
|
[stdout]
|
|
175
175
|
end
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
# --------------------------------------------------------------------------------
|
|
178
178
|
# Performance Report
|
|
179
179
|
# --------------------------------------------------------------------------------
|
|
@@ -275,14 +275,14 @@ module PaisLegacy
|
|
|
275
275
|
# data should be the whole params, which will include the pais_code, dr & cr amounts
|
|
276
276
|
#
|
|
277
277
|
def self.save_journals(ledger_code, data)
|
|
278
|
-
tranno=Pais.lasttrnno_read(ledger_code).to_i
|
|
278
|
+
tranno=Pais.lasttrnno_read(ledger_code).to_i
|
|
279
279
|
|
|
280
280
|
File.open(journals_file(ledger_code), "w") do |f|
|
|
281
281
|
f.write "AutoPost,LastTrnNo,Date,DR,DR_SUB,CR,CR_SUB,Description,Amount\n"
|
|
282
282
|
|
|
283
283
|
data[:dr].each_with_index do |d,i|
|
|
284
284
|
if data[:pais][i]
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
# Determine if it's a credit/debit transaction
|
|
287
287
|
if (amount = data[:dr][i].to_f) > 0
|
|
288
288
|
dr_account,dr_sub,cr_account = accounts(data[:pais][i])
|
|
@@ -294,7 +294,7 @@ module PaisLegacy
|
|
|
294
294
|
tranno += 1
|
|
295
295
|
date = data[:date_to].nil? ? Time.now : Date.parse(data[:date_to])
|
|
296
296
|
date = date.strftime("%d/%m/%Y")
|
|
297
|
-
|
|
297
|
+
|
|
298
298
|
f.write "GJ,#{tranno},#{date},#{dr_account},#{dr_sub},#{cr_account},#{cr_sub},#{description(data,i)},#{amount}\n"
|
|
299
299
|
end
|
|
300
300
|
end
|
|
@@ -331,7 +331,7 @@ module PaisLegacy
|
|
|
331
331
|
out=execute_ssh_command(cmd)
|
|
332
332
|
JSON.parse(out)
|
|
333
333
|
end
|
|
334
|
-
|
|
334
|
+
|
|
335
335
|
def self.gltr_create(ledger,line)
|
|
336
336
|
pais_api "gltr_create", ledger, "{{autopost}} {{lasttrnno}} {{date}} {{dr}} {{dr_sub}} {{cr}} {{cr_sub}} \'{{description}}\' {{amount}}"
|
|
337
337
|
.gsub("{{autopost}}",line[0])
|
|
@@ -363,7 +363,7 @@ module PaisLegacy
|
|
|
363
363
|
def self.rptrun_exec(ledger,date_to,from="0001",to="9999",program="rglch01a")
|
|
364
364
|
cmd=rptrun(ledger,date_to,from="0001",to="9999",program)
|
|
365
365
|
[execute_ssh_command(cmd)]
|
|
366
|
-
end
|
|
366
|
+
end
|
|
367
367
|
|
|
368
368
|
def self.post_journals(ledger)
|
|
369
369
|
count = 0
|
|
@@ -372,7 +372,7 @@ module PaisLegacy
|
|
|
372
372
|
CSV.readlines(journals_file(ledger)).drop(1).each do |line|
|
|
373
373
|
unless line[8].nil?
|
|
374
374
|
cmd = gltr_create(ledger,line)
|
|
375
|
-
puts cmd
|
|
375
|
+
puts cmd if ENV['DEBUG'] == 'true'
|
|
376
376
|
execute_ssh_command(cmd) # Post to PAIS
|
|
377
377
|
count += 1
|
|
378
378
|
end
|
|
@@ -387,10 +387,10 @@ module PaisLegacy
|
|
|
387
387
|
.gsub("{{ledger}}",ledger.to_s)
|
|
388
388
|
.gsub("{{end_date}}",end_date)
|
|
389
389
|
|
|
390
|
-
puts cmd
|
|
390
|
+
puts cmd if ENV['DEBUG'] == 'true'
|
|
391
391
|
execute_ssh_command(cmd)
|
|
392
392
|
end
|
|
393
|
-
|
|
393
|
+
|
|
394
394
|
def self.rebuild_ledger(ledger,end_date)
|
|
395
395
|
common_ledger_date("rebuild_after_post",ledger,end_date)
|
|
396
396
|
end
|
|
@@ -408,13 +408,13 @@ module PaisLegacy
|
|
|
408
408
|
.gsub("{{ledger}}",ledger.to_s)
|
|
409
409
|
.gsub("{{date}}",date)
|
|
410
410
|
|
|
411
|
-
puts cmd
|
|
411
|
+
puts cmd if ENV['DEBUG'] == 'true'
|
|
412
412
|
out=execute_ssh_command(cmd)
|
|
413
413
|
out.delete!("\\\\")
|
|
414
414
|
begin
|
|
415
415
|
out = JSON.parse(out)
|
|
416
416
|
rescue JSON::JSONError, ArgumentError => e
|
|
417
|
-
puts e.to_s
|
|
417
|
+
puts e.to_s if ENV['DEBUG'] == 'true'
|
|
418
418
|
exit
|
|
419
419
|
end
|
|
420
420
|
out = out["invoices"]
|
|
@@ -433,13 +433,13 @@ module PaisLegacy
|
|
|
433
433
|
.gsub("{{inv_no}}",inv_no)
|
|
434
434
|
.gsub("{{client}}",client)
|
|
435
435
|
|
|
436
|
-
puts cmd
|
|
436
|
+
puts cmd if ENV['DEBUG'] == 'true'
|
|
437
437
|
out=PaisLegacy::Pais.execute_ssh_command(cmd)
|
|
438
438
|
|
|
439
439
|
begin
|
|
440
440
|
out = JSON.parse(out)
|
|
441
441
|
rescue JSON::JSONError, ArgumentError => e
|
|
442
|
-
puts e.to_s
|
|
442
|
+
puts e.to_s if ENV['DEBUG'] == 'true'
|
|
443
443
|
raise "Couldn't find Invoice Number: #{inv_no} for client #{client}."
|
|
444
444
|
end
|
|
445
445
|
|