hledger-forecast 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/.gitignore +7 -1
- data/README.md +8 -2
- data/bin/hledger-forecast +0 -1
- data/example.yml +40 -0
- data/lib/hledger_forecast/command.rb +1 -1
- data/lib/hledger_forecast/options.rb +5 -1
- data/lib/hledger_forecast/version.rb +1 -1
- data/spec/command_spec.rb +12 -0
- data/spec/stubs/monthly/output_monthly.journal +32 -0
- data/spec/stubs/monthly/output_monthly_enddate.journal +48 -0
- data/spec/stubs/monthly/output_monthly_enddate_top.journal +40 -0
- data/spec/stubs/monthly/output_monthly_modifier.journal +20 -0
- data/spec/stubs/once/output_once.journal +12 -0
- data/spec/stubs/quarterly/output_quarterly.journal +20 -0
- data/spec/stubs/yearly/output_yearly.journal +16 -0
- metadata +19 -4
- data/Gemfile.lock +0 -41
- data/example.yaml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5643f9c8df4ba13c316af221d62c02e91263948fe34e42dc1a50683b164a73ba
|
4
|
+
data.tar.gz: 10dad47f307b30f253db51b78aa26bfdd915323c120160e9c29e8e8981fb87fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f1b17f8f0f0dba931d208e1f94d55dedfa1f6ee8a6506fc4ca7d456893d5725b2fef0e3a3e8650ca6916ce9edd9b9d6ba9ceebdacd3225f8f0160719063cb5d
|
7
|
+
data.tar.gz: b64392b194aedad3db34478d59ee124b6d857b68c152659abf2611c9a5e5418be3b784a389201b858fa0a9395e5669995afeffc4dce23e4b8cde2d28556bdd9c
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: Tests
|
2
2
|
|
3
3
|
on:
|
4
4
|
pull_request:
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
strategy:
|
14
14
|
matrix:
|
15
|
-
ruby-version: ['
|
15
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
16
16
|
|
17
17
|
steps:
|
18
18
|
- uses: actions/checkout@v3
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Hledger-Forecast
|
2
2
|
|
3
|
-
![Tests](https://github.com/olimorris/hledger-forecast/workflows/ci/badge.svg)
|
3
|
+
[![Tests](https://github.com/olimorris/hledger-forecast/actions/workflows/ci.yml/badge.svg)](https://github.com/olimorris/hledger-forecast/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
> **Warning**: This is still in the early stages of development and the API is likely to change
|
6
6
|
|
@@ -36,6 +36,7 @@ Running `hledger-forecast -h` shows the available options:
|
|
36
36
|
-o, --output-file FILE The OUTPUT file to create
|
37
37
|
-s, --start-date DATE The date to start generating from (yyyy-mm-dd)
|
38
38
|
-e, --end-date DATE The date to start generating to (yyyy-mm-dd)
|
39
|
+
--force Force an overwrite of the output file
|
39
40
|
-h, --help Show this message
|
40
41
|
--version Show version
|
41
42
|
|
@@ -43,10 +44,15 @@ To then include in Hledger:
|
|
43
44
|
|
44
45
|
hledger -f transactions.journal -f forecast.journal
|
45
46
|
|
46
|
-
where
|
47
|
+
where:
|
48
|
+
|
49
|
+
- `transactions.journal` might be your bank transactions (your "_actuals_")
|
50
|
+
- `forecast.journal` is the generated forecast file
|
47
51
|
|
48
52
|
### A simple config file
|
49
53
|
|
54
|
+
> **Note**: See the [example.yml](https://github.com/olimorris/hledger-forecast/blob/main/example.yml) file for all of the options
|
55
|
+
|
50
56
|
Firstly, create a `yml` file which will contain the transactions you'd like to forecast:
|
51
57
|
|
52
58
|
```yaml
|
data/bin/hledger-forecast
CHANGED
data/example.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
monthly:
|
2
|
+
- account: "[Assets:Bank]"
|
3
|
+
date: "2023-03-01"
|
4
|
+
transactions:
|
5
|
+
- amount: 1000.00
|
6
|
+
category: "[Expenses:Mortgage]"
|
7
|
+
description: Mortgage
|
8
|
+
- amount: 500.00
|
9
|
+
category: "[Expenses:Food]"
|
10
|
+
description: Food
|
11
|
+
|
12
|
+
quarterly:
|
13
|
+
- account: "[Assets:Bank]"
|
14
|
+
date: "2023-04-01"
|
15
|
+
transactions:
|
16
|
+
- amount: -1000.00
|
17
|
+
category: "[Income:Bonus]"
|
18
|
+
description: Bonus
|
19
|
+
|
20
|
+
yearly:
|
21
|
+
- account: "[Assets:Bank]"
|
22
|
+
date: "2023-04-01"
|
23
|
+
transactions:
|
24
|
+
- amount: -2000.00
|
25
|
+
category: "[Income:Bonus]"
|
26
|
+
description: Annual Bonus
|
27
|
+
|
28
|
+
once:
|
29
|
+
- account: "[Assets:Bank]"
|
30
|
+
date: "2024-01-01"
|
31
|
+
transactions:
|
32
|
+
- amount: 5000.00
|
33
|
+
category: "[Expenses:Car]"
|
34
|
+
description: Forecast new car cost
|
35
|
+
|
36
|
+
settings:
|
37
|
+
currency: GBP
|
38
|
+
show_symbol: false
|
39
|
+
sign_before_symbol: true
|
40
|
+
thousands_separator: false
|
@@ -11,7 +11,7 @@ module HledgerForecast
|
|
11
11
|
transactions = Generator.create_journal_entries(transactions, forecast, start_date, end_date)
|
12
12
|
|
13
13
|
output_file = args[:output_file]
|
14
|
-
if File.exist?(output_file)
|
14
|
+
if File.exist?(output_file) && !args[:force]
|
15
15
|
print "File '#{output_file}' already exists. Overwrite? (y/n): "
|
16
16
|
overwrite = gets.chomp.downcase
|
17
17
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module HledgerForecast
|
2
2
|
class Options
|
3
3
|
def self.parse_command_line_options(args = ARGV, _stdin = $stdin)
|
4
|
-
cli = HighLine.new
|
5
4
|
options = {}
|
6
5
|
|
7
6
|
OptionParser.new do |opts|
|
@@ -33,6 +32,11 @@ module HledgerForecast
|
|
33
32
|
options[:end_date] = a
|
34
33
|
end
|
35
34
|
|
35
|
+
opts.on("--force",
|
36
|
+
"Force an overwrite of the output file") do |a|
|
37
|
+
options[:force] = a
|
38
|
+
end
|
39
|
+
|
36
40
|
opts.on_tail("-h", "--help", "Show this message") do
|
37
41
|
puts opts
|
38
42
|
exit
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../lib/hledger_forecast'
|
2
|
+
|
3
|
+
RSpec.describe 'command' do
|
4
|
+
it 'uses the CLI to generate an output' do
|
5
|
+
system("./bin/hledger-forecast -t ./spec/stubs/transactions.journal -f ./spec/stubs/monthly/forecast_monthly.yml -o ./test_output.journal -s 2023-03-01 -e 2023-05-30 --force")
|
6
|
+
|
7
|
+
expected_output = File.read('spec/stubs/monthly/output_monthly.journal')
|
8
|
+
generated_journal = File.read('./test_output.journal')
|
9
|
+
|
10
|
+
expect(generated_journal).to eq(expected_output)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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 * Mortgage
|
10
|
+
[Expenses:Mortgage] £2,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2023-03-01 * Food
|
14
|
+
[Expenses:Food] £100.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
17
|
+
2023-04-01 * Mortgage
|
18
|
+
[Expenses:Mortgage] £2,000.00
|
19
|
+
[Assets:Bank]
|
20
|
+
|
21
|
+
2023-04-01 * Food
|
22
|
+
[Expenses:Food] £100.00
|
23
|
+
[Assets:Bank]
|
24
|
+
|
25
|
+
2023-05-01 * Mortgage
|
26
|
+
[Expenses:Mortgage] £2,000.00
|
27
|
+
[Assets:Bank]
|
28
|
+
|
29
|
+
2023-05-01 * Food
|
30
|
+
[Expenses:Food] £100.00
|
31
|
+
[Assets:Bank]
|
32
|
+
|
@@ -0,0 +1,48 @@
|
|
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 * Mortgage
|
10
|
+
[Expenses:Mortgage] £2,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2023-03-01 * Food
|
14
|
+
[Expenses:Food] £100.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
17
|
+
2023-04-01 * Mortgage
|
18
|
+
[Expenses:Mortgage] £2,000.00
|
19
|
+
[Assets:Bank]
|
20
|
+
|
21
|
+
2023-04-01 * Food
|
22
|
+
[Expenses:Food] £100.00
|
23
|
+
[Assets:Bank]
|
24
|
+
|
25
|
+
2023-05-01 * Mortgage
|
26
|
+
[Expenses:Mortgage] £2,000.00
|
27
|
+
[Assets:Bank]
|
28
|
+
|
29
|
+
2023-05-01 * Food
|
30
|
+
[Expenses:Food] £100.00
|
31
|
+
[Assets:Bank]
|
32
|
+
|
33
|
+
2023-06-01 * Mortgage
|
34
|
+
[Expenses:Mortgage] £2,000.00
|
35
|
+
[Assets:Bank]
|
36
|
+
|
37
|
+
2023-06-01 * Food
|
38
|
+
[Expenses:Food] £100.00
|
39
|
+
[Assets:Bank]
|
40
|
+
|
41
|
+
2023-07-01 * Food
|
42
|
+
[Expenses:Food] £100.00
|
43
|
+
[Assets:Bank]
|
44
|
+
|
45
|
+
2023-08-01 * Food
|
46
|
+
[Expenses:Food] £100.00
|
47
|
+
[Assets:Bank]
|
48
|
+
|
@@ -0,0 +1,40 @@
|
|
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 * Mortgage
|
10
|
+
[Expenses:Mortgage] £2,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2023-03-01 * Food
|
14
|
+
[Expenses:Food] £100.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
17
|
+
2023-04-01 * Mortgage
|
18
|
+
[Expenses:Mortgage] £2,000.00
|
19
|
+
[Assets:Bank]
|
20
|
+
|
21
|
+
2023-04-01 * Food
|
22
|
+
[Expenses:Food] £100.00
|
23
|
+
[Assets:Bank]
|
24
|
+
|
25
|
+
2023-05-01 * Mortgage
|
26
|
+
[Expenses:Mortgage] £2,000.00
|
27
|
+
[Assets:Bank]
|
28
|
+
|
29
|
+
2023-05-01 * Food
|
30
|
+
[Expenses:Food] £100.00
|
31
|
+
[Assets:Bank]
|
32
|
+
|
33
|
+
2023-06-01 * Mortgage
|
34
|
+
[Expenses:Mortgage] £2,000.00
|
35
|
+
[Assets:Bank]
|
36
|
+
|
37
|
+
2023-06-01 * Food
|
38
|
+
[Expenses:Food] £100.00
|
39
|
+
[Assets:Bank]
|
40
|
+
|
@@ -0,0 +1,20 @@
|
|
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 * Mortgage
|
10
|
+
[Expenses:Mortgage] £2,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2023-04-01 * Mortgage
|
14
|
+
[Expenses:Mortgage] £2,000.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
17
|
+
2023-05-01 * Mortgage
|
18
|
+
[Expenses:Mortgage] £2,000.00
|
19
|
+
[Assets:Bank]
|
20
|
+
|
@@ -0,0 +1,20 @@
|
|
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 * Bonus
|
10
|
+
[Income:Bonus] -£1,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2023-07-01 * Bonus
|
14
|
+
[Income:Bonus] -£1,000.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
17
|
+
2023-10-01 * Bonus
|
18
|
+
[Income:Bonus] -£1,000.00
|
19
|
+
[Assets:Bank]
|
20
|
+
|
@@ -0,0 +1,16 @@
|
|
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 * Bonus
|
10
|
+
[Income:Bonus] -£3,000.00
|
11
|
+
[Assets:Bank]
|
12
|
+
|
13
|
+
2024-04-01 * Bonus
|
14
|
+
[Income:Bonus] -£3,000.00
|
15
|
+
[Assets:Bank]
|
16
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hledger-forecast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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-04-
|
11
|
+
date: 2023-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -65,17 +65,17 @@ files:
|
|
65
65
|
- ".rubocop.yml"
|
66
66
|
- ".ruby-version"
|
67
67
|
- Gemfile
|
68
|
-
- Gemfile.lock
|
69
68
|
- LICENSE
|
70
69
|
- README.md
|
71
70
|
- bin/hledger-forecast
|
72
|
-
- example.
|
71
|
+
- example.yml
|
73
72
|
- hledger-forecast.gemspec
|
74
73
|
- lib/hledger_forecast.rb
|
75
74
|
- lib/hledger_forecast/command.rb
|
76
75
|
- lib/hledger_forecast/generator.rb
|
77
76
|
- lib/hledger_forecast/options.rb
|
78
77
|
- lib/hledger_forecast/version.rb
|
78
|
+
- spec/command_spec.rb
|
79
79
|
- spec/monthly_spec.rb
|
80
80
|
- spec/once_spec.rb
|
81
81
|
- spec/quarterly_spec.rb
|
@@ -83,10 +83,17 @@ files:
|
|
83
83
|
- spec/stubs/monthly/forecast_monthly_enddate.yml
|
84
84
|
- spec/stubs/monthly/forecast_monthly_enddate_top.yml
|
85
85
|
- spec/stubs/monthly/forecast_monthly_modifier.yml
|
86
|
+
- spec/stubs/monthly/output_monthly.journal
|
87
|
+
- spec/stubs/monthly/output_monthly_enddate.journal
|
88
|
+
- spec/stubs/monthly/output_monthly_enddate_top.journal
|
89
|
+
- spec/stubs/monthly/output_monthly_modifier.journal
|
86
90
|
- spec/stubs/once/forecast_once.yml
|
91
|
+
- spec/stubs/once/output_once.journal
|
87
92
|
- spec/stubs/quarterly/forecast_quarterly.yml
|
93
|
+
- spec/stubs/quarterly/output_quarterly.journal
|
88
94
|
- spec/stubs/transactions.journal
|
89
95
|
- spec/stubs/yearly/forecast_yearly.yml
|
96
|
+
- spec/stubs/yearly/output_yearly.journal
|
90
97
|
- spec/yearly_spec.rb
|
91
98
|
homepage: https://github.com/olimorris/hledger-forecast
|
92
99
|
licenses:
|
@@ -112,6 +119,7 @@ signing_key:
|
|
112
119
|
specification_version: 4
|
113
120
|
summary: Utility to generate forecasts in Hledger
|
114
121
|
test_files:
|
122
|
+
- spec/command_spec.rb
|
115
123
|
- spec/monthly_spec.rb
|
116
124
|
- spec/once_spec.rb
|
117
125
|
- spec/quarterly_spec.rb
|
@@ -119,8 +127,15 @@ test_files:
|
|
119
127
|
- spec/stubs/monthly/forecast_monthly_enddate.yml
|
120
128
|
- spec/stubs/monthly/forecast_monthly_enddate_top.yml
|
121
129
|
- spec/stubs/monthly/forecast_monthly_modifier.yml
|
130
|
+
- spec/stubs/monthly/output_monthly.journal
|
131
|
+
- spec/stubs/monthly/output_monthly_enddate.journal
|
132
|
+
- spec/stubs/monthly/output_monthly_enddate_top.journal
|
133
|
+
- spec/stubs/monthly/output_monthly_modifier.journal
|
122
134
|
- spec/stubs/once/forecast_once.yml
|
135
|
+
- spec/stubs/once/output_once.journal
|
123
136
|
- spec/stubs/quarterly/forecast_quarterly.yml
|
137
|
+
- spec/stubs/quarterly/output_quarterly.journal
|
124
138
|
- spec/stubs/transactions.journal
|
125
139
|
- spec/stubs/yearly/forecast_yearly.yml
|
140
|
+
- spec/stubs/yearly/output_yearly.journal
|
126
141
|
- spec/yearly_spec.rb
|
data/Gemfile.lock
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
hledger-forecast (0.1.0)
|
5
|
-
highline (~> 2.1.0)
|
6
|
-
money (~> 6.16.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
concurrent-ruby (1.2.2)
|
12
|
-
diff-lcs (1.5.0)
|
13
|
-
highline (2.1.0)
|
14
|
-
i18n (1.12.0)
|
15
|
-
concurrent-ruby (~> 1.0)
|
16
|
-
money (6.16.0)
|
17
|
-
i18n (>= 0.6.4, <= 2)
|
18
|
-
rspec (3.12.0)
|
19
|
-
rspec-core (~> 3.12.0)
|
20
|
-
rspec-expectations (~> 3.12.0)
|
21
|
-
rspec-mocks (~> 3.12.0)
|
22
|
-
rspec-core (3.12.1)
|
23
|
-
rspec-support (~> 3.12.0)
|
24
|
-
rspec-expectations (3.12.2)
|
25
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.12.0)
|
27
|
-
rspec-mocks (3.12.5)
|
28
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.12.0)
|
30
|
-
rspec-support (3.12.0)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
arm64-darwin-21
|
34
|
-
|
35
|
-
DEPENDENCIES
|
36
|
-
hledger-forecast!
|
37
|
-
money
|
38
|
-
rspec (~> 3.12)
|
39
|
-
|
40
|
-
BUNDLED WITH
|
41
|
-
2.4.10
|
data/example.yaml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
monthly:
|
2
|
-
- date: "2023-03-01"
|
3
|
-
account: "[Assets:Bank]"
|
4
|
-
transactions:
|
5
|
-
- description: Mortgage
|
6
|
-
category: "[Expenses:Mortgage]"
|
7
|
-
amount: £1,000.00
|
8
|
-
- description: Food
|
9
|
-
category: "[Expenses:Food]"
|
10
|
-
amount: £500.00
|
11
|
-
|
12
|
-
quarterly:
|
13
|
-
- date: "2023-04-01"
|
14
|
-
account: "[Assets:Bank]"
|
15
|
-
transactions:
|
16
|
-
- description: Bonus
|
17
|
-
category: "[Income:Bonus]"
|
18
|
-
amount: -£1,000.00
|
19
|
-
|
20
|
-
yearly:
|
21
|
-
- date: "2023-04-01"
|
22
|
-
account: "[Assets:Bank]"
|
23
|
-
transactions:
|
24
|
-
- description: Annual Bonus
|
25
|
-
category: "[Income:Bonus]"
|
26
|
-
amount: -£2,000.00
|