pais_legacy 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/pais_legacy/trial_balance.rb +97 -0
- data/lib/pais_legacy/version.rb +1 -1
- data/lib/pais_legacy.rb +42 -18
- data/readme.org +60 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e7343d5d73027bf0a6f53a1d1299173d633f14f5699e3fe6602eb08537613b0
|
4
|
+
data.tar.gz: a3c731576574895f1a490a5a687e9395837de385f588bf68a75fdae226340ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64234d19bbdd9e7eac721a6a127fccd6cd3d83c3531dfd6db73c065b0fe50401fde5300facd4f789b9b55299b57c5917f98e8f0607e74bdf862985226314d092
|
7
|
+
data.tar.gz: a11c115d23a1c7ad39c17df3b20101f84858740d3c3ec2b01d6663ab54613e31ea7a6aa9326156bff76e36a5bc5da69445150354aa032bae74e6ba78e464f6b2
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,97 @@
|
|
1
|
+
module PaisLegacy
|
2
|
+
class Error < StandardError; end
|
3
|
+
|
4
|
+
class TrialBalance
|
5
|
+
|
6
|
+
@report = nil
|
7
|
+
|
8
|
+
def initialize(report)
|
9
|
+
@report = report
|
10
|
+
end
|
11
|
+
|
12
|
+
def display
|
13
|
+
puts @report
|
14
|
+
end
|
15
|
+
|
16
|
+
def save_sample
|
17
|
+
File.open("tmp/trial_balance_screen.sample","w") do |f|
|
18
|
+
@report.each do |line|
|
19
|
+
f.write "#{line}\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def accounts_from_trial_balance
|
25
|
+
read = false
|
26
|
+
accounts = []
|
27
|
+
@report.each do |row|
|
28
|
+
next if row.strip.length == 0
|
29
|
+
|
30
|
+
read = false if end_reading(row)
|
31
|
+
if read && (row[0..9].to_i>0)
|
32
|
+
accounts << code_from_row(row)
|
33
|
+
end
|
34
|
+
read = true if start_reading(row)
|
35
|
+
end
|
36
|
+
|
37
|
+
accounts
|
38
|
+
end
|
39
|
+
|
40
|
+
def main_account(row)
|
41
|
+
@main_code = row[0..7].strip
|
42
|
+
@main_name = account_name(row)
|
43
|
+
{
|
44
|
+
code: "#{@main_code}",
|
45
|
+
name: "#{"#{@main_code}-#{@main_name}".strip}",
|
46
|
+
dr: dr(row),
|
47
|
+
cr: cr(row)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def sub_account(row)
|
52
|
+
code = "#{@main_code}/#{row[0..9].strip}"
|
53
|
+
name = "#{code}-#{@main_name} #{account_name(row)}"
|
54
|
+
{
|
55
|
+
code: "#{code}",
|
56
|
+
name: "#{name.strip}",
|
57
|
+
dr: dr(row),
|
58
|
+
cr: cr(row)
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def dr(row)
|
64
|
+
row[47..59].strip.gsub(",",'')
|
65
|
+
end
|
66
|
+
|
67
|
+
def cr(row)
|
68
|
+
row[60..74].strip.gsub(",",'')
|
69
|
+
end
|
70
|
+
|
71
|
+
def start_reading(row)
|
72
|
+
row.include?("Acc Gst")
|
73
|
+
end
|
74
|
+
|
75
|
+
def end_reading(row)
|
76
|
+
row.include?("Not Audited.")
|
77
|
+
end
|
78
|
+
|
79
|
+
def code_from_row(row)
|
80
|
+
if is_sub_account(row)
|
81
|
+
sub_account(row)
|
82
|
+
else
|
83
|
+
main_account(row)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def account_name(row)
|
88
|
+
row[14..46].strip
|
89
|
+
end
|
90
|
+
|
91
|
+
def is_sub_account(row)
|
92
|
+
sub = row[0..9].strip
|
93
|
+
sub.to_i > 0 && !sub.include?("/")
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
data/lib/pais_legacy/version.rb
CHANGED
data/lib/pais_legacy.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'date'
|
3
4
|
require 'json' # Output
|
4
5
|
require "open3" # File I/O
|
5
6
|
require 'pastel' # TTY Color
|
6
7
|
|
8
|
+
require_relative "pais_legacy/trial_balance"
|
7
9
|
require_relative "pais_legacy/version"
|
8
10
|
|
9
11
|
module PaisLegacy
|
@@ -14,9 +16,44 @@ module PaisLegacy
|
|
14
16
|
SUSPENSE_ACCOUNT=1599
|
15
17
|
CLEARING_ACCOUNT=5199
|
16
18
|
|
19
|
+
# --------------------------------------------------------------------------------
|
20
|
+
# Accounts
|
21
|
+
# --------------------------------------------------------------------------------
|
22
|
+
def self.glch_read_cmd(ledger)
|
23
|
+
pais_api("glch_read",ledger)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.glch_read(ledger)
|
27
|
+
out,_,_=Open3.capture2(glch_read_cmd(ledger.to_s))
|
28
|
+
|
29
|
+
out.
|
30
|
+
split("\n").
|
31
|
+
map{|line| line.split(",")}.
|
32
|
+
map{|line| {value: line[0], text: "#{line[0]}-#{line[1]}"}}
|
33
|
+
end
|
34
|
+
|
17
35
|
# --------------------------------------------------------------------------------
|
18
36
|
# Trial Balance
|
19
37
|
# --------------------------------------------------------------------------------
|
38
|
+
def self.get_trial_balance(from=nil,to=nil)
|
39
|
+
cmd=rptrun("1","30/06/2021")
|
40
|
+
out,_,_=Open3.capture2(cmd)
|
41
|
+
|
42
|
+
if from and to
|
43
|
+
out.split("\n").each_with_index do |line,index|
|
44
|
+
if index >= from and index <= to
|
45
|
+
puts "#{index}-#{line}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
out.split("\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# --------------------------------------------------------------------------------
|
55
|
+
# General Journals
|
56
|
+
# --------------------------------------------------------------------------------
|
20
57
|
def self.save_journals(ledger, data)
|
21
58
|
File.open(journals_file(ledger), "w") do |f|
|
22
59
|
f.write "AutoPost,LastTrnNo,Date,DR,DR_SUB,CR,CR_SUB,Description,Amount\n"
|
@@ -64,32 +101,19 @@ module PaisLegacy
|
|
64
101
|
.gsub("{{amount}}",line[8])
|
65
102
|
end
|
66
103
|
|
67
|
-
def self.rptrun(ledger,date_to)
|
104
|
+
def self.rptrun(ledger,date_to,from="0001",to="6399",program="rglch01a")
|
68
105
|
ssh + ' "bash -l -c \"'+ fglgo("rptrun") +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \{{account_from}} \{{account_to}} \1 \{{report_type}} \{{subaccs}} \{{date}}\' N\""'
|
69
|
-
.gsub("{{program}}",
|
70
|
-
.gsub("{{printer}}","
|
106
|
+
.gsub("{{program}}",program)
|
107
|
+
.gsub("{{printer}}","SCREEN")
|
71
108
|
.gsub("{{ccode}}","T1")
|
72
109
|
.gsub("{{ledger}}",ledger)
|
73
|
-
.gsub("{{account_from}}",
|
74
|
-
.gsub("{{account_to}}",
|
110
|
+
.gsub("{{account_from}}",from)
|
111
|
+
.gsub("{{account_to}}",to)
|
75
112
|
.gsub("{{date}}",Date.parse(date_to).strftime("%d/%m/%Y") || "30/06/2021")
|
76
113
|
.gsub("{{report_type}}","1")
|
77
114
|
.gsub("{{subaccs}}","N")
|
78
115
|
end
|
79
116
|
|
80
|
-
def self.glch_read_cmd(ledger)
|
81
|
-
pais_api("glch_read",ledger)
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.glch_read(ledger)
|
85
|
-
out,_,_=Open3.capture2(glch_read_cmd(ledger.to_s))
|
86
|
-
|
87
|
-
out.
|
88
|
-
split("\n").
|
89
|
-
map{|line| line.split(",")}.
|
90
|
-
map{|line| {value: line[0], text: "#{line[0]}-#{line[1]}"}}
|
91
|
-
end
|
92
|
-
|
93
117
|
def self.post_journals(ledger)
|
94
118
|
count = 0
|
95
119
|
|
data/readme.org
CHANGED
@@ -22,12 +22,69 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
Interacting with the GEM
|
24
24
|
|
25
|
+
*** Chart of Accounts
|
26
|
+
|
27
|
+
#+begin_src ruby
|
28
|
+
@pais_codes = PaisLegacy::Pais.glch_read(@pais_ledger)
|
29
|
+
#+end_src
|
30
|
+
|
31
|
+
Result;
|
32
|
+
: [{:value=>"1/1", :text=>"1/1-Sales Net Of Tax"}]
|
33
|
+
|
34
|
+
*** Trial Balance
|
35
|
+
|
36
|
+
**** Get trial balance
|
37
|
+
|
38
|
+
Get the trial balance from PAIS Legacy.
|
39
|
+
|
40
|
+
#+begin_src ruby
|
41
|
+
PaisLegacy::Pais.get_trial_balance
|
42
|
+
#+end_src
|
43
|
+
|
44
|
+
**** Get codes
|
45
|
+
|
46
|
+
Extract codes from Trial Balance
|
47
|
+
|
25
48
|
#+begin_src ruby
|
26
|
-
|
27
|
-
|
28
|
-
|
49
|
+
@report = PaisLegacy::Pais.get_trial_balance
|
50
|
+
@tb=PaisLegacy::TrialBalance.new(@report)
|
51
|
+
@codes = @tb.codes_from_trial_balance
|
29
52
|
#+end_src
|
30
53
|
|
54
|
+
Result of @codes;
|
55
|
+
: [{value: "1", text: "1-Sales"}]
|
56
|
+
|
57
|
+
**** Save journal entries
|
58
|
+
|
59
|
+
This method saves the journal entries from Xero's trial balance but with PAIS Legacy account & sub account codes from the allocation table created by the user.
|
60
|
+
|
61
|
+
#+begin_src ruby
|
62
|
+
@params={xero: ["270","200","0"],
|
63
|
+
xero_name: ["Interest Income (270)","Sales (200)","Cash on Hand (0)"],
|
64
|
+
pais: ["250/1","",""],
|
65
|
+
dr: ["","678672.92",""],
|
66
|
+
cr: ["0.75","","123"]}
|
67
|
+
PaisLegacy::Pais.save_journals(ledger_code, @params)
|
68
|
+
#+end_src
|
69
|
+
|
70
|
+
Result in CSV file output (FILE: "tmp/pais_journal_post_#{ledger}.csv")
|
71
|
+
: "GJ,2,14/07/2022,5199,,250,1,Auto post (Xero Interest Income (270) -> 250/1),0.75"
|
72
|
+
|
73
|
+
**** Post GJ to PAIS Legacy
|
74
|
+
|
75
|
+
This reads the CSV created by save_journals and posts them to PAIS Legacy.
|
76
|
+
|
77
|
+
#+begin_src ruby
|
78
|
+
@journal_count = PaisLegacy::Pais.post_journals(ledger_code)
|
79
|
+
#+end_src
|
80
|
+
|
81
|
+
*** Invoices
|
82
|
+
#+begin_src ruby
|
83
|
+
pais=PaisLegacy.new
|
84
|
+
invoices = pais.legacy_import_invoices(ledger,date)
|
85
|
+
pais.display_invoices(invoices)
|
86
|
+
#+end_src
|
87
|
+
|
31
88
|
** Development
|
32
89
|
|
33
90
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
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: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- bin/setup
|
96
96
|
- changelog.org
|
97
97
|
- lib/pais_legacy.rb
|
98
|
+
- lib/pais_legacy/trial_balance.rb
|
98
99
|
- lib/pais_legacy/version.rb
|
99
100
|
- readme.org
|
100
101
|
homepage: https://github.com/map7/pais_legacy
|