clinvoice 2.3.0 → 2.4.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/README.md +20 -5
- data/lib/clinvoice/generate_next_template.rb +63 -0
- data/lib/clinvoice/version.rb +1 -1
- data/lib/clinvoice.rb +13 -0
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd6602cc55be67b18e1507625e40cbfc5bebf18c8dabae2ffa6fb32177c61c92
|
|
4
|
+
data.tar.gz: ad155884e1f2cabc5df4e2ab57ae89866acf39276138576f8f98816ba9ed47ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9687ba2f286e4517c02626a63dbe06e77cbff5909ab3a4ef8dfe8fa091593edfaccf910ade7efb2b321964993b82f81e8fd8907cf27b2b8dea8478bfce5c854a
|
|
7
|
+
data.tar.gz: 16fd56e515bb4e6299026679b5b7c116b22503191850fceb680e8eb15469e13dfca485cf37d35fec7cb1be995af6edc6644e725aad4ddacdd575ab39b49705f6
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Generates invoices using command line based on yaml files
|
|
|
5
5
|
```shell
|
|
6
6
|
clinvoice init <datafile> # starts a new template with id 1 and empty entries.
|
|
7
7
|
clinvoice new <filename> # generates a pdf invoice based on a data file `yml`.
|
|
8
|
-
clinvoice next <datafile> # generates the next data file `yml
|
|
8
|
+
clinvoice next <datafile> # generates the next data file `yml`, based on the last one.
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
@@ -58,6 +58,14 @@ data:
|
|
|
58
58
|
notes: "footer notes optional"
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
`issue_date` and `due_date` are optional; add them to the data file to have them printed on the invoice:
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
data:
|
|
65
|
+
issue_date: "2021-08-11"
|
|
66
|
+
due_date: "2021-09-11"
|
|
67
|
+
```
|
|
68
|
+
|
|
61
69
|
2 - Edit the data file:
|
|
62
70
|
|
|
63
71
|
$ vim doge-client-1.yml
|
|
@@ -66,13 +74,20 @@ data:
|
|
|
66
74
|
|
|
67
75
|
$ clinvoice new doge-client-1
|
|
68
76
|
|
|
69
|
-
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`.
|
|
77
|
+
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`. You can also pass the filename with the `.yml` extension, e.g. `clinvoice new doge-client-1.yml`.
|
|
70
78
|
|
|
71
79
|
4 - Generate a next datafile
|
|
72
80
|
|
|
73
81
|
$ clinvoice next doge-client
|
|
74
82
|
|
|
75
|
-
This will create a `doge-client-2.yml` data file, based on the last data file
|
|
83
|
+
This will create a `doge-client-2.yml` data file, based on the last data file:
|
|
84
|
+
|
|
85
|
+
- `id` is incremented.
|
|
86
|
+
- `issue_date` and `due_date` are advanced by one month (rolling over the year when needed), keeping the `MM/dd/YYYY` format.
|
|
87
|
+
- Any `Mon YYYY` occurrence in item descriptions (e.g. `Aug 2026`) is advanced by one month too (e.g. `Sep 2026`).
|
|
88
|
+
- Everything else (items, notes, contractor, client, currency, etc.) is copied as is.
|
|
89
|
+
|
|
90
|
+
If the `$EDITOR` environment variable is set, the new data file is opened in it automatically.
|
|
76
91
|
|
|
77
92
|
## Development
|
|
78
93
|
|
|
@@ -82,7 +97,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
82
97
|
|
|
83
98
|
## Contributing
|
|
84
99
|
|
|
85
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/andrewaguiar/clinvoice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
86
101
|
|
|
87
102
|
## License
|
|
88
103
|
|
|
@@ -90,4 +105,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
90
105
|
|
|
91
106
|
## Code of Conduct
|
|
92
107
|
|
|
93
|
-
Everyone interacting in the Clinvoice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
|
108
|
+
Everyone interacting in the Clinvoice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrewaguiar/clinvoice/blob/master/CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
require 'date'
|
|
5
|
+
|
|
6
|
+
module Clinvoice
|
|
7
|
+
module GenerateNextTemplate
|
|
8
|
+
DATE_FORMAT = '%m/%d/%Y'
|
|
9
|
+
MONTH_YEAR_REGEX = /\b(#{Date::ABBR_MONTHNAMES.compact.join('|')}) (\d{4})\b/.freeze
|
|
10
|
+
|
|
11
|
+
def self.call(file)
|
|
12
|
+
last_data_file = find_last_data_file(file)
|
|
13
|
+
|
|
14
|
+
unless last_data_file
|
|
15
|
+
puts "No existing data file found for '#{file}'."
|
|
16
|
+
exit 1
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
yaml = YAML.load_file(last_data_file)
|
|
20
|
+
invoice_data = yaml['data']
|
|
21
|
+
|
|
22
|
+
invoice_data['id'] += 1
|
|
23
|
+
invoice_data['issue_date'] = increment_date(invoice_data['issue_date']) if invoice_data['issue_date']
|
|
24
|
+
invoice_data['due_date'] = increment_date(invoice_data['due_date']) if invoice_data['due_date']
|
|
25
|
+
|
|
26
|
+
invoice_data['items'].each do |item|
|
|
27
|
+
item['description'] = increment_month_year(item['description']) if item['description']
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
next_file = "#{file}-#{invoice_data['id']}.yml"
|
|
31
|
+
File.write(next_file, YAML.dump(yaml))
|
|
32
|
+
|
|
33
|
+
open_in_editor(next_file)
|
|
34
|
+
|
|
35
|
+
next_file
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.find_last_data_file(file)
|
|
39
|
+
Dir["#{file}-*.yml"].max_by { |f| f[/-(\d+)\.yml\z/, 1].to_i }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.increment_date(value)
|
|
43
|
+
(Date.strptime(value, DATE_FORMAT) >> 1).strftime(DATE_FORMAT)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.increment_month_year(text)
|
|
47
|
+
text.gsub(MONTH_YEAR_REGEX) do
|
|
48
|
+
month_number = Date::ABBR_MONTHNAMES.index(Regexp.last_match(1))
|
|
49
|
+
year = Regexp.last_match(2).to_i
|
|
50
|
+
next_month = Date.new(year, month_number, 1) >> 1
|
|
51
|
+
|
|
52
|
+
"#{Date::ABBR_MONTHNAMES[next_month.month]} #{next_month.year}"
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.open_in_editor(file)
|
|
57
|
+
editor = ENV['EDITOR']
|
|
58
|
+
return if editor.nil? || editor.empty?
|
|
59
|
+
|
|
60
|
+
system(editor, file)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/clinvoice/version.rb
CHANGED
data/lib/clinvoice.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'clinvoice/initialize_template'
|
|
4
|
+
require 'clinvoice/generate_next_template'
|
|
4
5
|
require 'clinvoice/generate_pdf'
|
|
5
6
|
require 'clinvoice/version'
|
|
6
7
|
|
|
@@ -16,6 +17,8 @@ module Clinvoice
|
|
|
16
17
|
Clinvoice::InitializeTemplate.call(file)
|
|
17
18
|
when 'new'
|
|
18
19
|
Clinvoice::GeneratePDF.call(file)
|
|
20
|
+
when 'next'
|
|
21
|
+
Clinvoice::GenerateNextTemplate.call(file)
|
|
19
22
|
else
|
|
20
23
|
show_usage_and_exit!
|
|
21
24
|
end
|
|
@@ -27,6 +30,7 @@ module Clinvoice
|
|
|
27
30
|
|
|
28
31
|
clinvoice init <datafile> # starts a new template with id 1 and empty entries.
|
|
29
32
|
clinvoice new <filename> # generates a pdf invoice based on a data file `yml`.
|
|
33
|
+
clinvoice next <datafile> # generates the next data file `yml`, based on the last one.
|
|
30
34
|
|
|
31
35
|
Args:
|
|
32
36
|
|
|
@@ -51,6 +55,15 @@ module Clinvoice
|
|
|
51
55
|
|
|
52
56
|
This will create a `doge-client-1.pdf` file based on the data file `doge-client-1.yml`.
|
|
53
57
|
|
|
58
|
+
4 - Generate a next datafile
|
|
59
|
+
|
|
60
|
+
`$ clinvoice next doge-client`
|
|
61
|
+
|
|
62
|
+
This will create a `doge-client-2.yml` data file, based on the last data file: id is incremented,
|
|
63
|
+
`issue_date` and `due_date` are advanced by one month, and any "Mon YYYY" occurrences in item
|
|
64
|
+
descriptions (example: "Aug 2026") are advanced by one month too. Everything else is copied as is.
|
|
65
|
+
The new file is opened in $EDITOR, if set.
|
|
66
|
+
|
|
54
67
|
USAGE
|
|
55
68
|
|
|
56
69
|
exit
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: clinvoice
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew S Aguiar
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -91,6 +90,7 @@ files:
|
|
|
91
90
|
- generate-gem
|
|
92
91
|
- lib/clinvoice.rb
|
|
93
92
|
- lib/clinvoice/data.rb
|
|
93
|
+
- lib/clinvoice/generate_next_template.rb
|
|
94
94
|
- lib/clinvoice/generate_pdf.rb
|
|
95
95
|
- lib/clinvoice/helper.rb
|
|
96
96
|
- lib/clinvoice/initialize_template.rb
|
|
@@ -105,7 +105,6 @@ homepage: https://github.com/andrewaguiar/clinvoice
|
|
|
105
105
|
licenses:
|
|
106
106
|
- MIT
|
|
107
107
|
metadata: {}
|
|
108
|
-
post_install_message:
|
|
109
108
|
rdoc_options: []
|
|
110
109
|
require_paths:
|
|
111
110
|
- lib
|
|
@@ -120,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
120
119
|
- !ruby/object:Gem::Version
|
|
121
120
|
version: '0'
|
|
122
121
|
requirements: []
|
|
123
|
-
rubygems_version:
|
|
124
|
-
signing_key:
|
|
122
|
+
rubygems_version: 4.0.7
|
|
125
123
|
specification_version: 4
|
|
126
124
|
summary: Generates invoices using command line
|
|
127
125
|
test_files: []
|