hledger-forecast 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/README.md +150 -71
  4. data/example.journal +35 -0
  5. data/example.yml +35 -36
  6. data/hledger-forecast.gemspec +5 -4
  7. data/lib/hledger_forecast/cli.rb +35 -93
  8. data/lib/hledger_forecast/generator.rb +233 -90
  9. data/lib/hledger_forecast/summarize.rb +4 -5
  10. data/lib/hledger_forecast/tracker.rb +37 -0
  11. data/lib/hledger_forecast/version.rb +1 -1
  12. data/lib/hledger_forecast.rb +1 -1
  13. data/spec/command_spec.rb +14 -4
  14. data/spec/custom_spec.rb +35 -42
  15. data/spec/half-yearly_spec.rb +22 -6
  16. data/spec/modifier_spec.rb +87 -0
  17. data/spec/monthly_end_date_spec.rb +47 -0
  18. data/spec/monthly_end_date_transaction_spec.rb +32 -0
  19. data/spec/monthly_spec.rb +35 -27
  20. data/spec/once_spec.rb +22 -7
  21. data/spec/quarterly_spec.rb +21 -7
  22. data/spec/stubs/{monthly/forecast_monthly.yml → forecast.yml} +7 -7
  23. data/spec/stubs/transactions_found.journal +24 -0
  24. data/spec/stubs/transactions_found_inverse.journal +24 -0
  25. data/spec/stubs/transactions_not_found.journal +16 -0
  26. data/spec/track_spec.rb +197 -0
  27. data/spec/yearly_spec.rb +21 -7
  28. metadata +32 -74
  29. data/spec/start_date_spec.rb +0 -12
  30. data/spec/stubs/custom/forecast_custom_days.yml +0 -14
  31. data/spec/stubs/custom/forecast_custom_months.yml +0 -14
  32. data/spec/stubs/custom/forecast_custom_weeks.yml +0 -14
  33. data/spec/stubs/custom/forecast_custom_weeks_twice.yml +0 -24
  34. data/spec/stubs/custom/output_custom_days.journal +0 -24
  35. data/spec/stubs/custom/output_custom_months.journal +0 -20
  36. data/spec/stubs/custom/output_custom_weeks.journal +0 -28
  37. data/spec/stubs/custom/output_custom_weeks_twice.journal +0 -44
  38. data/spec/stubs/half-yearly/forecast_half-yearly.yml +0 -10
  39. data/spec/stubs/half-yearly/output_half-yearly.journal +0 -20
  40. data/spec/stubs/modifiers/forecast_modifiers.yml +0 -13
  41. data/spec/stubs/modifiers/output_modifiers.journal +0 -44
  42. data/spec/stubs/monthly/forecast_monthly_enddate.yml +0 -14
  43. data/spec/stubs/monthly/forecast_monthly_enddate_top.yml +0 -14
  44. data/spec/stubs/monthly/forecast_monthly_modifier.yml +0 -11
  45. data/spec/stubs/monthly/output_monthly.journal +0 -44
  46. data/spec/stubs/monthly/output_monthly_enddate.journal +0 -48
  47. data/spec/stubs/monthly/output_monthly_enddate_top.journal +0 -40
  48. data/spec/stubs/monthly/output_monthly_modifier.journal +0 -20
  49. data/spec/stubs/once/forecast_once.yml +0 -10
  50. data/spec/stubs/once/output_once.journal +0 -12
  51. data/spec/stubs/quarterly/forecast_quarterly.yml +0 -10
  52. data/spec/stubs/quarterly/output_quarterly.journal +0 -20
  53. data/spec/stubs/start_date/forecast_startdate.yml +0 -26
  54. data/spec/stubs/start_date/output_startdate.journal +0 -56
  55. data/spec/stubs/transactions.journal +0 -8
  56. data/spec/stubs/yearly/forecast_yearly.yml +0 -10
  57. data/spec/stubs/yearly/output_yearly.journal +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a21d32c5ee145d0bca5cb25f07a2fbb6f65126f16c5e15faf2ca11b3fbfac03c
4
- data.tar.gz: bbf889db9f129ca62550399b2f2e7818936eee667d356bbeb52b476f305fe6b1
3
+ metadata.gz: cb90937d10de71d495146036711f7028d12de7f5b7c814ccf0fb62dc7ffc5e7f
4
+ data.tar.gz: 05143fad945647f27f30e49626974ec62b66074863a5f11e86898a824b182c85
5
5
  SHA512:
6
- metadata.gz: b0fa4ad6d50c30eac65acc292d96f500182e211b1a4b9e039dfcff0f204a32ad01d9c01a7570535301bffeb6be865c720d6b8be8ba3e17370a2b992586f351d5
7
- data.tar.gz: 554a06876170c161d35b68eececa7904b190aaa0fb6611e2a8bd672fad9b02b48a5a5e26e013db857671fd6f50e33242cb19ddf907fafb31b1b1bd27b74f86df
6
+ metadata.gz: 00e039f29f6f50237d4bca32d8f5e2f27173ac880661bb1445558a98380816de0718e3e748b639e7018d79b49ce019f6dac7b145b98104a687d04bbf36c8db57
7
+ data.tar.gz: 233262e4e1a0612c821334f97599a0d2b00962968a18f591eb5cd96f4efdd5116c037e5b5570f2b6c3e74b1955dec140ffd774a7c04feacdb6d628303d71cb87
data/.gitignore CHANGED
@@ -15,7 +15,5 @@ pkg/*
15
15
  /coverage
16
16
 
17
17
  # Misc
18
- forecast.yml
19
- forecast.journal
20
18
  test_output.journal
21
19
  todo.md
data/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
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
- Uses a YAML file to generate periodic transactions for better forecasting in [Hledger](https://github.com/simonmichael/hledger).
5
+ A wrapper which builds on [hledger's](https://github.com/simonmichael/hledger) [forecasting](https://hledger.org/dev/hledger.html#forecasting) capability. Uses a `YAML` config file to generate forecasts whilst adding functionality for future cost rises (e.g. inflation) and the automatic tracking of planned transactions.
6
6
 
7
7
  See the [rationale](#brain-rationale) section for why this gem may be useful to you.
8
8
 
9
9
  ## :sparkles: Features
10
10
 
11
- - :book: Uses simple YAML files to generate forecasts from periodic transactions
12
- - :date: Generate forecasts between specified start and end dates
11
+ - :book: Uses simple YAML files to generate forecasts which can be used with hledger
12
+ - :date: Can smartly track forecasted transactions against actuals
13
+ - :moneybag: Can automatically apply modifiers such as inflation/deflation to forecasts
13
14
  - :heavy_dollar_sign: Full currency support (uses the [RubyMoney](https://github.com/RubyMoney/money) gem)
14
15
  - :computer: Simple and easy to use CLI
15
16
  - :chart_with_upwards_trend: Summarize your forecasts by period and category and output to the CLI
@@ -24,58 +25,81 @@ Assuming you have Ruby and [Rubygems](http://rubygems.org/pages/download) instal
24
25
 
25
26
  Run:
26
27
 
27
- hledger-forecast generate
28
+ hledger-forecast
28
29
 
29
- > **Note**: This assumes that a `forecast.yml` exists in the current working directory
30
+ The available options are:
30
31
 
31
- Running `hledger-forecast -h` shows the available options:
32
+ Usage: hledger-forecast [command] [options]
32
33
 
33
- Usage: Hledger-Forecast generate [options]
34
+ Commands:
35
+ generate Generate the forecast file
36
+ summarize Summarize the forecast file and output to the terminal
34
37
 
35
- -t, --transaction FILE The base TRANSACTIONS file to extend from
36
- -f, --forecast FILE The FORECAST yaml file to generate from
37
- -o, --output-file FILE The OUTPUT file to create
38
- -s, --start-date DATE The date to start generating from (yyyy-mm-dd)
39
- -e, --end-date DATE The date to start generating to (yyyy-mm-dd)
40
- --force Force an overwrite of the output file
38
+ Options:
41
39
  -h, --help Show this help message
40
+ -v, --version Show version
42
41
 
43
- Another example of a common command:
42
+ ### Generate command
44
43
 
45
- hledger-forecast generate -f my_forecast.yml -s 2023-05-01 -e 2024-12-31
44
+ The `hledger-forecast generate` command will begin the generation of your forecast _from_ a `yaml` file _to_ a journal file.
46
45
 
47
- This will generate an output file (`my_forecast.journal`) from the forecast file between the two date ranges.
46
+ The available options are:
47
+
48
+ Usage: hledger-forecast generate [options]
49
+
50
+ -f, --forecast FILE The path to the FORECAST yaml file to generate from
51
+ -o, --output-file FILE The path to the OUTPUT file to create
52
+ -t, --transaction FILE The path to the TRANSACTION journal file
53
+ --force Force an overwrite of the output file
54
+ --no-track Don't track any transactions
55
+ -h, --help Show this help message
56
+
57
+ > **Note**: For the tracking of transactions you need to include the `-t` flag
58
+
59
+ Running the command with no options will assume a `forecast.yml` file exists.
48
60
 
49
61
  ### Using with Hledger
50
62
 
51
- To use the outputs in Hledger:
63
+ To work with hledger, include the forecast file and use the `--forecast` flag:
64
+
65
+ hledger -f bank_transactions.journal -f forecast.journal --forecast bal assets -e 2024-02
66
+
67
+ The command will generate a forecast up to the end of Feb 2024, showing the balance for any asset accounts, overlaying some bank transactions with the forecast journal file. Of course, refer to the [hledger](https://hledger.org/dev/hledger.html) documentation for more information on how to query your finances.
68
+
69
+ To apply any modifiers, use the `--auto` flag at the end of your command.
70
+
71
+ ### Summarize command
72
+
73
+ As your `yaml` configuration file grows, it can be helpful to sum up the total amounts and output them to the CLI. This can be achieved by:
74
+
75
+ hledger-forecast summarize -f my_forecast.yml
52
76
 
53
- hledger -f transactions.journal -f my_forecast.journal
77
+ The available options are:
54
78
 
55
- where:
79
+ Usage: hledger-forecast summarize [options]
56
80
 
57
- - `transactions.journal` might be your bank transactions (your "_actuals_")
58
- - `my_forecast.journal` is the generated forecast file
81
+ -f, --forecast FILE The path to the FORECAST yaml file to summarize
82
+ -h, --help Show this help message
59
83
 
60
84
  ## :gear: Configuration
61
85
 
62
86
  ### The YAML file
63
87
 
64
- > **Note**: See the [example.yml](https://github.com/olimorris/hledger-forecast/blob/main/example.yml) file for an example of a complex config file
88
+ > **Note**: See the [example.yml](https://github.com/olimorris/hledger-forecast/blob/main/example.yml) file for an example of a complex config file and its [output](https://github.com/olimorris/hledger-forecast/blob/main/example.journal)
65
89
 
66
- Firstly, create a `yml` file which will contain the transactions you'd like to forecast:
90
+ Firstly, create a `yaml` file which will contain the transactions you'd like to forecast:
67
91
 
68
92
  ```yaml
69
93
  # forecast.yml
70
94
  monthly:
71
- - account: "[Assets:Bank]"
72
- start: "2023-03-01"
95
+ - account: "Assets:Bank"
96
+ from: "2023-03-01"
73
97
  transactions:
74
98
  - amount: 2000
75
- category: "[Expenses:Mortgage]"
99
+ category: "Expenses:Mortgage"
76
100
  description: Mortgage
77
101
  - amount: 500
78
- category: "[Expenses:Food]"
102
+ category: "Expenses:Food"
79
103
  description: Food
80
104
 
81
105
  settings:
@@ -84,45 +108,38 @@ settings:
84
108
 
85
109
  Let's examine what's going on in this config file:
86
110
 
87
- - Firstly, we're telling the app to create two monthly transactions and repeat them, forever, starting from March 2023. In this case, forever will be the `end_date` specified when running the app
88
- - If you ran the app with `hledger-forecast -s 2023-04-01` then no transactions would be generated for March as the start date is greater than the periodic start date
89
- - Notice we're also using [virtual postings](https://hledger.org/1.29/hledger.html#virtual-postings) (designated by the brackets). This makes it easy to filter them out with the `-R` or `--real` option in Hledger
90
- - We also have not specified a currency; the default (`USD`) will be used
111
+ - We're telling the app to create two monthly transactions and repeat them, forever, starting from March 2023
112
+ - We're telling the app to link them both to the `Assets:Bank` account
113
+ - We've added descriptions to make it easy to follow in our output file
114
+ - Finally, we're telling the app to use the `GBP` currency; the default (`USD`) will be used if this is not specified
91
115
 
92
116
  ### Periods
93
117
 
94
118
  Besides monthly recurring transactions, the app also supports the following periods:
95
119
 
96
- - `quarterly` - For transactions every _3 months_ from the given start date
97
- - `half-yearly` - For transactions every _6 months_ from the given start date
98
- - `yearly` - Generate transactions _once a year_ from the given start date
120
+ - `quarterly` - For transactions every _3 months_
121
+ - `half-yearly` - For transactions every _6 months_
122
+ - `yearly` - Generate transactions _once a year_
99
123
  - `once` - Generate _one-time_ transactions on a specified date
100
124
  - `custom` - Generate transactions every _n days/weeks/months_
101
125
 
126
+ These will write periodic transactions such as `~ every 3 months` or `~ every year` in the output journal file.
127
+
102
128
  #### Custom period
103
129
 
104
- A custom period allows you to specify a given number of days, weeks or months for a transaction to repeat within. These can be included in the config file as follows:
130
+ When you need a bespoke time bound forecast, a custom period may be useful. Custom periods allow you to specify a periodic rule as per hledger's [periodic rule syntax](https://hledger.org/dev/hledger.html#periodic-transactions):
105
131
 
106
132
  ```yaml
107
133
  custom:
108
- - description: Fortnightly hair and beauty spend
109
- recurrence:
110
- period: weeks
111
- quantity: 2
112
- account: "[Assets:Bank]"
113
- start: "2023-03-01"
134
+ - frequency: "every 2 weeks"
135
+ account: "Assets:Bank"
136
+ from: "2023-03-01"
114
137
  transactions:
115
138
  - amount: 80
116
- category: "[Expenses:Personal Care]"
139
+ category: "Expenses:Personal Care"
117
140
  description: Hair and beauty
118
141
  ```
119
142
 
120
- Where `quantity` is an integer and `period` is one of:
121
-
122
- - days
123
- - weeks
124
- - months
125
-
126
143
  ### Dates
127
144
 
128
145
  The core of any solid forecast is predicting the correct periods that costs will fall into. When running the app from the CLI, you can specify specific dates to generate transactions over (see the [usage](#rocket-usage) section).
@@ -131,34 +148,97 @@ You can further control the dates at a period/top-level as well as at a transact
131
148
 
132
149
  #### Top level
133
150
 
134
- In the example below, all transactions in the `monthly` block will be constrained by the end date:
151
+ In the example below, all transactions in the `monthly` block will be constrained by the `to` date:
135
152
 
136
153
  ```yaml
137
154
  monthly:
138
- - account: "[Assets:Bank]"
139
- start: "2023-03-01"
140
- end: "2025-01-01"
155
+ - account: "Assets:Bank"
156
+ from: "2023-03-01"
157
+ to: "2025-01-01"
141
158
  transactions:
142
159
  # details omitted for brevity
143
160
  ```
144
161
 
145
162
  #### Transaction level
146
163
 
147
- In the example below, only the single transaction will be constrained by the end date and controlled via an additional start date:
164
+ In the example below, only the single transaction will be constrained by the `to` date:
148
165
 
149
166
  ```yaml
150
167
  monthly:
151
- - account: "[Assets:Bank]"
152
- start: "2023-03-01"
168
+ - account: "Assets:Bank"
169
+ from: "2023-03-01"
153
170
  transactions:
154
171
  - amount: 2000
155
- category: "[Expenses:Mortgage]"
172
+ category: "Expenses:Mortgage"
156
173
  description: Mortgage
157
- start: "2023-05-01"
158
- end: "2025-01-01"
174
+ to: "2025-01-01"
175
+ ```
176
+
177
+ ### Tracking transactions
178
+
179
+ > **Note**: Marking a transaction for tracking will ensure that it is only written into the forecast if it isn't found within a specified transaction file
180
+
181
+ Sometimes it can be useful to track and monitor forecasted transactions to ensure that they are accounted for in any financial projections. If they are present, then these should be discarded from your forecast as this will create a double count against your actuals. However, if they can't be found then they should be carried forward into a future period to ensure accurate recording.
182
+
183
+ To mark transactions as available for tracking you may use the `track` option in your config file:
184
+
185
+ ```yaml
186
+ once:
187
+ account: "Assets:Bank"
188
+ from: "2023-03-05"
189
+ transactions:
190
+ - amount: 3000
191
+ category: "Expenses:Shopping"
192
+ description: Refund for that damn laptop
193
+ track: true
194
+ ```
195
+
196
+ > **Note**: This feature has been designed to work with one-off transactions only
197
+
198
+ To use this feature, ensure you pass a filepath to the `-t` flag, such as:
199
+
200
+ hledger-forecast generate -t [journal_file_to_search] -f [path_to_yaml_file] -o [path_to_output_journal]
201
+
202
+ The app will use a hledger query to determine if the combination of category and amount is present in the periods between the `from` key and the current date in the journal file you've specified. If not, then the app will include it as a forecast transaction in the output file.
203
+
204
+ ### Applying modifiers
205
+
206
+ > **Note**: For modifiers to be included in your hledger reporting, use the `--auto` flag
207
+
208
+ Within your forecasts, it can be useful to reflect future increases/decreases in certain categories. For example, next year, I expect the cost of groceries to increase by 2%:
209
+
210
+ ```yaml
211
+ monthly:
212
+ account: "Assets:Bank"
213
+ from: "2023-03-05"
214
+ transactions:
215
+ - amount: 450
216
+ category: "Expenses:Groceries"
217
+ description: Food shopping
218
+ modifiers:
219
+ - amount: 0.02
220
+ description: "Inflation"
221
+ from: "2024-01-01"
222
+ to: "2024-12-31"
159
223
  ```
160
224
 
161
- The addition of the `start` key means that while the block will start on 2023-03-01, the transaction for the mortgage won't start until `2023-05-01`.
225
+ This will generate an [auto-posting](https://hledger.org/dev/hledger.html#auto-postings) in your forecast which will
226
+ uplift any transaction with an `Expenses:Groceries` category.
227
+
228
+ Of course you may wish to apply 2% for next year and another 3% for the year after:
229
+
230
+ ```yaml
231
+ # details above omitted for brevity
232
+ modifiers:
233
+ - amount: 0.02
234
+ description: "Inflation"
235
+ from: "2024-01-01"
236
+ to: "2024-12-31"
237
+ - amount: 0.05
238
+ description: "Inflation"
239
+ from: "2025-01-01"
240
+ to: "2025-12-31"
241
+ ```
162
242
 
163
243
  ### Additional settings
164
244
 
@@ -168,28 +248,27 @@ Additional settings in the config file to consider:
168
248
  settings:
169
249
  currency: GBP # Specify the currency to use
170
250
  show_symbol: true # Show the currency symbol?
171
- sign_before_symbol: true # Show the negative sign before the symbol?
172
251
  thousands_separator: true # Separate thousands with a comma?
173
252
  ```
174
253
 
175
- ## :rainbow: Helpers
254
+ ## :camera_flash: Screenshots
176
255
 
177
- ### Summarizing the forecast file
256
+ **Yaml config file and output**
178
257
 
179
- As your config file grows, it can be helpful to sum up the total amounts and output them in the CLI. This can be achieved by:
258
+ <img src="https://user-images.githubusercontent.com/9512444/234382872-b81ac84d-2bcc-4488-a041-364f72627087.png" alt="Hledger-Forecast" />
180
259
 
181
- hledger-forecast summarize -f my_forecast.yml
260
+ **Summarize command**
182
261
 
183
- where `my_forecast.yml` is the config file to sum up.
262
+ <img src="https://user-images.githubusercontent.com/9512444/234386807-1301c8d9-af77-4f58-a3c3-a345b5e890a2.png" alt="Summarize command" />
184
263
 
185
- ## :brain: Rationale
264
+ ## :paintbrush: Rationale
186
265
 
187
- Firstly, I've come to realise from reading countless blog and Reddit posts on [plain text accounting](https://plaintextaccounting.org), that everyone does it __completely__ differently!
266
+ Firstly, I've come to realise from reading countless blog and Reddit posts on [plain text accounting](https://plaintextaccounting.org), that everyone does it __completely__ differently! There is _great_ support in hledger for [forecasting](https://hledger.org/1.29/hledger.html#forecasting) using periodic transactions. Infact, it's nearly perfect for my needs. My only wishes were to be able to sum up monthly transactions much faster (so I can see my forecasted monthly I&E), apply future cost pressures more easily (such as inflation) and to be able to track and monitor specific transactions.
188
267
 
189
- My days working in financial modelling have meant that a big macro-enabled spreadsheet was my go-to tool. Growing tired with the manual approach of importing transactions, heavily manipulating them, watching Excel become increasingly slower lead me to PTA. It's been a wonderful discovery.
268
+ Regarding the latter; I may be expecting a material amount of money to leave my account in May (perhaps for a holiday booking). But maybe, that booking ends up leaving in July instead. Whilst I would have accounted for that expense in my forecast, it will likely be for the period of May. So if that transaction doesn't appear in the "actuals" of my May bank statement (which I import into hledger), it won't be included in my forecast at all (as the latest transaction period will be greater than the forecast period). The impact is that my forecasted balance in any future month could be $X better off than reality. Being able to automatically look out for these transactions is a nice time saver.
190
269
 
191
- One of the aspects of my previous approach to personal finance that I liked was the monthly recap of my performance and the looking ahead to the future. Am I still on track to hit my year-end savings goal given my performance to date and my future commitments? And what about my savings goal in 12 and 24 months time? Or, how much are my financial positions impacted if inflation increases by x%? It was at this point in my shift to PTA that I found it difficult to answer those questions quickly.
270
+ Also, I like to look ahead up to 3 years at a time and understand what my bank balances might look like. For this to be really accurate, factors such as inflation and salary expectations should be included. This is where the idea for modifiers came in. Being able to apply a percentage to a given category between two dates and automatically have the impact included any extended forecasts.
192
271
 
193
- While there is support in Hledger for [forecasting](https://hledger.org/1.29/hledger.html#forecasting) using periodic transactions, these are computed virtually at runtime. If I notice a big difference in my forecasted year-end balance compared to what I'm expecting, I want to investigate and start reconcilling. Computed transactions make this nigh on impossible to unpick. Also, I get a lot of value out of running different forecast scenarios and seeing the impact. For example, _"what's my savings balance looking like in 3 years time if I get the kitchen remodelled?"_.
272
+ Now I'll freely admit these are two minor issues. So minor infact that they can probably be addressed by a dedicated 5 minutes every month as part of your hledger workflow. However I liked the idea of automating as much of my month end process as possible and saw this as an interesting challenge to try and solve.
194
273
 
195
- With this gem, my aim was to make it easy for users to change their config file, regenerate the forecast and open a journal file and see the transactions. Or, use multiple forecast files for different scenarios and pass them in turn to Hledger to observe the impact.
274
+ Whilst I tried to work within the constraints of a `journal` file, moving to a `yaml` format made the implementation of these features much easier and allowed me to stay true to how you'd accomplish forecasting in hledger, manually. Whilst the config file can end up being many lines long, the output journal should be relatively streamlined and easy to follow.
data/example.journal ADDED
@@ -0,0 +1,35 @@
1
+ ~ monthly from 2023-03-01 * Bonus, Salary, Food, New cell phone
2
+ Income:Bonus £-100.00 ; Bonus
3
+ Income:Salary £-2,000.00; Salary
4
+ Expenses:Food £500.00 ; Food
5
+ Expenses:Phone £75.00 ; New cell phone
6
+ Assets:Bank
7
+
8
+ ~ monthly from 2023-03-01 to 2024-01-01 * Mortgage
9
+ Expenses:Mortgage £1,000.00 ; Mortgage
10
+ Assets:Bank
11
+
12
+ ~ monthly from 2023-03-01 * Pension draw down
13
+ Income:Pension £-500.00 ; Pension draw down
14
+ Assets:Savings
15
+
16
+ ~ every 3 months from 2023-04-01 * Bonus
17
+ Income:Bonus £-1,000.00; Bonus
18
+ Assets:Bank
19
+
20
+ ~ every 6 months from 2023-04-01 * Holiday
21
+ Expenses:Holiday £500.00 ; Holiday
22
+ Assets:Bank
23
+
24
+ ~ yearly from 2023-04-01 * Annual Bonus
25
+ Income:Bonus £-2,000.00; Annual Bonus
26
+ Assets:Bank
27
+
28
+ ~ every 5 days from 2023-03-01 * Car fuel
29
+ Expenses:Car:Fuel £150.00 ; Car fuel
30
+ Assets:Bank
31
+
32
+ = Expenses:Food date:2024-01-01..2024-12-31
33
+ Expenses:Food *0.1 ; Food - Inflation
34
+ Assets:Bank *-0.1
35
+
data/example.yml CHANGED
@@ -1,77 +1,76 @@
1
1
  monthly:
2
- - account: "[Assets:Bank]"
3
- start: "2023-03-01"
2
+ - account: "Assets:Bank"
3
+ from: "2023-03-01"
4
4
  transactions:
5
5
  - amount: -100
6
- category: "[Income:Bonus]"
6
+ category: "Income:Bonus"
7
7
  description: Bonus
8
8
  - amount: -2000
9
- category: "[Income:Salary]"
9
+ category: "Income:Salary"
10
10
  description: Salary
11
- - amount: 500.00
12
- category: "[Expenses:Food]"
11
+ - amount: 500
12
+ category: "Expenses:Food"
13
13
  description: Food
14
+ modifiers:
15
+ - amount: 0.1
16
+ description: "Inflation"
17
+ from: "2024-01-01"
18
+ to: "2024-12-31"
14
19
  - amount: 75
15
- category: "[Expenses:Phone]"
20
+ category: "Expenses:Phone"
16
21
  description: New cell phone
17
- start: "2023-08-01"
18
- - amount: 1000.00
19
- category: "[Expenses:Mortgage]"
22
+ - amount: 1000
23
+ category: "Expenses:Mortgage"
20
24
  description: Mortgage
21
- end: "2024-01-01"
22
- - account: "[Assets:Savings]"
23
- start: "2023-03-01"
25
+ to: "2024-01-01"
26
+ - account: "Assets:Savings"
27
+ from: "2023-03-01"
24
28
  transactions:
25
29
  - amount: -500
26
- category: "[Income:Pension]"
30
+ category: "Income:Pension"
27
31
  description: Pension draw down
28
32
 
29
33
  quarterly:
30
- - account: "[Assets:Bank]"
31
- start: "2023-04-01"
34
+ - account: "Assets:Bank"
35
+ from: "2023-04-01"
32
36
  transactions:
33
37
  - amount: -1000.00
34
- category: "[Income:Bonus]"
38
+ category: "Income:Bonus"
35
39
  description: Bonus
36
40
 
37
41
  half-yearly:
38
- - account: "[Assets:Bank]"
39
- start: "2023-04-01"
42
+ - account: "Assets:Bank"
43
+ from: "2023-04-01"
40
44
  transactions:
41
45
  - amount: 500
42
- category: "[Expenses:Holiday]"
46
+ category: "Expenses:Holiday"
43
47
  description: Holiday
44
48
 
45
49
  yearly:
46
- - account: "[Assets:Bank]"
47
- start: "2023-04-01"
50
+ - account: "Assets:Bank"
51
+ from: "2023-04-01"
48
52
  transactions:
49
53
  - amount: -2000.00
50
- category: "[Income:Bonus]"
54
+ category: "Income:Bonus"
51
55
  description: Annual Bonus
52
56
 
53
57
  once:
54
- - account: "[Assets:Bank]"
55
- start: "2024-01-01"
58
+ - account: "Assets:Bank"
59
+ from: "2023-03-01"
56
60
  transactions:
57
61
  - amount: 5000.00
58
- category: "[Expenses:Car]"
62
+ category: "Expenses:Car"
59
63
  description: Forecast new car cost
64
+ track: true
60
65
 
61
66
  custom:
62
- - description: Fuel every 5 days
63
- recurrence:
64
- period: days
65
- quantity: 5
66
- account: "[Assets:Bank]"
67
- start: "2023-03-01"
67
+ - frequency: "every 5 days"
68
+ account: "Assets:Bank"
69
+ from: "2023-03-01"
68
70
  transactions:
69
71
  - amount: 150
70
- category: "[Expenses:Car:Fuel]"
72
+ category: "Expenses:Car:Fuel"
71
73
  description: Car fuel
72
74
 
73
75
  settings:
74
76
  currency: GBP
75
- show_symbol: true
76
- sign_before_symbol: true
77
- thousands_separator: true
@@ -1,20 +1,21 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
3
4
  require 'hledger_forecast/version'
4
5
 
5
6
  Gem::Specification.new do |s|
6
7
  s.name = 'hledger-forecast'
7
8
  s.version = HledgerForecast::VERSION
8
9
  s.authors = ['Oli Morris']
9
- s.summary = 'Utility to generate forecasts in Hledger'
10
- s.description = 'Uses a YAML file to generate monthly, quarterly, yearly and one-off transactions for better forecasting in Hledger'
10
+ s.summary = "An extended wrapper around hledger's forecasting functionality"
11
+ s.description = 'Uses a YAML file to generate forecasts which can be used to extend the default functionality in hledger'
11
12
  s.email = 'olimorris@users.noreply.github.com'
12
13
  s.homepage = 'https://github.com/olimorris/hledger-forecast'
13
14
  s.license = 'MIT'
14
15
 
16
+ s.add_dependency "colorize", "~> 0.8.1"
15
17
  s.add_dependency "highline", "~> 2.1.0"
16
18
  s.add_dependency "money", "~> 6.16.0"
17
- s.add_dependency "colorize", "~> 0.8.1"
18
19
  s.add_dependency "terminal-table", "~> 3.0.2"
19
20
  s.add_development_dependency 'rspec', '~> 3.12'
20
21