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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63c99bf6126fd82479ca9280e75f8d5c9226b1e8f6df4f6f581476363fd45245
4
- data.tar.gz: 2f171fac8f490c259e6d259c848af330f3b7c4c1a35aea456fcc85251224f69e
3
+ metadata.gz: be09bb7513f3d614e12ff5868087d7c39f5c68f4f0ac43a87725a85cdba84e00
4
+ data.tar.gz: a9e33a415aa1bf242a29e4771f418583a38d22a8010103ae6ff7883000fb15ae
5
5
  SHA512:
6
- metadata.gz: 06227ef4baf7765404e787a91dd53728032cfcea6718b36d19bb378f35b754eabd365d1a2eea270299f6b2fb2ab98bfa529feff71426fd78b0968768c23131b2
7
- data.tar.gz: 6ac8d46c1f8afb609faf5145fe864e24b09de807691295eef2613029c0ebcfb30f92adbb60a437e810b14b7ba841e1e1bb5cb1499ca5fab5b7864907e91b4e53
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
 
@@ -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('-d', '--display', 'Display filtered transactions in table format') { |v| options[:display] = v }
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, duplicates_count = deduplicate(raw_transactions)
32
+ log_info("Total raw transactions collected: #{raw_transactions.size}")
29
33
 
30
- transactions = Mapper.new.map(transactions)
34
+ transactions, duplicates_count = deduplicate_across_files(raw_transactions)
35
+ log_info("Duplicates found and removed: #{duplicates_count}")
31
36
 
32
- # tp transactions, Appydave::Tools::BankReconciliation::Models::Transaction.csv_headers
37
+ transactions = Mapper.new.map(transactions)
38
+ log_info('Transactions mapped to chart of accounts and bank accounts')
33
39
 
34
- log.kv 'Deduped consolidated transactions', duplicates_count if duplicates_count.positive?
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
- log.kv 'Reading transactions from', file
59
+ log_kv 'Reading transactions from', file
53
60
  raw_transactions = ReadTransactions.new(file).read
54
- deduped_transactions, duplicates_count = deduplicate(raw_transactions)
61
+ deduped_transactions, duplicates_count = deduplicate_within_file(raw_transactions)
55
62
 
56
63
  if duplicates_count.positive?
57
- log.kv 'Duplicates count', duplicates_count
58
- log.kv 'File', file
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 deduplicate(transactions)
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 = File.join(output_folder, 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
- account_name
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
- @account_name
94
+ @source_files
85
95
  ]
86
96
  end
87
97
  end
@@ -15,7 +15,7 @@ module Appydave
15
15
 
16
16
  def initialize
17
17
  @config_path = File.join(Config.config_path, "#{config_name}.json")
18
- puts "Config path: #{config_path}"
18
+ # puts "Config path: #{config_path}"
19
19
  @data = load
20
20
  end
21
21
 
@@ -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
@@ -0,0 +1,5 @@
1
+ # AI Prompt Tool
2
+
3
+ Tool for running AI prompt based tasks.
4
+
5
+ [ChatGPT - Update video](https://chatgpt.com/c/cf08e889-cad7-4277-918e-82f4a23b0bc8)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Appydave
4
4
  module Tools
5
- VERSION = '0.10.2'
5
+ VERSION = '0.10.3'
6
6
  end
7
7
  end
@@ -2,4 +2,4 @@
2
2
 
3
3
  Service classes for interacting with the YouTube API.
4
4
 
5
- [ChatGPT - Update video](https://chatgpt.com/c/41b75159-95c5-4183-92f3-e1be5e52a1e8)
5
+ [ChatGPT - Update video](https://chatgpt.com/c/41b75159-95c5-4183-92f3-e1be5e52a1e8)
@@ -18,6 +18,7 @@ require 'webrick'
18
18
  require 'pry'
19
19
 
20
20
  require 'appydave/tools/version'
21
+ require 'appydave/tools/debuggable'
21
22
  require 'appydave/tools/types/indifferent_access_hash'
22
23
  require 'appydave/tools/types/hash_type'
23
24
  require 'appydave/tools/types/array_type'
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "appydave-tools",
3
- "version": "0.10.2",
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.2",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appydave-tools",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "AppyDave YouTube Automation Tools",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
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.2
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