hledger-forecast 0.1.1 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dec0f161d9d99f109fb449763f74d8ed4362deefe14996a540df934a6b318f08
4
- data.tar.gz: e88100cca81d8a444b1f7d9189e2d7149d03f0bcda7d133c09a393d7447b0e77
3
+ metadata.gz: 5643f9c8df4ba13c316af221d62c02e91263948fe34e42dc1a50683b164a73ba
4
+ data.tar.gz: 10dad47f307b30f253db51b78aa26bfdd915323c120160e9c29e8e8981fb87fc
5
5
  SHA512:
6
- metadata.gz: c07c049aded3d72ce1479c123d57d3e9b76a04318a6f18ee7ebff1505ff239fab6d6ca09fbe6bb6adaf9e2f26628d728bba89010ed6dcbf3b25eb49ffdbd3a89
7
- data.tar.gz: 19cd01fbfb3113228fe504b7e3984986400cd8c4bb1e6f3b49ef9e34c9c0c0e59ac9098f73878869d8856413e4959978f869f4add3227d3d9a5ea90c311abaa9
6
+ metadata.gz: 4f1b17f8f0f0dba931d208e1f94d55dedfa1f6ee8a6506fc4ca7d456893d5725b2fef0e3a3e8650ca6916ce9edd9b9d6ba9ceebdacd3225f8f0160719063cb5d
7
+ data.tar.gz: b64392b194aedad3db34478d59ee124b6d857b68c152659abf2611c9a5e5418be3b784a389201b858fa0a9395e5669995afeffc4dce23e4b8cde2d28556bdd9c
@@ -1,4 +1,4 @@
1
- name: Continuous Integration
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: ['2.6', '2.7', '3.0', '3.1', '3.2']
15
+ ruby-version: ['3.0', '3.1', '3.2']
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v3
data/.gitignore CHANGED
@@ -1,4 +1,10 @@
1
+
2
+ .bundle
3
+ Gemfile.lock
1
4
  *.gem
2
- *.journal
5
+
3
6
  forecast.yml
7
+ forecast.journal
8
+ test_output.journal
9
+
4
10
  todo.md
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 `transactions.journal` might be your bank transactions (your "actuals") and `forecast.journal` is the file generated with the `-o` option from above (your "forecast").
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
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/hledger_forecast'
4
- # require 'hledger_forecast'
5
4
 
6
5
  begin
7
6
  options = HledgerForecast::Options.parse_command_line_options
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
@@ -1,3 +1,3 @@
1
1
  module HledgerForecast
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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,12 @@
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-07-01 * New Kitchen
10
+ [Expense:House] £5,000.00
11
+ [Assets:Bank]
12
+
@@ -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.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-14 00:00:00.000000000 Z
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.yaml
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