hledger-forecast 3.0.0 → 3.1.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/CHANGELOG.md +7 -0
- data/README.md +20 -13
- data/Rakefile +6 -0
- data/example.csv +1 -1
- data/hledger-forecast.gemspec +2 -2
- data/lib/hledger_forecast/calculator.rb +2 -1
- data/lib/hledger_forecast/transaction.rb +1 -1
- data/lib/hledger_forecast/version.rb +1 -1
- data/spec/calculator_spec.rb +8 -0
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 914475b3b188c0bf0950e6d2e0a88eb374a4486d41c901603c8cb41332e268f7
|
|
4
|
+
data.tar.gz: 241b415b6b95b42e757fd5302700cb4b6395bdce105f00782a49b0149be6b2d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc7ee657e34ec05931165642761b797ec783d1c5c370d6085777d494503782efd32d140aea61e1e9f0d005ce5a6b69f5e28250a3c4150225ce70e5fbcc840a22
|
|
7
|
+
data.tar.gz: 5e6de9e3a6da7531b7d6a4f47b6126e6c34f92ba387cbdcb21584053530f46447d74c9a472bd34e89b566b731c6f71b56a826d17e2613632ae46f435bdbe9d65
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [3.1.0](https://github.com/olimorris/hledger-forecast/compare/v3.0.0...v3.1.0) (2026-04-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* dates now support `+` prefix ([#14](https://github.com/olimorris/hledger-forecast/issues/14)) ([16ee70e](https://github.com/olimorris/hledger-forecast/commit/16ee70ec6d3a717f679fddcbf22324f71010e93d))
|
|
9
|
+
|
|
3
10
|
## [3.0.0](https://github.com/olimorris/hledger-forecast/compare/v2.0.1...v3.0.0) (2026-03-27)
|
|
4
11
|
|
|
5
12
|
|
data/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
<a href="https://github.com/olimorris/hledger-forecast/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/olimorris/hledger-forecast/ci.yml?branch=main&label=tests&style=for-the-badge"></a>
|
|
10
10
|
<a href="https://github.com/olimorris/hledger-forecast/releases"><img src="https://img.shields.io/github/v/release/olimorris/hledger-forecast?style=for-the-badge"</a>
|
|
11
11
|
</p>
|
|
12
|
+
|
|
12
13
|
**"Improved", you say?** Using a _CSV_ file, forecasts can be quickly generated into a _journal_ file ready to be fed into [hledger](https://github.com/simonmichael/hledger). **A 16 line [CSV file](https://github.com/olimorris/hledger-forecast/blob/main/example.csv) can generate a 46 line hledger [forecast file](https://github.com/olimorris/hledger-forecast/blob/main/example.journal)!**
|
|
13
14
|
|
|
14
15
|
## :sparkles: Features
|
|
@@ -37,7 +38,7 @@ Except, you'd need to work out what 20 months from `2026-01-01` is and do $3000
|
|
|
37
38
|
In `hledger-forecast`, you add a single line to your CSV:
|
|
38
39
|
|
|
39
40
|
```csv
|
|
40
|
-
monthly,,Assets:Checking,01/01/2026
|
|
41
|
+
monthly,,Assets:Checking,01/01/2026,+20,New Laptop,Expenses:General Expenses,=3000/20,,,
|
|
41
42
|
```
|
|
42
43
|
|
|
43
44
|
The tool calculates the amount and the end date for you.
|
|
@@ -67,14 +68,14 @@ Assuming you have Ruby and [RubyGems](http://rubygems.org/pages/download) instal
|
|
|
67
68
|
## :rocket: Usage
|
|
68
69
|
|
|
69
70
|
hledger-forecast
|
|
70
|
-
|
|
71
|
+
|
|
71
72
|
Usage: hledger-forecast [command] [options]
|
|
72
|
-
|
|
73
|
+
|
|
73
74
|
Commands:
|
|
74
75
|
generate Generate a forecast from a CSV file
|
|
75
76
|
summarize Summarize the forecast file and output to the terminal
|
|
76
77
|
compare Compare and highlight the differences between two CSV files
|
|
77
|
-
|
|
78
|
+
|
|
78
79
|
Options:
|
|
79
80
|
-h, --help Show this help message
|
|
80
81
|
-v, --version Show version
|
|
@@ -84,9 +85,9 @@ Assuming you have Ruby and [RubyGems](http://rubygems.org/pages/download) instal
|
|
|
84
85
|
Reads your CSV file and creates a journal file ready to use with hledger. See [example.journal](https://github.com/olimorris/hledger-forecast/blob/main/example.journal) for an example of the output.
|
|
85
86
|
|
|
86
87
|
hledger-forecast generate -f my_forecast.csv -o forecast.journal
|
|
87
|
-
|
|
88
|
+
|
|
88
89
|
Usage: hledger-forecast generate [options]
|
|
89
|
-
|
|
90
|
+
|
|
90
91
|
-f, --forecast FILE The path to the FORECAST CSV file to generate from
|
|
91
92
|
-o, --output-file FILE The path to the OUTPUT file to create
|
|
92
93
|
-t, --tags TAGS Only include transactions with given tags (comma-separated)
|
|
@@ -111,9 +112,9 @@ This will generate a forecast up to the end of Feb 2027, showing asset balances
|
|
|
111
112
|
As your forecast grows, it's useful to see the totals at a glance. Think of this as your income statement, rolled up to whatever period makes sense.
|
|
112
113
|
|
|
113
114
|
hledger-forecast summarize -f my_forecast.csv
|
|
114
|
-
|
|
115
|
+
|
|
115
116
|
Usage: hledger-forecast summarize [options]
|
|
116
|
-
|
|
117
|
+
|
|
117
118
|
-f, --forecast FILE The path to the FORECAST CSV file to summarize
|
|
118
119
|
-r, --roll-up PERIOD The period to roll-up your forecasts into. One of:
|
|
119
120
|
[yearly], [half-yearly], [quarterly], [monthly], [weekly], [daily]
|
|
@@ -147,7 +148,7 @@ The CSV file should have a header row with these columns:
|
|
|
147
148
|
| `frequency` | string | `custom` only | Repeating frequency, using hledger's [periodic rule syntax](https://hledger.org/dev/hledger.html#periodic-transactions) |
|
|
148
149
|
| `account` | string | yes | The account the transaction applies to, e.g. `Assets:Bank` |
|
|
149
150
|
| `from` | date | yes | Start date, e.g. `01/03/2023` |
|
|
150
|
-
| `to` | date | no | End date, e.g. `01/01/2025` |
|
|
151
|
+
| `to` | date | no | End date, e.g. `01/01/2025`. Supports `+` prefix for calculated values, e.g. `+12` for 12 months |
|
|
151
152
|
| `description` | string | yes | A description of the transaction |
|
|
152
153
|
| `category` | string | yes | The category account, e.g. `Expenses:Food` |
|
|
153
154
|
| `amount` | number | yes | The transaction amount. Supports `=` prefix for calculated values |
|
|
@@ -164,7 +165,7 @@ monthly,,Assets:Bank,01/03/2023,01/01/2025,Mortgage,Expenses:Mortgage,2000,,,fix
|
|
|
164
165
|
monthly,,Assets:Bank,01/03/2023,,Bills,Expenses:Bills,175,,,fixed|essential
|
|
165
166
|
monthly,,Assets:Bank,01/03/2023,,Food,Expenses:Food,500,,,living|essential
|
|
166
167
|
monthly,,Assets:Bank,01/03/2023,,New Kitchen,Expenses:House,=5000/24,,,living
|
|
167
|
-
monthly,,Assets:Bank,01/03/2023
|
|
168
|
+
monthly,,Assets:Bank,01/03/2023,+12,Holiday,Expenses:Holiday,125,,,living
|
|
168
169
|
monthly,,Assets:Bank,01/03/2023,01/03/2025,Rainy day fund,Assets:Savings,300,,,saving
|
|
169
170
|
monthly,,Assets:Pension,01/01/2024,,Pension draw down,Income:Pension,-500,,,fixed|essential
|
|
170
171
|
quarterly,,Assets:Bank,01/04/2023,,Quarterly bonus,Income:Bonus,-1000,,,fixed
|
|
@@ -188,13 +189,19 @@ monthly,,Assets:Bank,01/03/2023,,New Kitchen,Expenses:House,=5000/24,,
|
|
|
188
189
|
|
|
189
190
|
### Calculated dates
|
|
190
191
|
|
|
191
|
-
The `to` column
|
|
192
|
+
The `to` column supports calculated values. Use `+` followed by a number to mean "N months from the `from` date":
|
|
193
|
+
|
|
194
|
+
```csv
|
|
195
|
+
monthly,,Assets:Bank,01/03/2026,+12,Holiday,Expenses:Holiday,125,,
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
That sets the end date to 12 months after `01/03/2026`. The `=` prefix also supports formulas — useful for longer periods:
|
|
192
199
|
|
|
193
200
|
```csv
|
|
194
|
-
monthly,,Assets:Bank,01/03/
|
|
201
|
+
monthly,,Assets:Bank,01/03/2026,=12*5,Mortgage,Expenses:Mortgage,2000,,
|
|
195
202
|
```
|
|
196
203
|
|
|
197
|
-
That sets the end date to
|
|
204
|
+
That sets the end date to 5 years (60 months) after `01/03/2026`.
|
|
198
205
|
|
|
199
206
|
### Tags
|
|
200
207
|
|
data/Rakefile
ADDED
data/example.csv
CHANGED
|
@@ -10,7 +10,7 @@ monthly,,Assets:Pension,01/01/2024,,Pension draw down,Income:Pension,-500,,,fixe
|
|
|
10
10
|
quarterly,,Assets:Bank,01/04/2023,,Quarterly bonus,Income:Bonus,-1000,,,fixed
|
|
11
11
|
half-yearly,,Assets:Bank,01/04/2023,,Top up holiday funds,Expenses:Holiday,500,,,living
|
|
12
12
|
yearly,,Assets:Bank,01/04/2023,,Annual bonus,Income:Bonus,-2000,,,fixed
|
|
13
|
-
once,,Assets:Bank,05/03/2023,,Refund for that damn laptop,Expenses:Shopping,-3000
|
|
13
|
+
once,,Assets:Bank,05/03/2023,,Refund for that damn laptop,Expenses:Shopping,-3000,,,
|
|
14
14
|
custom,every 2 weeks,Assets:Bank,01/03/2023,,Hair and beauty,Expenses:Personal Care,80,26,,living
|
|
15
15
|
custom,every 5 weeks,Assets:Bank,01/03/2023,,Misc expenses,Expenses:General Expenses,30,10.4,,living
|
|
16
16
|
settings,currency,USD,,,,,,,,
|
data/hledger-forecast.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.name = "hledger-forecast"
|
|
9
9
|
s.version = HledgerForecast::VERSION
|
|
10
10
|
s.authors = ["Oli Morris"]
|
|
11
|
-
s.summary = "
|
|
12
|
-
s.description = "
|
|
11
|
+
s.summary = "Generate hledger journal entries and income statements from a CSV forecast"
|
|
12
|
+
s.description = "Define recurring transactions in a CSV file with support for formulas, calculated dates, and tags. Generates hledger periodic transaction journals and provides income statement summaries with savings rates."
|
|
13
13
|
s.email = "olimorris@users.noreply.github.com"
|
|
14
14
|
s.homepage = "https://github.com/olimorris/hledger-forecast"
|
|
15
15
|
s.license = "MIT"
|
|
@@ -9,7 +9,8 @@ module HledgerForecast
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def self.evaluate_date(from, to)
|
|
12
|
-
return
|
|
12
|
+
return (from >> to) - 1 if to.is_a?(Numeric)
|
|
13
|
+
return Date.parse(to) unless to.start_with?("=") || to.start_with?("+")
|
|
13
14
|
|
|
14
15
|
(from >> @calc.evaluate(to.slice(1..-1))) - 1
|
|
15
16
|
end
|
|
@@ -30,7 +30,7 @@ module HledgerForecast
|
|
|
30
30
|
frequency: row[:frequency],
|
|
31
31
|
account: row[:account],
|
|
32
32
|
from: from,
|
|
33
|
-
to: row[:to] ? Calculator.evaluate_date(from, row[:to]
|
|
33
|
+
to: row[:to] ? Calculator.evaluate_date(from, row[:to]) : nil,
|
|
34
34
|
description: row[:description],
|
|
35
35
|
category: row[:category],
|
|
36
36
|
amount: Calculator.evaluate(row[:amount]),
|
data/spec/calculator_spec.rb
CHANGED
|
@@ -41,5 +41,13 @@ RSpec.describe HledgerForecast::Calculator do
|
|
|
41
41
|
it "handles a 24-month offset" do
|
|
42
42
|
expect(described_class.evaluate_date(from, "=24")).to(eq(Date.parse("2025-02-28")))
|
|
43
43
|
end
|
|
44
|
+
|
|
45
|
+
it "handles dates with a +" do
|
|
46
|
+
expect(described_class.evaluate_date(from, "+24")).to(eq(Date.parse("2025-02-28")))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "handles a numeric offset (CSV numeric converter coerces +N to integer)" do
|
|
50
|
+
expect(described_class.evaluate_date(from, 24)).to(eq(Date.parse("2025-02-28")))
|
|
51
|
+
end
|
|
44
52
|
end
|
|
45
53
|
end
|
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: 3.
|
|
4
|
+
version: 3.1.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: 2026-
|
|
11
|
+
date: 2026-04-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: abbrev
|
|
@@ -122,7 +122,9 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '3.12'
|
|
125
|
-
description:
|
|
125
|
+
description: Define recurring transactions in a CSV file with support for formulas,
|
|
126
|
+
calculated dates, and tags. Generates hledger periodic transaction journals and
|
|
127
|
+
provides income statement summaries with savings rates.
|
|
126
128
|
email: olimorris@users.noreply.github.com
|
|
127
129
|
executables:
|
|
128
130
|
- hledger-forecast
|
|
@@ -139,6 +141,7 @@ files:
|
|
|
139
141
|
- Gemfile
|
|
140
142
|
- LICENSE
|
|
141
143
|
- README.md
|
|
144
|
+
- Rakefile
|
|
142
145
|
- bin/hledger-forecast
|
|
143
146
|
- example.csv
|
|
144
147
|
- example.journal
|
|
@@ -201,7 +204,7 @@ requirements: []
|
|
|
201
204
|
rubygems_version: 3.4.20
|
|
202
205
|
signing_key:
|
|
203
206
|
specification_version: 4
|
|
204
|
-
summary:
|
|
207
|
+
summary: Generate hledger journal entries and income statements from a CSV forecast
|
|
205
208
|
test_files:
|
|
206
209
|
- spec/calculator_spec.rb
|
|
207
210
|
- spec/cli_spec.rb
|