appydave-tools 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/bank_reconciliation.rb +9 -5
- data/lib/appydave/tools/bank_reconciliation/clean/clean_transactions.rb +51 -12
- data/lib/appydave/tools/bank_reconciliation/clean/read_transactions.rb +2 -0
- data/lib/appydave/tools/bank_reconciliation/models/transaction.rb +17 -7
- data/lib/appydave/tools/configuration/models/config_base.rb +1 -1
- data/lib/appydave/tools/debuggable.rb +22 -0
- data/lib/appydave/tools/prompt_tools/_doc.md +5 -0
- data/lib/appydave/tools/version.rb +1 -1
- data/lib/appydave/tools/youtube_manager/_doc.md +1 -1
- data/lib/appydave/tools.rb +1 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be09bb7513f3d614e12ff5868087d7c39f5c68f4f0ac43a87725a85cdba84e00
|
4
|
+
data.tar.gz: a9e33a415aa1bf242a29e4771f418583a38d22a8010103ae6ff7883000fb15ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75c8a86342447e20e44f85bf82ea1796e3c5e9f125d4115e5a2b2317d831cacafd371bd3c0b097648e0dd8d20329900bb313d7f015cff6bd718d2074e013956d
|
7
|
+
data.tar.gz: 96f4839ea4e970747d056c676375bf730243b6f02894be86f9e056afbf54cd4584692d4b7ac3ebbf4ab99c4aa970622f3c7caacf2e408a16bb1493316fb58960
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.10.2](https://github.com/klueless-io/appydave-tools/compare/v0.10.1...v0.10.2) (2024-06-17)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* make progress on prompt completion tool ([fbc60b7](https://github.com/klueless-io/appydave-tools/commit/fbc60b712e3e18d7f73c47f4568bae65295557df))
|
7
|
+
|
1
8
|
## [0.10.1](https://github.com/klueless-io/appydave-tools/compare/v0.10.0...v0.10.1) (2024-06-13)
|
2
9
|
|
3
10
|
|
data/bin/bank_reconciliation.rb
CHANGED
@@ -48,6 +48,10 @@ class BankReconciliationCLI
|
|
48
48
|
options[:output] = v
|
49
49
|
end
|
50
50
|
|
51
|
+
opts.on('-d', '--debug', 'Enable debug mode') do
|
52
|
+
options[:debug] = true
|
53
|
+
end
|
54
|
+
|
51
55
|
opts.on_tail('-h', '--help', 'Show this message') do
|
52
56
|
puts opts
|
53
57
|
exit
|
@@ -58,17 +62,15 @@ class BankReconciliationCLI
|
|
58
62
|
output_file = options[:output] || 'clean_transactions.csv'
|
59
63
|
include_patterns = options[:include].empty? ? ['*'] : options[:include]
|
60
64
|
|
61
|
-
puts "Cleaning transactions with options: #{options}"
|
65
|
+
# puts "Cleaning transactions with options: #{options}"
|
62
66
|
|
63
67
|
# Ensure the clean directory exists
|
64
68
|
clean_dir = File.dirname(output_file)
|
65
69
|
FileUtils.mkdir_p(clean_dir)
|
66
70
|
|
67
71
|
# Initialize the CleanTransactions class and process the files
|
68
|
-
cleaner = Appydave::Tools::BankReconciliation::Clean::CleanTransactions.new(transaction_folder: transaction_folder)
|
72
|
+
cleaner = Appydave::Tools::BankReconciliation::Clean::CleanTransactions.new(transaction_folder: transaction_folder, debug: options[:debug])
|
69
73
|
cleaner.clean_transactions(include_patterns, output_file)
|
70
|
-
|
71
|
-
puts "Cleaning transactions with options: #{options}"
|
72
74
|
end
|
73
75
|
|
74
76
|
def process_transactions(args)
|
@@ -76,6 +78,7 @@ class BankReconciliationCLI
|
|
76
78
|
OptionParser.new do |opts|
|
77
79
|
opts.banner = 'Usage: bank_reconciliation.rb process [options]'
|
78
80
|
opts.on('-i', '--input FILE', 'Input CSV file with transactions') { |v| options[:input] = v }
|
81
|
+
opts.on('-d', '--debug', 'Enable debug mode') { |v| options[:debug] = v }
|
79
82
|
opts.on_tail('-h', '--help', 'Show this message') do
|
80
83
|
puts opts
|
81
84
|
exit
|
@@ -96,8 +99,9 @@ class BankReconciliationCLI
|
|
96
99
|
opts.on('-e', '--end DATE', 'Filter by dates less than or eqaul to DDMMYY') { |v| options[:year] = v }
|
97
100
|
opts.on('-c', '--codes CODES', 'Filter by chart of account codes (comma-separated)') { |v| options[:codes] = v }
|
98
101
|
opts.on('-w', '--wild TEXT', 'Wildcard text match') { |v| options[:text] = v }
|
99
|
-
opts.on('-
|
102
|
+
opts.on('-v', '--view', 'Display filtered transactions in table format') { |v| options[:display] = v }
|
100
103
|
opts.on('-o', '--output FILE', 'Output CSV file name') { |v| options[:output] = v }
|
104
|
+
opts.on('-d', '--debug', 'Enable debug mode') { |v| options[:debug] = v }
|
101
105
|
opts.on_tail('-h', '--help', 'Show this message') do
|
102
106
|
puts opts
|
103
107
|
exit
|
@@ -6,15 +6,17 @@ module Appydave
|
|
6
6
|
module Clean
|
7
7
|
# Clean transactions
|
8
8
|
class CleanTransactions
|
9
|
-
include Appydave::Tools::Configuration::Configurable
|
10
9
|
include KLog::Logging
|
10
|
+
include Appydave::Tools::Configuration::Configurable
|
11
|
+
include Appydave::Tools::Debuggable
|
11
12
|
|
12
13
|
attr_reader :transaction_folder
|
13
14
|
attr_reader :output_folder
|
14
15
|
attr_reader :transactions
|
15
16
|
|
16
17
|
# (config_file)
|
17
|
-
def initialize(transaction_folder: nil, output_folder: nil)
|
18
|
+
def initialize(transaction_folder: nil, output_folder: nil, debug: false)
|
19
|
+
@debug = debug
|
18
20
|
# needs to use config.bank_reconciliation.transaction_folder
|
19
21
|
transaction_folder ||= '/Volumes/Expansion/Sync/bank-reconciliation/original-transactions'
|
20
22
|
output_folder ||= File.join(transaction_folder, 'clean')
|
@@ -24,16 +26,21 @@ module Appydave
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def clean_transactions(input_globs, output_file)
|
29
|
+
log_info("Starting transaction cleaning with input patterns: #{input_globs}")
|
30
|
+
|
27
31
|
raw_transactions = grab_raw_transactions(input_globs)
|
28
|
-
transactions
|
32
|
+
log_info("Total raw transactions collected: #{raw_transactions.size}")
|
29
33
|
|
30
|
-
transactions =
|
34
|
+
transactions, duplicates_count = deduplicate_across_files(raw_transactions)
|
35
|
+
log_info("Duplicates found and removed: #{duplicates_count}")
|
31
36
|
|
32
|
-
|
37
|
+
transactions = Mapper.new.map(transactions)
|
38
|
+
log_info('Transactions mapped to chart of accounts and bank accounts')
|
33
39
|
|
34
|
-
|
40
|
+
log_kv 'Deduped consolidated transactions', duplicates_count if duplicates_count.positive?
|
35
41
|
|
36
42
|
save_to_csv(transactions, output_file)
|
43
|
+
log_kv('Transaction Output File', full_output_file(output_file))
|
37
44
|
|
38
45
|
@transactions = transactions
|
39
46
|
end
|
@@ -49,13 +56,13 @@ module Appydave
|
|
49
56
|
|
50
57
|
input_globs.each do |glob|
|
51
58
|
Dir.glob(glob).each do |file|
|
52
|
-
|
59
|
+
log_kv 'Reading transactions from', file
|
53
60
|
raw_transactions = ReadTransactions.new(file).read
|
54
|
-
deduped_transactions, duplicates_count =
|
61
|
+
deduped_transactions, duplicates_count = deduplicate_within_file(raw_transactions)
|
55
62
|
|
56
63
|
if duplicates_count.positive?
|
57
|
-
|
58
|
-
|
64
|
+
log_kv 'Duplicates count within file', duplicates_count
|
65
|
+
log_kv 'File', file
|
59
66
|
end
|
60
67
|
|
61
68
|
transactions += deduped_transactions
|
@@ -68,7 +75,7 @@ module Appydave
|
|
68
75
|
transactions
|
69
76
|
end
|
70
77
|
|
71
|
-
def
|
78
|
+
def deduplicate_within_file(transactions)
|
72
79
|
unique_transactions = transactions.uniq do |transaction|
|
73
80
|
[
|
74
81
|
transaction.bsb_number,
|
@@ -88,9 +95,41 @@ module Appydave
|
|
88
95
|
[unique_transactions, duplicates]
|
89
96
|
end
|
90
97
|
|
98
|
+
def deduplicate_across_files(transactions)
|
99
|
+
grouped_transactions = transactions.group_by do |transaction|
|
100
|
+
[
|
101
|
+
transaction.bsb_number,
|
102
|
+
transaction.account_number,
|
103
|
+
transaction.transaction_date,
|
104
|
+
transaction.narration,
|
105
|
+
transaction.cheque_number,
|
106
|
+
transaction.debit,
|
107
|
+
transaction.credit,
|
108
|
+
transaction.balance,
|
109
|
+
transaction.transaction_type
|
110
|
+
]
|
111
|
+
end
|
112
|
+
|
113
|
+
unique_transactions = []
|
114
|
+
duplicates_count = 0
|
115
|
+
|
116
|
+
grouped_transactions.each_value do |dupes|
|
117
|
+
unique_transaction = dupes.first
|
118
|
+
unique_transaction.source_files = dupes.flat_map(&:source_files).uniq
|
119
|
+
duplicates_count += dupes.size - 1
|
120
|
+
unique_transactions << unique_transaction
|
121
|
+
end
|
122
|
+
|
123
|
+
[unique_transactions, duplicates_count]
|
124
|
+
end
|
125
|
+
|
126
|
+
def full_output_file(output_file)
|
127
|
+
File.join(output_folder, output_file)
|
128
|
+
end
|
129
|
+
|
91
130
|
def save_to_csv(transactions, output_file)
|
92
131
|
FileUtils.mkdir_p(output_folder)
|
93
|
-
output_file =
|
132
|
+
output_file = full_output_file(output_file)
|
94
133
|
|
95
134
|
CSV.open(output_file, 'w') do |csv|
|
96
135
|
csv << Appydave::Tools::BankReconciliation::Models::Transaction.csv_headers
|
@@ -44,6 +44,7 @@ module Appydave
|
|
44
44
|
balance: row['Balance'],
|
45
45
|
transaction_type: row['Transaction Type']
|
46
46
|
)
|
47
|
+
transaction.add_source_file(@file)
|
47
48
|
@transactions << transaction
|
48
49
|
end
|
49
50
|
|
@@ -66,6 +67,7 @@ module Appydave
|
|
66
67
|
balance: row['Balance'],
|
67
68
|
transaction_type: row['Transaction Type']
|
68
69
|
)
|
70
|
+
transaction.add_source_file(@file)
|
69
71
|
@transactions << transaction
|
70
72
|
end
|
71
73
|
|
@@ -18,7 +18,8 @@ module Appydave
|
|
18
18
|
:platform,
|
19
19
|
:coa_code,
|
20
20
|
:coa_match_type,
|
21
|
-
:account_name
|
21
|
+
:account_name,
|
22
|
+
:source_files
|
22
23
|
|
23
24
|
def initialize(bsb_number: nil,
|
24
25
|
account_number: nil,
|
@@ -47,41 +48,50 @@ module Appydave
|
|
47
48
|
@coa_code = coa_code
|
48
49
|
@coa_match_type = coa_match_type
|
49
50
|
@account_name = account_name
|
51
|
+
@source_files = []
|
50
52
|
end
|
51
53
|
|
54
|
+
def add_source_file(source_file)
|
55
|
+
@source_files << source_file.strip unless @source_files.include?(source_file.strip)
|
56
|
+
end
|
57
|
+
|
58
|
+
# cheque_number
|
59
|
+
|
52
60
|
def self.csv_headers
|
53
61
|
%i[
|
62
|
+
platform
|
63
|
+
account_name
|
54
64
|
bsb_number
|
55
65
|
account_number
|
56
66
|
transaction_date
|
57
67
|
narration
|
58
|
-
cheque_number
|
59
68
|
debit
|
60
69
|
credit
|
61
70
|
balance
|
62
71
|
transaction_type
|
63
|
-
platform
|
64
72
|
coa_code
|
65
73
|
coa_match_type
|
66
|
-
|
74
|
+
source_files
|
67
75
|
]
|
68
76
|
end
|
69
77
|
|
78
|
+
# @cheque_number,
|
79
|
+
|
70
80
|
def to_csv_row
|
71
81
|
[
|
82
|
+
@platform,
|
83
|
+
@account_name,
|
72
84
|
@bsb_number,
|
73
85
|
@account_number,
|
74
86
|
@transaction_date,
|
75
87
|
@narration,
|
76
|
-
@cheque_number,
|
77
88
|
@debit,
|
78
89
|
@credit,
|
79
90
|
@balance,
|
80
91
|
@transaction_type,
|
81
|
-
@platform,
|
82
92
|
@coa_code,
|
83
93
|
@coa_match_type,
|
84
|
-
@
|
94
|
+
@source_files
|
85
95
|
]
|
86
96
|
end
|
87
97
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Appydave
|
4
|
+
module Tools
|
5
|
+
# Debuggable is a module for adding debug logging to classes
|
6
|
+
module Debuggable
|
7
|
+
attr_accessor :debug
|
8
|
+
|
9
|
+
def log_info(message)
|
10
|
+
log.info(message) if debug
|
11
|
+
end
|
12
|
+
|
13
|
+
def log_kv(key, value)
|
14
|
+
log.kv(key, value) if debug
|
15
|
+
end
|
16
|
+
|
17
|
+
def log_subheading(message)
|
18
|
+
log.subheading(message) if debug
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/appydave/tools.rb
CHANGED
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "appydave-tools",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.3",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "appydave-tools",
|
9
|
-
"version": "0.10.
|
9
|
+
"version": "0.10.3",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.3",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appydave-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
@@ -187,10 +187,12 @@ files:
|
|
187
187
|
- lib/appydave/tools/configuration/models/settings_config.rb
|
188
188
|
- lib/appydave/tools/configuration/models/youtube_automation_config.rb
|
189
189
|
- lib/appydave/tools/configuration/openai.rb
|
190
|
+
- lib/appydave/tools/debuggable.rb
|
190
191
|
- lib/appydave/tools/gpt_context/_doc.md
|
191
192
|
- lib/appydave/tools/gpt_context/file_collector.rb
|
192
193
|
- lib/appydave/tools/name_manager/_doc.md
|
193
194
|
- lib/appydave/tools/name_manager/project_name.rb
|
195
|
+
- lib/appydave/tools/prompt_tools/_doc.md
|
194
196
|
- lib/appydave/tools/prompt_tools/models/llm_info.rb
|
195
197
|
- lib/appydave/tools/prompt_tools/prompt_completion.rb
|
196
198
|
- lib/appydave/tools/subtitle_master/_doc.md
|