hledger-forecast 0.2.1 → 0.3.0
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/.gitignore +0 -2
- data/README.md +150 -71
- data/example.journal +35 -0
- data/example.yml +35 -36
- data/hledger-forecast.gemspec +5 -4
- data/lib/hledger_forecast/cli.rb +35 -93
- data/lib/hledger_forecast/generator.rb +233 -90
- data/lib/hledger_forecast/summarize.rb +4 -5
- data/lib/hledger_forecast/tracker.rb +37 -0
- data/lib/hledger_forecast/version.rb +1 -1
- data/lib/hledger_forecast.rb +1 -1
- data/spec/command_spec.rb +14 -4
- data/spec/custom_spec.rb +35 -42
- data/spec/half-yearly_spec.rb +22 -6
- data/spec/modifier_spec.rb +87 -0
- data/spec/monthly_end_date_spec.rb +47 -0
- data/spec/monthly_end_date_transaction_spec.rb +32 -0
- data/spec/monthly_spec.rb +35 -27
- data/spec/once_spec.rb +22 -7
- data/spec/quarterly_spec.rb +21 -7
- data/spec/stubs/{monthly/forecast_monthly.yml → forecast.yml} +7 -7
- data/spec/stubs/transactions_found.journal +24 -0
- data/spec/stubs/transactions_found_inverse.journal +24 -0
- data/spec/stubs/transactions_not_found.journal +16 -0
- data/spec/track_spec.rb +197 -0
- data/spec/yearly_spec.rb +21 -7
- metadata +32 -74
- data/spec/start_date_spec.rb +0 -12
- data/spec/stubs/custom/forecast_custom_days.yml +0 -14
- data/spec/stubs/custom/forecast_custom_months.yml +0 -14
- data/spec/stubs/custom/forecast_custom_weeks.yml +0 -14
- data/spec/stubs/custom/forecast_custom_weeks_twice.yml +0 -24
- data/spec/stubs/custom/output_custom_days.journal +0 -24
- data/spec/stubs/custom/output_custom_months.journal +0 -20
- data/spec/stubs/custom/output_custom_weeks.journal +0 -28
- data/spec/stubs/custom/output_custom_weeks_twice.journal +0 -44
- data/spec/stubs/half-yearly/forecast_half-yearly.yml +0 -10
- data/spec/stubs/half-yearly/output_half-yearly.journal +0 -20
- data/spec/stubs/modifiers/forecast_modifiers.yml +0 -13
- data/spec/stubs/modifiers/output_modifiers.journal +0 -44
- data/spec/stubs/monthly/forecast_monthly_enddate.yml +0 -14
- data/spec/stubs/monthly/forecast_monthly_enddate_top.yml +0 -14
- data/spec/stubs/monthly/forecast_monthly_modifier.yml +0 -11
- data/spec/stubs/monthly/output_monthly.journal +0 -44
- data/spec/stubs/monthly/output_monthly_enddate.journal +0 -48
- data/spec/stubs/monthly/output_monthly_enddate_top.journal +0 -40
- data/spec/stubs/monthly/output_monthly_modifier.journal +0 -20
- data/spec/stubs/once/forecast_once.yml +0 -10
- data/spec/stubs/once/output_once.journal +0 -12
- data/spec/stubs/quarterly/forecast_quarterly.yml +0 -10
- data/spec/stubs/quarterly/output_quarterly.journal +0 -20
- data/spec/stubs/start_date/forecast_startdate.yml +0 -26
- data/spec/stubs/start_date/output_startdate.journal +0 -56
- data/spec/stubs/transactions.journal +0 -8
- data/spec/stubs/yearly/forecast_yearly.yml +0 -10
- data/spec/stubs/yearly/output_yearly.journal +0 -16
data/spec/track_spec.rb
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
require_relative '../lib/hledger_forecast'
|
2
|
+
|
3
|
+
current_month = Date.new(Date.today.year, Date.today.month, 1)
|
4
|
+
previous_month = current_month.prev_month
|
5
|
+
next_month = current_month.next_month
|
6
|
+
|
7
|
+
base_config = <<~YAML
|
8
|
+
once:
|
9
|
+
- account: "Assets:Bank"
|
10
|
+
from: "2023-03-05"
|
11
|
+
transactions:
|
12
|
+
- amount: 3000
|
13
|
+
category: "Expenses:Tax"
|
14
|
+
description: Tax owed
|
15
|
+
track: true
|
16
|
+
- amount: 100
|
17
|
+
category: "Expenses:Food"
|
18
|
+
description: Food expenses
|
19
|
+
- amount: -1500
|
20
|
+
category: "Income:Salary"
|
21
|
+
description: Salary
|
22
|
+
to: "2023-08-01"
|
23
|
+
track: true
|
24
|
+
|
25
|
+
settings:
|
26
|
+
currency: GBP
|
27
|
+
YAML
|
28
|
+
|
29
|
+
base_output = <<~JOURNAL
|
30
|
+
~ 2023-03-05 * Food expenses
|
31
|
+
Expenses:Food £100.00 ; Food expenses
|
32
|
+
Assets:Bank
|
33
|
+
|
34
|
+
~ #{next_month} * [TRACKED] Tax owed
|
35
|
+
Expenses:Tax £3,000.00; Tax owed
|
36
|
+
Assets:Bank
|
37
|
+
|
38
|
+
~ #{next_month} * [TRACKED] Salary
|
39
|
+
Income:Salary £-1,500.00; Salary
|
40
|
+
Assets:Bank
|
41
|
+
|
42
|
+
JOURNAL
|
43
|
+
|
44
|
+
RSpec.describe 'Tracking transactions -' do
|
45
|
+
it 'Determines which transactions should be tracked' do
|
46
|
+
generated = HledgerForecast::Generator
|
47
|
+
generated.generate(base_config)
|
48
|
+
tracked = generated.tracked
|
49
|
+
|
50
|
+
expect(tracked[0]['transaction']).to eq(
|
51
|
+
{ "amount" => "£3,000.00", "category" => "Expenses:Tax", "description" => "Tax owed",
|
52
|
+
"inverse_amount" => "£-3,000.00", "track" => true }
|
53
|
+
)
|
54
|
+
expect(tracked[0]['account']).to eq("Assets:Bank")
|
55
|
+
|
56
|
+
expect(tracked[1]['transaction']).to eq(
|
57
|
+
{ "amount" => "£-1,500.00", "category" => "Income:Salary", "description" => "Salary", "to" => "2023-08-01",
|
58
|
+
"inverse_amount" => "£1,500.00", "track" => true }
|
59
|
+
)
|
60
|
+
expect(tracked[1]['account']).to eq("Assets:Bank")
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'marks a transaction as NOT FOUND if it doesnt exist' do
|
64
|
+
generated = HledgerForecast::Generator
|
65
|
+
generated.tracked = {} # Clear tracked transactions
|
66
|
+
generated.generate(base_config)
|
67
|
+
transactions_to_track = generated.tracked
|
68
|
+
|
69
|
+
track = HledgerForecast::Tracker.track(transactions_to_track, 'spec/stubs/transactions_not_found.journal')
|
70
|
+
|
71
|
+
expect(track[0]['found']).to eq(false)
|
72
|
+
expect(track[1]['found']).to eq(false)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'marks a transaction as FOUND if it exists' do
|
76
|
+
generated = HledgerForecast::Generator
|
77
|
+
generated.tracked = {} # Clear tracked transactions
|
78
|
+
generated.generate(base_config)
|
79
|
+
transactions_to_track = generated.tracked
|
80
|
+
|
81
|
+
track = HledgerForecast::Tracker.track(transactions_to_track, 'spec/stubs/transactions_found.journal')
|
82
|
+
|
83
|
+
expect(track[0]['found']).to eq(true)
|
84
|
+
expect(track[1]['found']).to eq(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'marks a transaction as FOUND if it exists, even if the category/amount are inversed' do
|
88
|
+
generated = HledgerForecast::Generator
|
89
|
+
generated.tracked = {} # Clear tracked transactions
|
90
|
+
generated.generate(base_config)
|
91
|
+
transactions_to_track = generated.tracked
|
92
|
+
|
93
|
+
track = HledgerForecast::Tracker.track(transactions_to_track, 'spec/stubs/transactions_found_inverse.journal')
|
94
|
+
|
95
|
+
expect(track[0]['found']).to eq(true)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'writes a NON-FOUND entry into a journal' do
|
99
|
+
options = {}
|
100
|
+
options[:transaction_file] = 'spec/stubs/transactions_not_found.journal'
|
101
|
+
|
102
|
+
generated = HledgerForecast::Generator
|
103
|
+
generated.tracked = {} # Clear tracked transactions
|
104
|
+
|
105
|
+
generated_journal = generated.generate(base_config, options)
|
106
|
+
|
107
|
+
expected_output = base_output
|
108
|
+
expect(generated_journal).to eq(expected_output)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'writes a NON-FOUND entry for dates that are close to the current period' do
|
112
|
+
require 'tempfile'
|
113
|
+
|
114
|
+
forecast_config = <<~YAML
|
115
|
+
once:
|
116
|
+
- account: "Assets:Bank"
|
117
|
+
from: "#{previous_month}"
|
118
|
+
transactions:
|
119
|
+
- amount: 5000
|
120
|
+
category: "Expenses:House"
|
121
|
+
description: New kitchen
|
122
|
+
track: true
|
123
|
+
|
124
|
+
settings:
|
125
|
+
currency: GBP
|
126
|
+
YAML
|
127
|
+
|
128
|
+
journal = <<~JOURNAL
|
129
|
+
#{previous_month} * Opening balance
|
130
|
+
Assets:Bank £1,000.00
|
131
|
+
Equity:Opening balance
|
132
|
+
|
133
|
+
#{previous_month} * Mortgage payment
|
134
|
+
Expenses:Mortgage £1,500.00
|
135
|
+
Assets:Bank
|
136
|
+
|
137
|
+
#{current_month - 10} * Groceries
|
138
|
+
Expenses:Groceries £1,500.00
|
139
|
+
Assets:Bank
|
140
|
+
|
141
|
+
JOURNAL
|
142
|
+
|
143
|
+
temp_file = Tempfile.new('journal')
|
144
|
+
temp_file.write(journal)
|
145
|
+
temp_file.close
|
146
|
+
|
147
|
+
options = {}
|
148
|
+
options[:transaction_file] = temp_file.path
|
149
|
+
|
150
|
+
generated = HledgerForecast::Generator
|
151
|
+
generated.tracked = {} # Clear tracked transactions
|
152
|
+
|
153
|
+
generated_journal = generated.generate(forecast_config, options)
|
154
|
+
|
155
|
+
expected_output = <<~JOURNAL
|
156
|
+
~ #{next_month} * [TRACKED] New kitchen
|
157
|
+
Expenses:House £5,000.00; New kitchen
|
158
|
+
Assets:Bank
|
159
|
+
|
160
|
+
JOURNAL
|
161
|
+
|
162
|
+
expect(generated_journal).to eq(expected_output)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'treats a future tracked transaction as a regular transaction' do
|
166
|
+
forecast_config = <<~YAML
|
167
|
+
monthly:
|
168
|
+
- account: "Assets:Bank"
|
169
|
+
from: "#{next_month}"
|
170
|
+
transactions:
|
171
|
+
- amount: 100
|
172
|
+
category: "Expenses:Food"
|
173
|
+
description: Food expenses
|
174
|
+
track: true
|
175
|
+
|
176
|
+
settings:
|
177
|
+
currency: GBP
|
178
|
+
YAML
|
179
|
+
|
180
|
+
options = {}
|
181
|
+
options[:transaction_file] = 'spec/stubs/transactions_not_found.journal'
|
182
|
+
|
183
|
+
generated = HledgerForecast::Generator
|
184
|
+
generated.tracked = {} # Clear tracked transactions
|
185
|
+
|
186
|
+
generated_journal = generated.generate(forecast_config, options)
|
187
|
+
|
188
|
+
output = <<~JOURNAL
|
189
|
+
~ monthly from #{next_month} * Food expenses
|
190
|
+
Expenses:Food £100.00; Food expenses
|
191
|
+
Assets:Bank
|
192
|
+
|
193
|
+
JOURNAL
|
194
|
+
|
195
|
+
expect(generated_journal).to eq(output)
|
196
|
+
end
|
197
|
+
end
|
data/spec/yearly_spec.rb
CHANGED
@@ -1,13 +1,27 @@
|
|
1
1
|
require_relative '../lib/hledger_forecast'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
config = <<~YAML
|
4
|
+
settings:
|
5
|
+
currency: GBP
|
6
|
+
|
7
|
+
yearly:
|
8
|
+
- account: "Assets:Bank"
|
9
|
+
from: "2023-04-01"
|
10
|
+
transactions:
|
11
|
+
- description: Bonus
|
12
|
+
category: "Income:Bonus"
|
13
|
+
amount: -3,000.00
|
14
|
+
YAML
|
7
15
|
|
8
|
-
|
16
|
+
output = <<~JOURNAL
|
17
|
+
~ yearly from 2023-04-01 * Bonus
|
18
|
+
Income:Bonus £-3,000.00; Bonus
|
19
|
+
Assets:Bank
|
9
20
|
|
10
|
-
|
11
|
-
|
21
|
+
JOURNAL
|
22
|
+
|
23
|
+
RSpec.describe 'generate' do
|
24
|
+
it 'generates a forecast with correct YEARLY transactions' do
|
25
|
+
expect(HledgerForecast::Generator.generate(config)).to eq(output)
|
12
26
|
end
|
13
27
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hledger-forecast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oli Morris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: colorize
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.8.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: highline
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: money
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 6.16.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 6.16.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: terminal-table
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,8 +80,8 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.12'
|
83
|
-
description: Uses a YAML file to generate
|
84
|
-
|
83
|
+
description: Uses a YAML file to generate forecasts which can be used to extend the
|
84
|
+
default functionality in hledger
|
85
85
|
email: olimorris@users.noreply.github.com
|
86
86
|
executables:
|
87
87
|
- hledger-forecast
|
@@ -95,49 +95,29 @@ files:
|
|
95
95
|
- LICENSE
|
96
96
|
- README.md
|
97
97
|
- bin/hledger-forecast
|
98
|
+
- example.journal
|
98
99
|
- example.yml
|
99
100
|
- hledger-forecast.gemspec
|
100
101
|
- lib/hledger_forecast.rb
|
101
102
|
- lib/hledger_forecast/cli.rb
|
102
103
|
- lib/hledger_forecast/generator.rb
|
103
104
|
- lib/hledger_forecast/summarize.rb
|
105
|
+
- lib/hledger_forecast/tracker.rb
|
104
106
|
- lib/hledger_forecast/version.rb
|
105
107
|
- spec/command_spec.rb
|
106
108
|
- spec/custom_spec.rb
|
107
109
|
- spec/half-yearly_spec.rb
|
110
|
+
- spec/modifier_spec.rb
|
111
|
+
- spec/monthly_end_date_spec.rb
|
112
|
+
- spec/monthly_end_date_transaction_spec.rb
|
108
113
|
- spec/monthly_spec.rb
|
109
114
|
- spec/once_spec.rb
|
110
115
|
- spec/quarterly_spec.rb
|
111
|
-
- spec/
|
112
|
-
- spec/stubs/
|
113
|
-
- spec/stubs/
|
114
|
-
- spec/stubs/
|
115
|
-
- spec/
|
116
|
-
- spec/stubs/custom/output_custom_days.journal
|
117
|
-
- spec/stubs/custom/output_custom_months.journal
|
118
|
-
- spec/stubs/custom/output_custom_weeks.journal
|
119
|
-
- spec/stubs/custom/output_custom_weeks_twice.journal
|
120
|
-
- spec/stubs/half-yearly/forecast_half-yearly.yml
|
121
|
-
- spec/stubs/half-yearly/output_half-yearly.journal
|
122
|
-
- spec/stubs/modifiers/forecast_modifiers.yml
|
123
|
-
- spec/stubs/modifiers/output_modifiers.journal
|
124
|
-
- spec/stubs/monthly/forecast_monthly.yml
|
125
|
-
- spec/stubs/monthly/forecast_monthly_enddate.yml
|
126
|
-
- spec/stubs/monthly/forecast_monthly_enddate_top.yml
|
127
|
-
- spec/stubs/monthly/forecast_monthly_modifier.yml
|
128
|
-
- spec/stubs/monthly/output_monthly.journal
|
129
|
-
- spec/stubs/monthly/output_monthly_enddate.journal
|
130
|
-
- spec/stubs/monthly/output_monthly_enddate_top.journal
|
131
|
-
- spec/stubs/monthly/output_monthly_modifier.journal
|
132
|
-
- spec/stubs/once/forecast_once.yml
|
133
|
-
- spec/stubs/once/output_once.journal
|
134
|
-
- spec/stubs/quarterly/forecast_quarterly.yml
|
135
|
-
- spec/stubs/quarterly/output_quarterly.journal
|
136
|
-
- spec/stubs/start_date/forecast_startdate.yml
|
137
|
-
- spec/stubs/start_date/output_startdate.journal
|
138
|
-
- spec/stubs/transactions.journal
|
139
|
-
- spec/stubs/yearly/forecast_yearly.yml
|
140
|
-
- spec/stubs/yearly/output_yearly.journal
|
116
|
+
- spec/stubs/forecast.yml
|
117
|
+
- spec/stubs/transactions_found.journal
|
118
|
+
- spec/stubs/transactions_found_inverse.journal
|
119
|
+
- spec/stubs/transactions_not_found.journal
|
120
|
+
- spec/track_spec.rb
|
141
121
|
- spec/yearly_spec.rb
|
142
122
|
homepage: https://github.com/olimorris/hledger-forecast
|
143
123
|
licenses:
|
@@ -161,42 +141,20 @@ requirements: []
|
|
161
141
|
rubygems_version: 3.4.12
|
162
142
|
signing_key:
|
163
143
|
specification_version: 4
|
164
|
-
summary:
|
144
|
+
summary: An extended wrapper around hledger's forecasting functionality
|
165
145
|
test_files:
|
166
146
|
- spec/command_spec.rb
|
167
147
|
- spec/custom_spec.rb
|
168
148
|
- spec/half-yearly_spec.rb
|
149
|
+
- spec/modifier_spec.rb
|
150
|
+
- spec/monthly_end_date_spec.rb
|
151
|
+
- spec/monthly_end_date_transaction_spec.rb
|
169
152
|
- spec/monthly_spec.rb
|
170
153
|
- spec/once_spec.rb
|
171
154
|
- spec/quarterly_spec.rb
|
172
|
-
- spec/
|
173
|
-
- spec/stubs/
|
174
|
-
- spec/stubs/
|
175
|
-
- spec/stubs/
|
176
|
-
- spec/
|
177
|
-
- spec/stubs/custom/output_custom_days.journal
|
178
|
-
- spec/stubs/custom/output_custom_months.journal
|
179
|
-
- spec/stubs/custom/output_custom_weeks.journal
|
180
|
-
- spec/stubs/custom/output_custom_weeks_twice.journal
|
181
|
-
- spec/stubs/half-yearly/forecast_half-yearly.yml
|
182
|
-
- spec/stubs/half-yearly/output_half-yearly.journal
|
183
|
-
- spec/stubs/modifiers/forecast_modifiers.yml
|
184
|
-
- spec/stubs/modifiers/output_modifiers.journal
|
185
|
-
- spec/stubs/monthly/forecast_monthly.yml
|
186
|
-
- spec/stubs/monthly/forecast_monthly_enddate.yml
|
187
|
-
- spec/stubs/monthly/forecast_monthly_enddate_top.yml
|
188
|
-
- spec/stubs/monthly/forecast_monthly_modifier.yml
|
189
|
-
- spec/stubs/monthly/output_monthly.journal
|
190
|
-
- spec/stubs/monthly/output_monthly_enddate.journal
|
191
|
-
- spec/stubs/monthly/output_monthly_enddate_top.journal
|
192
|
-
- spec/stubs/monthly/output_monthly_modifier.journal
|
193
|
-
- spec/stubs/once/forecast_once.yml
|
194
|
-
- spec/stubs/once/output_once.journal
|
195
|
-
- spec/stubs/quarterly/forecast_quarterly.yml
|
196
|
-
- spec/stubs/quarterly/output_quarterly.journal
|
197
|
-
- spec/stubs/start_date/forecast_startdate.yml
|
198
|
-
- spec/stubs/start_date/output_startdate.journal
|
199
|
-
- spec/stubs/transactions.journal
|
200
|
-
- spec/stubs/yearly/forecast_yearly.yml
|
201
|
-
- spec/stubs/yearly/output_yearly.journal
|
155
|
+
- spec/stubs/forecast.yml
|
156
|
+
- spec/stubs/transactions_found.journal
|
157
|
+
- spec/stubs/transactions_found_inverse.journal
|
158
|
+
- spec/stubs/transactions_not_found.journal
|
159
|
+
- spec/track_spec.rb
|
202
160
|
- spec/yearly_spec.rb
|
data/spec/start_date_spec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require_relative '../lib/hledger_forecast'
|
2
|
-
RSpec.describe 'generate' do
|
3
|
-
it 'generates a forecast with correct MONTHLY transactions that have a START DATE' do
|
4
|
-
transactions = File.read('spec/stubs/transactions.journal')
|
5
|
-
forecast = File.read('spec/stubs/start_date/forecast_startdate.yml')
|
6
|
-
|
7
|
-
generated_journal = HledgerForecast::Generator.generate(transactions, forecast, '2023-03-01', '2023-08-30')
|
8
|
-
|
9
|
-
expected_output = File.read('spec/stubs/start_date/output_startdate.journal')
|
10
|
-
expect(generated_journal).to eq(expected_output)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
custom:
|
2
|
-
- description: Repeat every 3 days
|
3
|
-
recurrence:
|
4
|
-
period: days
|
5
|
-
quantity: 3
|
6
|
-
account: "[Assets:Bank]"
|
7
|
-
start: "2023-03-01"
|
8
|
-
transactions:
|
9
|
-
- amount: 80
|
10
|
-
category: "[Expenses:Personal Care]"
|
11
|
-
description: Hair and beauty
|
12
|
-
|
13
|
-
settings:
|
14
|
-
currency: GBP
|
@@ -1,14 +0,0 @@
|
|
1
|
-
custom:
|
2
|
-
- description: Repeat every 5 months
|
3
|
-
recurrence:
|
4
|
-
period: months
|
5
|
-
quantity: 5
|
6
|
-
account: "[Assets:Bank]"
|
7
|
-
start: "2023-03-01"
|
8
|
-
transactions:
|
9
|
-
- amount: 100
|
10
|
-
category: "[Expenses:Personal Care]"
|
11
|
-
description: Hair and beauty
|
12
|
-
|
13
|
-
settings:
|
14
|
-
currency: GBP
|
@@ -1,14 +0,0 @@
|
|
1
|
-
custom:
|
2
|
-
- description: Repeat every 2 weeks
|
3
|
-
recurrence:
|
4
|
-
period: weeks
|
5
|
-
quantity: 2
|
6
|
-
account: "[Assets:Bank]"
|
7
|
-
start: "2023-03-01"
|
8
|
-
transactions:
|
9
|
-
- amount: 75
|
10
|
-
category: "[Expenses:Personal Care]"
|
11
|
-
description: Hair and beauty
|
12
|
-
|
13
|
-
settings:
|
14
|
-
currency: GBP
|
@@ -1,24 +0,0 @@
|
|
1
|
-
custom:
|
2
|
-
- description: Beauty expenses every 2 weeks
|
3
|
-
recurrence:
|
4
|
-
period: weeks
|
5
|
-
quantity: 2
|
6
|
-
account: "[Assets:Bank]"
|
7
|
-
start: "2023-03-01"
|
8
|
-
transactions:
|
9
|
-
- amount: 75
|
10
|
-
category: "[Expenses:Personal Care]"
|
11
|
-
description: Hair and beauty
|
12
|
-
- description: Car fuel every 5 days
|
13
|
-
recurrence:
|
14
|
-
period: days
|
15
|
-
quantity: 5
|
16
|
-
account: "[Assets:Bank]"
|
17
|
-
start: "2023-03-01"
|
18
|
-
transactions:
|
19
|
-
- amount: 150
|
20
|
-
category: "[Expenses:Car:Fuel]"
|
21
|
-
description: Car Fuel
|
22
|
-
|
23
|
-
settings:
|
24
|
-
currency: GBP
|
@@ -1,24 +0,0 @@
|
|
1
|
-
2023-02-01 * Opening balance
|
2
|
-
Assets:Bank £1,000.00
|
3
|
-
Equity:Opening balance
|
4
|
-
|
5
|
-
2023-02-05 * Mortgage payment
|
6
|
-
Expenses:Mortgage £1,500.00
|
7
|
-
Assets:Bank
|
8
|
-
|
9
|
-
2023-03-01 * Hair and beauty
|
10
|
-
[Expenses:Personal Care] £80.00
|
11
|
-
[Assets:Bank]
|
12
|
-
|
13
|
-
2023-03-04 * Hair and beauty
|
14
|
-
[Expenses:Personal Care] £80.00
|
15
|
-
[Assets:Bank]
|
16
|
-
|
17
|
-
2023-03-07 * Hair and beauty
|
18
|
-
[Expenses:Personal Care] £80.00
|
19
|
-
[Assets:Bank]
|
20
|
-
|
21
|
-
2023-03-10 * Hair and beauty
|
22
|
-
[Expenses:Personal Care] £80.00
|
23
|
-
[Assets:Bank]
|
24
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
2023-02-01 * Opening balance
|
2
|
-
Assets:Bank £1,000.00
|
3
|
-
Equity:Opening balance
|
4
|
-
|
5
|
-
2023-02-05 * Mortgage payment
|
6
|
-
Expenses:Mortgage £1,500.00
|
7
|
-
Assets:Bank
|
8
|
-
|
9
|
-
2023-03-01 * Hair and beauty
|
10
|
-
[Expenses:Personal Care] £100.00
|
11
|
-
[Assets:Bank]
|
12
|
-
|
13
|
-
2023-08-01 * Hair and beauty
|
14
|
-
[Expenses:Personal Care] £100.00
|
15
|
-
[Assets:Bank]
|
16
|
-
|
17
|
-
2024-01-01 * Hair and beauty
|
18
|
-
[Expenses:Personal Care] £100.00
|
19
|
-
[Assets:Bank]
|
20
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
2023-02-01 * Opening balance
|
2
|
-
Assets:Bank £1,000.00
|
3
|
-
Equity:Opening balance
|
4
|
-
|
5
|
-
2023-02-05 * Mortgage payment
|
6
|
-
Expenses:Mortgage £1,500.00
|
7
|
-
Assets:Bank
|
8
|
-
|
9
|
-
2023-03-01 * Hair and beauty
|
10
|
-
[Expenses:Personal Care] £75.00
|
11
|
-
[Assets:Bank]
|
12
|
-
|
13
|
-
2023-03-15 * Hair and beauty
|
14
|
-
[Expenses:Personal Care] £75.00
|
15
|
-
[Assets:Bank]
|
16
|
-
|
17
|
-
2023-03-29 * Hair and beauty
|
18
|
-
[Expenses:Personal Care] £75.00
|
19
|
-
[Assets:Bank]
|
20
|
-
|
21
|
-
2023-04-12 * Hair and beauty
|
22
|
-
[Expenses:Personal Care] £75.00
|
23
|
-
[Assets:Bank]
|
24
|
-
|
25
|
-
2023-04-26 * Hair and beauty
|
26
|
-
[Expenses:Personal Care] £75.00
|
27
|
-
[Assets:Bank]
|
28
|
-
|
@@ -1,44 +0,0 @@
|
|
1
|
-
2023-02-01 * Opening balance
|
2
|
-
Assets:Bank £1,000.00
|
3
|
-
Equity:Opening balance
|
4
|
-
|
5
|
-
2023-02-05 * Mortgage payment
|
6
|
-
Expenses:Mortgage £1,500.00
|
7
|
-
Assets:Bank
|
8
|
-
|
9
|
-
2023-03-01 * Hair and beauty
|
10
|
-
[Expenses:Personal Care] £75.00
|
11
|
-
[Assets:Bank]
|
12
|
-
|
13
|
-
2023-03-01 * Car Fuel
|
14
|
-
[Expenses:Car:Fuel] £150.00
|
15
|
-
[Assets:Bank]
|
16
|
-
|
17
|
-
2023-03-06 * Car Fuel
|
18
|
-
[Expenses:Car:Fuel] £150.00
|
19
|
-
[Assets:Bank]
|
20
|
-
|
21
|
-
2023-03-11 * Car Fuel
|
22
|
-
[Expenses:Car:Fuel] £150.00
|
23
|
-
[Assets:Bank]
|
24
|
-
|
25
|
-
2023-03-15 * Hair and beauty
|
26
|
-
[Expenses:Personal Care] £75.00
|
27
|
-
[Assets:Bank]
|
28
|
-
|
29
|
-
2023-03-16 * Car Fuel
|
30
|
-
[Expenses:Car:Fuel] £150.00
|
31
|
-
[Assets:Bank]
|
32
|
-
|
33
|
-
2023-03-21 * Car Fuel
|
34
|
-
[Expenses:Car:Fuel] £150.00
|
35
|
-
[Assets:Bank]
|
36
|
-
|
37
|
-
2023-03-26 * Car Fuel
|
38
|
-
[Expenses:Car:Fuel] £150.00
|
39
|
-
[Assets:Bank]
|
40
|
-
|
41
|
-
2023-03-29 * Hair and beauty
|
42
|
-
[Expenses:Personal Care] £75.00
|
43
|
-
[Assets:Bank]
|
44
|
-
|
@@ -1,20 +0,0 @@
|
|
1
|
-
2023-02-01 * Opening balance
|
2
|
-
Assets:Bank £1,000.00
|
3
|
-
Equity:Opening balance
|
4
|
-
|
5
|
-
2023-02-05 * Mortgage payment
|
6
|
-
Expenses:Mortgage £1,500.00
|
7
|
-
Assets:Bank
|
8
|
-
|
9
|
-
2023-04-01 * Holiday
|
10
|
-
[Expenses:Holiday] £500.00
|
11
|
-
[Assets:Bank]
|
12
|
-
|
13
|
-
2023-10-01 * Holiday
|
14
|
-
[Expenses:Holiday] £500.00
|
15
|
-
[Assets:Bank]
|
16
|
-
|
17
|
-
2024-04-01 * Holiday
|
18
|
-
[Expenses:Holiday] £500.00
|
19
|
-
[Assets:Bank]
|
20
|
-
|