hledger-forecast 0.1.3 → 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: 5643f9c8df4ba13c316af221d62c02e91263948fe34e42dc1a50683b164a73ba
4
- data.tar.gz: 10dad47f307b30f253db51b78aa26bfdd915323c120160e9c29e8e8981fb87fc
3
+ metadata.gz: efe6bca69db97f1f08539e609f7f6db6af22d40c5cf514dce6e543fbc34cd442
4
+ data.tar.gz: 21ccaeb1bbfd846e5cf7afc3da4ffa17a9064a851380ed17b09d4efeb517d197
5
5
  SHA512:
6
- metadata.gz: 4f1b17f8f0f0dba931d208e1f94d55dedfa1f6ee8a6506fc4ca7d456893d5725b2fef0e3a3e8650ca6916ce9edd9b9d6ba9ceebdacd3225f8f0160719063cb5d
7
- data.tar.gz: b64392b194aedad3db34478d59ee124b6d857b68c152659abf2611c9a5e5418be3b784a389201b858fa0a9395e5669995afeffc4dce23e4b8cde2d28556bdd9c
6
+ metadata.gz: ede280944f144b0b055068d5f8e919ab48f2534299dbbd2ff51c599ce1f57a7a1cb7ea72474e0d08a6f3ec27ab17b9ba06ebfe8de7319d7a87d9815648297ffa
7
+ data.tar.gz: 1d19fdf61f57e622e734797ce304d4b0337d5942b27aaefcb90965593ecf0a769d811f457ea5424a4eb22e989d6babd562d1cf15f2a556edf103a2430301fb3c
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby-version: ['3.0', '3.1', '3.2']
15
+ ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v3
data/.gitignore CHANGED
@@ -1,10 +1,21 @@
1
-
1
+ # Bundler
2
2
  .bundle
3
3
  Gemfile.lock
4
+ pkg/*
4
5
  *.gem
5
6
 
7
+ # Project
8
+ .rbenv-version
9
+ .rbx
10
+ .rvmrc
11
+ .ruby-version
12
+ .ruby-gemset
13
+
14
+ # Spec artifacts
15
+ /coverage
16
+
17
+ # Misc
6
18
  forecast.yml
7
19
  forecast.journal
8
20
  test_output.journal
9
-
10
21
  todo.md
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"
@@ -12,8 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.homepage = 'https://github.com/olimorris/hledger-forecast'
13
13
  s.license = 'MIT'
14
14
 
15
- s.required_ruby_version = '>= 3.0.0'
16
-
17
15
  s.add_dependency "highline", "~> 2.1.0"
18
16
  s.add_dependency "money", "~> 6.16.0"
19
17
  s.add_development_dependency 'rspec', '~> 3.12'
@@ -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.3"
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.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oli Morris
@@ -63,7 +63,6 @@ files:
63
63
  - ".github/workflows/ci.yml"
64
64
  - ".gitignore"
65
65
  - ".rubocop.yml"
66
- - ".ruby-version"
67
66
  - Gemfile
68
67
  - LICENSE
69
68
  - README.md
@@ -76,9 +75,12 @@ files:
76
75
  - lib/hledger_forecast/options.rb
77
76
  - lib/hledger_forecast/version.rb
78
77
  - spec/command_spec.rb
78
+ - spec/half-yearly_spec.rb
79
79
  - spec/monthly_spec.rb
80
80
  - spec/once_spec.rb
81
81
  - spec/quarterly_spec.rb
82
+ - spec/stubs/half-yearly/forecast_half-yearly.yml
83
+ - spec/stubs/half-yearly/output_half-yearly.journal
82
84
  - spec/stubs/monthly/forecast_monthly.yml
83
85
  - spec/stubs/monthly/forecast_monthly_enddate.yml
84
86
  - spec/stubs/monthly/forecast_monthly_enddate_top.yml
@@ -107,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
109
  requirements:
108
110
  - - ">="
109
111
  - !ruby/object:Gem::Version
110
- version: 3.0.0
112
+ version: '0'
111
113
  required_rubygems_version: !ruby/object:Gem::Requirement
112
114
  requirements:
113
115
  - - ">="
@@ -120,9 +122,12 @@ specification_version: 4
120
122
  summary: Utility to generate forecasts in Hledger
121
123
  test_files:
122
124
  - spec/command_spec.rb
125
+ - spec/half-yearly_spec.rb
123
126
  - spec/monthly_spec.rb
124
127
  - spec/once_spec.rb
125
128
  - spec/quarterly_spec.rb
129
+ - spec/stubs/half-yearly/forecast_half-yearly.yml
130
+ - spec/stubs/half-yearly/output_half-yearly.journal
126
131
  - spec/stubs/monthly/forecast_monthly.yml
127
132
  - spec/stubs/monthly/forecast_monthly_enddate.yml
128
133
  - spec/stubs/monthly/forecast_monthly_enddate_top.yml
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.0