hledger-forecast 0.1.4 → 0.1.5

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: 6d7bd2190c7f86b3d6a1fe76583a8f7e959f4429719b9903de343d25e0bf3b51
4
- data.tar.gz: 7bb59da35fc2f9f3c47b6ed8b45d2ef38fb9c5c084c6bce9d6ee66fd004157a8
3
+ metadata.gz: efe6bca69db97f1f08539e609f7f6db6af22d40c5cf514dce6e543fbc34cd442
4
+ data.tar.gz: 21ccaeb1bbfd846e5cf7afc3da4ffa17a9064a851380ed17b09d4efeb517d197
5
5
  SHA512:
6
- metadata.gz: 3251f466cd2072685cf063268aca5c9ddc6231e9ac5c217049369c3e6b1c1d729967059441d4318247b7477ebaf357dc317e4f40df6b8e44dbe59a14b5005b9a
7
- data.tar.gz: 55251b35a8cfea885fbbcb861ad650635a0fed4c91e618942ddd4eb76c38b9d3826d1b35e9078c1fae9c2ea96aa311cef750cc37fd88d5e4aed75ecb5c6db21f
6
+ metadata.gz: ede280944f144b0b055068d5f8e919ab48f2534299dbbd2ff51c599ce1f57a7a1cb7ea72474e0d08a6f3ec27ab17b9ba06ebfe8de7319d7a87d9815648297ffa
7
+ data.tar.gz: 1d19fdf61f57e622e734797ce304d4b0337d5942b27aaefcb90965593ecf0a769d811f457ea5424a4eb22e989d6babd562d1cf15f2a556edf103a2430301fb3c
data/README.md CHANGED
@@ -73,16 +73,17 @@ Let's examine what's going on in this config file:
73
73
 
74
74
  - 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
75
75
  - 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
76
- - Notice we're also using [virtual postings](https://hledger.org/1.29/hledger.html#virtual-postings) (designated by the brackets) to be explicit to Hledger. This also makes it easy to filter them out with the `-R` or `--real` option in Hledger
76
+ - 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
77
77
  - We also have not specified a currency; the default (`USD`) will be used
78
78
 
79
79
  ### Extending the config file
80
80
 
81
81
  #### Periods
82
82
 
83
- If you'd like to add quarterly, yearly or one-off transactions, use the following keys:
83
+ If you'd like to add quarterly, half-yearly, yearly or one-off transactions, use the following keys:
84
84
 
85
85
  - `quarterly`
86
+ - `half-yearly`
86
87
  - `yearly`
87
88
  - `once`
88
89
 
data/example.yml CHANGED
@@ -17,6 +17,14 @@ quarterly:
17
17
  category: "[Income:Bonus]"
18
18
  description: Bonus
19
19
 
20
+ half-yearly:
21
+ - account: "[Assets:Bank]"
22
+ date: "2023-04-01"
23
+ transactions:
24
+ - amount: 500
25
+ category: "[Expenses:Holiday]"
26
+ description: Holiday
27
+
20
28
  yearly:
21
29
  - account: "[Assets:Bank]"
22
30
  date: "2023-04-01"
@@ -48,6 +48,8 @@ module HledgerForecast
48
48
  date.day == start_date.day
49
49
  when 'quarterly'
50
50
  date.day == start_date.day && date.month % 3 == start_date.month % 3
51
+ when 'half-yearly'
52
+ date.day == start_date.day && (date.month - start_date.month) % 6 == 0
51
53
  when 'yearly'
52
54
  date.day == start_date.day && date.month == start_date.month
53
55
  when 'once'
@@ -81,6 +83,7 @@ module HledgerForecast
81
83
  while date <= end_date
82
84
  process_forecast(output, forecast_data, 'monthly', date)
83
85
  process_forecast(output, forecast_data, 'quarterly', date)
86
+ process_forecast(output, forecast_data, 'half-yearly', date)
84
87
  process_forecast(output, forecast_data, 'yearly', date)
85
88
  process_forecast(output, forecast_data, 'once', date)
86
89
 
@@ -1,3 +1,3 @@
1
1
  module HledgerForecast
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require_relative '../lib/hledger_forecast'
2
+
3
+ RSpec.describe 'generate' do
4
+ it 'generates a forecast with correct HALF-YEARLY transactions' do
5
+ transactions = File.read('spec/stubs/transactions.journal')
6
+ forecast = File.read('spec/stubs/half-yearly/forecast_half-yearly.yml')
7
+
8
+ generated_journal = HledgerForecast::Generator.create_journal_entries(transactions, forecast, '2023-03-01', '2024-04-30')
9
+
10
+ expected_output = File.read('spec/stubs/half-yearly/output_half-yearly.journal')
11
+ expect(generated_journal).to eq(expected_output)
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ settings:
2
+ currency: GBP
3
+
4
+ half-yearly:
5
+ - start: "2023-04-01"
6
+ account: "[Assets:Bank]"
7
+ transactions:
8
+ - description: Holiday
9
+ category: "[Expenses:Holiday]"
10
+ amount: 500
@@ -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 * 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
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hledger-forecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oli Morris
@@ -75,9 +75,12 @@ files:
75
75
  - lib/hledger_forecast/options.rb
76
76
  - lib/hledger_forecast/version.rb
77
77
  - spec/command_spec.rb
78
+ - spec/half-yearly_spec.rb
78
79
  - spec/monthly_spec.rb
79
80
  - spec/once_spec.rb
80
81
  - spec/quarterly_spec.rb
82
+ - spec/stubs/half-yearly/forecast_half-yearly.yml
83
+ - spec/stubs/half-yearly/output_half-yearly.journal
81
84
  - spec/stubs/monthly/forecast_monthly.yml
82
85
  - spec/stubs/monthly/forecast_monthly_enddate.yml
83
86
  - spec/stubs/monthly/forecast_monthly_enddate_top.yml
@@ -119,9 +122,12 @@ specification_version: 4
119
122
  summary: Utility to generate forecasts in Hledger
120
123
  test_files:
121
124
  - spec/command_spec.rb
125
+ - spec/half-yearly_spec.rb
122
126
  - spec/monthly_spec.rb
123
127
  - spec/once_spec.rb
124
128
  - spec/quarterly_spec.rb
129
+ - spec/stubs/half-yearly/forecast_half-yearly.yml
130
+ - spec/stubs/half-yearly/output_half-yearly.journal
125
131
  - spec/stubs/monthly/forecast_monthly.yml
126
132
  - spec/stubs/monthly/forecast_monthly_enddate.yml
127
133
  - spec/stubs/monthly/forecast_monthly_enddate_top.yml